Skip to content

Commit 31929fd

Browse files
authored
Index declarations as symbols for LSP symbol search (#87)
Index procedure declarations as "symbols" in the language server, making them available for document and project-wide symbol searches. Among other things this involved a bit of cleanup in the initialization code path, and exposing the `textDocument/documentSymbol` and `workspace/symbol` capabilities. To facilitate project-wide symbol search by a user, we add a cache and populate it with symbols from _all_ Technique files in the local project. The **ignore** crate is used so that files ignored by e.g. _.gitignore_ are omitted when searching. Procedure declarations are sent as `SymbolKind::CONSTRUCTOR`, matching the context used in syntax highlighting.
2 parents 0d09bab + 4073389 commit 31929fd

File tree

4 files changed

+456
-37
lines changed

4 files changed

+456
-37
lines changed

Cargo.lock

Lines changed: 87 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ license = "MIT"
99

1010
[dependencies]
1111
clap = { version = "4.5.16", features = [ "wrap_help" ] }
12+
ignore = "0.4"
1213
lsp-server = "0.7.9"
1314
lsp-types = "0.97"
1415
owo-colors = "4"

src/editor/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,19 @@ pub(crate) fn run_language_server() {
1414
let capabilities = serde_json::to_value(ServerCapabilities {
1515
text_document_sync: Some(TextDocumentSyncCapability::Kind(TextDocumentSyncKind::FULL)),
1616
document_formatting_provider: Some(OneOf::Left(true)),
17+
document_symbol_provider: Some(OneOf::Left(true)),
18+
workspace_symbol_provider: Some(OneOf::Left(true)),
1719
..Default::default()
1820
})
1921
.unwrap();
2022

2123
// extract any initialization parameters passed from the editor.
2224
if let Ok(params) = connection.initialize(capabilities) {
23-
let _params = serde_json::from_value::<InitializeParams>(params).unwrap();
25+
let params = serde_json::from_value::<InitializeParams>(params).unwrap();
2426

2527
info!("Technique Language Server starting on stdin");
2628

27-
let server = server::TechniqueLanguageServer::new();
29+
let server = server::TechniqueLanguageServer::new(params);
2830

2931
if let Err(e) = server.run(connection) {
3032
eprintln!("Server error: {}", e);

0 commit comments

Comments
 (0)