Skip to content

Commit 658e210

Browse files
committed
add documentation for highlight groups
1 parent 41b050a commit 658e210

File tree

5 files changed

+92
-40
lines changed

5 files changed

+92
-40
lines changed

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ let g:lua_tree_show_icons = {
3434
nnoremap <C-n> :LuaTreeToggle<CR>
3535
nnoremap <leader>r :LuaTreeRefresh<CR>
3636
nnoremap <leader>n :LuaTreeFindFile<CR>
37+
38+
" a list of highlight groups is available at :help nvim-tree-highlight
39+
" example configuration:
40+
set termguicolors " this variable must be enabled for colors to be applied properly
41+
42+
highlight LuaTreeFolderName guibg=cyan gui=bold,underline
43+
highlight LuaTreeFolderIcon guibg=blue
44+
" ...
3745
```
3846

3947
## KeyBindings
@@ -74,5 +82,4 @@ nnoremap <leader>n :LuaTreeFindFile<CR>
7482

7583
### Features
7684
- better default colors (use vim highlight groups)
77-
- create proper highlight groups or add highlight function to give the user ability to setup colors themselves
7885
- bufferize leafs of node being closed so when opening again the node, we open every directory that was previously open

doc/nvim-tree-lua.txt

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,5 +131,49 @@ Git integration tells when a file is:
131131

132132
Mouse support defined in |KeyBindings|
133133

134+
==============================================================================
135+
HIGHLIGHT GROUPS *nvim-tree-highlight*
136+
137+
All the following highlight groups can be configured by hand. It is not
138+
advised to colorize the background of these groups.
139+
140+
Example (in your `init.vim`):
141+
>
142+
highlight LuaTreeSymlink guifg=blue gui=bold,underline
143+
<
144+
You should have 'termguicolors' enabled, otherwise, colors will not be
145+
applied.
146+
147+
LuaTreeSymlink
148+
LuaTreeFolderName
149+
LuaTreeFolderIcon
150+
LuaTreeExecFile
151+
LuaTreeSpecialFile
152+
LuaTreeImageFile
153+
LuaTreeMarkdownFile
154+
155+
LuaTreeLicenseIcon
156+
LuaTreeYamlIcon
157+
LuaTreeTomlIcon
158+
LuaTreeGitignoreIcon
159+
LuaTreeJsonIcon
160+
161+
LuaTreeLuaIcon
162+
LuaTreePythonIcon
163+
LuaTreeShellIcon
164+
LuaTreeJavascriptIcon
165+
LuaTreeCIcon
166+
LuaTreeReactIcon
167+
LuaTreeHtmlIcon
168+
LuaTreeRustIcon
169+
LuaTreeVimIcon
170+
LuaTreeTypescriptIcon
171+
172+
LuaTreeGitDirty
173+
LuaTreeGitStaged
174+
LuaTreeGitMerge
175+
LuaTreeGitRenamed
176+
LuaTreeGitNew
177+
134178
vim:tw=78:ts=8:noet:ft=help:norl:
135179

doc/tags

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ g:lua_tree_side nvim-tree-lua.txt /*g:lua_tree_side*
1010
g:lua_tree_size nvim-tree-lua.txt /*g:lua_tree_size*
1111
nvim-tree-commands nvim-tree-lua.txt /*nvim-tree-commands*
1212
nvim-tree-features nvim-tree-lua.txt /*nvim-tree-features*
13+
nvim-tree-highlight nvim-tree-lua.txt /*nvim-tree-highlight*
1314
nvim-tree-info nvim-tree-lua.txt /*nvim-tree-info*
1415
nvim-tree-introduction nvim-tree-lua.txt /*nvim-tree-introduction*
1516
nvim-tree-keybindings nvim-tree-lua.txt /*nvim-tree-keybindings*

lua/lib/colors.lua

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,22 @@ local HIGHLIGHTS = {
1111
SpecialFile = { gui = 'bold,underline', fg = colors.yellow },
1212
ImageFile = { gui = 'bold', fg = colors.purple },
1313
MarkdownFile = { fg = colors.purple },
14-
LicenseFile = { fg = colors.yellow },
15-
YamlFile = { fg = colors.yellow },
16-
TomlFile = { fg = colors.yellow },
17-
GitignoreFile = { fg = colors.yellow },
18-
JsonFile = { fg = colors.yellow },
19-
20-
LuaFile = { fg = '#42a5f5' },
21-
PythonFile = { fg = colors.green },
22-
ShellFile = { fg = colors.green },
23-
JavascriptFile = { fg = colors.yellow },
24-
CFile = { fg = colors.blue },
25-
ReactFile = { fg = colors.cyan },
26-
HtmlFile = { fg = colors.orange },
27-
RustFile = { fg = colors.orange },
28-
VimFile = { fg = colors.green },
29-
TypescriptFile = { fg = colors.blue },
14+
LicenseIcon = { fg = colors.yellow },
15+
YamlIcon = { fg = colors.yellow },
16+
TomlIcon = { fg = colors.yellow },
17+
GitignoreIcon = { fg = colors.yellow },
18+
JsonIcon = { fg = colors.yellow },
19+
20+
LuaIcon = { fg = '#42a5f5' },
21+
PythonIcon = { fg = colors.green },
22+
ShellIcon = { fg = colors.green },
23+
JavascriptIcon = { fg = colors.yellow },
24+
CIcon = { fg = colors.blue },
25+
ReactIcon = { fg = colors.cyan },
26+
HtmlIcon = { fg = colors.orange },
27+
RustIcon = { fg = colors.orange },
28+
VimIcon = { fg = colors.green },
29+
TypescriptIcon = { fg = colors.blue },
3030

3131
GitDirty = { fg = colors.dark_red },
3232
GitStaged = { fg = colors.green },

lua/lib/format.lua

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -87,28 +87,28 @@ local function format_tree(tree)
8787
return dirs
8888
end
8989

90-
local HIGHLIGHT_GROUPS = {
91-
['^LICENSE$'] = 'LicenseFile';
92-
['^%.?vimrc$'] = 'VimFile';
93-
['%.vim$'] = 'VimFile';
94-
['%.c$'] = 'CFile';
95-
['%.cpp$'] = 'CFile';
96-
['%.cxx$'] = 'CFile';
97-
['%.h$'] = 'CFile';
98-
['%.hpp$'] = 'CFile';
99-
['%.py$'] = 'PythonFile';
100-
['%.lua$'] = 'LuaFile';
101-
['%.rs$'] = 'RustFile';
102-
['%.[cz]?sh$'] = 'ShellFile';
103-
['%.md$'] = 'MarkdownFile';
104-
['%.json$'] = 'JsonFile';
105-
['%.toml$'] = 'TomlFile';
106-
['%.yml$'] = 'YamlFile';
107-
['%.gitignore$'] = 'GitignoreFile';
108-
['%.js$'] = 'JavascriptFile';
109-
['%.ts$'] = 'TypescriptFile';
110-
['%.[tj]sx$'] = 'ReactFile';
111-
['%.html?$'] = 'HtmlFile';
90+
local HIGHLIGHT_ICON_GROUPS = {
91+
['^LICENSE$'] = 'LicenseIcon';
92+
['^%.?vimrc$'] = 'VimIcon';
93+
['%.vim$'] = 'VimIcon';
94+
['%.c$'] = 'CIcon';
95+
['%.cpp$'] = 'CIcon';
96+
['%.cxx$'] = 'CIcon';
97+
['%.h$'] = 'CIcon';
98+
['%.hpp$'] = 'CIcon';
99+
['%.py$'] = 'PythonIcon';
100+
['%.lua$'] = 'LuaIcon';
101+
['%.rs$'] = 'RustIcon';
102+
['%.[cz]?sh$'] = 'ShellIcon';
103+
['%.md$'] = 'MarkdownIcon';
104+
['%.json$'] = 'JsonIcon';
105+
['%.toml$'] = 'TomlIcon';
106+
['%.yml$'] = 'YamlIcon';
107+
['%.gitignore$'] = 'GitignoreIcon';
108+
['%.js$'] = 'JavascriptIcon';
109+
['%.ts$'] = 'TypescriptIcon';
110+
['%.[tj]sx$'] = 'ReactIcon';
111+
['%.html?$'] = 'HtmlIcon';
112112
}
113113

114114
local function highlight_line(buffer)
@@ -141,7 +141,7 @@ local function highlight_line(buffer)
141141
highlight('LuaTreeImageFile', line, text_start + gitlen, -1)
142142

143143
elseif config.SHOW_FILE_ICON then
144-
for k, v in pairs(HIGHLIGHT_GROUPS) do
144+
for k, v in pairs(HIGHLIGHT_ICON_GROUPS) do
145145
if string.match(node.name, k) ~= nil then
146146
text_start = text_start + 4
147147
highlight('LuaTree' .. v, line, 0, text_start)

0 commit comments

Comments
 (0)