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_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_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_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_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 = {
|
let g:lua_tree_show_icons = {
|
||||||
\ 'git': 1,
|
\ 'git': 1,
|
||||||
@ -45,21 +46,22 @@ let g:lua_tree_show_icons = {
|
|||||||
" You don't have to define all keys.
|
" You don't have to define all keys.
|
||||||
" NOTE: the 'edit' key will wrap/unwrap a folder and open a file
|
" NOTE: the 'edit' key will wrap/unwrap a folder and open a file
|
||||||
let g:lua_tree_bindings = {
|
let g:lua_tree_bindings = {
|
||||||
\ 'edit': '<CR>',
|
\ 'edit': '<CR>',
|
||||||
\ 'edit_vsplit': '<C-v>',
|
\ 'edit_vsplit': '<C-v>',
|
||||||
\ 'edit_split': '<C-x>',
|
\ 'edit_split': '<C-x>',
|
||||||
\ 'edit_tab': '<C-t>',
|
\ 'edit_tab': '<C-t>',
|
||||||
\ 'toggle_ignored': 'I',
|
\ 'toggle_ignored': 'I',
|
||||||
\ 'preview': '<Tab>',
|
\ 'toggle_dotfiles': 'H',
|
||||||
\ 'cd': '<C-]>',
|
\ 'preview': '<Tab>',
|
||||||
\ 'create': 'a',
|
\ 'cd': '<C-]>',
|
||||||
\ 'remove': 'd',
|
\ 'create': 'a',
|
||||||
\ 'rename': 'r',
|
\ 'remove': 'd',
|
||||||
\ 'cut': 'x',
|
\ 'rename': 'r',
|
||||||
\ 'copy': 'c',
|
\ 'cut': 'x',
|
||||||
\ 'paste': 'p',
|
\ 'copy': 'c',
|
||||||
\ 'prev_git_item': '[c',
|
\ 'paste': 'p',
|
||||||
\ 'next_git_item': ']c',
|
\ 'prev_git_item': '[c',
|
||||||
|
\ 'next_git_item': ']c',
|
||||||
}
|
}
|
||||||
|
|
||||||
" Disable default mappings by plugin
|
" Disable default mappings by plugin
|
||||||
@ -115,6 +117,7 @@ highlight LuaTreeFolderIcon guibg=blue
|
|||||||
- `<C-t>` will open the file in a new tab
|
- `<C-t>` will open the file in a new tab
|
||||||
- `<Tab>` will open the file as a preview (keeps the cursor in the tree)
|
- `<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|
|
- `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
|
- `gx` opens the file with the `open` command on MACOS and `xdg-open` in linux
|
||||||
- Double left click acts like `<CR>`
|
- Double left click acts like `<CR>`
|
||||||
- Double right click acts like `<C-]>`
|
- Double right click acts like `<C-]>`
|
||||||
|
|||||||
@ -138,6 +138,13 @@ Default is 0
|
|||||||
|g:lua_tree_indent_markers| *g:lua_tree_indent_markers*
|
|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
|
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*
|
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_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_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_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_side nvim-tree-lua.txt /*g:lua_tree_side*
|
||||||
g:lua_tree_size nvim-tree-lua.txt /*g:lua_tree_size*
|
g:lua_tree_size nvim-tree-lua.txt /*g:lua_tree_size*
|
||||||
lua_tree_highlight nvim-tree-lua.txt /*lua_tree_highlight*
|
lua_tree_highlight nvim-tree-lua.txt /*lua_tree_highlight*
|
||||||
|
|||||||
@ -45,22 +45,23 @@ end
|
|||||||
function M.get_bindings()
|
function M.get_bindings()
|
||||||
local keybindings = vim.g.lua_tree_bindings or {}
|
local keybindings = vim.g.lua_tree_bindings or {}
|
||||||
return {
|
return {
|
||||||
edit = keybindings.edit or '<CR>',
|
edit = keybindings.edit or '<CR>',
|
||||||
edit_vsplit = keybindings.edit_vsplit or '<C-v>',
|
edit_vsplit = keybindings.edit_vsplit or '<C-v>',
|
||||||
edit_split = keybindings.edit_split or '<C-x>',
|
edit_split = keybindings.edit_split or '<C-x>',
|
||||||
edit_tab = keybindings.edit_tab or '<C-t>',
|
edit_tab = keybindings.edit_tab or '<C-t>',
|
||||||
preview = keybindings.preview or '<Tab>',
|
preview = keybindings.preview or '<Tab>',
|
||||||
toggle_ignored = keybindings.toggle_ignored or 'I',
|
toggle_ignored = keybindings.toggle_ignored or 'I',
|
||||||
refresh = keybindings.refresh or 'R',
|
toggle_dotfiles = keybindings.toggle_dotfiles or 'H',
|
||||||
cd = keybindings.cd or '<C-]>',
|
refresh = keybindings.refresh or 'R',
|
||||||
create = keybindings.create or 'a',
|
cd = keybindings.cd or '<C-]>',
|
||||||
remove = keybindings.remove or 'd',
|
create = keybindings.create or 'a',
|
||||||
rename = keybindings.rename or 'r',
|
remove = keybindings.remove or 'd',
|
||||||
cut = keybindings.cut or 'x',
|
rename = keybindings.rename or 'r',
|
||||||
copy = keybindings.copy or 'c',
|
cut = keybindings.cut or 'x',
|
||||||
paste = keybindings.paste or 'p',
|
copy = keybindings.copy or 'c',
|
||||||
prev_git_item = keybindings.prev_git_item or '[c',
|
paste = keybindings.paste or 'p',
|
||||||
next_git_item = keybindings.next_git_item or ']c',
|
prev_git_item = keybindings.prev_git_item or '[c',
|
||||||
|
next_git_item = keybindings.next_git_item or ']c',
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -224,6 +224,7 @@ local function set_mappings()
|
|||||||
[bindings.edit_split] = 'on_keypress("split")';
|
[bindings.edit_split] = 'on_keypress("split")';
|
||||||
[bindings.edit_tab] = 'on_keypress("tabnew")';
|
[bindings.edit_tab] = 'on_keypress("tabnew")';
|
||||||
[bindings.toggle_ignored] = 'on_keypress("toggle_ignored")';
|
[bindings.toggle_ignored] = 'on_keypress("toggle_ignored")';
|
||||||
|
[bindings.toggle_dotfiles] = 'on_keypress("toggle_dotfiles")';
|
||||||
[bindings.refresh] = 'on_keypress("refresh")';
|
[bindings.refresh] = 'on_keypress("refresh")';
|
||||||
[bindings.create] = 'on_keypress("create")';
|
[bindings.create] = 'on_keypress("create")';
|
||||||
[bindings.remove] = 'on_keypress("remove")';
|
[bindings.remove] = 'on_keypress("remove")';
|
||||||
@ -304,4 +305,9 @@ function M.toggle_ignored()
|
|||||||
return M.refresh_tree()
|
return M.refresh_tree()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function M.toggle_dotfiles()
|
||||||
|
pops.show_dotfiles = not pops.show_dotfiles
|
||||||
|
return M.refresh_tree()
|
||||||
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|||||||
@ -6,7 +6,8 @@ local api = vim.api
|
|||||||
local luv = vim.loop
|
local luv = vim.loop
|
||||||
|
|
||||||
local M = {
|
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
|
local path_to_matching_str = require'lib.utils'.path_to_matching_str
|
||||||
@ -65,7 +66,9 @@ local function gen_ignore_check()
|
|||||||
end
|
end
|
||||||
|
|
||||||
return function(path)
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -46,6 +46,7 @@ local keypress_funcs = {
|
|||||||
cut = fs.cut,
|
cut = fs.cut,
|
||||||
paste = fs.paste,
|
paste = fs.paste,
|
||||||
toggle_ignored = lib.toggle_ignored,
|
toggle_ignored = lib.toggle_ignored,
|
||||||
|
toggle_dotfiles = lib.toggle_dotfiles,
|
||||||
refresh = lib.refresh_tree,
|
refresh = lib.refresh_tree,
|
||||||
prev_git_item = gen_go_to('prev_git_item'),
|
prev_git_item = gen_go_to('prev_git_item'),
|
||||||
next_git_item = gen_go_to('next_git_item'),
|
next_git_item = gen_go_to('next_git_item'),
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user