nvim-tree.lua/lua/nvim-tree/config.lua
Kiyan 6662b60a2b
feat/chore: rewrite git with job and some other fixes (#743)
* feat/chore: rewrite git with job and some other fixes

* fix: fs clear window, rename echo_warning -> warn

also fix renaming and add an event blocker to avoid running many events
at the same time
2021-11-27 16:02:54 +01:00

103 lines
2.4 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 = "",
},
}
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
end
local has_devicons = pcall(require, 'nvim-web-devicons')
return {
show_file_icon = show_icons.files == 1,
show_folder_icon = show_icons.folders == 1,
show_git_icon = show_icons.git == 1,
show_folder_arrows = show_icons.folder_arrows == 1,
has_devicons = has_devicons,
icons = icons
}
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 = {}
local side = require'nvim-tree.view'.View.side
if side == 'right' then
opts.open_command = 'h'
opts.preview_command = 'l'
opts.split_command = 'aboveleft'
elseif side == "left" then
opts.open_command = 'l'
opts.preview_command = 'h'
opts.split_command = 'belowright'
elseif side == "top" then
opts.open_command = 'j'
opts.preview_command = 'k'
opts.split_command = 'bot'
else
opts.open_command = 'k'
opts.preview_command = 'j'
opts.split_command = 'top'
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