Skip to content

Commit 7e3ff3d

Browse files
committed
change icon selection
1 parent abaf077 commit 7e3ff3d

File tree

5 files changed

+30
-20
lines changed

5 files changed

+30
-20
lines changed

README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,16 @@ let g:lua_tree_size = 40 "30 by default
2020
let g:lua_tree_ignore = [ '.git', 'node_modules', '.cache' ] "empty by default, not working on mac atm
2121
let g:lua_tree_auto_open = 1 "0 by default, opens the tree when typing `vim $DIR` or `vim`
2222
let g:lua_tree_auto_close = 1 "0 by default, closes the tree when it's the last window
23-
let g:lua_tree_show_folders = 0 "1 by default, do not show folder icons if you font doesn't render them
24-
let g:lua_tree_show_git_icons = 0 "1 by default, do not show git icons if you font doesn't render them
2523
let g:lua_tree_follow = 1 "0 by default, this option will bind BufEnter to the LuaTreeFindFile command
2624
" :help LuaTreeFindFile for more info
25+
let g:lua_tree_show_icons = {
26+
\ 'git': 1,
27+
\ 'folders': 0,
28+
\ 'files': 0,
29+
\}
30+
"If 0, do not show the icons for one of 'git' 'folder' and 'files'
31+
"1 by default, notice that if 'files' is 1, it will only display
32+
"if web-devicons is installed and on your runtimepath
2733
2834
nnoremap <C-n> :LuaTreeToggle<CR>
2935
nnoremap <leader>r :LuaTreeRefresh<CR>
@@ -67,9 +73,6 @@ nnoremap <leader>n :LuaTreeFindFile<CR>
6773
- refactor all `system` call to `libuv` functions, with better error management
6874
- bufferize leafs of node being closed so when opening again the node, we open every directory that was previously open
6975

70-
### Code
71-
- change `lua_tree_show...` to an object
72-
7376
### Features
7477
- sneak like cd command to find a file/directory
7578
- better default colors (use default vim groups)

doc/nvim-tree-lua.txt

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,21 @@ Each pattern is passed into the 'ls' function as `--ignore=PATTERN`
5353
>
5454
example: let g:lua_tree_ignore = [ '.git', 'node_modules' ]
5555
56-
|g:lua_tree_show_folders| *g:lua_tree_show_folders*
56+
|g:lua_tree_show_icons| *g:lua_tree_show_icons*
5757

58-
Can be `0` or `1`. When `0` it will not show the folder icons
59-
Default is 1
60-
61-
|g:lua_tree_show_git_icons| *g:lua_tree_show_git_icons*
62-
63-
Can be `0` or `1`. When `0` it will not show git icons.
64-
Default is 1
58+
Dictionnary, if your terminal or font doesn't support certain unicode
59+
character, the tree UI might be messed up. The following configuration
60+
can disable icons per type:
61+
>
62+
let g:lua_tree_show_icons = {
63+
\ 'git': 1,
64+
\ 'folders': 1,
65+
\ 'icons': 1
66+
\}
67+
68+
Can be one of `1` and `0` for each key. By default the tree will try
69+
to render the icons. The `icons` key can only work if `vim-devicons`
70+
is installed and in your |runtimepath|
6571

6672
|g:lua_tree_follow| *g:lua_tree_follow*
6773

doc/tags

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ g:lua_tree_auto_close nvim-tree-lua.txt /*g:lua_tree_auto_close*
55
g:lua_tree_auto_open nvim-tree-lua.txt /*g:lua_tree_auto_open*
66
g:lua_tree_follow nvim-tree-lua.txt /*g:lua_tree_follow*
77
g:lua_tree_ignore nvim-tree-lua.txt /*g:lua_tree_ignore*
8-
g:lua_tree_show_folders nvim-tree-lua.txt /*g:lua_tree_show_folders*
9-
g:lua_tree_show_git_icons nvim-tree-lua.txt /*g:lua_tree_show_git_icons*
8+
g:lua_tree_show_icons nvim-tree-lua.txt /*g:lua_tree_show_icons*
109
g:lua_tree_side nvim-tree-lua.txt /*g:lua_tree_side*
1110
g:lua_tree_size nvim-tree-lua.txt /*g:lua_tree_size*
1211
nvim-tree-commands nvim-tree-lua.txt /*nvim-tree-commands*

lua/lib/config.lua

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ end
1010

1111
local HAS_DEV_ICONS = api.nvim_call_function('exists', { "*WebDevIconsGetFileTypeSymbol" }) == 1
1212

13-
local SHOW_FOLDER_ICON = get('lua_tree_show_folders', 1) == 1
13+
local show_icons = get('lua_tree_show_icons', { git = 1, folders = 1, files = 1 })
1414

15-
local SHOW_GIT_ICON = get('lua_tree_show_git_icons', 1) == 1
15+
local SHOW_FILE_ICON = HAS_DEV_ICONS and show_icons.files == 1
16+
local SHOW_FOLDER_ICON = show_icons.folders == 1
17+
local SHOW_GIT_ICON = show_icons.git == 1
1618

1719
local colors = {
1820
red = get('terminal_color_1', 'Red'),
@@ -26,7 +28,7 @@ local colors = {
2628
}
2729
return {
2830
SHOW_FOLDER_ICON = SHOW_FOLDER_ICON,
29-
HAS_DEV_ICONS = HAS_DEV_ICONS,
31+
SHOW_FILE_ICON = SHOW_FILE_ICON,
3032
SHOW_GIT_ICON = SHOW_GIT_ICON,
3133
colors = colors
3234
}

lua/lib/format.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ local function dev_icons(pathname, isdir, open)
5959
end
6060

6161
local function get_icon_func_gen()
62-
if config.HAS_DEV_ICONS then
62+
if config.SHOW_FILE_ICON then
6363
return dev_icons
6464
else
6565
return default_icons
@@ -140,7 +140,7 @@ local function highlight_line(buffer)
140140
elseif is_pic(node.path .. node.name) then
141141
highlight('LuaTreeImageFile', line, text_start + gitlen, -1)
142142

143-
elseif config.HAS_DEV_ICONS then
143+
elseif config.SHOW_FILE_ICON then
144144
for k, v in pairs(HIGHLIGHT_GROUPS) do
145145
if string.match(node.name, k) ~= nil then
146146
text_start = text_start + 4

0 commit comments

Comments
 (0)