luukvbaal / statuscol.nvim

Status column plugin that provides a configurable 'statuscolumn' and click handlers.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

feature request: fallback char for sign segment

sodiumjoe opened this issue · comments

I would like to be able to render a default string for a sign segment. Something like:

			require("statuscol").setup({
				segments = {
					{
						sign = {
							name = { "Signify.*" },
							fallback = " | ",
						},
					},
				},
			})

So that if there is no sign placed on that line, I could render a default placeholder.

Alternatively, if the args for text functions contained the list of signs placed for that line, I could do this myself.

Sounds like signs.fillchar no?

fillchar = " ", -- character used to fill a segment with less signs than maxwidth

Also, the placed signs for a line are contained in the second argument to text functions formatargs.sign.wins[args.win].signs[args.lnum]:

function M.signfunc(args, formatarg)
local ss = formatarg.sign
local wss = ss.wins[args.win]
if args.virtnum ~= 0 and not ss.wrap then return wss.empty.."%*" end
local sss = wss.signs[args.lnum]

I tried fillchar, but it seemed not to do what I wanted, but maybe I'm mistaken. I'll try both of those options, thanks!

I think fillchar does exactly what you describe for a sign segment that is only a single cell wide (colwidth == 1). We may need to tweak it to account for different colwidth.

Also, the placed signs for a line are contained in the second argument to text functions

This is only true for an actual configured sign segment sorry.

fillchars seems to do what i want, but I'm still running into a weird alignment issue:

      local builtin = require("statuscol.builtin")
      require("statuscol").setup({
        segments = {
          {
            text = { builtin.lnumfunc },
            sign = { name = { "Diagnostic" } },
          },
          {
            sign = {
              name = { "Signify.*" },
              fillchar = "%#LineNr#%=│",
              colwidth = 1,
            },
          },
        },
      })

results in:

image

For some reason it adds extra padding to the linenr

Sorry took a while to get back to this. I can reproduce the alignment issue, I'll look into it.

OK so TBH I hadn't even considered setting fillchar to anything other than an actual single character, as the name suggests.

You have set it as %#LineNr#%=│. If it works it works I guess but perhaps adding a fillcharhl cfg to set the highlight group would be better.

The misalignment comes from the %= you added. What did you add it for? Removing it fixes the misalignment: fillchar = "%#LineNr#│"

I couldn't figure out another way to highlight the fillchar. It seems to get the Normal highlight otherwise?

perhaps adding a fillcharhl cfg to set the highlight group would be better.

that would work for me!

Adding %#LineNr# to set the highlight group is fine (like I said didn't consider this for fillchar but it happens to work).

%= is an alignment separation point marker though, adding that is what is causing your alignment issues.

ohh I'm not actually sure why I added that one, thank you! I'll close this issue.

It seems to get the Normal highlight otherwise?

It uses the SignColumn/CursorLineSign highlight groups (depending on the value of 'cursorline(opt)' and the cursor position).

00c4e6c adds the fillcharhl option for if you want fillchar to be a different color than SignColumn I guess.

Interesting, I think what I actually want is for it to use LineNr and CursorLineNr like an arbitrary text segment would, but this is probably an extreme edge case.

:hi! link CursorLineSign CursorLineNr
:hi! link SignColumn LineNr

?

Ah, I think CursorLineSign was what I was missing. Thank you so much!