stevearc / oil.nvim

Neovim file explorer: edit your filesystem like a buffer
MIT License
3.68k stars 102 forks source link

bug: Buffer modified highlight group #254

Open gruvw opened 9 months ago

gruvw commented 9 months ago

Did you check the docs and existing issues?

Neovim version (nvim -v)

NVIM v0.9.2

Operating system/version

Ubuntu 22.04 LTS

Describe the bug

The highlight group of the directory/file is not followed when modifying the buffer:

image

What is the severity of this bug?

tolerable (can work around it)

Steps To Reproduce

  1. Change default highlighting rules for OilDir highlight group
  2. Open oil.nvim
  3. Change the name of a directory

Expected Behavior

The modified text content test should have the highlight group OilDir instead of the default highlighting of oil.

Note: if this is intended to be the default behavior, I would advise adding an option to have a new highlight group for "modified buffer content" so that we can customize the color and highlighting of the names we want to change (or at least make it match the default highlight).

Directory structure

root/MyDir

Repro

-- save as repro.lua
-- run with nvim -u repro.lua
-- DO NOT change the paths
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "runtime", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({
    "git",
    "clone",
    "--filter=blob:none",
    "--single-branch",
    "https://github.com/folke/lazy.nvim.git",
    lazypath,
  })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  {
        "stevearc/oil.nvim",
        config = function()
            require("oil").setup({
              -- add any needed settings here
            })
        end,
  },
  -- add any other plugins here
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here
-- NOTHING ELSE REQUIRED

Did you check the bug with a clean config?

stevearc commented 8 months ago

This is a technical limitation. The highlighting is done via extmarks rather than a syntax file. It might be possible to do the OilDir highlighting via the syntax file; I haven't investigated yet. The main reason it's currently done with extmarks is because the arbitrary combination of columns makes the exact syntax structure of the buffer hard to define.