chentoast/marks.nvim

How to cancel definition of highlight group?

fjchen7 opened this issue · 6 comments

I use Gitsigns and find that color of marks.nvim distracted.
image

I try to clear color of the highlight group MarkSignNumHL.

Here is the effect after setting :highlight link MarkSignNumHL LineNr to make color of MarkSignNumHL the same with normal line.
image

But this is not quite what I want. I would like to make color MarkSignNumHL transparent, to make it not overwrite color of other highlight definication. That is to say, in the screen above all line number of marks follows the color of Gitsigns (all green defined by GitSignsAdd in this case).

How can I do this? Thanks a lot!

It sounds like what you want is to set bg=NONE in the definition of your highlight group - does that solve the issue?

No. I try the command hi MarkSignNumHL guibg=NONE itermbg=NONE, but it doesn't work. The effect is just like the picture above shows.

marks.nvim refresh both Sign and NR column when adding a new mark. Even though I remove highlight by :hi! clear MarkSignNumHL, the highlights are still here (may fallback to a default color?).

I think you should separate Sign and NR toggle command, like MarksToggleSign for Sign and MarksToggleNr for Nr. Currently only a MarksToggleSigns toggles both.

Same here, this was too distracting... Appreciated this plugins tho, thanks!

One workaround is to set gitsigns.nvim's opts.sign_priority = 11 (or any value higher than marks, defaulting at 10), or to set marks.nvim's opts.sign_priority = 5 (or any value lower than gitsigns, defaulting at 6). This will allow gitsigns to override the numhl set by marks.

I share my workaround here.

return {
  "chentoast/marks.nvim",
  config = function(_, opts)
    local marks_utils = require("marks.utils")
    -- Tweak from https://github.com/chentoast/marks.nvim/blob/a69253e4b471a2421f9411bc5bba127eef878dc0/lua/marks/utils.lua#L9
    marks_utils.add_sign = function(bufnr, text, line, id, group, priority)
      priority = priority or 10
      local sign_name = "Marks_" .. text
      if not marks_utils.sign_cache[sign_name] then
        marks_utils.sign_cache[sign_name] = true
        vim.fn.sign_define(sign_name, { text = text, texthl = "MarkSignHL" })
      end
      vim.fn.sign_place(id, group, sign_name, bufnr, { lnum = line, priority = priority })
    end

    require("marks").setup(opts)
  end,
}