-
Notifications
You must be signed in to change notification settings - Fork 17.1k
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
Fix highlight errors when lsp crash or stop #864
Conversation
It adds a check wether the client is still available before highlighting. If the client is not there anymore it returns `true` to unregister the autocommand This fix the `method textDocument/documentHighlight is not supported by any of the servers registered for the current buffer` errors when doing a LspRestart or the server crashes
Please forgive my ignorance here but will this fix negatively affect people with different LSP configurations etc? |
How do you test or reproduce this error?
These cases seem to work normally. |
I have a pretty unstable LSP (tsserver) on a couple projects. That requires me to frequently restart it. When the server crash I receive a load of errors Theses errors are probably not an issue by themselves because they are silent, but I'm using Noice and nvim-notify so they are pretty noisy. The issue is that the more I restart the LSP the more errors notifications I get, tsserver sometimes require 3 restart in a row. This led me to believe that there might be a small memory leak as the more you restart the lsp the more autocmds are created. This might be an edge case but doing this trick completely resolved my issues and I can restart the LSP and continue working. I thought I'd share through this pull request. |
Hmm I wonder if a more proper approach would be to listen to the |
It's is a good idea and it seems to work properly by removing the command in the LspDetatch. As per the crash I have to wait until it happens to see if the error is still there, but with this fix LspRestart will clear the commands the error will automatically be cleared as well. I would say it is not really an issue anymore. I updated the PR to remove the the commands in the LspDetatch event like you suggested. |
@sudo-tee It's looking much better now.
If you agree that this works and is cleaner go ahead and integrate it and I think we have a final solution. |
I confirm that it works with the I updated the PR to use this method instead. Thanks lot for your help on the issue :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks for working towards the best solution on this everyone! |
* Fix highlight errors when lsp crash or stop It adds a check wether the client is still available before highlighting. If the client is not there anymore it returns `true` to unregister the autocommand This fix the `method textDocument/documentHighlight is not supported by any of the servers registered for the current buffer` errors when doing a LspRestart or the server crashes * Delete the highlight autocommands in the LspDetatch event * Only delete autocmds for the current buffer with the group name * Simplify clearing the autocommands --------- Co-authored-by: Francis Belanger <francis.belanger@ubisoft.com>
* Fix highlight errors when lsp crash or stop It adds a check wether the client is still available before highlighting. If the client is not there anymore it returns `true` to unregister the autocommand This fix the `method textDocument/documentHighlight is not supported by any of the servers registered for the current buffer` errors when doing a LspRestart or the server crashes * Delete the highlight autocommands in the LspDetatch event * Only delete autocmds for the current buffer with the group name * Simplify clearing the autocommands --------- Co-authored-by: Francis Belanger <francis.belanger@ubisoft.com>
* Fix highlight errors when lsp crash or stop It adds a check wether the client is still available before highlighting. If the client is not there anymore it returns `true` to unregister the autocommand This fix the `method textDocument/documentHighlight is not supported by any of the servers registered for the current buffer` errors when doing a LspRestart or the server crashes * Delete the highlight autocommands in the LspDetatch event * Only delete autocmds for the current buffer with the group name * Simplify clearing the autocommands --------- Co-authored-by: Francis Belanger <francis.belanger@ubisoft.com>
* Fix highlight errors when lsp crash or stop It adds a check wether the client is still available before highlighting. If the client is not there anymore it returns `true` to unregister the autocommand This fix the `method textDocument/documentHighlight is not supported by any of the servers registered for the current buffer` errors when doing a LspRestart or the server crashes * Delete the highlight autocommands in the LspDetatch event * Only delete autocmds for the current buffer with the group name * Simplify clearing the autocommands --------- Co-authored-by: Francis Belanger <francis.belanger@ubisoft.com>
* Fix highlight errors when lsp crash or stop It adds a check wether the client is still available before highlighting. If the client is not there anymore it returns `true` to unregister the autocommand This fix the `method textDocument/documentHighlight is not supported by any of the servers registered for the current buffer` errors when doing a LspRestart or the server crashes * Delete the highlight autocommands in the LspDetatch event * Only delete autocmds for the current buffer with the group name * Simplify clearing the autocommands --------- Co-authored-by: Francis Belanger <francis.belanger@ubisoft.com>
* Fix highlight errors when lsp crash or stop It adds a check wether the client is still available before highlighting. If the client is not there anymore it returns `true` to unregister the autocommand This fix the `method textDocument/documentHighlight is not supported by any of the servers registered for the current buffer` errors when doing a LspRestart or the server crashes * Delete the highlight autocommands in the LspDetatch event * Only delete autocmds for the current buffer with the group name * Simplify clearing the autocommands --------- Co-authored-by: Francis Belanger <francis.belanger@ubisoft.com>
* upstream/master: (46 commits) Automatically set detached state as needed. (nvim-lua#925) fix: debug.lua (nvim-lua#918) Add diff to treesitter's ensure_installed languages (nvim-lua#908) Move LspDetach handler near kickstart-lsp-highlight group (nvim-lua#900) README: add clipboard tool dependency (nvim-lua#886) Update README.md (nvim-lua#875) fix: highlight group clear on each attach (nvim-lua#874) Fix highlight errors when lsp crash or stop (nvim-lua#864) Fix deprecation notice of inlay hints (nvim-lua#873) Add a commented out example of the classic complete keymaps. Fixes nvim-lua#866 (nvim-lua#868) Minor improvements of debian install instructions. Fixes nvim-lua#859 (nvim-lua#869) Update README.md (nvim-lua#860) fix: restore Mason config timing for DAP startup (again) (nvim-lua#865) Add gitsigns recommended keymaps as an optional plugin (nvim-lua#858) Move plugin examples from README to optional plugin files (nvim-lua#831) Enable inlay hints for the supporting servers (nvim-lua#843) Fix: nvim-lua#847 - add prefer_git to treesitter config (nvim-lua#856) Comment about nerd font selection. Fixes nvim-lua#853 (nvim-lua#854) Arch, btw (nvim-lua#852) Update README (nvim-lua#832) Add a pull request template (nvim-lua#825) README: move backup and paths from external deps to install section (nvim-lua#819) Don't lazy load conform plugin (nvim-lua#818) Add a keymap space-f to format buffer using conform (nvim-lua#817) Add instructions to quit :lazy. Fixes nvim-lua#761 fix nvim-lua#799 (nvim-lua#800) README: wrap long lines (nvim-lua#784) Update README.md (nvim-lua#781) Add nvim-nio as dependency for nvim-dap-ui (nvim-lua#774) Some suggestions and capitalised a few words (nvim-lua#771) ... > **NOTE**
* Fix highlight errors when lsp crash or stop It adds a check wether the client is still available before highlighting. If the client is not there anymore it returns `true` to unregister the autocommand This fix the `method textDocument/documentHighlight is not supported by any of the servers registered for the current buffer` errors when doing a LspRestart or the server crashes * Delete the highlight autocommands in the LspDetatch event * Only delete autocmds for the current buffer with the group name * Simplify clearing the autocommands --------- Co-authored-by: Francis Belanger <francis.belanger@ubisoft.com>
* Fix highlight errors when lsp crash or stop It adds a check wether the client is still available before highlighting. If the client is not there anymore it returns `true` to unregister the autocommand This fix the `method textDocument/documentHighlight is not supported by any of the servers registered for the current buffer` errors when doing a LspRestart or the server crashes * Delete the highlight autocommands in the LspDetatch event * Only delete autocmds for the current buffer with the group name * Simplify clearing the autocommands --------- Co-authored-by: Francis Belanger <francis.belanger@ubisoft.com>
* Fix highlight errors when lsp crash or stop It adds a check wether the client is still available before highlighting. If the client is not there anymore it returns `true` to unregister the autocommand This fix the `method textDocument/documentHighlight is not supported by any of the servers registered for the current buffer` errors when doing a LspRestart or the server crashes * Delete the highlight autocommands in the LspDetatch event * Only delete autocmds for the current buffer with the group name * Simplify clearing the autocommands --------- Co-authored-by: Francis Belanger <francis.belanger@ubisoft.com>
* Fix highlight errors when lsp crash or stop It adds a check wether the client is still available before highlighting. If the client is not there anymore it returns `true` to unregister the autocommand This fix the `method textDocument/documentHighlight is not supported by any of the servers registered for the current buffer` errors when doing a LspRestart or the server crashes * Delete the highlight autocommands in the LspDetatch event * Only delete autocmds for the current buffer with the group name * Simplify clearing the autocommands --------- Co-authored-by: Francis Belanger <francis.belanger@ubisoft.com>
* Fix highlight errors when lsp crash or stop It adds a check wether the client is still available before highlighting. If the client is not there anymore it returns `true` to unregister the autocommand This fix the `method textDocument/documentHighlight is not supported by any of the servers registered for the current buffer` errors when doing a LspRestart or the server crashes * Delete the highlight autocommands in the LspDetatch event * Only delete autocmds for the current buffer with the group name * Simplify clearing the autocommands --------- Co-authored-by: Francis Belanger <francis.belanger@ubisoft.com>
* Fix highlight errors when lsp crash or stop It adds a check wether the client is still available before highlighting. If the client is not there anymore it returns `true` to unregister the autocommand This fix the `method textDocument/documentHighlight is not supported by any of the servers registered for the current buffer` errors when doing a LspRestart or the server crashes * Delete the highlight autocommands in the LspDetatch event * Only delete autocmds for the current buffer with the group name * Simplify clearing the autocommands --------- Co-authored-by: Francis Belanger <francis.belanger@ubisoft.com>
* Fix highlight errors when lsp crash or stop It adds a check wether the client is still available before highlighting. If the client is not there anymore it returns `true` to unregister the autocommand This fix the `method textDocument/documentHighlight is not supported by any of the servers registered for the current buffer` errors when doing a LspRestart or the server crashes * Delete the highlight autocommands in the LspDetatch event * Only delete autocmds for the current buffer with the group name * Simplify clearing the autocommands --------- Co-authored-by: Francis Belanger <francis.belanger@ubisoft.com>
* Fix highlight errors when lsp crash or stop It adds a check wether the client is still available before highlighting. If the client is not there anymore it returns `true` to unregister the autocommand This fix the `method textDocument/documentHighlight is not supported by any of the servers registered for the current buffer` errors when doing a LspRestart or the server crashes * Delete the highlight autocommands in the LspDetatch event * Only delete autocmds for the current buffer with the group name * Simplify clearing the autocommands --------- Co-authored-by: Francis Belanger <francis.belanger@ubisoft.com>
It adds a check wether the client is still available before highlighting.
If the client is not there anymore it returns true to unregister the autocommand
This fix the
method textDocument/documentHighlight is not supported by any of the servers registered for the current buffer
errors when doing a LspRestart or the server crashes