diff --git a/README.md b/README.md index 749dc4e4..2a39b25d 100644 --- a/README.md +++ b/README.md @@ -221,6 +221,7 @@ require'nvim-tree'.setup { - Double right click acts like `` - `W` will collapse the whole tree - `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 @@ -285,7 +286,8 @@ local list = { { key = "q", action = "close" }, { key = "g?", action = "toggle_help" }, { key = "W", action = "collapse_all" }, - { key = "S", action = "search_node" } + { key = "S", action = "search_node" }, + { key = ".", action = "run_file_command" } } ``` diff --git a/doc/nvim-tree-lua.txt b/doc/nvim-tree-lua.txt index a0e2fe3b..86b73873 100644 --- a/doc/nvim-tree-lua.txt +++ b/doc/nvim-tree-lua.txt @@ -615,6 +615,7 @@ INFORMATIONS *nvim-tree-info* - Double right click acts like - `W` will collapse the whole tree - `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: > @@ -655,7 +656,8 @@ Defaults to: { key = "q", action = "close" }, { key = "g?", action = "toggle_help" }, { 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 diff --git a/lua/nvim-tree/actions/init.lua b/lua/nvim-tree/actions/init.lua index d58f42f5..e49a5cfa 100644 --- a/lua/nvim-tree/actions/init.lua +++ b/lua/nvim-tree/actions/init.lua @@ -42,7 +42,8 @@ local M = { { key = "q", action = "close"}, { key = "g?", action = "toggle_help" }, { key = 'W', action = "collapse_all" }, - { key = "S", action = "search_node" } + { key = "S", action = "search_node" }, + { key = ".", action = "run_file_command" } }, custom_keypress_funcs = {}, } @@ -70,6 +71,7 @@ local keypress_funcs = { refresh = require'nvim-tree.actions.reloaders'.reload_explorer, remove = require'nvim-tree.actions.remove-file'.fn, 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, system_open = require'nvim-tree.actions.system-open'.fn, toggle_dotfiles = require"nvim-tree.actions.toggles".dotfiles, diff --git a/lua/nvim-tree/actions/run-command.lua b/lua/nvim-tree/actions/run-command.lua new file mode 100644 index 00000000..400e55e5 --- /dev/null +++ b/lua/nvim-tree/actions/run-command.lua @@ -0,0 +1,8 @@ +local M = {} + +function M.run_file_command(node) + vim.api.nvim_input(": " .. node.absolute_path .. "") +end + +return M +