Skip to content

Commit 0e8d7d4

Browse files
committed
feat(lsp): support workspace/codeLens/refresh server request
1 parent 1332408 commit 0e8d7d4

4 files changed

Lines changed: 24 additions & 2 deletions

File tree

helix-lsp/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,7 @@ pub enum MethodCall {
476476
UnregisterCapability(lsp::UnregistrationParams),
477477
ShowDocument(lsp::ShowDocumentParams),
478478
WorkspaceDiagnosticRefresh,
479+
CodeLensRefresh,
479480
}
480481

481482
impl MethodCall {
@@ -508,6 +509,7 @@ impl MethodCall {
508509
Self::ShowDocument(params)
509510
}
510511
lsp::request::WorkspaceDiagnosticRefresh::METHOD => Self::WorkspaceDiagnosticRefresh,
512+
lsp::request::CodeLensRefresh::METHOD => Self::CodeLensRefresh,
511513
_ => {
512514
return Err(Error::Unhandled);
513515
}

helix-term/src/application.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,6 +1123,26 @@ impl Application {
11231123
);
11241124
}
11251125

1126+
Ok(serde_json::Value::Null)
1127+
}
1128+
Ok(MethodCall::CodeLensRefresh) => {
1129+
let language_server = language_server!().id();
1130+
1131+
let documents: Vec<_> = self
1132+
.editor
1133+
.documents
1134+
.values()
1135+
.filter(|x| x.supports_language_server(language_server))
1136+
.map(|x| x.id())
1137+
.collect();
1138+
1139+
for document in documents {
1140+
handlers::code_lenses::request_document_code_lenses(
1141+
&mut self.editor,
1142+
document,
1143+
);
1144+
}
1145+
11261146
Ok(serde_json::Value::Null)
11271147
}
11281148
};

helix-term/src/handlers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub use helix_view::handlers::{word_index, Handlers};
1515
use self::document_colors::DocumentColorsHandler;
1616

1717
mod auto_save;
18-
mod code_lenses;
18+
pub mod code_lenses;
1919
pub mod completion;
2020
pub mod diagnostics;
2121
mod document_colors;

helix-term/src/handlers/code_lenses.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ impl helix_event::AsyncHook for DocumentCodeLensesHandler {
4444
}
4545
}
4646

47-
fn request_document_code_lenses(editor: &mut Editor, doc_id: DocumentId) {
47+
pub fn request_document_code_lenses(editor: &mut Editor, doc_id: DocumentId) {
4848
if !editor.config().lsp.display_code_lenses {
4949
return;
5050
}

0 commit comments

Comments
 (0)