Add "code_actions_on_format" (#7860)

This lets Go programmers configure `"code_actions_on_format": {
  "source.organizeImports": true,
}` so that they don't have to manage their imports manually

I landed on `code_actions_on_format` instead of `code_actions_on_save`
(the
VSCode version of this) because I want to run these when I explicitly
format
(and not if `format_on_save` is disabled).

Co-Authored-By: Thorsten <thorsten@zed.dev>

Release Notes:

- Added `"code_actions_on_format"` to control additional formatting
steps on format/save
([#5232](https://github.com/zed-industries/zed/issues/5232)).
- Added a `"code_actions_on_format"` of `"source.organizeImports"` for
Go ([#4886](https://github.com/zed-industries/zed/issues/4886)).

Co-authored-by: Thorsten <thorsten@zed.dev>
This commit is contained in:
Conrad Irwin 2024-02-15 14:19:57 -07:00 committed by GitHub
parent e1ae0d46da
commit ea322e1d1c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 221 additions and 13 deletions

View file

@ -123,6 +123,7 @@ pub(crate) struct GetCompletions {
pub(crate) struct GetCodeActions {
pub range: Range<Anchor>,
pub kinds: Option<Vec<lsp::CodeActionKind>>,
}
pub(crate) struct OnTypeFormatting {
@ -1603,7 +1604,10 @@ impl LspCommand for GetCodeActions {
partial_result_params: Default::default(),
context: lsp::CodeActionContext {
diagnostics: relevant_diagnostics,
only: language_server.code_action_kinds(),
only: self
.kinds
.clone()
.or_else(|| language_server.code_action_kinds()),
..lsp::CodeActionContext::default()
},
}
@ -1664,7 +1668,10 @@ impl LspCommand for GetCodeActions {
})?
.await?;
Ok(Self { range: start..end })
Ok(Self {
range: start..end,
kinds: None,
})
}
fn response_to_proto(