Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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': '<CR>',
\ 'edit_vsplit': '<C-v>',
\ 'edit_split': '<C-x>',
\ 'edit_tab': '<C-t>',
\ 'preview': '<Tab>',
\ 'cd': '<C-]>',
\ 'edit': '<CR>',
\ 'edit_vsplit': '<C-v>',
\ 'edit_split': '<C-x>',
\ 'edit_tab': '<C-t>',
\ 'toggle_ignored': 'I',
\ 'preview': '<Tab>',
\ 'cd': '<C-]>',
}

" Disable default mappings by plugin
Expand Down Expand Up @@ -99,6 +100,7 @@ highlight LuaTreeFolderIcon guibg=blue
- `<C-x>` will open the file in a horizontal split
- `<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|
- `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-]>`
Expand Down
1 change: 1 addition & 0 deletions doc/nvim-tree-lua.txt
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ INFORMATIONS *nvim-tree-info*
- '<C-x>' will open the file in a horizontal split
- '<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|
- 'gx' opens the file with the `open` command on macos and `xdg-open`
on linux.

Expand Down
19 changes: 10 additions & 9 deletions lua/lib/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,16 @@ 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>',
cd = keybindings.cd or '<C-]>',
create = keybindings.create or 'a',
remove = keybindings.remove or 'd',
rename = keybindings.rename or 'r',
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',
cd = keybindings.cd or '<C-]>',
create = keybindings.create or 'a',
remove = keybindings.remove or 'd',
rename = keybindings.rename or 'r',
}
end

Expand Down
6 changes: 6 additions & 0 deletions lua/lib/lib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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")';
Expand Down Expand Up @@ -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
6 changes: 4 additions & 2 deletions lua/lib/populate.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions lua/tree.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down