luukvbaal/nnn.nvim

Built-in actions not working

anjerukare opened this issue · 8 comments

Hello, I faced a problem with the built-in actions.
Executing an action turns the Nnn window into a normal buffer. In the case of NnnPicker, the window doesn't close and no action occurs.

Here is a screencast of this behavior:

Screencast.from.26.06.2022.23.53.48.webm.mov
  1. Trying to Ctrl+T on flutter-tools.lua: it turns floating window in normal buffer;
  2. Trying same on autocompletion.lua - same here;
  3. Trying select autopairs.lua with Space and then press Ctrl+T - nothing changes.

Also I reproduce it in NnnExplorer and with open_in_split, open_in_vsplit actions - got the same problem.

My configurations:

nnn.nvim
local builtin = require("nnn").builtin

-- Nnn setup
require('nnn').setup {
  replace_netrw = 'picker',
  mappings = {
    { "<C-t>", builtin.open_in_tab },     -- open file(s) in tab
    -- { "<C-s>", builtin.open_in_split },   -- open file(s) in split
    -- { "<C-v>", builtin.open_in_vsplit },  -- open file(s) in vertsplit
  }
}
.bashrc
# Nnn configuration
export NNN_OPTS='eR'
export NNN_COLORS='#a8a8a8a8'
export NNN_FCOLORS='a8a8a8fbfbfbfbfbfbfbfbfb'
export NNN_FIFO='/tmp/nnn.fifo'
export NNN_PLUG='f:autojump'
eval "$(jump shell bash --bind=f)"
t ()
{
  # Block nesting of nnn in subshells
  if [ -n $NNNLVL ] && [ "${NNNLVL:-0}" -ge 1 ]; then
      echo "nnn is already running"
      return
  fi

  export NNN_TMPFILE="${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.lastd"

  nnn "$@"

  if [ -f "$NNN_TMPFILE" ]; then
          . "$NNN_TMPFILE"
          rm -f "$NNN_TMPFILE" > /dev/null
  fi
}

Works fine on my end. What's happening in your gif is that instead of executing the nnn mapping is that you're leaving terminal mode. Do you have any conflicting mappings to leave terminal mode?

I didn't map keys to exit terminal mode.

Here is my :tmap output:
t ,t * <Cmd>NnnPicker<CR>

Even if I disable this remapping, have the same problem.

Then the it would seem the feedkeys part of handle_mapping() is not working properly on your end, I have no idea why.

feedkeys("i<CR>")

Created minimal vim config and ran from it. Couldn't reproduce the problem.
It's a good sign.

Problem was in this mapping:

noremap i l|        "move Right

Which is part of hjkl remappings for Colemak-DH:

noremap m h|        "move Left
noremap n gj|       "move Down
noremap e gk|       "move Up
noremap i l|        "move Right

Great, thanks for reporting back. Doest the following diff fix the issue with your usual config?

diff --git a/lua/nnn.lua b/lua/nnn.lua
index 4e3eb36..b74c02e 100644
--- a/lua/nnn.lua
+++ b/lua/nnn.lua
@@ -194,7 +194,7 @@ local function on_stdout(_, data, _)
 end

 local function feedkeys(keys)
-       api.nvim_feedkeys(api.nvim_replace_termcodes(keys, true, true, true), "m", true)
+       api.nvim_feedkeys(api.nvim_replace_termcodes(keys, true, true, true), "n", true)
 end

 local function buffer_setup(mode, tab)

I think it should, do let me know if it doesn't.

It works! Thanks a lot!