feat: add new keybinding "b" to run a command in the focused node (#1024)

This commit is contained in:
Andreas Bissinger
2022-03-03 09:05:03 +01:00
committed by GitHub
parent 866442fd2c
commit 4fedb93cec
4 changed files with 17 additions and 3 deletions

View File

@@ -221,6 +221,7 @@ require'nvim-tree'.setup {
- Double right click acts like `<C-]>` - Double right click acts like `<C-]>`
- `W` will collapse the whole tree - `W` will collapse the whole tree
- `S` will prompt the user to enter a path and then expands the tree to match the path - `S` will prompt the user to enter a path and then expands the tree to match the path
- `.` will enter vim command mode with the file the cursor is on
### Settings ### Settings
@@ -285,7 +286,8 @@ local list = {
{ key = "q", action = "close" }, { key = "q", action = "close" },
{ key = "g?", action = "toggle_help" }, { key = "g?", action = "toggle_help" },
{ key = "W", action = "collapse_all" }, { key = "W", action = "collapse_all" },
{ key = "S", action = "search_node" } { key = "S", action = "search_node" },
{ key = ".", action = "run_file_command" }
} }
``` ```

View File

@@ -615,6 +615,7 @@ INFORMATIONS *nvim-tree-info*
- Double right click acts like <C-]> - Double right click acts like <C-]>
- `W` will collapse the whole tree - `W` will collapse the whole tree
- `S` will prompt the user to enter a path and then expands the tree to match the path - `S` will prompt the user to enter a path and then expands the tree to match the path
- `.` will enter vim command mode with the file the cursor is on
Defaults to: Defaults to:
> >
@@ -655,7 +656,8 @@ Defaults to:
{ key = "q", action = "close" }, { key = "q", action = "close" },
{ key = "g?", action = "toggle_help" }, { key = "g?", action = "toggle_help" },
{ key = 'W', action = "collapse_all" }, { key = 'W', action = "collapse_all" },
{ key = "S", action = "search_node" } { key = "S", action = "search_node" },
{ key = ".", action = "run_file_command" }
} }
< <
The `list` option in `view.mappings.list` is a table of The `list` option in `view.mappings.list` is a table of

View File

@@ -42,7 +42,8 @@ local M = {
{ key = "q", action = "close"}, { key = "q", action = "close"},
{ key = "g?", action = "toggle_help" }, { key = "g?", action = "toggle_help" },
{ key = 'W', action = "collapse_all" }, { key = 'W', action = "collapse_all" },
{ key = "S", action = "search_node" } { key = "S", action = "search_node" },
{ key = ".", action = "run_file_command" }
}, },
custom_keypress_funcs = {}, custom_keypress_funcs = {},
} }
@@ -70,6 +71,7 @@ local keypress_funcs = {
refresh = require'nvim-tree.actions.reloaders'.reload_explorer, refresh = require'nvim-tree.actions.reloaders'.reload_explorer,
remove = require'nvim-tree.actions.remove-file'.fn, remove = require'nvim-tree.actions.remove-file'.fn,
rename = require'nvim-tree.actions.rename-file'.fn(false), rename = require'nvim-tree.actions.rename-file'.fn(false),
run_file_command = require'nvim-tree.actions.run-command'.run_file_command,
search_node = require'nvim-tree.actions.search-node'.fn, search_node = require'nvim-tree.actions.search-node'.fn,
system_open = require'nvim-tree.actions.system-open'.fn, system_open = require'nvim-tree.actions.system-open'.fn,
toggle_dotfiles = require"nvim-tree.actions.toggles".dotfiles, toggle_dotfiles = require"nvim-tree.actions.toggles".dotfiles,

View File

@@ -0,0 +1,8 @@
local M = {}
function M.run_file_command(node)
vim.api.nvim_input(": " .. node.absolute_path .. "<Home>")
end
return M