Improve highlight options (#331)
This commit is contained in:
parent
12dd571202
commit
18fffc09bf
@ -29,6 +29,7 @@ let g:nvim_tree_follow = 1 "0 by default, this option allows the cursor to be up
|
||||
let g:nvim_tree_indent_markers = 1 "0 by default, this option shows indent markers when folders are open
|
||||
let g:nvim_tree_hide_dotfiles = 1 "0 by default, this option hides files and folders starting with a dot `.`
|
||||
let g:nvim_tree_git_hl = 1 "0 by default, will enable file highlight for git attributes (can be used without the icons).
|
||||
let g:nvim_tree_highlight_opened_files = 1 "0 by default, will enable folder and file icon highlight for opened files/directories.
|
||||
let g:nvim_tree_root_folder_modifier = ':~' "This is the default. See :help filename-modifiers for more options
|
||||
let g:nvim_tree_tab_open = 1 "0 by default, will open the tree when entering a new tab and the tree was previously open
|
||||
let g:nvim_tree_width_allow_resize = 1 "0 by default, will not resize the tree when opening a file
|
||||
|
||||
@ -97,9 +97,15 @@ is installed and in your |runtimepath|
|
||||
|
||||
|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
|
||||
Highlight icons and/or names for opened files and directories
|
||||
Default is 0
|
||||
|
||||
Must be:
|
||||
0: No highlight
|
||||
1: Enable highligting for folders and file icons only.
|
||||
2: Enable highligting for folders and file names only.
|
||||
3: Enable highligting for folders and both file icons and names.
|
||||
|
||||
|g:nvim_tree_icons| *g:nvim_tree_icons*
|
||||
|
||||
You can set icons for:
|
||||
|
||||
@ -11,6 +11,8 @@ local namespace_id = api.nvim_create_namespace('NvimTreeHighlights')
|
||||
|
||||
local icon_state = config.get_icon_state()
|
||||
|
||||
local should_hl_opened_files = (vim.g.nvim_tree_highlight_opened_files or 0) ~= 0
|
||||
|
||||
local get_folder_icon = function() return "" end
|
||||
local function get_trailing_length()
|
||||
return vim.g.nvim_tree_add_trailing and 1 or 0
|
||||
@ -44,7 +46,8 @@ if icon_state.show_folder_icon then
|
||||
end
|
||||
set_folder_hl = function(line, depth, icon_len, name_len, hl_group)
|
||||
table.insert(hl, {hl_group, line, depth+icon_len, depth+icon_len+name_len+get_trailing_length()})
|
||||
table.insert(hl, {'NvimTreeFolderIcon', line, depth, depth+icon_len})
|
||||
local hl_icon = (vim.g.nvim_tree_highlight_opened_files or 0) ~= 0 and hl_group or 'NvimTreeFolderIcon'
|
||||
table.insert(hl, {hl_icon, line, depth, depth+icon_len})
|
||||
end
|
||||
end
|
||||
|
||||
@ -314,9 +317,15 @@ 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 == 1 then
|
||||
if should_hl_opened_files then
|
||||
if vim.fn.bufloaded(node.absolute_path) > 0 then
|
||||
table.insert(hl, {'NvimTreeOpenedFile', index, offset, offset+#icon })
|
||||
if vim.g.nvim_tree_highlight_opened_files == 1 then
|
||||
table.insert(hl, {'NvimTreeOpenedFile', index, offset, offset+#icon }) -- highlight icon only
|
||||
elseif vim.g.nvim_tree_highlight_opened_files == 2 then
|
||||
table.insert(hl, {'NvimTreeOpenedFile', index, offset+#icon+#git_icons, offset+#icon+#git_icons+#node.name }) -- highlight name only
|
||||
elseif vim.g.nvim_tree_highlight_opened_files == 3 then
|
||||
table.insert(hl, {'NvimTreeOpenedFile', index, offset, -1 }) -- highlight whole line
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user