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

Commit fe88eade4ab50fca9ace99205cad1d91645ed9e8 breaks pyright and ruff #3456

Closed
danpascu opened this issue Nov 26, 2024 · 9 comments
Closed
Labels
bug Something isn't working

Comments

@danpascu
Copy link

danpascu commented Nov 26, 2024

Description

I'm using the plugin for python with pyright and ruff as language servers. This morning after I updated nvim-lspconfig I noticed things behaving weirdly. Checking the health of the plugin showed two instances of both ruff and pyright running in the initial buffer that was entered after restoring the session. Keyboard shortcuts for prev-symbol ([[) didn't work anymore and the shortcut for the next-symbol (]]) jumped to weird positions, like from a symbol (class name) jumped to the next class keyword.

At some point after changing buffers and restarting nvim a couple of times I noticed I had 3-4 copies of each language server running and keyboard shortcuts became even more broken. The keyboard shortcut for the previous-symbol deleted a range of text and replaced it with some random pasted content.

This only seems to apply to the first buffer entered after starting nvim and restoring the session. The other buffers I switch to only seem to have a single copy of the language server running for them and they don't exhibit keyboard shortcut problems.

Image

I reverted fe88ead and things went back to normal.

@danpascu danpascu added the bug Something isn't working label Nov 26, 2024
@danpascu
Copy link
Author

I should note this doesn't only happen when restoring the previous session. It applies to the first opened buffer, be that from restoring the last session, starting nvim with a file argument or starting nvim and then loading a file.

@glepnir
Copy link
Member

glepnir commented Nov 26, 2024

If the server does not support workspaceFolder,should not reuse the existing server. Provide complete minimal reproduction steps. If it is caused by session, then it should be the issue I raised in the previous refactored PR.

@danpascu
Copy link
Author

Maybe it shouldn't reuse servers, but that's not what I see. In the screenshot I attached you can see that buffers 4, 7 and 11 share one copy of the servers and in addition buffer 7 has another copy for each of the servers. Buffer 7 having the 2 copies for each of the server is what causes the problems with the keyboard shortcuts. Buffer 7 is the buffer that was opened first.

Something is obviously wrong since it starts two copies for each language server in the first buffer.

@glepnir
Copy link
Member

glepnir commented Nov 26, 2024

. Provide complete minimal reproduction steps.

please

@danpascu
Copy link
Author

I'm not sure what qualifies as minimal reproduction steps. I use LazyVim to manage my configuration. If I provide you with the stripped down nvim config folder where I remove all other settings and just leave in the lspconfig settings, is that good enough?

@glepnir
Copy link
Member

glepnir commented Nov 26, 2024

nvim --clean -u minimal.lua

-- down load lspconfig to somewhere
vim.opt.rtp:append('path/to/nvim-lspconfig')
local lspconfig = require('lspconfig')
lspconfig.pyright.setup({})
lspconfig.ruff.setup({})

reproduce steps

  1. foo
  2. bar

@glepnir
Copy link
Member

glepnir commented Nov 26, 2024

I can reproduce with start neovim from a session file . yes that's what i already comment in there #3450 (comment)

when load frome sesssion the first client is not initialized we can't get the server_capabilities at that time then the second buffer is loaded . so reuse client return false after fe88ead ...before refactor i use a timer to wait the first client initialized then to check worksapceFolder.supported ...but if there revert this will cause another prolem if server doesn't support workspaceFolder there sill use server to attach the buffer which in anohter project...

@danpascu
Copy link
Author

Same thing happens if there is no session involved. If I start nvim like nvim file.py or I start nvim and then open a file without restoring any session the same thing happens. I always get duplicate language server instances on the first buffer.

@glepnir
Copy link
Member

glepnir commented Nov 26, 2024

I have revert. but it still have another probelm so i will close this issue and open new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants