Feat/icon highlighting for opened files and directories (#258)
This commit is contained in:
parent
82b20f5b5e
commit
c2f2c665d8
@ -95,6 +95,11 @@ to render the icons. The `icons` key can only work if `nvim-web-devicons`
|
|||||||
is installed and in your |runtimepath|
|
is installed and in your |runtimepath|
|
||||||
(https://github.com/kyazdani42/nvim-web-devicons)
|
(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*
|
|g:nvim_tree_icons| *g:nvim_tree_icons*
|
||||||
|
|
||||||
You can set icons for:
|
You can set icons for:
|
||||||
@ -361,7 +366,9 @@ NvimTreeFolderName
|
|||||||
NvimTreeRootFolder
|
NvimTreeRootFolder
|
||||||
NvimTreeFolderIcon
|
NvimTreeFolderIcon
|
||||||
NvimTreeEmptyFolderName
|
NvimTreeEmptyFolderName
|
||||||
|
NvimTreeOpenedFolderName
|
||||||
NvimTreeExecFile
|
NvimTreeExecFile
|
||||||
|
NvimTreeOpenedFile
|
||||||
NvimTreeSpecialFile
|
NvimTreeSpecialFile
|
||||||
NvimTreeImageFile
|
NvimTreeImageFile
|
||||||
NvimTreeMarkdownFile
|
NvimTreeMarkdownFile
|
||||||
|
|||||||
@ -39,6 +39,7 @@ local function get_hl_groups()
|
|||||||
ExecFile = { gui = 'bold', fg = colors.green },
|
ExecFile = { gui = 'bold', fg = colors.green },
|
||||||
SpecialFile = { gui = 'bold,underline', fg = colors.yellow },
|
SpecialFile = { gui = 'bold,underline', fg = colors.yellow },
|
||||||
ImageFile = { gui = 'bold', fg = colors.purple },
|
ImageFile = { gui = 'bold', fg = colors.purple },
|
||||||
|
OpenedFile = { gui = 'bold', fg = colors.green },
|
||||||
|
|
||||||
GitDirty = { fg = colors.dark_red },
|
GitDirty = { fg = colors.dark_red },
|
||||||
GitDeleted = { fg = colors.dark_red },
|
GitDeleted = { fg = colors.dark_red },
|
||||||
@ -53,6 +54,7 @@ local function get_links()
|
|||||||
return {
|
return {
|
||||||
FolderName = 'Directory',
|
FolderName = 'Directory',
|
||||||
EmptyFolderName = 'Directory',
|
EmptyFolderName = 'Directory',
|
||||||
|
OpenedFolderName = 'Directory',
|
||||||
Normal = 'Normal',
|
Normal = 'Normal',
|
||||||
EndOfBuffer = 'EndOfBuffer',
|
EndOfBuffer = 'EndOfBuffer',
|
||||||
CursorLine = 'CursorLine',
|
CursorLine = 'CursorLine',
|
||||||
|
|||||||
@ -274,6 +274,8 @@ function M.open_file(mode, filename)
|
|||||||
if vim.g.nvim_tree_quit_on_open == 1 and mode ~= 'preview' then
|
if vim.g.nvim_tree_quit_on_open == 1 and mode ~= 'preview' then
|
||||||
M.close()
|
M.close()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
renderer.draw(M.Tree, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.change_dir(foldername)
|
function M.change_dir(foldername)
|
||||||
|
|||||||
@ -261,6 +261,7 @@ local function update_draw_data(tree, depth, markers)
|
|||||||
next = next.group_next
|
next = next.group_next
|
||||||
end
|
end
|
||||||
if not has_children then folder_hl = "NvimTreeEmptyFolderName" 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)
|
set_folder_hl(index, offset, #icon, #name+#git_icon, folder_hl)
|
||||||
if git_hl then
|
if git_hl then
|
||||||
set_folder_hl(index, offset, #icon, #name+#git_icon, git_hl)
|
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 })
|
table.insert(hl, {'NvimTreeImageFile', index, offset+#icon+#git_icons, -1 })
|
||||||
end
|
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
|
if git_hl then
|
||||||
table.insert(hl, {git_hl, index, offset+#icon+#git_icons, -1 })
|
table.insert(hl, {git_hl, index, offset+#icon+#git_icons, -1 })
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user