alexghergh / nvim-tmux-navigation

Easy Neovim-Tmux navigation, completely written in Lua
MIT License
273 stars 21 forks source link

"not an editor command" for all NvimTmuxNavigate* Commands #12

Closed after-ephemera closed 1 year ago

after-ephemera commented 1 year ago

I'm using Neovim 0.8.2, tmux 3.3a.

I installed the plugin with vim plugged

Plug 'alexghergh/nvim-tmux-navigation'

and added the remaps to my vimrc

nnoremap <silent> <C-h> <Cmd>NvimTmuxNavigateLeft<CR>
nnoremap <silent> <C-j> <Cmd>NvimTmuxNavigateDown<CR>
nnoremap <silent> <C-k> <Cmd>NvimTmuxNavigateUp<CR>
nnoremap <silent> <C-l> <Cmd>NvimTmuxNavigateRight<CR>
nnoremap <silent> <C-\> <Cmd>NvimTmuxNavigateLastActive<CR>
nnoremap <silent> <C-Space> <Cmd>NvimTmuxNavigateNext<CR>

but it's telling me that the commands aren't editor commands. However, I am able to get christoomey/vim-tmux-navigator working. I did a :PlugClean after switching over but I'm not sure exactly what I'm doing wrong.

vhristev commented 1 year ago

I have the same problem that is not working for me with Neovim 0.8.2, tmux 3.3a.

vhristev commented 1 year ago

I was able to track down the problem. @after-ephemera check if you install Fig - https://fig.io

Troubleshoot from here: https://vimawesome.com/plugin/vim-tmux-navigator Another option is that the pattern matching included in the .tmux.conf is not recognizing that Vim is active. To check that tmux is properly recognizing Vim, use the provided Vim command :TmuxNavigatorProcessList. The output of that command should be a list like:

When i run : TmuxNavigatorProcessList i got just "Figterm." There was no vim, tmux, or both.

The solution was to uninstall it brew uninstall fig

alexghergh commented 1 year ago

Thanks for bringing this up!

I am currently not using Fig, not sure exactly what that is.

Running the same setup as you, and it runs fine for me.

Could you try the above suggested fix? If that is not the issue, could you disable all plugins and just run this plugin (just to rule out any potential clash issues)?

after-ephemera commented 1 year ago

Edit: I also get not an editor command when trying to run :TmuxNavigatorProcessList from within neovim.

What an interesting conflict. I previously installed Fig to play with it, but I thought I uninstalled it. I went through their basic manual uninstallation instructions but I'm still getting the same error. I'll do all of the optional steps and then come back around and try again.

vhristev commented 1 year ago

I'm currently migrating from vimrc to Lua and starting from scratch, so it's a bit of the wild west, which I'm trying to put in order. I've been using vi/vim for ~15y, so it was time to start from scratch. The main goal is to use Lua as much as possible, so I tried new plugins and configs to make my setup how I liked it but it's very time-consuming finding everything for Lua. It will take some time, but I know it is for good.

@after-ephemera

Check the documentation i send you and try to troubleshoot it. Checkthe command :TmuxNavigatorProcessList output is. Also I alias my grep to "rg" alias grep=rg ( ripgrep ), so if you did something like this, expect to have issues where scripts are using pure old good gnu grep.

after-ephemera commented 1 year ago

I tried following the full uninstallation process for Fig and still haven't had success. Is there any other way to discover potential conflicts?

after-ephemera commented 1 year ago

I also tried what you suggested @alexghergh by disabling all other plugins and only running this plugin and it's still failing to recognize the commands.

micku commented 1 year ago

Same here, tried with my old config and it didn't work, while this other way worked:

local nvim_tmux_nav = require('nvim-tmux-navigation')
vim.keymap.set('n', '<C-J>', nvim_tmux_nav.NvimTmuxNavigateDown, {silent = true})
...

Now I'm starting from scratch with Lazy and would like to use these commands, but it fails with the error E492: Not an editor command: TmuxNavigatorProcessList whatever the command.

alexghergh commented 1 year ago

I am not sure what the command TmuxNavigatorProcessList is. Is that something related to Fig?

Could you try to invoke the commands manually (i.e. type :NvimTmuxNavigateDown<CR>) and see what happens?

I am honestly quite in the dark here, since I cannot reproduce the error. It would help a lot if you could try maybe a different shell altogether (bash, zsh, fish etc.), different versions of Neovim or Tmux and see when the issue starts to appear/disappear.

micku commented 1 year ago

In my case, the same error happened for any command, even for NvimTmuxNavigateDown.

Doing some tests I found the reason why it didn't work for me, I didn't require the plugin (because I didn't need to change any setting), therefore the functions weren't loaded. Adding a simple require("nvim-tmux-navigation") is enough to fix the issue for me.

alexghergh commented 1 year ago

Ah, thank you very much for the help investigating the issue @micku .

Indeed, looks like I omitted to treat a few cases where a user would not run the setup() function at all or would not require the plugin.

I will attend to a solution to this in a couple of days (hopefully).

Until then, the simple solution is just requiring the plugin, which lets it do all the setup necessary for the functions and commands.

Could you try see if that solves your problem? @vhristev @after-ephemera

after-ephemera commented 1 year ago

I am using vimscript and not lua. Sorry for my ignorance but how do I/can I even require the plugin in vimscript?

alexghergh commented 1 year ago

I think it should be as easy as adding a lua require('nvim-tmux-navigation') in your init.vim.

after-ephemera commented 1 year ago

Yep that fixed it for me, thanks!