Improve highlight options (#331)
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user