fix gitignore feature (#264)
This commit is contained in:
parent
d19a6feb24
commit
1f1b25de4b
@ -20,7 +20,7 @@ Plug 'kyazdani42/nvim-tree.lua'
|
|||||||
let g:nvim_tree_side = 'right' "left by default
|
let g:nvim_tree_side = 'right' "left by default
|
||||||
let g:nvim_tree_width = 40 "30 by default
|
let g:nvim_tree_width = 40 "30 by default
|
||||||
let g:nvim_tree_ignore = [ '.git', 'node_modules', '.cache' ] "empty by default
|
let g:nvim_tree_ignore = [ '.git', 'node_modules', '.cache' ] "empty by default
|
||||||
let g:nvim_tree_gitignore = 2 "0 by default
|
let g:nvim_tree_gitignore = 1 "0 by default
|
||||||
let g:nvim_tree_auto_open = 1 "0 by default, opens the tree when typing `vim $DIR` or `vim`
|
let g:nvim_tree_auto_open = 1 "0 by default, opens the tree when typing `vim $DIR` or `vim`
|
||||||
let g:nvim_tree_auto_close = 1 "0 by default, closes the tree when it's the last window
|
let g:nvim_tree_auto_close = 1 "0 by default, closes the tree when it's the last window
|
||||||
let g:nvim_tree_auto_ignore_ft = [ 'startify', 'dashboard' ] "empty by default, don't auto open tree on specific filetypes.
|
let g:nvim_tree_auto_ignore_ft = [ 'startify', 'dashboard' ] "empty by default, don't auto open tree on specific filetypes.
|
||||||
|
|||||||
@ -75,8 +75,7 @@ files ignored by git.
|
|||||||
|
|
||||||
Must be:
|
Must be:
|
||||||
0: not ignored
|
0: not ignored
|
||||||
1: ignored files from .gitignore
|
1: ignored files from `git ls-files --others --ignored --exclude-standard --directory`
|
||||||
2: ignored files from .gitignore and git exclude
|
|
||||||
|
|
||||||
>
|
>
|
||||||
|g:nvim_tree_show_icons| *g:nvim_tree_show_icons*
|
|g:nvim_tree_show_icons| *g:nvim_tree_show_icons*
|
||||||
|
|||||||
@ -30,8 +30,8 @@ local function update_root_status(root)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.get_path_gitexclude()
|
function M.get_gitexclude()
|
||||||
return vim.fn.system("git config --get core.excludesFile")
|
return vim.fn.system("git ls-files --others --ignored --exclude-standard --directory")
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.reload_roots()
|
function M.reload_roots()
|
||||||
|
|||||||
@ -101,20 +101,16 @@ end
|
|||||||
local function gen_ignore_check()
|
local function gen_ignore_check()
|
||||||
local ignore_list = {}
|
local ignore_list = {}
|
||||||
|
|
||||||
local function add_toignore(path)
|
local function add_toignore(content)
|
||||||
local content = utils.read_file(path)
|
|
||||||
for s in content:gmatch("[^\r\n]+") do
|
for s in content:gmatch("[^\r\n]+") do
|
||||||
ignore_list[s] = true
|
ignore_list[s] = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if (vim.g.nvim_tree_gitignore or 0) > 0 then
|
if (vim.g.nvim_tree_gitignore or 0) == 1 then
|
||||||
add_toignore('.gitignore')
|
add_toignore(git.get_gitexclude())
|
||||||
end
|
end
|
||||||
if (vim.g.nvim_tree_gitignore or 0) == 2 then
|
|
||||||
add_toignore(git.get_path_gitexclude())
|
|
||||||
end
|
|
||||||
|
|
||||||
if vim.g.nvim_tree_ignore and #vim.g.nvim_tree_ignore > 0 then
|
if vim.g.nvim_tree_ignore and #vim.g.nvim_tree_ignore > 0 then
|
||||||
for _, entry in pairs(vim.g.nvim_tree_ignore) do
|
for _, entry in pairs(vim.g.nvim_tree_ignore) do
|
||||||
ignore_list[entry] = true
|
ignore_list[entry] = true
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user