oil.nvim icon indicating copy to clipboard operation
oil.nvim copied to clipboard

Question: How to disable dimming hidden entries?

Open fredrikfoss opened this issue 1 year ago • 3 comments

Hi,

Is there a straightforward way to disable dimming hidden files? Right now all hidden files are set to use hl-OilHidden, but M._get_highlights in lua/oil/init.lua contains:

M._get_highlights = function()
  return {
    {
      name = "OilHidden",
      link = "Comment",
      desc = "Hidden entry in an oil buffer",
    },
    {
      name = "OilDir",
      link = "Directory",
      desc = "Directory names in an oil buffer",
    },
    {
      name = "OilDirHidden",
      link = "OilHidden",
      desc = "Hidden directory names in an oil buffer",
    },

It seem to suggest one can somehow remove the OilHidden highlight, and then all other Oil*Hidden highlights should point to their not-hidden version? But I wasn't able to get this to work properly. Setting vim.api.nvim_set_hl(0, "OilHidden", {}) did remove the Comment colors, but replaced them all with just the default foreground color instead.

Any help much appreciated!

fredrikfoss avatar Feb 08 '25 02:02 fredrikfoss

Hmm...I think I saw something in neovim nightly about supporting adding multiple highlight groups to a text section via extmarks, and it merges them. We could maybe leverage this and add the OilHidden highlight on top of the normal file type highlight so that when you clear the OilHidden highlight it reveals the other highlight instead of the default foreground.

stevearc avatar Feb 13 '25 01:02 stevearc

Not sure that I understood the details of the question correctly but if you want to

disable dimming hidden entries?

I am doing this by passing a winhighlight option including "OilFileHidden:OilFile,OilDirHidden:OilDir" to simply remap the hidden files highlight groups to their non hidden counterparts

GNRSN avatar Feb 22 '25 16:02 GNRSN

I forgot about this issue, but this is what I ended up doing back then:

for _, group in ipairs(vim.fn.getcompletion("Oil", "highlight")) do
  local base = group:match("^(Oil.+)Hidden$")
  if base then
    vim.api.nvim_set_hl(0, group, { link = base })
  end
end

fredrikfoss avatar Jul 04 '25 15:07 fredrikfoss