Add setting to show/hide hidden files by default

This commit is contained in:
kosayoda 2020-08-02 17:50:49 +08:00
parent 7511c8430f
commit f78483c59f
4 changed files with 16 additions and 6 deletions

View File

@ -31,6 +31,7 @@ let g:lua_tree_auto_open = 1 "0 by default, opens the tree when typing `vim $DIR
let g:lua_tree_auto_close = 1 "0 by default, closes the tree when it's the last window
let g:lua_tree_follow = 1 "0 by default, this option allows the cursor to be updated when entering a buffer
let g:lua_tree_indent_markers = 1 "0 by default, this option shows indent markers when folders are open
let g:lua_tree_show_hidden = 0 "1 by default, this option shows files and folders starting with a dot `.`
let g:lua_tree_show_icons = {
\ 'git': 1,
\ 'folders': 0,

View File

@ -128,6 +128,13 @@ Default is 0
|g:lua_tree_indent_markers| *g:lua_tree_indent_markers*
Can be `0` or `1`. When `1`, will display indent markers when folders are open
Default is 0
|g:lua_tree_show_hidden| *g:lua_tree_show_hidden*
Can be `0` or `1`. When `1`, will show hidden files or folders, which
start with the `.` character.
Default is 1
==============================================================================
INFORMATIONS *nvim-tree-info*

View File

@ -1,3 +1,4 @@
:LuaTreeClipboard nvim-tree-lua.txt /*:LuaTreeClipboard*
:LuaTreeClose nvim-tree-lua.txt /*:LuaTreeClose*
:LuaTreeFindFile nvim-tree-lua.txt /*:LuaTreeFindFile*
:LuaTreeOpen nvim-tree-lua.txt /*:LuaTreeOpen*
@ -6,11 +7,13 @@
g:lua_tree_auto_close nvim-tree-lua.txt /*g:lua_tree_auto_close*
g:lua_tree_auto_open nvim-tree-lua.txt /*g:lua_tree_auto_open*
g:lua_tree_bindings nvim-tree-lua.txt /*g:lua_tree_bindings*
g:lua_tree_disable_keybindings nvim-tree-lua.txt /*g:lua_tree_disable_keybindings*
g:lua_tree_follow nvim-tree-lua.txt /*g:lua_tree_follow*
g:lua_tree_icons nvim-tree-lua.txt /*g:lua_tree_icons*
g:lua_tree_ignore nvim-tree-lua.txt /*g:lua_tree_ignore*
g:lua_tree_indent_markers nvim-tree-lua.txt /*g:lua_tree_indent_markers*
g:lua_tree_show_icons nvim-tree-lua.txt /*g:lua_tree_show_icons*
g:lua_tree_show_hidden nvim-tree-lua.txt /*g:lua_tree_show_hidden*
g:lua_tree_side nvim-tree-lua.txt /*g:lua_tree_side*
g:lua_tree_size nvim-tree-lua.txt /*g:lua_tree_size*
lua_tree_highlight nvim-tree-lua.txt /*lua_tree_highlight*

View File

@ -7,7 +7,7 @@ local luv = vim.loop
local M = {
show_ignored = false,
show_hidden = false,
show_hidden = vim.g.lua_tree_show_hidden == 1,
}
local path_to_matching_str = require'lib.utils'.path_to_matching_str
@ -66,14 +66,13 @@ local function gen_ignore_check()
end
return function(path)
return not M.show_ignored and ignore_list[path] == true
local ignore_path = not M.show_ignored and ignore_list[path] == true
local ignore_hidden = not M.show_hidden and path:sub(1, 1) == '.'
return ignore_path or ignore_hidden
end
end
local function should_ignore(path)
local ignore_func = gen_ignore_check()
return ignore_func(path) or (M.show_hidden and path:sub(1, 1) == '.')
end
local should_ignore = gen_ignore_check()
function M.refresh_entries(entries, cwd)
local handle = luv.fs_scandir(cwd)