Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't navigate between Nvim splits #41

Open
bushblade opened this issue Mar 1, 2023 · 20 comments
Open

Can't navigate between Nvim splits #41

bushblade opened this issue Mar 1, 2023 · 20 comments

Comments

@bushblade
Copy link

Hi I've been using this plugin for quite a long time without problem.
I'm not sure what changed if it's a Nvim update or a Kitty update but I can no longer navigate between Nvim splits.
I haveCtrl + h/j/k/lmapped in Nvim to Ctrl + w h/j/k/l for easier navigation between splits but that no longer works.
Instead the cursor jumps to the kitty split, ignoring the Nvim splits.

I'm using Nvim 0.8.3, kitty 0.27.1

I can still navigate between Nvim splits by using Ctrl + w h/j/k/l it's just my bindings that no longer work.
I tried disabling my bindings in case that was now the default but that didn't work.

I ran kitty in debug mode with the print statement in my pass_keys.py and this is what I see....

KeyPress matched action: kitten
[{'pid': 23495, 'cmdline': ['/bin/fish'], 'cwd': '/home/will/.config/nvim'}]
handled as shortcut
Release xkb_keycode: 0x2b clean_sym: h mods: ctrl glfw_key: 104 (h) xkb_key: 104 (h)
on_key_input: glfw key: 0x68 native_code: 0x68 action: RELEASE mods: ctrl text: '' state: 0 ignoring as keyboard mode does not support encoding this event
Release xkb_keycode: 0x25 clean_sym: Control_L mods: ctrl glfw_key: 57442 (LEFT_CONTROL) xkb_key: 65507 (Control_L)
on_key_input: glfw key: 0xe062 native_code: 0xffe3 action: RELEASE mods: ctrl text: '' state: 0 ignoring as keyboard mode does not support encoding this event
Press xkb_keycode: 0x25 clean_sym: Control_L composed_sym: Control_L mods: none glfw_key: 57442 (LEFT_CONTROL) xkb_key: 65507 (Control_L)
on_key_input: glfw key: 0xe062 native_code: 0xffe3 action: PRESS mods: none text: '' state: 0 ignoring as keyboard mode does not support encoding this event
Press xkb_keycode: 0x2e clean_sym: l composed_sym: l mods: ctrl glfw_key: 108 (l) xkb_key: 108 (l)
on_key_input: glfw key: 0x6c native_code: 0x6c action: PRESS mods: ctrl text: '' state: 0 
KeyPress matched action: kitten
[{'pid': 23341, 'cmdline': ['nvim'], 'cwd': '/home/will/.config/nvim'}]
handled as shortcut
Release xkb_keycode: 0x2e clean_sym: l mods: ctrl glfw_key: 108 (l) xkb_key: 108 (l)
on_key_input: glfw key: 0x6c native_code: 0x6c action: RELEASE mods: ctrl text: '' state: 0 ignoring as keyboard mode does not support encoding this event
Release xkb_keycode: 0x25 clean_sym: Control_L mods: ctrl glfw_key: 57442 (LEFT_CONTROL) xkb_key: 65507 (Control_L)
on_key_input: glfw key: 0xe062 native_code: 0xffe3 action: RELEASE mods: ctrl text: '' state: 0 ignoring as keyboard mode does not support encoding this event

Though I have no idea what it means.

@knubie
Copy link
Owner

knubie commented Mar 2, 2023

