alexghergh / nvim-tmux-navigation

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

Can not navigate out of neovim using keymap but works using Cmdline? #23

Closed mrt181 closed 2 months ago

mrt181 commented 2 months ago

I have copied the config from the README to .config/nvim/lua/plugins/nvim-tmux-navigator.lua

I am using LazyVim.

I can navigate

Navigating from neovim to tmux does not work using <C-hjkl> but it works using NvimTmuxNavigate*.

How can I fix that?

mrt181 commented 2 months ago

I had to move the keymap config to ~/.config/nvim/lua/config/keymaps.lua to make it work in LazyVim

Elyviere commented 2 months ago

I'd say this is an issue with the README, which should be improved. I tried placing both of the LazyVim suggestions from the README in a file I named tmux-navigation.lua, but neither one worked.

~~I solved it the same way as mrt181, but I'll provide the solution as well for anyone else who stumbles upon this thread: nvim/lua/plugins/tmux-navigation.lua (or whatever you've named your plugin file):~~

Edit: After looking at the LazyVim documentation, I was able to resolve it using the following nvim/lua/plugins/tmux-navigation.lua file.

return {
  "alexghergh/nvim-tmux-navigation",
  keys = function()
    return {
      { "<C-h>", require("nvim-tmux-navigation").NvimTmuxNavigateLeft },
      { "<C-j>", require("nvim-tmux-navigation").NvimTmuxNavigateDown },
      { "<C-k>", require("nvim-tmux-navigation").NvimTmuxNavigateUp },
      { "<C-l>", require("nvim-tmux-navigation").NvimTmuxNavigateRight },
      { "<C-\\>", require("nvim-tmux-navigation").NvimTmuxNavigateLastActive },
      { "<C-Space>", require("nvim_tmux_navigation").NvimTmuxNavigateNext },
    }
  end,
}
alexghergh commented 2 months ago

Hey,

Thanks for opening the issue and thanks for chiming in @Elyviere.

I agree that the README is not completely transparent for the beginner user (either with Neovim or with installing plugins in general). It's not as straightforward as literally "copy this piece of code into this file and it will work". It does involve placing into it's corresponding section inside the lazy.nvim setup.

Moving onto the issue with LazyVim (just making sure, you mean the distribution on top of Neovim, not the plugin manager lazy.nvim, correct?), I am not quite sure how it handles custom plugin installs. Do you mind pointing to the relevant part of the documentation where you found the solution? I could consider changing / improving the README here to reflect potentially different configs for LazyVim.

Please confirm, though, that this is not an issue with the plugin itself, but rather just a "where do I place this piece of code" kind of issue.

Thanks!

Elyviere commented 2 months ago

Hey alex.

In my case I am indeed using LazyVim, but since it in turn uses lazy.nvim I'm not sure there's actually a difference. As far as I know, lazy.nvim is the one defining that all plugin specs in the lua/plugins/ folder will be automatically read, not LazyVim (lazy.nvim#structuring-your-plugins).

I cannot tell you why the code provided in the readme for lazy.nvim didn't work for me. To my eyes, it looks like it should work since it's making use of the config property of lazy.nvim.

The documentation I was following was from the LazyVim distribution: lazyvim#adding&disabling-plugin-keymaps

And yes, it's not an issue with this plugin itself, only potentially an issue with the readme provided for this plugin, although I'm not myself sure what the issue is.