add icon padding

This commit is contained in:
kiyan 2021-06-07 17:34:02 +02:00
parent 82f1598bd4
commit f1f14885f7
3 changed files with 13 additions and 6 deletions

View File

@ -40,6 +40,7 @@ let g:nvim_tree_group_empty = 1 " 0 by default, compact folders that only contai
let g:nvim_tree_lsp_diagnostics = 1 "0 by default, will show lsp diagnostics in the signcolumn. See :help nvim_tree_lsp_diagnostics
let g:nvim_tree_disable_window_picker = 1 "0 by default, will disable the window picker.
let g:nvim_tree_hijack_cursor = 0 "1 by default, when moving cursor in the tree, will position the cursor at the start of the file on the current line
let g:nvim_tree_icon_padding = ' ' "one space by default, used for rendering the space between the icon and the filename. Use with caution, it could break rendering if you set an empty string depending on your font.
let g:nvim_tree_window_picker_exclude = {
\ 'filetype': [
\ 'packer',

View File

@ -293,6 +293,10 @@ Can be 0 or 1. 1 by default.
When 1, moving cursor in the tree will position the cursor at the start
of the file on the current line.
|g:nvim_tree_icon_padding| *g:nvim_tree_icon_padding*
One space by default, used for rendering the space between the icon and the filename. Use with caution, it could break rendering if you set an empty string depending on your font.
==============================================================================
INFORMATIONS *nvim-tree-info*

View File

@ -22,6 +22,8 @@ local set_folder_hl = function(line, depth, git_icon_len, _, hl_group)
table.insert(hl, {hl_group, line, depth+git_icon_len, -1})
end
local icon_padding = vim.g.nvim_tree_icon_padding or " "
if icon_state.show_folder_icon then
get_folder_icon = function(open, is_symlink, has_children)
local n = ""
@ -42,7 +44,7 @@ if icon_state.show_folder_icon then
n = icon_state.icons.folder_icons.empty
end
end
return n.." "
return n..icon_padding
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()})
@ -62,12 +64,12 @@ if icon_state.show_file_icon then
if hl_group then
table.insert(hl, { hl_group, line, depth, depth + #icon + 1 })
end
return icon.." "
return icon..icon_padding
elseif string.match(extension, "%.(.*)") then
-- If there are more extensions to the file, try to grab the icon for them recursively
return get_file_icon(fname, string.match(extension, "%.(.*)"), line, depth)
else
return #icon_state.icons.default > 0 and icon_state.icons.default.." " or ""
return #icon_state.icons.default > 0 and icon_state.icons.default..icon_padding or ""
end
end
@ -76,14 +78,14 @@ end
local get_symlink_icon = function() return icon_state.icons.symlink end
if icon_state.show_file_icon then
get_symlink_icon = function()
return #icon_state.icons.symlink > 0 and icon_state.icons.symlink.." " or ""
return #icon_state.icons.symlink > 0 and icon_state.icons.symlink..icon_padding or ""
end
end
local get_special_icon = function() return icon_state.icons.default end
if icon_state.show_file_icon then
get_special_icon = function()
return #icon_state.icons.default > 0 and icon_state.icons.default.." " or ""
return #icon_state.icons.default > 0 and icon_state.icons.default..icon_padding or ""
end
end
@ -204,7 +206,7 @@ if icon_state.show_git_icon then
end
for _, v in ipairs(icons) do
table.insert(hl, { v.hl, line, depth+icon_len+#icon, depth+icon_len+#icon+#v.icon })
icon = icon..v.icon.." "
icon = icon..v.icon..icon_padding
end
return icon