mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-29 23:04:49 +00:00
First pass at semantic tokens
This commit is contained in:
parent
0437645293
commit
ce6c340ebc
10 changed files with 981 additions and 34 deletions
|
@ -1,3 +1,4 @@
|
|||
use analysis::HIGHLIGHT_TOKENS_LEGEND;
|
||||
use parking_lot::{Mutex, MutexGuard};
|
||||
use registry::{DocumentChange, Registry};
|
||||
use tower_lsp::jsonrpc::Result;
|
||||
|
@ -48,12 +49,25 @@ impl RocLs {
|
|||
work_done_progress: None,
|
||||
},
|
||||
};
|
||||
let semantic_tokens_provider =
|
||||
SemanticTokensServerCapabilities::SemanticTokensOptions(SemanticTokensOptions {
|
||||
work_done_progress_options: WorkDoneProgressOptions {
|
||||
work_done_progress: None,
|
||||
},
|
||||
legend: SemanticTokensLegend {
|
||||
token_types: HIGHLIGHT_TOKENS_LEGEND.into(),
|
||||
token_modifiers: vec![],
|
||||
},
|
||||
range: None,
|
||||
full: Some(SemanticTokensFullOptions::Bool(true)),
|
||||
});
|
||||
|
||||
ServerCapabilities {
|
||||
text_document_sync: Some(text_document_sync),
|
||||
hover_provider: Some(hover_provider),
|
||||
definition_provider: Some(OneOf::Right(definition_provider)),
|
||||
document_formatting_provider: Some(OneOf::Right(document_formatting_provider)),
|
||||
semantic_tokens_provider: Some(semantic_tokens_provider),
|
||||
..ServerCapabilities::default()
|
||||
}
|
||||
}
|
||||
|
@ -162,6 +176,19 @@ impl LanguageServer for RocLs {
|
|||
|
||||
panic_wrapper(|| self.registry().formatting(&text_document.uri))
|
||||
}
|
||||
|
||||
async fn semantic_tokens_full(
|
||||
&self,
|
||||
params: SemanticTokensParams,
|
||||
) -> Result<Option<SemanticTokensResult>> {
|
||||
let SemanticTokensParams {
|
||||
text_document,
|
||||
work_done_progress_params: _,
|
||||
partial_result_params: _,
|
||||
} = params;
|
||||
|
||||
panic_wrapper(|| self.registry().semantic_tokens(&text_document.uri))
|
||||
}
|
||||
}
|
||||
|
||||
fn panic_wrapper<T>(f: impl FnOnce() -> Option<T> + std::panic::UnwindSafe) -> Result<Option<T>> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue