Closed stefanlogue closed 11 months ago
My guess is something is overriding the key bindings when opened without an arg. Two questions:
nvim .
and nvim
cases: :verbose nmap <C-h>
?nvim
, I get:
n <C-H> * <C-W>h Go to left window Last set from Lua
In the case of nvim .
, I get:
<C-H> * :<C-U>TmuxNavigateLeft<CR> Last set from ~/.local/share/nvim/lazy/vim-tmux-navigator/plugin/tmux_navigator.vim line 19
So yes, it's being overwritten when opened without an arg. Do you know if there's a way to stop this from happening?
I've managed to work around this now by adding the keymaps to my keymap.lua
file manually. For future reference, this is caused by LazyVim loading it's own keymaps for those keys on startup. I'm still not 100% sure why this only happens when Neovim is opened without arguments though
Glad you're able to sort this out, and thanks for sharing back the notes. I'm going to close this now as I don't believe the issue is in the plugin.
@stefanlogue Can you share your keymaps.lua file with me? I'm new to lazyvim and my file is blank. I'm not sure how to add keymaps to it. Not sure what kind of data structure it is supposed to return. Thanks.
@sdondley Sure thing! I have a local function in there to make mapping a bit more readable, I'll include that below:
local function map(mode, lhs, rhs, opts)
local keys = require("lazy.core.handler").handlers.keys
---@cast keys LazyKeysHandler
-- do not create the keymap if a lazy keys handler exists
if not keys.active[keys.parse({ lhs, mode = mode }).id] then
opts = opts or {}
opts.silent = opts.silent ~= false
if opts.remap and not vim.g.vscode then
opts.remap = nil
end
vim.keymap.set(mode, lhs, rhs, opts)
end
end
You'll then want to use this funtion to remap keys, here are my maps to make this plugin work correctly on all loads:
-- Vim Tmux Navigator (needed as LazyVim overwrites these when opened without args)
map("n", "<C-h>", "<Cmd>TmuxNavigateLeft<CR>", { desc = "Navigate Left" })
map("n", "<C-j>", "<Cmd>TmuxNavigateDown<CR>", { desc = "Navigate Down" })
map("n", "<C-k>", "<Cmd>TmuxNavigateUp<CR>", { desc = "Navigate Up" })
map("n", "<C-l>", "<Cmd>TmuxNavigateRight<CR>", { desc = "Navigate Right" })
map("n", "<C-\\>", "<Cmd>TmuxNavigatePrevious<CR>", { desc = "Previous Window" })
Guys, anyone can help me? I'm using lazy vim and did the remapping, but it simply does not work.
i get this:
when using verbose nmap
I'm using this installed as a TPM plugin, but the same can be seen for both setup options.
The plugin works fine when I open a Neovim window with arguments, e.g.
nvim .
However, if I open Neovim without arguments, i.e.nvim
, I cannot navigate out of the pane containing Neovim.I've checked
:TmuxNavigatorProcessList
both when working and not working, and it doesn't change.