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

feat(oxc_language_server): implement oxc.fixAll workspace command #8858

Merged
merged 7 commits into from
Feb 4, 2025

Conversation

marekvospel
Copy link
Contributor

This pull request focuses on optimizing the implementation of the oxlint.applyAllFixesFile vscode command by adding the command interface to the LSP instead of requesting all code actions and executing the preferred ones. This PR contains an abstraction above the LSP workspace commands, the oxc.fixAll command itself and minor changes to the vscode extension.

Since the workspace/executeCommand handler is new, I've created an abstraction to register the commands and parse their arguments. While it isn't necessary, I feel like it makes future additions to the LS easier.

I tested the command in both vscode and neovim, doubt it will be hard to use this in the zed / intellij projects.

Copy link

graphite-app bot commented Feb 3, 2025

How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

@github-actions github-actions bot added A-editor Area - Editor and Language Server C-enhancement Category - New feature or request labels Feb 3, 2025
@Boshen Boshen requested a review from Sysix February 3, 2025 14:48
@marekvospel
Copy link
Contributor Author

I've added some notes that I'd like to have your input on 😀

Copy link
Collaborator

@Sysix Sysix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work. I could not test it (see one discussion) but from the outside this looks great 👍

crates/oxc_language_server/src/capabilities.rs Outdated Show resolved Hide resolved
crates/oxc_language_server/src/capabilities.rs Outdated Show resolved Hide resolved
crates/oxc_language_server/src/capabilities.rs Outdated Show resolved Hide resolved
crates/oxc_language_server/src/commands.rs Outdated Show resolved Hide resolved
@marekvospel
Copy link
Contributor Author

@Sysix
I tested the code on the default vscodium installation on nixos and the command worked.

Do you perhaps have oxlint installed in the project you are testing in? The vscode extension prefers the binary in node modules if available. (Resulting in Method not found error. - This is not optimal, but I'm not sure how to handle this other than creating an issue that users can find telling them to update oxlint to latest)

The commands in package.json are only the CTRL + Shift + P commands, not the LSP ones (at least from what I know)

@Sysix
Copy link
Collaborator

Sysix commented Feb 3, 2025

The commands in package.json are only the CTRL + Shift + P commands, not the LSP ones (at least from what I know)

How do I tell vscode to execute the LSP Command?

Do you perhaps have oxlint installed in the project you are testing in?

Yes. But it still works (somehow). I printed the vscode ClientCapability with this method for you.

@marekvospel
Copy link
Contributor Author

The commands in package.json are only the CTRL + Shift + P commands, not the LSP ones (at least from what I know)

How do I tell vscode to execute the LSP Command?

Do you perhaps have oxlint installed in the project you are testing in?

Yes. But it still works (somehow). I printed the vscode ClientCapability with this method for you.

I don't think that you can directly exefute the LSP command without the use of a plugin. It's more like an interface for an editor to use - This PR updates the vscode command to use the new LSP command, so if the fix all (file) command works as intended with the latest build, it should be working.

@Sysix
Copy link
Collaborator

Sysix commented Feb 3, 2025

Thanks for the explanation. I tested this command. worked!

Copy link

codspeed-hq bot commented Feb 3, 2025

CodSpeed Performance Report

Merging #8858 will not alter performance

Comparing marekvospel:lsp-fix-all-command (04db8e0) with main (d6d80f7)

Summary

✅ 33 untouched benchmarks

Copy link
Collaborator

@Sysix Sysix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks you. there can probably be more optimization done in this package.

crates/oxc_language_server/src/commands.rs Outdated Show resolved Hide resolved
crates/oxc_language_server/src/commands.rs Show resolved Hide resolved
crates/oxc_language_server/Cargo.toml Show resolved Hide resolved
@Sysix Sysix merged commit f4662a9 into oxc-project:main Feb 4, 2025
29 checks passed
Boshen added a commit that referenced this pull request Feb 6, 2025
## [0.15.10] - 2025-02-06

### Features

- d6d80f7 linter: Add suggestion fixer for `eslint/no-iterator` (#8894)
(dalaoshu)
- 7e8568b linter: Junit reporter (#8756) (Tapan Prakash)
- f4662a9 oxc_language_server: Implement `oxc.fixAll` workspace command
(#8858) (Marek Vospel)

### Bug Fixes

- baf3e4e linter: Correctly replace rule severity with duplicate rule
name configurations (#8840) (dalaoshu)

### Performance

- 8a4988d linter: Use parallel iterator directly instead of iter and
parallel bridge (#8831) (Cam McHenry)

### Refactor

- bb9d763 linter: Remove usage of `url` crate (#8833) (camchenry)
- 4fcf719 linter: Replace MIME guessing with extension check (#8832)
(camchenry)

Co-authored-by: Boshen <[email protected]>
@marekvospel marekvospel deleted the lsp-fix-all-command branch February 6, 2025 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-editor Area - Editor and Language Server C-enhancement Category - New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants