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

Calling 'vim.diagnostic.goto_next()' inactivates lightline #661

Closed
crowdigit opened this issue Oct 17, 2023 · 7 comments
Closed

Calling 'vim.diagnostic.goto_next()' inactivates lightline #661

crowdigit opened this issue Oct 17, 2023 · 7 comments

Comments

@crowdigit
Copy link

I'm using Neovim with LSP plugins namely neovim/nvim-lspconfig.

There's functions that moves cursor to next/previous diagnose called vim.diagnostic.goto_next() and goto_prev().

Here's how I configured:

vim.keymap.set('n', '[d', vim.diagnostic.goto_prev)
vim.keymap.set('n', ']d', vim.diagnostic.goto_next)

You can find out more at their github.

Problem is, moving to next/previous diagnose inactivates Lightline.

  1. Initial state, everything is fine
    Screenshot 2023-10-17 at 3 15 01 PM
  2. Moved cursor by calling goto_next
    Screenshot 2023-10-17 at 3 15 08 PM
  3. Now my Lightline is disabled oh no
    Screenshot 2023-10-17 at 3 15 28 PM

Moving to other buffer or reopening the buffer reactivates it but this is a little bit disturbing :(

asdf@asdarf ~ $ nvim --version
NVIM v0.9.2
Build type: Release
LuaJIT 2.1.0-beta3

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/opt/homebrew/Cellar/neovim/0.9.2/share/nvim"

Run :checkhealth for more info
@crowdigit
Copy link
Author

I figured out it's not related to goto_next, it's caused by opening floating window.

It has been discussed already, and there's a plugin implementing it using Neovim's laststatus feature, but it's limited to Neovim.

@itchyny
Copy link
Owner

itchyny commented Oct 19, 2023

Are you using the latest version of lightline? I recently accepted a Neovim related patch so make sure to update. If it is the latest, please create a precise steps to reproduce the issue. Just lua vim.diagnostic.goto_next() warns No more valid diagnostics to move to.

@crowdigit
Copy link
Author

crowdigit commented Oct 19, 2023

Thanks for checking out,

I'm using latest commit

commit f11645cc6d37871244f2ea0ae972d3f6af9c8f73 (HEAD -> master, origin/master, origin/HEAD)
Merge: b1e91b4 3d10b50
Author: itchyny <itchyny@cybozu.co.jp>
Date:   Sun Sep 3 19:09:07 2023 +0900

    Merge pull request #659 from 4513ECHO/fix/neovim-floatwin
    
    fix: Make not to skip floatwin if it is focusable

I have checked, opening floating window actually does not inactivates lightline, I used below command to check

:call nvim_open_win(0, v:false, { "relative": "editor", "width": 40, "height": 20, "col": 0, "row": 20})

I think goto_next does some more work than just opening window.

To reproduce, we need working LSP environment which includes,

  1. Neovim
  2. Neovim LSP config
  3. Dev environment and an language server
  • I used Typescript tsserver for the example, so npm and Typescript compiler is required.
    # assume npm is already installed and $PATH is configured
    npm install --global typescript
    npm install --global typescript-language-server
  • Link to tsserver configuration doc for nvim-lspconfig
  1. Assume now you have working LSP config, make a directory and init Typescript project
    npm init -y
    npx tsc --init
  2. Type some erroneous code, below code should suffice
    function foo() {
      throw new Error("oh no");
      console.log("bar")
    }
  3. Invoke goto_next

I attached my minimal Typescript project for case if you have trouble creating project.

ts.tar.gz

@itchyny
Copy link
Owner

itchyny commented Oct 19, 2023

@4513ECHO Would you help us fixing this?

@4513ECHO
Copy link
Contributor

Please try this workaround. Maybe this is bug of Neovim itself...

#659 (comment)

@itchyny
Copy link
Owner

itchyny commented Oct 20, 2023

Ah, okay, thanks. Is there any bug report to Neovim?

@crowdigit
Copy link
Author

@4513ECHO Yup I tried the patch and it works well now.

It looks like it's default behavior, (i.e. it's not a bug) so I think it won't be changed.

@itchyny We may conclude this issue invalid and close, but new users would face this issue later on so documenting it would be helpful. If you mind cluttered README file with troubleshooting methods, Github Wiki might come in handy.

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

3 participants