Add basic syntax highlight colors for typescript completions
This commit is contained in:
parent
5090e6f146
commit
7ad862673d
1 changed files with 23 additions and 0 deletions
|
@ -115,6 +115,29 @@ impl LspAdapter for TypeScriptLspAdapter {
|
||||||
|
|
||||||
fn process_diagnostics(&self, _: &mut lsp::PublishDiagnosticsParams) {}
|
fn process_diagnostics(&self, _: &mut lsp::PublishDiagnosticsParams) {}
|
||||||
|
|
||||||
|
fn label_for_completion(
|
||||||
|
&self,
|
||||||
|
item: &lsp::CompletionItem,
|
||||||
|
language: &language::Language,
|
||||||
|
) -> Option<language::CodeLabel> {
|
||||||
|
use lsp::CompletionItemKind as Kind;
|
||||||
|
let len = item.label.len();
|
||||||
|
let grammar = language.grammar()?;
|
||||||
|
let highlight_id = match item.kind? {
|
||||||
|
Kind::CLASS | Kind::INTERFACE => grammar.highlight_id_for_name("type"),
|
||||||
|
Kind::CONSTRUCTOR => grammar.highlight_id_for_name("type"),
|
||||||
|
Kind::CONSTANT => grammar.highlight_id_for_name("constant"),
|
||||||
|
Kind::FUNCTION | Kind::METHOD => grammar.highlight_id_for_name("function"),
|
||||||
|
Kind::PROPERTY | Kind::FIELD => grammar.highlight_id_for_name("property"),
|
||||||
|
_ => None,
|
||||||
|
}?;
|
||||||
|
Some(language::CodeLabel {
|
||||||
|
text: item.label.clone(),
|
||||||
|
runs: vec![(0..len, highlight_id)],
|
||||||
|
filter_range: 0..len,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
fn initialization_options(&self) -> Option<serde_json::Value> {
|
fn initialization_options(&self) -> Option<serde_json::Value> {
|
||||||
Some(json!({
|
Some(json!({
|
||||||
"provideFormatter": true
|
"provideFormatter": true
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue