Skip to content

Commit 0b4c9d8

Browse files
committed
add config option to disable the icons
1 parent 3678169 commit 0b4c9d8

File tree

5 files changed

+41
-6
lines changed

5 files changed

+41
-6
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ 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
2325
let g:lua_tree_follow = 1 "0 by default, this option will bind BufEnter to the LuaTreeFindFile command
2426
" :help LuaTreeFindFile for more info
2527

doc/nvim-tree-lua.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,16 @@ An array of strings that the tree won't display.
5252
Each pattern is passed into the 'ls' function as `--ignore=PATTERN`
5353
>
5454
example: let g:lua_tree_ignore = [ '.git', 'node_modules' ]
55-
<
55+
56+
|g:lua_tree_show_folders| *g:lua_tree_show_folders*
57+
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
5665

5766
|g:lua_tree_follow| *g:lua_tree_follow*
5867

doc/tags

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
:LuaTreeFindFile nvim-tree-lua.txt /*:LuaTreeFindFile*
22
:LuaTreeRefresh nvim-tree-lua.txt /*:LuaTreeRefresh*
33
:LuaTreeToggle nvim-tree-lua.txt /*:LuaTreeToggle*
4-
g:lua_tree_auto_open nvim-tree-lua.txt /*g:lua_tree_auto_open*
4+
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*
810
g:lua_tree_side nvim-tree-lua.txt /*g:lua_tree_side*
911
g:lua_tree_size nvim-tree-lua.txt /*g:lua_tree_size*
1012
nvim-tree-commands nvim-tree-lua.txt /*nvim-tree-commands*

lua/lib/format.lua

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@ local api = vim.api
22

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

5+
local function get(var, fallback)
6+
if api.nvim_call_function('exists', { 'g:'..var }) == 1 then
7+
return api.nvim_get_var(var)
8+
else
9+
return fallback
10+
end
11+
end
12+
13+
local SHOW_FOLDER_ICON = get('lua_tree_show_folders', 1) == 1
14+
515
local function get_padding(depth)
616
local str = ""
717

@@ -14,7 +24,7 @@ local function get_padding(depth)
1424
end
1525

1626
local function default_icons(_, isdir, open)
17-
if isdir == true then
27+
if isdir == true and SHOW_FOLDER_ICON then
1828
if open == true then return "" end
1929
return ""
2030
end
@@ -122,8 +132,10 @@ local function highlight_line(buffer)
122132
highlight('LuaTreeFolderName', line, 0, -1)
123133

124134
elseif node.dir == true then
125-
text_start = text_start + 4
126-
highlight('LuaTreeFolderIcon', line, 0, text_start)
135+
if SHOW_FOLDER_ICON then
136+
text_start = text_start + 4
137+
highlight('LuaTreeFolderIcon', line, 0, text_start)
138+
end
127139
highlight('LuaTreeFolderName', line, text_start + gitlen, -1)
128140

129141
elseif node.link == true then

lua/lib/git.lua

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,18 @@ local unmerged = create_git_checker('^[U ][U ]')
5151
local renamed = create_git_checker('^R')
5252
local untracked = create_git_checker('^%?%?')
5353

54+
local function get(var, fallback)
55+
if vim.api.nvim_call_function('exists', { 'g:'..var }) == 1 then
56+
return vim.api.nvim_get_var(var)
57+
else
58+
return fallback
59+
end
60+
end
61+
62+
local SHOW_GIT_ICON = get('lua_tree_show_git_icons', 1) == 1
63+
5464
local function get_git_attr(path, is_dir)
55-
if IS_GIT_REPO == false then return '' end
65+
if IS_GIT_REPO == false or not SHOW_GIT_ICON then return '' end
5666
if is_dir then
5767
if is_folder_dirty(path) == true then return '' end
5868
else

0 commit comments

Comments
 (0)