mcchrish / nnn.vim

File manager for vim/neovim powered by n³
BSD 2-Clause "Simplified" License
646 stars 25 forks source link

Action setting not working on vim 8.1 #108

Closed jorgeegomez closed 3 years ago

jorgeegomez commented 3 years ago

The mappings set in the nnn#action setting is being ignored, and sent as select_action(key) to n³. (I'm pretty sure it's the same issue that Jarun was seeing in #71)

To reproduce, in a clean Ubuntu 20.04 container, with default vim (8.1) and nnn 4.2:

Setup a minimal vim config:

call plug#begin('~/.vim/plugged')
Plug 'mcchrish/nnn.vim'
call plug#end()
let mapleader=","      " change leader key to ,
let maplocalleader="," " change local leader key to ,

let g:nnn#set_default_mappings = 0
nnoremap <leader>n :NnnPicker %:p:h<CR>
let g:nnn#replace_netrw = 1 " Open nnn instead of netrw when opening a directory
let g:nnn#command = 'NNN_RESTRICT_NAV_OPEN=1 NNN_CONTEXT_COLORS="4236" nnn'
let g:nnn#action = {
    \ '<c-h>': 'tab split',
    \ '<c-x>': 'split',
    \ '<c-v>': 'vsplit' }
let g:nnn#statusline = 0

Call the plugin, and press c-h on a file.

Expected: File opens in a new tab

Result: A new buffer opens, with the current dir listing, and the text elect_action("\<c-h>") on the first line (no s)

jorgeegomez commented 3 years ago

Running :tmap while n³ is running (using c-\ c-n keys, as suggested in #71 ), results in:

t  <C-H>       *@<cmd>call nnn#select_action("<c-h>")<CR>
t  <C-X>       *@<cmd>call nnn#select_action("<c-x>")<CR>
t  <C-V>       *@<cmd>call nnn#select_action("<c-v>")<CR>

This is the same with any letter I've tried in .vimrc

Also: version 3.0.2 of the plugin works fine (even when mapping c-t which is now used in nnn); version 3.1 presents the bug.

mcchrish commented 3 years ago

My guess would be <cmd> is a very recent addition to vim/neovim. Comparing https://github.com/mcchrish/nnn.vim/compare/v3.0.2...v3.2 Edit: Looks like it https://github.com/vim/vim/pull/7282

Can you try the no-cmd-map branch if it helps? https://github.com/mcchrish/nnn.vim/tree/no-cmd-map

jorgeegomez commented 3 years ago

Yes! that branch works with vim 8.1 and n³ 4.2 using the default mappings in the documentation.

For future reference, this is how to specify a branch of the plugin when using vim-plug, in .vimrc:

Plug 'mcchrish/nnn.vim', { 'branch': 'no-cmd-map' }

Thanks!

mcchrish commented 3 years ago

@jorgeegomez I merged the branch to master. It should be ok to go back to the previous setup.