Skip to content

renderer.highlight_modified with NvimTreeModified does not seem to be working #1997

Closed
@mangelozzi

Description

@mangelozzi

Description

When a file is modified, it is possible to highlight the filename in the tree, does not seem to be working (hopefully it's not a case of you're doing it wrong).

Read the help here: nvim-tree.renderer.highlight_modified

Side note (a different issue), the heading just before it, *nvim-tree.renderer.highlight_opened_files*, does not mention which highlight group it uses.

Neovim version

NVIM v0.8.2
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by runner@fv-az190-151

Operating system and version

Ubuntu 22.04

nvim-tree version

4222bb8

Minimal config

local ensure_packer = function()
    local fn = vim.fn
    local install_path = fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim"
    if fn.empty(fn.glob(install_path)) > 0 then
        fn.system({"git", "clone", "--depth", "1", "https://github.com/wbthomason/packer.nvim", install_path})
        vim.cmd [[packadd packer.nvim]]
        return true
    end
    return false
end
local packer_bootstrap = ensure_packer()

local minimal_plugins = function(use)
    use {
        -- optional, for file icons, better to load it before than as a requirement: https://github.com/nvim-tree/nvim-tree.lua/issues/1458
        "nvim-tree/nvim-web-devicons",
        "nvim-tree/nvim-tree.lua"
    }

    if packer_bootstrap then
        require("packer").sync()
    end
end
require("packer").startup(minimal_plugins)

-- Highlight color if buffer modified
vim.api.nvim_set_hl(0, "NvimTreeModified", { fg = "#ff0000", bg="#00ff00" })

require('nvim-tree').setup { -- BEGIN_DEFAULT_OPTS
     auto_reload_on_write = true,
     renderer = {
          highlight_opened_files = "icon", -- "none" (default), "icon", "name" or "all"
          highlight_modified = "name",
    }
}

vim.defer_fn(function() vim.cmd(":NvimTreeOpen") end , 500)

Steps to reproduce

  1. Run the above minimal config
  2. Open a file and make some changes, don't save them
  3. Look at the node in the tree, it's name will not be highlighted.

Expected behavior

The node to be highlighted with the NvimTreeModified group.

Actual behavior

No highlighting occurs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingreproducedIssue confirmed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions