Feat: Allow hiding dotfiles (#69)

This commit is contained in:
Kieran Siek
2020-08-03 22:13:25 +08:00
committed by GitHub
parent 1aee593b5d
commit 06558a25da
7 changed files with 55 additions and 33 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_hide_dotfiles = 1 "0 by default, this option hides files and folders starting with a dot `.`
let g:lua_tree_git_hl = 1 "0 by default, will enable file highlight for git attributes (can be used without the icons).
let g:lua_tree_show_icons = {
\ 'git': 1,
@@ -50,6 +51,7 @@ let g:lua_tree_bindings = {
\ 'edit_split': '<C-x>',
\ 'edit_tab': '<C-t>',
\ 'toggle_ignored': 'I',
\ 'toggle_dotfiles': 'H',
\ 'preview': '<Tab>',
\ 'cd': '<C-]>',
\ 'create': 'a',
@@ -115,6 +117,7 @@ highlight LuaTreeFolderIcon guibg=blue
- `<C-t>` will open the file in a new tab
- `<Tab>` will open the file as a preview (keeps the cursor in the tree)
- `I` will toggle visibility of folders hidden via |g:lua_tree_ignore|
- `H` will toggle visibility of dotfiles (files/folders starting with a `.`)
- `gx` opens the file with the `open` command on MACOS and `xdg-open` in linux
- Double left click acts like `<CR>`
- Double right click acts like `<C-]>`

View File

@@ -138,6 +138,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_hide_dotfiles| *g:lua_tree_hide_dotfiles*
Can be `0` or `1`. When `1`, will hide dotfiles, files or folders which start
with the `.` character.
Default is 0
==============================================================================
INFORMATIONS *nvim-tree-info*

View File

@@ -14,6 +14,7 @@ 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_hide_dotfiles nvim-tree-lua.txt /*g:lua_tree_hide_dotfiles*
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

@@ -51,6 +51,7 @@ function M.get_bindings()
edit_tab = keybindings.edit_tab or '<C-t>',
preview = keybindings.preview or '<Tab>',
toggle_ignored = keybindings.toggle_ignored or 'I',
toggle_dotfiles = keybindings.toggle_dotfiles or 'H',
refresh = keybindings.refresh or 'R',
cd = keybindings.cd or '<C-]>',
create = keybindings.create or 'a',

View File

@@ -224,6 +224,7 @@ local function set_mappings()
[bindings.edit_split] = 'on_keypress("split")';
[bindings.edit_tab] = 'on_keypress("tabnew")';
[bindings.toggle_ignored] = 'on_keypress("toggle_ignored")';
[bindings.toggle_dotfiles] = 'on_keypress("toggle_dotfiles")';
[bindings.refresh] = 'on_keypress("refresh")';
[bindings.create] = 'on_keypress("create")';
[bindings.remove] = 'on_keypress("remove")';
@@ -304,4 +305,9 @@ function M.toggle_ignored()
return M.refresh_tree()
end
function M.toggle_dotfiles()
pops.show_dotfiles = not pops.show_dotfiles
return M.refresh_tree()
end
return M

View File

@@ -6,7 +6,8 @@ local api = vim.api
local luv = vim.loop
local M = {
show_ignored = false
show_ignored = false,
show_dotfiles = vim.g.lua_tree_hide_dotfiles ~= 1,
}
local path_to_matching_str = require'lib.utils'.path_to_matching_str
@@ -65,7 +66,9 @@ 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_dotfiles = not M.show_dotfiles and path:sub(1, 1) == '.'
return ignore_path or ignore_dotfiles
end
end

View File

@@ -46,6 +46,7 @@ local keypress_funcs = {
cut = fs.cut,
paste = fs.paste,
toggle_ignored = lib.toggle_ignored,
toggle_dotfiles = lib.toggle_dotfiles,
refresh = lib.refresh_tree,
prev_git_item = gen_go_to('prev_git_item'),
next_git_item = gen_go_to('next_git_item'),