nvim-tree / nvim-tree.lua

A file explorer tree for neovim written in lua

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unbind default keymap

0rtz opened this issue · comments

Hello, thank you for the plugin, i wonder if it is possible to unbind default key mapping? E.g. nvim-tree.lua has default mapping { key = "s", cb = tree_cb("system_open") }, as stated in docs, i use s key with a https://github.com/phaazon/hop.nvim plugin, specifically to jump to a word, so i would also like to be able to use it inside NvimTree buffer.

You can try setting cb to ''.

@gegoune tried to, it does not work. Nvim tree just closes whenever i press s in this case.

Interesting, I've got:

{ key = '<C-x>', cb = '' },

and it does nothing for me (as intended).

@gegoune i have this nvim-tree config

lua << EOF
local tree_cb = require'nvim-tree.config'.nvim_tree_callback

local list_binds = {
    { key = "<C-s>",                        cb = tree_cb("vsplit") },
    { key = "<C-[>",                        cb = tree_cb("dir_up") },
    { key = "s",                            cb = tree_cb('') },
}

require'nvim-tree'.setup {
	view = {
		width = 40,
		auto_resize = true,
		mappings = {
    		list = list_binds,
    	},
	},
    filters = {
    	dotfiles = false,
		custom = {
		    '.git',
		    'node_modules',
		    '.cache',
		    '*.o',
		}
    },
    update_cwd = true,
    update_focused_file = {
    	enable = true,
    	update_cwd = true,
    },
	trash = {
		cmd = "trash",
        require_confirm = true,
	},
}
EOF
let g:nvim_tree_quit_on_open = 1
nnoremap \n :NvimTreeFindFileToggle<CR>

with the latest nvim-tree, and whenever i press s file under cursor is opened. And i would like to have it mapped to my own custom command: <Cmd>HopWord<CR>

commented

{ key = "s", cb = "<cmd>HopWord<CR>" }

Ah, so different perhaps was

cb = tree_cb('')

vs

cb = ''

@gegoune Yea, sorry, missed that part 👀

@0xrz @gegoune I just mapped this because it clashed with one of my mappings, but much easier (not having to map things twice for hop)

{key = "s"},
{key = "S", cb = tree_cb("system_open")}

Hello,
I'd like to unbind <"Tab"> in nvim-tree so that pressing tab behaves the same way as in a normal buffer.

How can I do this?

{ key = "<Tab>", action = "" } doesn't work.

commented

#1000
should be able to set action = nil to disable