Add a mode that allows edit without the picker (#873)

This commit is contained in:
Sander van Harmelen 2022-01-21 12:36:28 +01:00 committed by GitHub
parent 1ac3502290
commit 14bdf134f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 3 deletions

View File

@ -243,6 +243,7 @@ These are the default bindings:
-- default mappings
local list = {
{ key = {"<CR>", "o", "<2-LeftMouse>"}, action = "edit" },
{ key = {"O"}, action = tree_cb("edit_no_picker") },
{ key = {"<2-RightMouse>", "<C-]>"}, action = "cd" },
{ key = "<C-v>", action = "vsplit" },
{ key = "<C-x>", action = "split" },

View File

@ -579,6 +579,7 @@ Defaults to:
lua <<EOF
local list = {
{ key = {"<CR>", "o", "<2-LeftMouse>"}, action = "edit" },
{ key = {"O"}, action = tree_cb("edit_no_picker") },
{ key = {"<2-RightMouse>", "<C-]>"}, action = "cd" },
{ key = "<C-v>", action = "vsplit" },
{ key = "<C-x>", action = "split" },
@ -621,11 +622,11 @@ The `list` option in `view.mappings.list` is a table of
>
lua <<EOF
local tree_cb = require'nvim-tree.config'.nvim_tree_callback
local function print_node_path(node) {
print(node.absolute_path)
}
local list = {
{ key = {"<CR>", "o" }, action = "edit", mode = "n"},
{ key = "p", action = "print_path", action_cb = print_node_path },

View File

@ -8,6 +8,7 @@ local nvim_tree_callback = require'nvim-tree.config'.nvim_tree_callback
local M = {
mappings = {
{ key = {"<CR>", "o", "<2-LeftMouse>"}, action = "edit" },
{ key = {"O"}, action = nvim_tree_callback("edit_no_picker") },
{ key = {"<2-RightMouse>", "<C-]>"}, action = "cd" },
{ key = "<C-v>", action = "vsplit" },
{ key = "<C-x>", action = "split"},

View File

@ -131,7 +131,7 @@ function M.fn(mode, filename)
local win_ids = api.nvim_tabpage_list_wins(tabpage)
local target_winid
if vim.g.nvim_tree_disable_window_picker == 1 then
if vim.g.nvim_tree_disable_window_picker == 1 or mode == "edit_no_picker" then
target_winid = lib.Tree.target_winid
else
target_winid = pick_window()