Skip to content

Commit

Permalink
rust & vscode implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
goulvenclech committed Dec 14, 2024
1 parent 977b77b commit 1b95775
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
9 changes: 8 additions & 1 deletion crates/weblsp/src/css.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use csslsrs::service::LanguageService;
use lsp_server::{Connection, Message, Request, Response};
use lsp_types::request::{
ColorPresentationRequest, DocumentColor, FoldingRangeRequest, HoverRequest,
ColorPresentationRequest, DocumentColor, DocumentSymbolRequest, FoldingRangeRequest,
HoverRequest,
};
use std::error::Error;

Expand Down Expand Up @@ -57,6 +58,12 @@ pub fn handle_request(
);
send_result(connection, id, serde_json::to_value(&hover).unwrap())?;
}
"textDocument/documentSymbol" => {
let (id, params) = cast::<DocumentSymbolRequest>(req)?;
let symbols = language_service
.get_document_symbols(get_text_document(params.text_document, language_service)?);
send_result(connection, id, serde_json::to_value(&symbols).unwrap())?;
}
_ => {
eprintln!("handle_request: unsupported request: {}", req.method);
}
Expand Down
1 change: 1 addition & 0 deletions crates/weblsp/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pub(crate) fn get_server_capabilities() -> serde_json::Value {
let capabilities = ServerCapabilities {
hover_provider: Some(lsp_types::HoverProviderCapability::Simple(true)),
color_provider: Some(lsp_types::ColorProviderCapability::Simple(true)),
document_symbol_provider: Some(lsp_types::OneOf::Left(true)),
folding_range_provider: Some(lsp_types::FoldingRangeProviderCapability::Simple(true)),
text_document_sync: Some(TextDocumentSyncCapability::Kind(
lsp_types::TextDocumentSyncKind::FULL,
Expand Down

0 comments on commit 1b95775

Please sign in to comment.