Feat/icon highlighting for opened files and directories (#258)

This commit is contained in:
Carlos Afonso
2021-04-13 15:12:21 -03:00
committed by GitHub
parent 82b20f5b5e
commit c2f2c665d8
4 changed files with 18 additions and 0 deletions

View File

@@ -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',

View File

@@ -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)

View File

@@ -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