diff --git a/doc/nvim-tree-lua.txt b/doc/nvim-tree-lua.txt index bdd3372f..148201ce 100644 --- a/doc/nvim-tree-lua.txt +++ b/doc/nvim-tree-lua.txt @@ -95,6 +95,11 @@ to render the icons. The `icons` key can only work if `nvim-web-devicons` is installed and in your |runtimepath| (https://github.com/kyazdani42/nvim-web-devicons) +|g:nvim_tree_highlight_opened_files| *g:nvim_tree_highlight_opened_files* + +Can be `0` or `1`. When `1`, will highlight icons for opened files and directories +Default is 0 + |g:nvim_tree_icons| *g:nvim_tree_icons* You can set icons for: @@ -361,7 +366,9 @@ NvimTreeFolderName NvimTreeRootFolder NvimTreeFolderIcon NvimTreeEmptyFolderName +NvimTreeOpenedFolderName NvimTreeExecFile +NvimTreeOpenedFile NvimTreeSpecialFile NvimTreeImageFile NvimTreeMarkdownFile diff --git a/lua/nvim-tree/colors.lua b/lua/nvim-tree/colors.lua index 9a222001..7789a63f 100644 --- a/lua/nvim-tree/colors.lua +++ b/lua/nvim-tree/colors.lua @@ -39,6 +39,7 @@ local function get_hl_groups() ExecFile = { gui = 'bold', fg = colors.green }, SpecialFile = { gui = 'bold,underline', fg = colors.yellow }, ImageFile = { gui = 'bold', fg = colors.purple }, + OpenedFile = { gui = 'bold', fg = colors.green }, GitDirty = { fg = colors.dark_red }, GitDeleted = { fg = colors.dark_red }, @@ -53,6 +54,7 @@ local function get_links() return { FolderName = 'Directory', EmptyFolderName = 'Directory', + OpenedFolderName = 'Directory', Normal = 'Normal', EndOfBuffer = 'EndOfBuffer', CursorLine = 'CursorLine', diff --git a/lua/nvim-tree/lib.lua b/lua/nvim-tree/lib.lua index 3fff15fc..75c2266a 100644 --- a/lua/nvim-tree/lib.lua +++ b/lua/nvim-tree/lib.lua @@ -274,6 +274,8 @@ function M.open_file(mode, filename) if vim.g.nvim_tree_quit_on_open == 1 and mode ~= 'preview' then M.close() end + + renderer.draw(M.Tree, true) end function M.change_dir(foldername) diff --git a/lua/nvim-tree/renderer.lua b/lua/nvim-tree/renderer.lua index d7c6f0e7..b2ae55de 100644 --- a/lua/nvim-tree/renderer.lua +++ b/lua/nvim-tree/renderer.lua @@ -261,6 +261,7 @@ local function update_draw_data(tree, depth, markers) next = next.group_next end if not has_children then folder_hl = "NvimTreeEmptyFolderName" end + if node.open then folder_hl = "NvimTreeOpenedFolderName" end set_folder_hl(index, offset, #icon, #name+#git_icon, folder_hl) if git_hl then set_folder_hl(index, offset, #icon, #name+#git_icon, git_hl) @@ -298,6 +299,12 @@ local function update_draw_data(tree, depth, markers) table.insert(hl, {'NvimTreeImageFile', index, offset+#icon+#git_icons, -1 }) end + if vim.g.nvim_tree_highlight_opened_files then + if vim.fn.bufloaded(node.absolute_path) > 0 then + table.insert(hl, {'NvimTreeOpenedFile', index, offset, offset+#icon }) + end + end + if git_hl then table.insert(hl, {git_hl, index, offset+#icon+#git_icons, -1 }) end