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

Navigating out of lazy.nvim window results in Error: WinLeave Autocommands ... #107

Closed
oschrenk opened this issue Oct 25, 2023 · 6 comments
Labels
bug Something isn't working question Further information is requested

Comments

@oschrenk
Copy link

oschrenk commented Oct 25, 2023

I am using https://github.com/folke/lazy.nvim as my package manager and when I open it via :Lazy it opens a floating window in nvim.

Trying to then navigate using tmux.nvim results in:

E5108: Error executing lua ...are/nvim/lazy/tmux.nvim/lua/tmux/navigation/
navigate.lua:37: WinLeave Autocommands for "*": Vim(substitute):E21: Cannot make changes, 'modifiable' is off
stack traceback:
        [C]: in function 'wincmd'
        ...are/nvim/lazy/tmux.nvim/lua/tmux/navigation/navigate.lua:37: in
 function 'to'
        ...l/share/nvim/lazy/tmux.nvim/lua/tmux/navigation/init.lua:30: in
 function 'move_right'
        [string ":lua"]:1: in main chunk

My config

return {
  "aserowy/tmux.nvim",
  keys = { "<C-h>", "<C-j>", "<C-k>", "<C-l>" },
  config = function()
    require("tmux").setup({
      copy_sync = { enable = false },
      navigation = { cycle_navigation = true, enable_default_keybindings = true },
      resize = { enable_default_keybindings = true, resize_step_x = 1, resize_step_y = 1 },
    })
  end,
}

My best guess is that I am missing some config flag for floating windows, but I also feel that it was happening only since my upgrade from nvim 0.9.2 to 0.9.4. I'm suspecting that maybe neovim/neovim#25523 introduced an issue (it did for other plugins using auto_cmd

@aserowy aserowy added bug Something isn't working question Further information is requested labels Oct 28, 2023
@aserowy
Copy link
Owner

aserowy commented Oct 28, 2023

Heho,

is this still relevant? The only auto cmds in tmux nvim are separated. Those should not lead to an error.

Kind regards
Alexander

@oschrenk
Copy link
Author

Let's close it. It's still occurring but I'm having a hard time finding the source of the error. It expresses itself mostly when using tmux.nvim but I guess it's not the source of the error.

@oschrenk
Copy link
Author

Still investigating. I reverted to https://github.com/christoomey/vim-tmux-navigator to see if it changes things. I still get an error but the error is now maybe more clear )well at least different):

I get

E11: Invalid in command-line window; <CR> executes, CTRL-C quits: wincm
d k

It still works but it still shows an error.

It comes from here:

function! s:VimNavigate(direction)
  try
    execute 'wincmd ' . a:direction
  catch
    echohl ErrorMsg | echo 'E11: Invalid in command-line window; <CR> executes, CTRL-C quits: wincmd k' | echohl None
  endtry
endfunction

I would think that there is something special about the :Lazy window. I also assume that your plugin also relies on wincmd and it perhaps fails the same way .

It seems it's maybe not about Winleave autocmd but just about applying wincmd on a special window.

I also opened a discussion over at folke/lazy.nvim#1156

@oschrenk oschrenk reopened this Oct 28, 2023
@aserowy
Copy link
Owner

aserowy commented Oct 28, 2023

ill follow it. lets see what we get.

and thanks for taking the time!

@oschrenk
Copy link
Author

I also found an issue from 2015

christoomey/vim-tmux-navigator#67

and actually removing/commenting out the echohl line

function! s:VimNavigate(direction)
  try
    execute 'wincmd ' . a:direction
  catch
    " echohl ErrorMsg | echo 'E11: Invalid in command-line window; <CR> executes, CTRL-C quits: wincmd k' | echohl None
  endtry
endfunction

in the "original" christoomey/vim-tmux-navigator code actually still works. It's jumping to the pane.

It seems that there is some issue with vim vs nvim and commandline windows.

@oschrenk
Copy link
Author

oschrenk commented Dec 5, 2023

It was my own configuration 🤦

local my_actions = augroup("MyActions", { clear = true })

-- Autosave on focus lost or when exiting the buffer
autocmd({ "FocusLost", "WinLeave" }, {
  pattern = "*",
  command = ":...",
  group = my_actions,
})

The autocmd fired on lazy window and created issues with non modifiable windows. Nothing to do with tmux.

@oschrenk oschrenk closed this as completed Dec 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants