* chore: refacto setup part 1 refacto setup for code entrypoint following options switched boolean values as options to the setup function: - `nvim_tree_disable_netrw` -> `disable_netrw` - `nvim_tree_hijack_netrw` -> `hijack_netrw` - `nvim_tree_auto_open` -> `open_on_setup` - `nvim_tree_auto_close` -> `auto_close` - `nvim_tree_tab_open` -> `tab_open` - `nvim-tree-update-cwd` -> `update_cwd` - `nvim_tree_hijack_cursor` -> `hijack_cursor` - `nvim_tree_system_open_command` -> `system_open.cmd` - `nvim_tree_system_open_command_args` -> `system_open.args` - `nvim_tree_follow` -> `update_focused_file.enable` - `nvim_tree_follow_update_path` -> `update_focused_file.update_cwd` Also added new option `update_focused_file.ignore_list` which will ignore filepath or filetypes that matches one entry of the list when updating the path if update_cwd is true. * add deprecation warning * update readme * schedule on enter to avoid running before vim first buffer has loaded * update docs * correct typo * rename tab open -> open on tab
110 lines
2.5 KiB
Lua
110 lines
2.5 KiB
Lua
local M = {}
|
|
|
|
function M.get_icon_state()
|
|
local show_icons = vim.g.nvim_tree_show_icons or { git = 1, folders = 1, files = 1, folder_arrows = 1 }
|
|
local icons = {
|
|
default = "",
|
|
symlink = "",
|
|
git_icons = {
|
|
unstaged = "✗",
|
|
staged = "✓",
|
|
unmerged = "",
|
|
renamed = "➜",
|
|
untracked = "★",
|
|
deleted = "",
|
|
ignored = "◌"
|
|
},
|
|
folder_icons = {
|
|
arrow_closed = "",
|
|
arrow_open = "",
|
|
default = "",
|
|
open = "",
|
|
empty = "",
|
|
empty_open = "",
|
|
symlink = "",
|
|
symlink_open = "",
|
|
},
|
|
lsp = {
|
|
hint = "",
|
|
info = "",
|
|
warning = "",
|
|
error = "",
|
|
},
|
|
}
|
|
|
|
local user_icons = vim.g.nvim_tree_icons
|
|
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
|
|
icons.git_icons[key] = val
|
|
end
|
|
end
|
|
for key, val in pairs(user_icons.folder or {}) do
|
|
if icons.folder_icons[key] then
|
|
icons.folder_icons[key] = val
|
|
end
|
|
end
|
|
for key, val in pairs(user_icons.lsp or {}) do
|
|
if icons.lsp[key] then
|
|
icons.lsp[key] = val
|
|
end
|
|
end
|
|
end
|
|
|
|
local has_devicons = pcall(require, 'nvim-web-devicons')
|
|
return {
|
|
show_file_icon = show_icons.files == 1 and has_devicons,
|
|
show_folder_icon = show_icons.folders == 1,
|
|
show_git_icon = show_icons.git == 1,
|
|
show_folder_arrows = show_icons.folder_arrows == 1,
|
|
icons = icons
|
|
}
|
|
end
|
|
|
|
function M.use_git()
|
|
return M.get_icon_state().show_git_icon
|
|
or vim.g.nvim_tree_git_hl == 1
|
|
or vim.g.nvim_tree_gitignore == 1
|
|
end
|
|
|
|
function M.nvim_tree_callback(callback_name)
|
|
return string.format(":lua require'nvim-tree'.on_keypress('%s')<CR>", callback_name)
|
|
end
|
|
|
|
function M.window_options()
|
|
local opts = {}
|
|
if vim.g.nvim_tree_side == 'right' then
|
|
opts.open_command = 'h'
|
|
opts.preview_command = 'l'
|
|
opts.split_command = 'aboveleft'
|
|
else
|
|
opts.open_command = 'l'
|
|
opts.preview_command = 'h'
|
|
opts.split_command = 'belowright'
|
|
end
|
|
|
|
return opts
|
|
end
|
|
|
|
function M.window_picker_exclude()
|
|
if type(vim.g.nvim_tree_window_picker_exclude) == "table" then
|
|
return vim.g.nvim_tree_window_picker_exclude
|
|
end
|
|
return {
|
|
filetype = {
|
|
"notify",
|
|
"packer",
|
|
"qf"
|
|
}
|
|
}
|
|
end
|
|
|
|
return M
|