diff --git a/README.md b/README.md index 4220f978bad..ec0eef764f1 100644 --- a/README.md +++ b/README.md @@ -44,12 +44,13 @@ 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': '', - \ 'edit_vsplit': '', - \ 'edit_split': '', - \ 'edit_tab': '', - \ 'preview': '', - \ 'cd': '', + \ 'edit': '', + \ 'edit_vsplit': '', + \ 'edit_split': '', + \ 'edit_tab': '', + \ 'toggle_ignored': 'I', + \ 'preview': '', + \ 'cd': '', } " Disable default mappings by plugin @@ -99,6 +100,7 @@ highlight LuaTreeFolderIcon guibg=blue - `` will open the file in a horizontal split - `` will open the file in a new 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| - `gx` opens the file with the `open` command on MACOS and `xdg-open` in linux - Double left click acts like `` - Double right click acts like `` diff --git a/doc/nvim-tree-lua.txt b/doc/nvim-tree-lua.txt index 3becdce3480..41342eb5ebb 100644 --- a/doc/nvim-tree-lua.txt +++ b/doc/nvim-tree-lua.txt @@ -145,6 +145,7 @@ INFORMATIONS *nvim-tree-info* - '' will open the file in a horizontal split - '' will open the file in a new 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| - 'gx' opens the file with the `open` command on macos and `xdg-open` on linux. diff --git a/lua/lib/config.lua b/lua/lib/config.lua index bab24e44a83..70a39c625d1 100644 --- a/lua/lib/config.lua +++ b/lua/lib/config.lua @@ -45,15 +45,16 @@ end function M.get_bindings() local keybindings = vim.g.lua_tree_bindings or {} return { - edit = keybindings.edit or '', - edit_vsplit = keybindings.edit_vsplit or '', - edit_split = keybindings.edit_split or '', - edit_tab = keybindings.edit_tab or '', - preview = keybindings.preview or '', - cd = keybindings.cd or '', - create = keybindings.create or 'a', - remove = keybindings.remove or 'd', - rename = keybindings.rename or 'r', + edit = keybindings.edit or '', + edit_vsplit = keybindings.edit_vsplit or '', + edit_split = keybindings.edit_split or '', + edit_tab = keybindings.edit_tab or '', + preview = keybindings.preview or '', + toggle_ignored = keybindings.toggle_ignored or 'I', + cd = keybindings.cd or '', + create = keybindings.create or 'a', + remove = keybindings.remove or 'd', + rename = keybindings.rename or 'r', } end diff --git a/lua/lib/lib.lua b/lua/lib/lib.lua index 724645adbd2..fe8a2f57114 100644 --- a/lua/lib/lib.lua +++ b/lua/lib/lib.lua @@ -205,6 +205,7 @@ local function set_mappings() [bindings.edit_vsplit] = 'on_keypress("vsplit")'; [bindings.edit_split] = 'on_keypress("split")'; [bindings.edit_tab] = 'on_keypress("tabnew")'; + [bindings.toggle_ignored] = 'on_keypress("toggle_ignored")'; [bindings.create] = 'on_keypress("create")'; [bindings.remove] = 'on_keypress("remove")'; [bindings.rename] = 'on_keypress("rename")'; @@ -278,4 +279,9 @@ function M.win_open() return false end +function M.toggle_ignored() + pops.show_ignored = not pops.show_ignored + return M.refresh_tree() +end + return M diff --git a/lua/lib/populate.lua b/lua/lib/populate.lua index 365e89fc13b..f3a4f9ee293 100644 --- a/lua/lib/populate.lua +++ b/lua/lib/populate.lua @@ -5,7 +5,9 @@ local icon_config = config.get_icon_state() local api = vim.api local luv = vim.loop -local M = {} +local M = { + show_ignored = false +} local path_to_matching_str = require'lib.utils'.path_to_matching_str @@ -63,7 +65,7 @@ local function gen_ignore_check() end return function(path) - return ignore_list[path] == true + return not M.show_ignored and ignore_list[path] == true end end diff --git a/lua/tree.lua b/lua/tree.lua index c4f8565ec0e..e700f343e94 100644 --- a/lua/tree.lua +++ b/lua/tree.lua @@ -45,6 +45,10 @@ function M.on_keypress(mode) return lib.open_file(mode, node.absolute_path) end + if mode == 'toggle_ignored' then + return lib.toggle_ignored() + end + if node.name == ".." then return lib.change_dir("..") elseif mode == "cd" and node.entries ~= nil then