make linking of default groups for tree style and add docs

This commit is contained in:
kiyan42
2020-04-03 11:50:14 +02:00
parent 658e2100eb
commit c003626dee
7 changed files with 26 additions and 8 deletions

View File

@@ -39,9 +39,9 @@ nnoremap <leader>n :LuaTreeFindFile<CR>
" example configuration: " example configuration:
set termguicolors " this variable must be enabled for colors to be applied properly set termguicolors " this variable must be enabled for colors to be applied properly
" a list of groups can be found in `:help lua_tree_highlight`
highlight LuaTreeFolderName guibg=cyan gui=bold,underline highlight LuaTreeFolderName guibg=cyan gui=bold,underline
highlight LuaTreeFolderIcon guibg=blue highlight LuaTreeFolderIcon guibg=blue
" ...
``` ```
## KeyBindings ## KeyBindings

View File

@@ -134,6 +134,8 @@ Mouse support defined in |KeyBindings|
============================================================================== ==============================================================================
HIGHLIGHT GROUPS *nvim-tree-highlight* HIGHLIGHT GROUPS *nvim-tree-highlight*
|lua_tree_highlight| *lua_tree_highlight*
All the following highlight groups can be configured by hand. It is not All the following highlight groups can be configured by hand. It is not
advised to colorize the background of these groups. advised to colorize the background of these groups.
@@ -175,5 +177,13 @@ LuaTreeGitMerge
LuaTreeGitRenamed LuaTreeGitRenamed
LuaTreeGitNew LuaTreeGitNew
There are also links to normal bindings to style the tree itself.
Normal
EndOfBuffer
CursorLine
VertSplit
CursorColumn
vim:tw=78:ts=8:noet:ft=help:norl: vim:tw=78:ts=8:noet:ft=help:norl:

View File

@@ -8,6 +8,7 @@ g:lua_tree_ignore nvim-tree-lua.txt /*g:lua_tree_ignore*
g:lua_tree_show_icons nvim-tree-lua.txt /*g:lua_tree_show_icons* g:lua_tree_show_icons nvim-tree-lua.txt /*g:lua_tree_show_icons*
g:lua_tree_side nvim-tree-lua.txt /*g:lua_tree_side* g:lua_tree_side nvim-tree-lua.txt /*g:lua_tree_side*
g:lua_tree_size nvim-tree-lua.txt /*g:lua_tree_size* g:lua_tree_size nvim-tree-lua.txt /*g:lua_tree_size*
lua_tree_highlight nvim-tree-lua.txt /*lua_tree_highlight*
nvim-tree-commands nvim-tree-lua.txt /*nvim-tree-commands* nvim-tree-commands nvim-tree-lua.txt /*nvim-tree-commands*
nvim-tree-features nvim-tree-lua.txt /*nvim-tree-features* nvim-tree-features nvim-tree-lua.txt /*nvim-tree-features*
nvim-tree-highlight nvim-tree-lua.txt /*nvim-tree-highlight* nvim-tree-highlight nvim-tree-lua.txt /*nvim-tree-highlight*

View File

@@ -32,9 +32,15 @@ local HIGHLIGHTS = {
GitStaged = { fg = colors.green }, GitStaged = { fg = colors.green },
GitMerge = { fg = colors.orange }, GitMerge = { fg = colors.orange },
GitRenamed = { fg = colors.purple }, GitRenamed = { fg = colors.purple },
GitNew = { fg = colors.yellow }, GitNew = { fg = colors.yellow }
}
EndOfBuffer = { fg = 'bg' } local LINKS = {
Normal = 'Normal',
EndOfBuffer = 'EndOfBuffer',
CursorLine = 'CursorLine',
VertSplit = 'VertSplit',
CursorColumn = 'CursorColumn'
} }
local function init_colors() local function init_colors()
@@ -42,6 +48,10 @@ local function init_colors()
local gui = d.gui or 'NONE' local gui = d.gui or 'NONE'
vim.api.nvim_command('hi def LuaTree'..k..' gui='..gui..' guifg='..d.fg) vim.api.nvim_command('hi def LuaTree'..k..' gui='..gui..' guifg='..d.fg)
end end
for k, d in pairs(LINKS) do
vim.api.nvim_command('hi def link LuaTree'..k..' '..d)
end
end end
return { return {

View File

@@ -26,6 +26,7 @@ local colors = {
orange = get('terminal_color_11', 'Orange'), orange = get('terminal_color_11', 'Orange'),
dark_red = get('terminal_color_9', 'DarkRed'), dark_red = get('terminal_color_9', 'DarkRed'),
} }
return { return {
SHOW_FOLDER_ICON = SHOW_FOLDER_ICON, SHOW_FOLDER_ICON = SHOW_FOLDER_ICON,
SHOW_FILE_ICON = SHOW_FILE_ICON, SHOW_FILE_ICON = SHOW_FILE_ICON,

View File

@@ -71,7 +71,7 @@ local function open()
api.nvim_command('vertical resize '..WIN_WIDTH) api.nvim_command('vertical resize '..WIN_WIDTH)
api.nvim_win_set_buf(0, buf) api.nvim_win_set_buf(0, buf)
api.nvim_command('setlocal winhighlight=EndOfBuffer:LuaTreeEndOfBuffer') api.nvim_command('setlocal winhighlight=EndOfBuffer:LuaTreeEndOfBuffer,Normal:LuaTreeNormal,CursorLine:LuaTreeCursorLine,VertSplit:LuaTreeVertSplit')
for _, opt in pairs(BUF_OPTIONS) do for _, opt in pairs(BUF_OPTIONS) do
api.nvim_command('setlocal '..opt) api.nvim_command('setlocal '..opt)
end end

View File

@@ -18,10 +18,6 @@ if get(g:, 'lua_tree_auto_open') != 0
au VimEnter * lua require'tree'.check_buffer_and_open() au VimEnter * lua require'tree'.check_buffer_and_open()
endif endif
" TODO set status line dynamically on bufenter in the luatree
" to remove lightline and other possible components
au BufEnter LuaTree setlocal statusline=""
if get(g:, 'lua_tree_follow') != 0 if get(g:, 'lua_tree_follow') != 0
au BufEnter * :LuaTreeFindFile au BufEnter * :LuaTreeFindFile
endif endif