forked from nvim-tree/nvim-tree.lua
-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.lua
113 lines (104 loc) · 2.67 KB
/
config.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
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
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,
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.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 = {}
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