From c003626deef70b900a5768f40759f6c53d2effb3 Mon Sep 17 00:00:00 2001 From: kiyan42 Date: Fri, 3 Apr 2020 11:50:14 +0200 Subject: [PATCH] make linking of default groups for tree style and add docs --- README.md | 2 +- doc/nvim-tree-lua.txt | 10 ++++++++++ doc/tags | 1 + lua/lib/colors.lua | 14 ++++++++++++-- lua/lib/config.lua | 1 + lua/lib/winutils.lua | 2 +- plugin/tree.vim | 4 ---- 7 files changed, 26 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 38ee417a..e2bd12d3 100644 --- a/README.md +++ b/README.md @@ -39,9 +39,9 @@ nnoremap n :LuaTreeFindFile " example configuration: 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 LuaTreeFolderIcon guibg=blue -" ... ``` ## KeyBindings diff --git a/doc/nvim-tree-lua.txt b/doc/nvim-tree-lua.txt index 747b7d0f..e4f7370e 100644 --- a/doc/nvim-tree-lua.txt +++ b/doc/nvim-tree-lua.txt @@ -134,6 +134,8 @@ Mouse support defined in |KeyBindings| ============================================================================== HIGHLIGHT GROUPS *nvim-tree-highlight* +|lua_tree_highlight| *lua_tree_highlight* + All the following highlight groups can be configured by hand. It is not advised to colorize the background of these groups. @@ -175,5 +177,13 @@ LuaTreeGitMerge LuaTreeGitRenamed 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: diff --git a/doc/tags b/doc/tags index 754d05ed..a9ea49b6 100644 --- a/doc/tags +++ b/doc/tags @@ -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_side nvim-tree-lua.txt /*g:lua_tree_side* 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-features nvim-tree-lua.txt /*nvim-tree-features* nvim-tree-highlight nvim-tree-lua.txt /*nvim-tree-highlight* diff --git a/lua/lib/colors.lua b/lua/lib/colors.lua index 49768db2..ed338919 100644 --- a/lua/lib/colors.lua +++ b/lua/lib/colors.lua @@ -32,9 +32,15 @@ local HIGHLIGHTS = { GitStaged = { fg = colors.green }, GitMerge = { fg = colors.orange }, 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() @@ -42,6 +48,10 @@ local function init_colors() local gui = d.gui or 'NONE' vim.api.nvim_command('hi def LuaTree'..k..' gui='..gui..' guifg='..d.fg) end + + for k, d in pairs(LINKS) do + vim.api.nvim_command('hi def link LuaTree'..k..' '..d) + end end return { diff --git a/lua/lib/config.lua b/lua/lib/config.lua index fcedf901..603031a9 100644 --- a/lua/lib/config.lua +++ b/lua/lib/config.lua @@ -26,6 +26,7 @@ local colors = { orange = get('terminal_color_11', 'Orange'), dark_red = get('terminal_color_9', 'DarkRed'), } + return { SHOW_FOLDER_ICON = SHOW_FOLDER_ICON, SHOW_FILE_ICON = SHOW_FILE_ICON, diff --git a/lua/lib/winutils.lua b/lua/lib/winutils.lua index d9a4273a..71fd51c5 100644 --- a/lua/lib/winutils.lua +++ b/lua/lib/winutils.lua @@ -71,7 +71,7 @@ local function open() api.nvim_command('vertical resize '..WIN_WIDTH) 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 api.nvim_command('setlocal '..opt) end diff --git a/plugin/tree.vim b/plugin/tree.vim index 905cf024..17b12193 100644 --- a/plugin/tree.vim +++ b/plugin/tree.vim @@ -18,10 +18,6 @@ if get(g:, 'lua_tree_auto_open') != 0 au VimEnter * lua require'tree'.check_buffer_and_open() 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 au BufEnter * :LuaTreeFindFile endif