mcchrish / nnn.vim

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

Error when mapping action to <backspace> #156

Open heynemann opened 2 years ago

heynemann commented 2 years ago

Describe the bug

When adding action to call a function when <backspace> is pressed. I get an error:

Error detected while processing function nnn#select_action:
line    6:
E728: Using a Dictionary as a Number

To Reproduce

Add this config on top of nnn.vim:

function! QuitNNN()
    execute('normal! q')
endfunction

let g:nnn#action = { '<backspace>': funcref('QuitNNN') }
  1. Open vim
  2. Press key n
  3. Press key
  4. See error

Expected behavior

Should call my function (and in turn close explorer).

Environment:

heynemann commented 2 years ago

The problem seems to be related to explorer as using nnn#pick it works.

heynemann commented 2 years ago

It works now with any <c- key, but not with or . (and not in explorer, only in pick)

mcchrish commented 2 years ago

I can reproduce the problem. However, I would suggest an alternative (better) way to achieve the behavior you want:

autocmd FileType nnn tnoremap <buffer><silent> <backspace> q

Or place the mapping in ftplugin/nnn.vim.

A problem though with mapping backspace with q is that, backspace will not work as intended in moments like entering texts in renaming files/new file name etc.