Feat: Allow hiding dotfiles (#69)
This commit is contained in:
parent
1aee593b5d
commit
06558a25da
33
README.md
33
README.md
@ -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,
|
||||
@ -45,21 +46,22 @@ let g:lua_tree_show_icons = {
|
||||
" You don't have to define all keys.
|
||||
" NOTE: the 'edit' key will wrap/unwrap a folder and open a file
|
||||
let g:lua_tree_bindings = {
|
||||
\ 'edit': '<CR>',
|
||||
\ 'edit_vsplit': '<C-v>',
|
||||
\ 'edit_split': '<C-x>',
|
||||
\ 'edit_tab': '<C-t>',
|
||||
\ 'toggle_ignored': 'I',
|
||||
\ 'preview': '<Tab>',
|
||||
\ 'cd': '<C-]>',
|
||||
\ 'create': 'a',
|
||||
\ 'remove': 'd',
|
||||
\ 'rename': 'r',
|
||||
\ 'cut': 'x',
|
||||
\ 'copy': 'c',
|
||||
\ 'paste': 'p',
|
||||
\ 'prev_git_item': '[c',
|
||||
\ 'next_git_item': ']c',
|
||||
\ 'edit': '<CR>',
|
||||
\ 'edit_vsplit': '<C-v>',
|
||||
\ 'edit_split': '<C-x>',
|
||||
\ 'edit_tab': '<C-t>',
|
||||
\ 'toggle_ignored': 'I',
|
||||
\ 'toggle_dotfiles': 'H',
|
||||
\ 'preview': '<Tab>',
|
||||
\ 'cd': '<C-]>',
|
||||
\ 'create': 'a',
|
||||
\ 'remove': 'd',
|
||||
\ 'rename': 'r',
|
||||
\ 'cut': 'x',
|
||||
\ 'copy': 'c',
|
||||
\ 'paste': 'p',
|
||||
\ 'prev_git_item': '[c',
|
||||
\ 'next_git_item': ']c',
|
||||
}
|
||||
|
||||
" Disable default mappings by plugin
|
||||
@ -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-]>`
|
||||
|
||||
@ -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*
|
||||
|
||||
1
doc/tags
1
doc/tags
@ -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*
|
||||
|
||||
@ -45,22 +45,23 @@ end
|
||||
function M.get_bindings()
|
||||
local keybindings = vim.g.lua_tree_bindings or {}
|
||||
return {
|
||||
edit = keybindings.edit or '<CR>',
|
||||
edit_vsplit = keybindings.edit_vsplit or '<C-v>',
|
||||
edit_split = keybindings.edit_split or '<C-x>',
|
||||
edit_tab = keybindings.edit_tab or '<C-t>',
|
||||
preview = keybindings.preview or '<Tab>',
|
||||
toggle_ignored = keybindings.toggle_ignored or 'I',
|
||||
refresh = keybindings.refresh or 'R',
|
||||
cd = keybindings.cd or '<C-]>',
|
||||
create = keybindings.create or 'a',
|
||||
remove = keybindings.remove or 'd',
|
||||
rename = keybindings.rename or 'r',
|
||||
cut = keybindings.cut or 'x',
|
||||
copy = keybindings.copy or 'c',
|
||||
paste = keybindings.paste or 'p',
|
||||
prev_git_item = keybindings.prev_git_item or '[c',
|
||||
next_git_item = keybindings.next_git_item or ']c',
|
||||
edit = keybindings.edit or '<CR>',
|
||||
edit_vsplit = keybindings.edit_vsplit or '<C-v>',
|
||||
edit_split = keybindings.edit_split or '<C-x>',
|
||||
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',
|
||||
remove = keybindings.remove or 'd',
|
||||
rename = keybindings.rename or 'r',
|
||||
cut = keybindings.cut or 'x',
|
||||
copy = keybindings.copy or 'c',
|
||||
paste = keybindings.paste or 'p',
|
||||
prev_git_item = keybindings.prev_git_item or '[c',
|
||||
next_git_item = keybindings.next_git_item or ']c',
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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'),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user