Fallback to default icon for symlinks and fix padding
Fixes https://github.com/kyazdani42/nvim-tree.lua/issues/80
This commit is contained in:
committed by
Kiyan Yazdani
parent
62846b1e31
commit
222732d9d4
@@ -53,6 +53,7 @@ let g:lua_tree_bindings = {
|
|||||||
\ 'edit_tab': '<C-t>',
|
\ 'edit_tab': '<C-t>',
|
||||||
\ 'toggle_ignored': 'I',
|
\ 'toggle_ignored': 'I',
|
||||||
\ 'toggle_dotfiles': 'H',
|
\ 'toggle_dotfiles': 'H',
|
||||||
|
\ 'refresh': 'R',
|
||||||
\ 'preview': '<Tab>',
|
\ 'preview': '<Tab>',
|
||||||
\ 'cd': '<C-]>',
|
\ 'cd': '<C-]>',
|
||||||
\ 'create': 'a',
|
\ 'create': 'a',
|
||||||
@@ -73,6 +74,7 @@ let g:lua_tree_bindings = {
|
|||||||
" default shows no icon by default
|
" default shows no icon by default
|
||||||
let g:lua_tree_icons = {
|
let g:lua_tree_icons = {
|
||||||
\ 'default': '',
|
\ 'default': '',
|
||||||
|
\ 'symlink': '',
|
||||||
\ 'git': {
|
\ 'git': {
|
||||||
\ 'unstaged': "✗",
|
\ 'unstaged': "✗",
|
||||||
\ 'staged': "✓",
|
\ 'staged': "✓",
|
||||||
@@ -119,6 +121,7 @@ highlight LuaTreeFolderIcon guibg=blue
|
|||||||
- `<Tab>` will open the file as a preview (keeps the cursor in the tree)
|
- `<Tab>` 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|
|
- `I` will toggle visibility of folders hidden via |g:lua_tree_ignore|
|
||||||
- `H` will toggle visibility of dotfiles (files/folders starting with a `.`)
|
- `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
|
- `gx` opens the file with the `open` command on MACOS and `xdg-open` in linux
|
||||||
- Double left click acts like `<CR>`
|
- Double left click acts like `<CR>`
|
||||||
- Double right click acts like `<C-]>`
|
- Double right click acts like `<C-]>`
|
||||||
@@ -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.
|
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
|
## Features
|
||||||
- Open file in current buffer or in split with FzF like bindings (`<CR>`, `<C-v>`, `<C-x>`, `<C-t>`)
|
- Open file in current buffer or in split with FzF like bindings (`<CR>`, `<C-v>`, `<C-x>`, `<C-t>`)
|
||||||
|
|||||||
@@ -87,11 +87,16 @@ is installed and in your |runtimepath|
|
|||||||
|
|
||||||
|g:lua_tree_icons| *g:lua_tree_icons*
|
|g:lua_tree_icons| *g:lua_tree_icons*
|
||||||
|
|
||||||
You can set some icons for the git status and the default icon that shows
|
You can set icons for:
|
||||||
when no icon is found for a file.
|
|
||||||
|
- 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 = {
|
let g:lua_tree_icons = {
|
||||||
\ 'default': '',
|
\ 'default': '',
|
||||||
|
\ 'symlink': '',
|
||||||
\ 'git': {
|
\ 'git': {
|
||||||
\ 'unstaged': "✗",
|
\ 'unstaged': "✗",
|
||||||
\ 'staged': "✓",
|
\ 'staged': "✓",
|
||||||
|
|||||||
@@ -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 show_icons = vim.g.lua_tree_show_icons or { git = 1, folders = 1, files = 1 }
|
||||||
local icons = {
|
local icons = {
|
||||||
default = "",
|
default = "",
|
||||||
|
symlink = "",
|
||||||
git_icons = {
|
git_icons = {
|
||||||
unstaged = "✗",
|
unstaged = "✗",
|
||||||
staged = "✓",
|
staged = "✓",
|
||||||
@@ -22,6 +23,10 @@ function M.get_icon_state()
|
|||||||
if user_icons then
|
if user_icons then
|
||||||
if user_icons.default then
|
if user_icons.default then
|
||||||
icons.default = user_icons.default
|
icons.default = user_icons.default
|
||||||
|
icons.symlink = user_icons.default
|
||||||
|
end
|
||||||
|
if user_icons.symlink then
|
||||||
|
icons.symlink = user_icons.symlink
|
||||||
end
|
end
|
||||||
for key, val in pairs(user_icons.git or {}) do
|
for key, val in pairs(user_icons.git or {}) do
|
||||||
if icons.git_icons[key] then
|
if icons.git_icons[key] then
|
||||||
|
|||||||
@@ -49,6 +49,20 @@ if icon_state.show_file_icon then
|
|||||||
|
|
||||||
end
|
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_icons = function() return "" end
|
||||||
local get_git_hl = 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)
|
table.insert(lines, padding..icon..git_icon..node.name)
|
||||||
end
|
end
|
||||||
elseif node.link_to then
|
elseif node.link_to then
|
||||||
|
local icon = get_symlink_icon()
|
||||||
local link_hl = git_hl or 'LuaTreeSymlink'
|
local link_hl = git_hl or 'LuaTreeSymlink'
|
||||||
table.insert(hl, { link_hl, index, offset, -1 })
|
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
|
index = index + 1
|
||||||
|
|
||||||
else
|
else
|
||||||
local icon
|
local icon
|
||||||
local git_icons
|
local git_icons
|
||||||
if special[node.name] then
|
if special[node.name] then
|
||||||
icon = icon_state.icons.default
|
icon = get_special_icon()
|
||||||
if icon ~= "" then icon = icon.." " end
|
|
||||||
git_icons = get_git_icons(node, index, offset, 0)
|
git_icons = get_git_icons(node, index, offset, 0)
|
||||||
table.insert(hl, {'LuaTreeSpecialFile', index, offset+#git_icons, -1})
|
table.insert(hl, {'LuaTreeSpecialFile', index, offset+#git_icons, -1})
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user