Kitty has released some breaking changes in the past that have broken the plugin (#16 #20 #25), so it wouldn't surprise me if that happened again.

A good first step would be to downgrade kitty to a lower known-good version and see if the problem persists. FWIW I'm using neovim 8.1 with kitty 24.4.

@bushblade
Copy link
Author

Thanks for the reply.
I installed via my package manager ( Pamac on Manjaro ) from the community repositories.
I don't have an older version of kitty in my packages cache so can't easily test and older version.
I suppose I could build from source, but would rather stick with my package manager.
For now I'll just disable the plugin and stick with kitty default bindings to get me out of a Nvim split.

@rombrom
Copy link
Contributor

rombrom commented Mar 24, 2023

I think I figured this out. Basically, nvim doesn't run ! or system() commands against the hosting terminal.

Treat Nvim as a server, not a terminal application. Or use Vim.
neovim/neovim#8217 (comment)

The vim process detection in neighboring_window.py goes out of whack because nvim spawns sub shells with it's job control implementation. This means the kitty @ kitten command, executed outside of the kitty context, doesn't have any notion of kitty's windows.

I don't have time currently to search/implement a fix, but I think instead of deferring vim process detection to the kitten, this needs to be inverted and nvim needs to execute a noop or something so the mapping is handled by kitty?

@oliverlambson
Copy link

Any progress on this? I'm having the same issue. Is it best for me to downgrade kitty? If so, what is the latest kitty version known where nvim split navigation wasn't broken?

I'm on kitty 0.28.1 and nvim 0.9.0 fwiw

@rrpolanco
Copy link

Has anyone attempted a fix for this? This is a legitimate bug. Bindings don't work for me with Kitty 0.28.1 and nvim 0.8.0.

@rombrom
Copy link
Contributor

rombrom commented Jun 27, 2023

Haven't found time nor do I have the need anymore. I've ejected to using two sets of keybindings. The CTRL-h/j/k/l for when in nvim and CTRL-SUPER-h/j/k/l when requiring to navigate Kitty.

@markos-stefanidis
Copy link

markos-stefanidis commented Aug 22, 2023

I have noticed this is still open. Is this still an issue? Works fine for me with kitty v0.29.2 and nvim v0.9.1.
It would not work if I passed the process as an argument to pass_keys.py.

EDIT: If you can move between nvim splits but can't go to a kitty pane, make sure you don't overwrite the keybindings later in your neovim config.

@rrpolanco
Copy link

This plugin no longer seems to work for me. I tried following the troubleshooting steps and have narrowed it down to a possible issue with the encoded key map. I'm not sure. This is what I see in my kitty debug output when I press ctrl+l:

-------------- flags changed -----------------
NSEvent: type=FlagsChanged loc=(1191.67,302.184) time=49481.4 flags=0x40101 win=0x13b7956c0 winNum=1154 ctxt=0x0 keyCode=59
flagsChanged: modifier: ctrl native_key: 0x3b (<noname>) glfw_key: 0xe062 mods: ctrl 
on_key_input: glfw key: 0xe062 native_code: 0x3b action: PRESS mods: ctrl text: '' state: 0 ignoring as keyboard mode does not support encoding this event
---------------- key down -------------------
NSEvent: type=KeyDown loc=(1191.67,302.184) time=49481.5 flags=0x40101 win=0x13b7956c0 winNum=1154 ctxt=0x0 chars="
                                                                                                                   " unmodchars="l" repeat=0 keyCode=37
Press: native_key: 0x25 (l) glfw_key: 0x6c mods: ctrl char_count: 1 deadKeyState: 0 repeat: 0 
	TextInputCtx: doCommandBySelector: (centerSelectionInVisibleArea:)
text: <none> glfw_key: l marked_text: ()
on_key_input: glfw key: 0x6c native_code: 0x25 action: PRESS mods: ctrl text: '' state: 0 
KeyPress matched action: kitten
***vim_id= n?vim
[{'pid': 27640, 'cmdline': ['nvim'], 'cwd': '/Users/rafael/.dotfiles-custom/config/kitty'}]
*** is_window_vim= True
handled as shortcut

Any thoughts on how to debug further?

@markos-stefanidis
Copy link

@rrpolanco Not sure, debug output doesn't give me enough to go on. Care to share your configuration so maybe I could try to replicate the issue?

@cyaconi
Copy link

cyaconi commented Aug 31, 2023

Same problem here. Anything I can do to help?

@jacobrreed
Copy link

seems to be an issue for me still

@traviscrist
Copy link

Have you tried to solution in #43 outlined by this comment?
#43 (comment)

@jacobrreed
Copy link

jacobrreed commented Jul 23, 2024 via email

@jacobrreed
Copy link

jacobrreed commented Jul 23, 2024 via email

@jacobrreed
Copy link

So I did some testing, I can navigate up and down in kitty splits using the command in neovim :KittyNavigateDown etc, but the mappings dont work, so I assume LazyVim in my case is overwriting the binds

@jacobrreed
Copy link

was able to get it working with this:

-- Kitty
if os.getenv("TERM") == "xterm-kitty" then
  vim.g.kitty_navigator_no_mappings = 1
  vim.g.tmux_navigator_no_mappings = 1

  vim.cmd([[
    noremap <silent> <c-h> :<C-U>KittyNavigateLeft<cr>
    noremap <silent> <c-l> :<C-U>KittyNavigateRight<cr>
    noremap <silent> <c-j> :<C-U>KittyNavigateDown<cr>
    noremap <silent> <c-k> :<C-U>KittyNavigateUp<cr>
  ]])
end

in my keymaps.lua
for some reason setting the keymap with vim.keymap.set didn't work

@carlos-algms
Copy link

Is it still not working?
I was just about giving it a shot and found this issue 😞

@knubie
Copy link
Owner

knubie commented Oct 17, 2024

@carlos-algms The plugin is still working (I use it every day). Some people have random issues due to configuration or environment or whatever, so I leave this issue as an open forum for troubleshooting various problems.

@carlos-algms
Copy link

I'm back to report that the plugin worked first try, with no custom code Thank you @knubie, the experience is amazing.

Since the docs said the plugin would bind the keys for me, I disabled my custom keybindings beforehand, just to make sure I had no conflicts.

Since I'm using Lazy, and the README only mentions Plug, I'll leave the config here so others can try:

-- plugins/vim-navigator.lua
return {
    "knubie/vim-kitty-navigator",
    build = "cp ./*.py ~/.config/kitty/",
}

Remember to quit Kitty, closing the last window isn't enough 😉.

@garrettmaring
Copy link

garrettmaring commented Dec 5, 2024

Something in the way I'm launching it on macOS (Sequoia) causes is_window_vim to always return false. Logging showed the process name was never the right match (key presses from a terminal pane vs. vim split both showed 'zsh'). So made a small update to is_window_vim to look at sub-processes and now it's working great as is otherwise 👍

def is_window_vim(window, vim_id):
    window_pid = window.child.pid

    def check_process_tree(pid):
        try:
            process = psutil.Process(pid)
            if re.search(vim_id, process.name() or ' '.join(process.cmdline()), re.I):
                return True

            for child in process.children(recursive=True):
                if re.search(vim_id, child.name() or ' '.join(child.cmdline()), re.I):
                    return True
            
            return False
        except psutil.NoSuchProcess:
            return False
        except Exception as e:
            return False

    return check_process_tree(window_pid)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests