Action not working
Closed this issue · 44 comments
I was trying to set actions with ^H for vsplit which is unused in nnn
.
I selected a file using ^J and then pressed ^H but nothing happned other than the cursor blinking in the status bar.
Can you please take a look or help me fix this?
I am on nnn.vim & nnn master. vim version 8.2.579.
Actions are actually working fine for me. I'm using nvim v0.5 with this config:
let g:nnn#set_default_mappings = 0
let g:nnn#replace_netrw = 1
nnoremap <silent><Leader>/ :NnnPicker '%:p:h'<CR>
let g:nnn#layout = { 'window': { 'width': 1, 'height': 0.5, 'yoffset': 1, 'border': 'top'} }
let g:nnn#action = {
\ '<c-t>': 'tab split',
\ '<c-x>': 'split',
\ '<c-v>': 'vsplit' }
let g:nnn#command = 'nnn -o'
Did you try different key bindings? Could it be that ^J is being overwritten by another plugin/program?
I am using vim. Also which version of nnn
are you? ^T, ^X and ^V have their own bindings in nnn
on v3.3.
That would work for me. But somehow the nnn.vim plugin doesn't work.
@jarun cannot reproduce the issue. Minimum config:
let g:nnn#command = 'nnn -C'
let g:nnn#action = { '<c-h>': 'vsplit' }
I am on nnn master. I have also updated to nnn.vim master. My vim version is version 8.2.579.
I have the following in .vimrc:
let g:nnn#set_default_mappings = 0
let g:nnn#replace_netrw = 1
nnoremap <leader>n :NnnPicker %:p:h<CR>
let g:nnn#layout = { 'window': { 'width': 0.9, 'height': 0.6, 'highlight':'Debug' } }
let g:nnn#command = 'nnn -C'
let g:nnn#action = { '<c-h>': 'vsplit' }
Now I open a file in vim, press \n
to show nnn floating window, navigate to a text file and press ^H
(same result with some other bindings).
File is not opened and I see the cursor at the end of the statusbar:
@jarun I'm assuming you are in a linux env.
Correct me if I'm wrong but in linux ctrl-h is mapped as backspace. I don't have a linux machine to confirm.
That may cause mapping to be problematic.
That's correct but I tried with ^K also which is now unused in nnn.
Is there a way to override how nnn.vim is working and make 'Enter' to open the file in a new tab?
Here is the current situation. I know that in NNN 'Enter' key will move into the folder for which I'm using "l" ( vim navigation ). Using 'Enter' for 'Tab' is going to stop entering in the folder and I'm fine with that.
let g:nnn#action = {
\ '<c-t>': 'tab split',
\ '<c-s>': 'split',
\ '<c-v>': 'vsplit' }
Here is how it's done in FZF.
let g:fzf_action = {
\ 'return': 'tab split',
\ 'ctrl-s': 'split',
\ 'ctrl-v': 'vsplit' }```
Your original config:
let g:nnn#set_default_mappings = 0
let g:nnn#replace_netrw = 1
nnoremap <leader>n :NnnPicker %:p:h<CR>
let g:nnn#layout = { 'window': { 'width': 0.9, 'height': 0.6, 'highlight':'Debug' } }
let g:nnn#command = 'nnn -C'
let g:nnn#action = { '<c-h>': 'vsplit' }
works for me on:
- Vim version 8.2
nnn
version 4.0- macOS 10.15.7
Are you still experiencing this problem? I have some speculations but I would like to know if this problem still persists for you.
Yes, this still persists for me. Removed everything else from .vimrc
, nnn
master, Ubuntu 20.04.
$ vim --version
VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Sep 28 2020 13:35:01)
Included patches: 1-1767
Modified by jonathon.fernyhough@york.ac.uk
Compiled by jonathon.fernyhough@york.ac.uk
Huge version without GUI. Features included (+) or not (-):
+acl -farsi +mouse_sgr +tag_binary
+arabic +file_in_path -mouse_sysmouse -tag_old_static
+autocmd +find_in_path +mouse_urxvt -tag_any_white
+autochdir +float +mouse_xterm -tcl
-autoservername +folding +multi_byte +termguicolors
-balloon_eval -footer +multi_lang +terminal
+balloon_eval_term +fork() -mzscheme +terminfo
-browse +gettext +netbeans_intg +termresponse
++builtin_terms -hangul_input +num64 +textobjects
+byte_offset +iconv +packages +textprop
+channel +insert_expand +path_extra +timers
+cindent +ipv6 -perl +title
-clientserver +job +persistent_undo -toolbar
-clipboard +jumplist +popupwin +user_commands
+cmdline_compl +keymap +postscript +vartabs
+cmdline_hist +lambda +printer +vertsplit
+cmdline_info +langmap +profile +virtualedit
+comments +libcall -python +visual
+conceal +linebreak +python3 +visualextra
+cryptv +lispindent +quickfix +viminfo
+cscope +listcmds +reltime +vreplace
+cursorbind +localmap +rightleft +wildignore
+cursorshape -lua -ruby +wildmenu
+dialog_con +menu +scrollbind +windows
+diff +mksession +signs +writebackup
+digraphs +modify_fname +smartindent -X11
-dnd +mouse +sound -xfontset
-ebcdic -mouseshape +spell -xim
+emacs_tags +mouse_dec +startuptime -xpm
+eval +mouse_gpm +statusline -xsmp
+ex_extra -mouse_jsbterm -sun_workshop -xterm_clipboard
+extra_search +mouse_netterm +syntax -xterm_save
system vimrc file: "$VIM/vimrc"
user vimrc file: "$HOME/.vimrc"
2nd user vimrc file: "~/.vim/vimrc"
user exrc file: "$HOME/.exrc"
defaults file: "$VIMRUNTIME/defaults.vim"
fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -Wdate-time -g -O2 -fdebug-prefix-map=/build/vim-0bnN0A/vim-8.2.1767=. -fstack-protector-strong -Wformat -Werror=format-security -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -o vim -lm -ltinfo -lselinux -lcanberra -lacl -lattr -lgpm -ldl -L/usr/lib/python3.6/config-3.6m-x86_64-linux-gnu -lpython3.6m -lpthread -ldl -lutil -lm
Can you confirm that this occurs when you choose a layout other than a popup? This is because my build of Vim does not have the popupwin patch and I can't quite figure out how to obtain it, but I still want to reliably debug this problem on my end.
Also, if possible, could you see if this problem happens on Neovim as well?
I see this with tabedit
layout also.
Could you please do the following and report what shows up:
- Open up nnn.vim (through <leader>n) in Vim
- Hit <C-\><C-n> (to exit terminal mode into normal mode)
- run
:tmap
and provide me the output
Can you explain the <C-\><C-n>
sequence? Should the second key be as I mapped to vsplit.
Also, if you do mean the sequence you mentioned, after pressing the keys I'll have to quit nnn
with q
and then run :tmap
right?
No, <C-\><C-n>
is the key sequence to exit the "terminal insert" mode. After that, you will be in normal mode in the terminal buffer, so immediately run :tmap
without typing anything else before that.
Where do I close nnn
in this sequence?
I effectively want you to display active keybindings. For example, this is what I see:
t <C-H> *@<C-\><C-N>:<C-U>call nnn#select_action("vsplit")<CR>
Now because your cursor jumps to the end of the buffer, I already suspect your output will look like this. The issue is that the part :<C-U>call nnn#select_action("vsplit")<CR>
is probably not working.
Where do I close
nnn
in this sequence?
You don't. The window should be open when you type :tmap
:tmap
shows No mapping found
Your cursor needs to be in the nnn
window when you run :tmap
OK. Do I need to compile nnn
with mouse enabled?
:tmap
in nnn
shows:
cp: '/home/vaio/Amrita' and './Amrita' are the same file │elveti ca│ cp: '/home/vaio/Desktop' and './Desktop' are the same file │family :A│ cp: '/home/vaio/Documents' and './Documents' are the same file │<td st yl│ cp: '/home/vaio/Downloads' and './Downloads' are the same file │ 56001 0<│ cp: '/home/vaio/Dropbox' and './Dropbox' are the same file │.No : 08│ cp: '/home/vaio/GitHub' and './GitHub' are the same file │t:bold ;"│ cp: '/home/vaio/Music' and './Music' are the same file │nt-siz e:│ cp: '/home/vaio/Pictures' and './Pictures' are the same file │></td> <t│ cp: '/home/vaio/Videos' and './Videos' are the same file │g="0" ce│ cp: '/home/vaio/ACT_Invoice-MAR-2020.html' and './ACT_Invoice-MAR-2020.html' are the same file │rc="ht tp│ cp: '/home/vaio/ACT_Invoice.pdf' and './ACT_Invoice.pdf' are the same file │lign=" ri│ cp: '/home/vaio/IMG20210404104315.jpg' and './IMG20210404104315.jpg' are the same file │the Re ce│ cp: '/home/vaio/IMG20210404143849.jpg' and './IMG20210404143849.jpg' are the same file │le="bo rd│ │left:3 5p│ 'Enter' to continue
No. To be more specific, upon entering the nnn
window with <leader>n
, hit this exact sequence of keys and nothing else:
<C-\><C-n>:tmap<CR>
Again, you are not trying to send the :tmap
sequence to nnn
process, but rather to vim process (the command tmap
)
The <C-\><C-n>
key sequence is used to escape insert mode in the terminal. As you can see, it is also used in the keymapping for nnn.vim
:
Line 8 in c678c7e
Since your cursor does jump to the end of the buffer, that means the <C-\><C-n>
part is working. That however means that the rest of the command is not working, as I mention earlier. To help debug this, could you locate your local plugin directory and find nnn.vim/ftplugin/nnn.vim
and remove <silent>
from lines 8 and 10?
Same No mapping found
.
Does running <c-h>
still put your cursor at the end of the buffer?
yes
How do I exit the :tmap
mode in the popup window?
I'm afraid you're not accurately reporting the :tmap
bit. Could you send a screenshot of what your Vim state looks like when you run :tmap
?
Unfortunately in this screenshot you must have hit qq
which populates the output area at the bottom with recording @q
and thus hiding the output of :tmap
. I'm interested in the output at the very bottom of the screen. Remember that once you've hit <C-\><C-n>
you're in normal mode and therefore, to continue interacting with nnn
, you will need to hit i
to go back into "insert" mode before hitting q
etc.
I guess I'll have to take your word for it, though I don't know how <c-h>
is able to jump to the end of the buffer if there is no mapping...
Can you hit <C-\><C-n>
and then do :echo b:nnn_ftplugin
and let me know if the output is 1
?
Also can you edit the source code of nnn.vim
and remove <silent>
from lines 8 and 10 in ftplugin/nnn.vim
like I mention earlier? After you do this go back and try <c-h>
and tell me what you see at the bottom of your screen.
I have removed silent
from ftplugin/nnn.vim
. The earlier screenshot was taken after that.
:echo b:nnn_ftplugin
gives:
E121: Undefined variable: b:nnn_ftplugin
Maybe my instructions aren't clear enough or this is a very weird situation...
I would have a much easier time working with this if I could reproduce it. Until then, I don't think we are going very far.
Have you determined this was a vim-specific issue? Could you try nvim -u ~/.vimrc
and see if it persists?
Does :echo b:nnn_ftplugin
showing undefined
mean ftplugin/nnn.vim
is not loaded or something?
I can try the nvim experiment later.
Does
:echo b:nnn_ftplugin
showing undefined meanftplugin/nnn.vim
is not loaded or something?
Yes, assuming that the the buffer you were in when you ran that command was the nnn
buffer.
Is there a way to generate a fault when loading ftplugin? That way we can ensure it's being loaded.
Sure, you can error if b:nnn_ftplugin
is undefined. It should be working fine though, assuming the filetype of the terminal buffer is set to nnn
as it is here:
Line 354 in c678c7e
Maybe this function is not getting run?
Not sure. I am not familiar with vimscript. But I think we can get back to this later as this is not an issue for most users.
Closing this as somehow this feels to be a local issue than a generic issue. All people other than me in this thread don't see this. And it's not a big deal for me either.
Update: I have switched to nvim
and this issue is gone for good.