fix: LSP补全触发和语法高亮更新

- completion_provider 注册 a-z A-Z _ . 为触发字符,解决 Copilot 拦截补全问题
- 语法高亮新增 try catch finally throw 关键字

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
0264408
2026-06-26 15:13:51 +08:00
parent a70e5fbc30
commit af63957b11
3 changed files with 14 additions and 10 deletions
+2 -8
View File
@@ -41,14 +41,8 @@ pub fn handle_goto_definition(
let location = Location { let location = Location {
uri: uri.clone(), uri: uri.clone(),
range: Range { range: Range {
start: Position { start: Position { line: l, character: c },
line: l, end: Position { line: l, character: c + word.len() as u32 },
character: c,
},
end: Position {
line: l,
character: c + word.len() as u32,
},
}, },
}; };
let response: GotoDefinitionResponse = GotoDefinitionResponse::Scalar(location); let response: GotoDefinitionResponse = GotoDefinitionResponse::Scalar(location);
+11 -1
View File
@@ -28,7 +28,17 @@ pub fn run() {
text_document_sync: Some(TextDocumentSyncCapability::Kind( text_document_sync: Some(TextDocumentSyncCapability::Kind(
TextDocumentSyncKind::FULL, TextDocumentSyncKind::FULL,
)), )),
completion_provider: Some(lsp_types::CompletionOptions::default()), completion_provider: Some(lsp_types::CompletionOptions {
trigger_characters: Some(
(b'a'..=b'z').chain(b'A'..=b'Z')
.map(|c| (c as char).to_string())
.chain(std::iter::once(".".to_string()))
.chain(std::iter::once("_".to_string()))
.collect()
),
resolve_provider: Some(false),
..Default::default()
}),
hover_provider: Some(lsp_types::HoverProviderCapability::Simple(true)), hover_provider: Some(lsp_types::HoverProviderCapability::Simple(true)),
signature_help_provider: Some(lsp_types::SignatureHelpOptions::default()), signature_help_provider: Some(lsp_types::SignatureHelpOptions::default()),
definition_provider: Some(lsp_types::OneOf::Left(true)), definition_provider: Some(lsp_types::OneOf::Left(true)),
+1 -1
View File
@@ -84,7 +84,7 @@
"patterns": [ "patterns": [
{ {
"name": "keyword.control.aster", "name": "keyword.control.aster",
"match": "\\b(let|const|fn|if|else|while|for|in|break|continue|return)\\b" "match": "\\b(let|const|fn|if|else|while|for|in|break|continue|return|try|catch|finally|throw)\\b"
} }
] ]
}, },