diff --git a/README.md b/README.md index bfe984fa..580a0a88 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,7 @@ let g:lua_tree_bindings = { \ 'edit_tab': '', \ 'toggle_ignored': 'I', \ 'toggle_dotfiles': 'H', + \ 'refresh': 'R', \ 'preview': '', \ 'cd': '', \ 'create': 'a', @@ -73,6 +74,7 @@ let g:lua_tree_bindings = { " default shows no icon by default let g:lua_tree_icons = { \ 'default': '', + \ 'symlink': '', \ 'git': { \ 'unstaged': "✗", \ 'staged': "✓", @@ -119,6 +121,7 @@ highlight LuaTreeFolderIcon guibg=blue - `` will open the file as a preview (keeps the cursor in the tree) - `I` will toggle visibility of folders hidden via |g:lua_tree_ignore| - `H` will toggle visibility of dotfiles (files/folders starting with a `.`) +- `R` will refresh the tree - `gx` opens the file with the `open` command on MACOS and `xdg-open` in linux - Double left click acts like `` - Double right click acts like `` @@ -127,7 +130,7 @@ highlight LuaTreeFolderIcon guibg=blue This plugin is very fast because it uses the `libuv` `scandir` and `scandir_next` functions instead of spawning an `ls` process which can get slow on large files when combining with `stat` to get file informations. -The Netrw vim plugin is disabled, hence features like `gx` don't work accross your windows/buffers. You could use a plugin like [this one](https://github.com/stsewd/gx-extended.vim) if you wish to use that feature. +The Netrw vim plugin is disabled, hence features like `gx` don't work across your windows/buffers. You could use a plugin like [this one](https://github.com/stsewd/gx-extended.vim) if you wish to use that feature. ## Features - Open file in current buffer or in split with FzF like bindings (``, ``, ``, ``) diff --git a/doc/nvim-tree-lua.txt b/doc/nvim-tree-lua.txt index c9db0bff..2c2fb0ec 100644 --- a/doc/nvim-tree-lua.txt +++ b/doc/nvim-tree-lua.txt @@ -87,11 +87,16 @@ is installed and in your |runtimepath| |g:lua_tree_icons| *g:lua_tree_icons* -You can set some icons for the git status and the default icon that shows -when no icon is found for a file. +You can set icons for: + +- The git status. +- The default icon that shows when no icon is found for a file + or if you are not using icons. +- Symlinks. If an icon is not provided, the `default` icon is used. > let g:lua_tree_icons = { \ 'default': '', + \ 'symlink': '', \ 'git': { \ 'unstaged': "✗", \ 'staged': "✓", diff --git a/lua/lib/config.lua b/lua/lib/config.lua index f91592a6..874a81cc 100644 --- a/lua/lib/config.lua +++ b/lua/lib/config.lua @@ -4,6 +4,7 @@ function M.get_icon_state() local show_icons = vim.g.lua_tree_show_icons or { git = 1, folders = 1, files = 1 } local icons = { default = "", + symlink = "", git_icons = { unstaged = "✗", staged = "✓", @@ -22,6 +23,10 @@ function M.get_icon_state() if user_icons then if user_icons.default then icons.default = user_icons.default + icons.symlink = user_icons.default + end + if user_icons.symlink then + icons.symlink = user_icons.symlink end for key, val in pairs(user_icons.git or {}) do if icons.git_icons[key] then diff --git a/lua/lib/renderer.lua b/lua/lib/renderer.lua index 546d7ecd..24117ba4 100644 --- a/lua/lib/renderer.lua +++ b/lua/lib/renderer.lua @@ -49,6 +49,20 @@ if icon_state.show_file_icon then end +local get_symlink_icon = function() return icon_state.icons.symlink end +if icon_state.show_file_icon then + get_symlink_icon = function() + return #icon_state.icons.symlink > 0 and icon_state.icons.symlink.." " or "" + end +end + +local get_special_icon = function() return icon_state.icons.default end +if icon_state.show_file_icon then + get_special_icon = function() + return icon_state.icons.default.." " + end +end + local get_git_icons = function() return "" end local get_git_hl = function() return end @@ -210,17 +224,17 @@ local function update_draw_data(tree, depth, markers) table.insert(lines, padding..icon..git_icon..node.name) end elseif node.link_to then + local icon = get_symlink_icon() local link_hl = git_hl or 'LuaTreeSymlink' table.insert(hl, { link_hl, index, offset, -1 }) - table.insert(lines, padding..node.name.." ➛ "..node.link_to) + table.insert(lines, padding..icon..node.name.." ➛ "..node.link_to) index = index + 1 else local icon local git_icons if special[node.name] then - icon = icon_state.icons.default - if icon ~= "" then icon = icon.." " end + icon = get_special_icon() git_icons = get_git_icons(node, index, offset, 0) table.insert(hl, {'LuaTreeSpecialFile', index, offset+#git_icons, -1}) else