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

Proposal to rename "quickfix.biome" to "source.fixAll.biome" #3339

Closed
predragnikolic opened this issue Jul 2, 2024 · 14 comments · Fixed by #3731
Closed

Proposal to rename "quickfix.biome" to "source.fixAll.biome" #3339

predragnikolic opened this issue Jul 2, 2024 · 14 comments · Fixed by #3731
Labels
A-LSP Area: language server protocol S-Enhancement Status: Improve an existing feature S-Help-wanted Status: you're familiar with the code base and want to help the project

Comments

@predragnikolic
Copy link

predragnikolic commented Jul 2, 2024

Description

Hello,

Currently biome exposes a "quickfix.biome" code action on save. (see the docs)
The proposal is to rename quickfix.biome to source.fixAll.biome because it adheres to the LSP spec more:

microsoft/language-server-protocol#1629 (comment)

For code actions on save: the client will ask with a specific kind for code actions on save. The kind is CodeActionKind.SourceFixAll

export namespace CodeActionKind {
	export const Empty: CodeActionKind = '';

	/**
	 * Base kind for quickfix actions: 'quickfix'.
	 */
	export const QuickFix: CodeActionKind = 'quickfix';

	// ...
	/**
	 * Base kind for a 'fix all' source action: `source.fixAll`.
	 *
	 * 'Fix all' actions automatically fix errors that have a clear fix that
	 * do not require user input. They should not suppress errors or perform
	 * unsafe fixes such as generating new types or classes.
	 *
	 * @since 3.17.0
	 */
	export const SourceFixAll: CodeActionKind = 'source.fixAll';
}

Related issues:
sublimelsp/LSP#2495

@ematipico
Copy link
Member

That's definitely a sound proposal. I wouldn't change it right away because it would break people's code.

We can add it, deprecate the current when, and remove it in V2. How does that sound?

@predragnikolic
Copy link
Author

@ematipico yes, sounds good. Not breaking anyone workflow is a good option.

@ematipico ematipico added S-Help-wanted Status: you're familiar with the code base and want to help the project A-LSP Area: language server protocol S-Enhancement Status: Improve an existing feature labels Jul 15, 2024
@suxin2017
Copy link
Contributor

suxin2017 commented Jul 23, 2024

image I noticed this code action already exist

ActionCategory::Source(SourceActionKind::FixAll) => {
Cow::Borrowed("source.fixAll.biome")
}

@ematipico
Copy link
Member

ematipico commented Jul 23, 2024

@suxin2017 It does but it's not currently used in the LSP

if action.category.matches("quickfix.biome") && !file_features.supports_lint() {
return None;

@suxin2017
Copy link
Contributor

const FIX_ALL_CATEGORY: ActionCategory = ActionCategory::Source(SourceActionKind::FixAll);

if let Some(filter) = &params.context.only {
for kind in filter {
let kind = kind.as_str();
if FIX_ALL_CATEGORY.matches(kind) {
has_fix_all = true;
} else if ActionCategory::QuickFix.to_str() == kind {
// The action is a on-save quick-fixes
has_quick_fix = true;
}
filters.push(kind);
}
}

{
  "editor.codeActionsOnSave": {
    "source.fixAll.biome": "explicit"
  }
}

I see that the code here has fix-all, and my vscode can also work properly, is I looking for the wrong location?

@ematipico
Copy link
Member

Nice analysis! I believe it's an issue in our documentation then

@rchl
Copy link
Contributor

rchl commented Aug 5, 2024

Note that biome must also report that code action through codeActionProvider.codeActionKinds server capability. See microsoft/language-server-protocol#1629 (comment)

@suxin2017
Copy link
Contributor

Note that biome must also report that code action through codeActionProvider.codeActionKinds server capability. See microsoft/language-server-protocol#1629 (comment)

image

I think it's set to true, but I'm not sure if true will meet your needs

@rchl
Copy link
Contributor

rchl commented Aug 28, 2024

I'm talking about codeActionProvider.codeActionKinds capability which accepts an array of kinds.

@suxin2017
Copy link
Contributor

suxin2017 commented Aug 28, 2024

@predragnikolic
Copy link
Author

@suxin2017 this comment should answer your question ->
microsoft/language-server-protocol#1629 (comment)

@rchl
Copy link
Contributor

rchl commented Aug 28, 2024

The LSP spec author admitted in microsoft/language-server-protocol#1629 (comment) that if the code action is not registered in codeActionProvider.codeActionKinds then the editor should not utilize it for the "code actions on save" functionality.

That said, it was also said that VSCode doesn't follow that now.
And also, not sure how the codeActionProvider: true response should be treated in this case...

I would say that specifying the code action should be ideal and most compatible with different LSP clients.

@suxin2017
Copy link
Contributor

Ok, I got it. Can you check this pr

@predragnikolic
Copy link
Author

reopening this as part of #3897

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-LSP Area: language server protocol S-Enhancement Status: Improve an existing feature S-Help-wanted Status: you're familiar with the code base and want to help the project
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants