1use lsp_types::{
4 SemanticTokenModifier as LspModifier, SemanticTokenType as LspTokenType,
5 SemanticTokensFullOptions, SemanticTokensLegend, SemanticTokensOptions,
6 SemanticTokensServerCapabilities, ServerCapabilities, TextDocumentSyncCapability,
7 TextDocumentSyncKind,
8};
9
10pub fn server_capabilities() -> ServerCapabilities {
12 ServerCapabilities {
13 text_document_sync: Some(TextDocumentSyncCapability::Kind(TextDocumentSyncKind::FULL)),
14 semantic_tokens_provider: Some(SemanticTokensServerCapabilities::SemanticTokensOptions(
15 SemanticTokensOptions {
16 work_done_progress_options: Default::default(),
17 legend: semantic_token_legend(),
18 range: Some(false),
19 full: Some(SemanticTokensFullOptions::Bool(true)),
20 },
21 )),
22 ..Default::default()
23 }
24}
25
26fn semantic_token_legend() -> SemanticTokensLegend {
31 SemanticTokensLegend {
32 token_types: vec![
33 LspTokenType::KEYWORD, LspTokenType::NUMBER, LspTokenType::STRING, LspTokenType::COMMENT, LspTokenType::OPERATOR, LspTokenType::PROPERTY, LspTokenType::new("punctuation"), LspTokenType::MACRO, LspTokenType::DECORATOR, LspTokenType::new("sectionMarker"), LspTokenType::new("extensionMarker"), LspTokenType::new("extensionIdent"), ],
46 token_modifiers: vec![
47 LspModifier::DECLARATION, LspModifier::DEFINITION, LspModifier::new("sectionHeader"), ],
51 }
52}