diff --git a/README.md b/README.md index a31adb4a..18e34ec4 100644 --- a/README.md +++ b/README.md @@ -20,10 +20,16 @@ let g:lua_tree_size = 40 "30 by default let g:lua_tree_ignore = [ '.git', 'node_modules', '.cache' ] "empty by default, not working on mac atm let g:lua_tree_auto_open = 1 "0 by default, opens the tree when typing `vim $DIR` or `vim` let g:lua_tree_auto_close = 1 "0 by default, closes the tree when it's the last window -let g:lua_tree_show_folders = 0 "1 by default, do not show folder icons if you font doesn't render them -let g:lua_tree_show_git_icons = 0 "1 by default, do not show git icons if you font doesn't render them let g:lua_tree_follow = 1 "0 by default, this option will bind BufEnter to the LuaTreeFindFile command " :help LuaTreeFindFile for more info +let g:lua_tree_show_icons = { + \ 'git': 1, + \ 'folders': 0, + \ 'files': 0, + \} +"If 0, do not show the icons for one of 'git' 'folder' and 'files' +"1 by default, notice that if 'files' is 1, it will only display +"if web-devicons is installed and on your runtimepath nnoremap :LuaTreeToggle nnoremap r :LuaTreeRefresh @@ -67,9 +73,6 @@ nnoremap n :LuaTreeFindFile - refactor all `system` call to `libuv` functions, with better error management - bufferize leafs of node being closed so when opening again the node, we open every directory that was previously open -### Code -- change `lua_tree_show...` to an object - ### Features - sneak like cd command to find a file/directory - better default colors (use default vim groups) diff --git a/doc/nvim-tree-lua.txt b/doc/nvim-tree-lua.txt index ce58da2a..297c5a43 100644 --- a/doc/nvim-tree-lua.txt +++ b/doc/nvim-tree-lua.txt @@ -53,15 +53,21 @@ Each pattern is passed into the 'ls' function as `--ignore=PATTERN` > example: let g:lua_tree_ignore = [ '.git', 'node_modules' ] -|g:lua_tree_show_folders| *g:lua_tree_show_folders* +|g:lua_tree_show_icons| *g:lua_tree_show_icons* -Can be `0` or `1`. When `0` it will not show the folder icons -Default is 1 +Dictionnary, if your terminal or font doesn't support certain unicode +character, the tree UI might be messed up. The following configuration +can disable icons per type: +> + let g:lua_tree_show_icons = { + \ 'git': 1, + \ 'folders': 1, + \ 'icons': 1 + \} -|g:lua_tree_show_git_icons| *g:lua_tree_show_git_icons* - -Can be `0` or `1`. When `0` it will not show git icons. -Default is 1 +Can be one of `1` and `0` for each key. By default the tree will try +to render the icons. The `icons` key can only work if `vim-devicons` +is installed and in your |runtimepath| |g:lua_tree_follow| *g:lua_tree_follow* diff --git a/doc/tags b/doc/tags index 065d42f4..c67ceb2a 100644 --- a/doc/tags +++ b/doc/tags @@ -5,8 +5,7 @@ g:lua_tree_auto_close nvim-tree-lua.txt /*g:lua_tree_auto_close* g:lua_tree_auto_open nvim-tree-lua.txt /*g:lua_tree_auto_open* g:lua_tree_follow nvim-tree-lua.txt /*g:lua_tree_follow* g:lua_tree_ignore nvim-tree-lua.txt /*g:lua_tree_ignore* -g:lua_tree_show_folders nvim-tree-lua.txt /*g:lua_tree_show_folders* -g:lua_tree_show_git_icons nvim-tree-lua.txt /*g:lua_tree_show_git_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_size nvim-tree-lua.txt /*g:lua_tree_size* nvim-tree-commands nvim-tree-lua.txt /*nvim-tree-commands* diff --git a/lua/lib/config.lua b/lua/lib/config.lua index 7cc53ece..fcedf901 100644 --- a/lua/lib/config.lua +++ b/lua/lib/config.lua @@ -10,9 +10,11 @@ end local HAS_DEV_ICONS = api.nvim_call_function('exists', { "*WebDevIconsGetFileTypeSymbol" }) == 1 -local SHOW_FOLDER_ICON = get('lua_tree_show_folders', 1) == 1 +local show_icons = get('lua_tree_show_icons', { git = 1, folders = 1, files = 1 }) -local SHOW_GIT_ICON = get('lua_tree_show_git_icons', 1) == 1 +local SHOW_FILE_ICON = HAS_DEV_ICONS and show_icons.files == 1 +local SHOW_FOLDER_ICON = show_icons.folders == 1 +local SHOW_GIT_ICON = show_icons.git == 1 local colors = { red = get('terminal_color_1', 'Red'), @@ -26,7 +28,7 @@ local colors = { } return { SHOW_FOLDER_ICON = SHOW_FOLDER_ICON, - HAS_DEV_ICONS = HAS_DEV_ICONS, + SHOW_FILE_ICON = SHOW_FILE_ICON, SHOW_GIT_ICON = SHOW_GIT_ICON, colors = colors } diff --git a/lua/lib/format.lua b/lua/lib/format.lua index ef22ab77..f1bfc3e2 100644 --- a/lua/lib/format.lua +++ b/lua/lib/format.lua @@ -59,7 +59,7 @@ local function dev_icons(pathname, isdir, open) end local function get_icon_func_gen() - if config.HAS_DEV_ICONS then + if config.SHOW_FILE_ICON then return dev_icons else return default_icons @@ -140,7 +140,7 @@ local function highlight_line(buffer) elseif is_pic(node.path .. node.name) then highlight('LuaTreeImageFile', line, text_start + gitlen, -1) - elseif config.HAS_DEV_ICONS then + elseif config.SHOW_FILE_ICON then for k, v in pairs(HIGHLIGHT_GROUPS) do if string.match(node.name, k) ~= nil then text_start = text_start + 4