diff options
author | Grzegorz Baranski | 2021-07-24 01:26:43 +0000 |
---|---|---|
committer | GitHub | 2021-07-24 01:26:43 +0000 |
commit | 48e344a2a813b875ca813be726387692b7ba0762 (patch) | |
tree | f9582a940e326e663200fb46d4fded6738950276 /helix-lsp/src | |
parent | bda4f5c1cdd2f84a06647f7dce45a8f6d06401ae (diff) |
feat: code actions - document edits (#478)
* wip: Code actions
* fix(term): use current macro instead Context::context
* feat(lsp): set code_action capabilities
* feat(term): set SPC-a to code_action
* feat(term): wip on applying code actions
* deps: `cargo update`
* feat(term): applying code actions edits
* fix(term): cleanup of apply_edit
* fix(term): applying edits as a whole thing instead one by one
* refactor(term): move apply_edits below
* fix(term): improve unimplemented messages for further investigation
* fix(term): change code action command comment
Co-authored-by: Ivan Tham <pickfire@riseup.net>
* fix(term): add matching `}`
* fix(term): cleanup, todo!() on workspace edit
* fix(term): remove unrelated workspace_symbol_picker
* fix(term): apply cargo-clippy suggestions
* fix(term): replace todo!'s with editor.set_error
Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
Co-authored-by: Ivan Tham <pickfire@riseup.net>
Diffstat (limited to 'helix-lsp/src')
-rw-r--r-- | helix-lsp/src/client.rs | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/helix-lsp/src/client.rs b/helix-lsp/src/client.rs index 1c2a49b5..fd34f45d 100644 --- a/helix-lsp/src/client.rs +++ b/helix-lsp/src/client.rs @@ -247,6 +247,26 @@ impl Client { content_format: Some(vec![lsp::MarkupKind::Markdown]), ..Default::default() }), + code_action: Some(lsp::CodeActionClientCapabilities { + code_action_literal_support: Some(lsp::CodeActionLiteralSupport { + code_action_kind: lsp::CodeActionKindLiteralSupport { + value_set: [ + lsp::CodeActionKind::EMPTY, + lsp::CodeActionKind::QUICKFIX, + lsp::CodeActionKind::REFACTOR, + lsp::CodeActionKind::REFACTOR_EXTRACT, + lsp::CodeActionKind::REFACTOR_INLINE, + lsp::CodeActionKind::REFACTOR_REWRITE, + lsp::CodeActionKind::SOURCE, + lsp::CodeActionKind::SOURCE_ORGANIZE_IMPORTS, + ] + .iter() + .map(|kind| kind.as_str().to_string()) + .collect(), + }, + }), + ..Default::default() + }), ..Default::default() }), window: Some(lsp::WindowClientCapabilities { @@ -713,4 +733,31 @@ impl Client { self.call::<lsp::request::DocumentSymbolRequest>(params) } + + // empty string to get all symbols + pub fn workspace_symbols(&self, query: String) -> impl Future<Output = Result<Value>> { + let params = lsp::WorkspaceSymbolParams { + query, + work_done_progress_params: lsp::WorkDoneProgressParams::default(), + partial_result_params: lsp::PartialResultParams::default(), + }; + + self.call::<lsp::request::WorkspaceSymbol>(params) + } + + pub fn code_actions( + &self, + text_document: lsp::TextDocumentIdentifier, + range: lsp::Range, + ) -> impl Future<Output = Result<Value>> { + let params = lsp::CodeActionParams { + text_document, + range, + context: lsp::CodeActionContext::default(), + work_done_progress_params: lsp::WorkDoneProgressParams::default(), + partial_result_params: lsp::PartialResultParams::default(), + }; + + self.call::<lsp::request::CodeActionRequest>(params) + } } |