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

Move RuboCop file watching to the server #2982

Merged
merged 1 commit into from
Jan 7, 2025

Conversation

vinistock
Copy link
Member

@vinistock vinistock commented Dec 13, 2024

Motivation

Closes #1457

This was originally attempted in #1921 and #2510. This PR moves watching .rubocop.yml to the server, so that we can avoid a full server restart and instead just create a new instance of the RuboCop runner.

This PR still suffers from the same issue reported in both previous attempts: trying to clear existing diagnostics after changing .rubocop.yml simply does not work. I believe this must be some sort of bug in the client or some assumption we're not satisfying. Clearing diagnostics works normally when closing files on textDocument/didClose notifications, so I see no reason why it wouldn't work while processing a did change watched files notification.

Despite the bug, since we're trying to improve stability of the LSP, I think it's still worth moving forward. Launching the server is still the most critical part in our entire life cycle and reducing the amount of times we restart helps prevent unnecessary pain for developers. Additionally, simply editing the file with the stale diagnostics already makes them go away immediately, so the bug is not that terrible.

I created an issue to discuss the bug with the maintainers of the protocol microsoft/vscode-languageserver-node#1594.

Implementation

Stopped restarting the server on .rubocop.yml and .rubocop modifications. Instead, we watch the files in the server and simply re-create the instance of the runner.

Note that this has the added benefit of working on any editor.

@vinistock vinistock added server This pull request should be included in the server gem's release notes enhancement New feature or request labels Dec 13, 2024 — with Graphite App
Copy link
Member Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

lib/ruby_lsp/server.rb Outdated Show resolved Hide resolved
@vinistock vinistock force-pushed the 11-22-move_rubocop_file_watching_to_the_server branch 2 times, most recently from 9ce82ba to 565544b Compare January 6, 2025 22:49
Copy link

graphite-app bot commented Jan 6, 2025

Merge activity

  • Jan 6, 6:19 PM EST: Graphite disabled "merge when ready" on this PR due to: a merge conflict with the target branch; resolve the conflict and try again..
  • Jan 7, 9:07 AM EST: A user merged this pull request with Graphite.

@vinistock vinistock force-pushed the 11-22-move_rubocop_file_watching_to_the_server branch from 565544b to 176f2cb Compare January 7, 2025 13:41
@vinistock vinistock merged commit 516cff3 into main Jan 7, 2025
41 checks passed
@vinistock vinistock deleted the 11-22-move_rubocop_file_watching_to_the_server branch January 7, 2025 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request server This pull request should be included in the server gem's release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrate .rubocop.yml watching to the server
2 participants