diff --git a/CHANGELOG.md b/CHANGELOG.md index 02c4f29cc4d..b1dffab041a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,8 +27,14 @@ our [guidelines for writing a good changelog entry](https://github.com/biomejs/b - Fix [#3923](https://github.com/biomejs/biome/issues/3923). Now the `.editorconfig` is correctly parsed by the LSP, and the options are correctly applied to files when formatting is triggered. Plus, the Biome LSP now watches for any change to the `.editorconfig`, and updates the formatting settings. - - Reduced the number of log files generated by the LSP server. Now the maximum number of logs saved on disk is **seven**. Contributed by @ematipico +- Fix the code actions capabilities available in the LSP Biome server. Before, the LSP was using the default capabilities, which resulted in pulling code actions even when they were disabled by the editor. + + This means that the code actions are pulled by the client **only** when the editor enables `quickfix.biome`, `source.organizeImports.biome` and `source.fixAll.biome`. + + Now, if you enable `organizeImports.enabled: true` in the `biome.json`, and then you configure your editor with the following code action `source.organizeImports.biome: false`, the editor **won't** sort the imports. + + Contributed by @ematipico ### Formatter diff --git a/crates/biome_graphql_analyze/src/lint/nursery/use_deprecated_reason.rs b/crates/biome_graphql_analyze/src/lint/nursery/use_deprecated_reason.rs index 173567078a3..0c73621337e 100644 --- a/crates/biome_graphql_analyze/src/lint/nursery/use_deprecated_reason.rs +++ b/crates/biome_graphql_analyze/src/lint/nursery/use_deprecated_reason.rs @@ -6,9 +6,9 @@ use biome_graphql_syntax::GraphqlDirective; use biome_rowan::AstNode; declare_lint_rule! { - /// Require specifying the reason argument when using @deprecated directive + /// Require specifying the reason argument when using `@deprecated` directive /// - /// This rule checks the parameter of @deprecated directive for the use of reason argument, + /// This rule checks the parameter of `@deprecated` directive for the use of reason argument, /// suggesting user to add it in case the argument is missing. /// /// ## Examples diff --git a/crates/biome_lsp/src/capabilities.rs b/crates/biome_lsp/src/capabilities.rs index fb59a6c723c..899f25ef68b 100644 --- a/crates/biome_lsp/src/capabilities.rs +++ b/crates/biome_lsp/src/capabilities.rs @@ -1,7 +1,8 @@ use crate::converters::{negotiated_encoding, PositionEncoding, WideEncoding}; use tower_lsp::lsp_types::{ - ClientCapabilities, CodeActionProviderCapability, DocumentOnTypeFormattingOptions, OneOf, - PositionEncodingKind, ServerCapabilities, TextDocumentSyncCapability, TextDocumentSyncKind, + ClientCapabilities, CodeActionKind, CodeActionOptions, CodeActionProviderCapability, + DocumentOnTypeFormattingOptions, OneOf, PositionEncodingKind, ServerCapabilities, + TextDocumentSyncCapability, TextDocumentSyncKind, }; /// The capabilities to send from server as part of [`InitializeResult`] @@ -50,6 +51,23 @@ pub(crate) fn server_capabilities(capabilities: &ClientCapabilities) -> ServerCa } }); + let code_action_provider = capabilities + .text_document + .as_ref() + .and_then(|text_document| text_document.code_action.as_ref()) + .and_then(|code_action| code_action.code_action_literal_support.as_ref()) + .map(|_| { + CodeActionOptions { + code_action_kinds: Some(vec![ + CodeActionKind::from("quickfix.biome"), + CodeActionKind::from("source.fixAll.biome"), + CodeActionKind::from("source.organizeImports.biome"), + ]), + ..Default::default() + } + .into() + }) + .or(Some(CodeActionProviderCapability::Simple(true))); ServerCapabilities { position_encoding: Some(match negotiated_encoding(capabilities) { PositionEncoding::Utf8 => PositionEncodingKind::UTF8, @@ -64,7 +82,7 @@ pub(crate) fn server_capabilities(capabilities: &ClientCapabilities) -> ServerCa document_formatting_provider: supports_formatter_dynamic_registration, document_range_formatting_provider: supports_range_formatter_dynamic_registration, document_on_type_formatting_provider: supports_on_type_formatter_dynamic_registration, - code_action_provider: Some(CodeActionProviderCapability::Simple(true)), + code_action_provider, rename_provider: None, ..Default::default() }