Skip to content

Commit

Permalink
fix: handle lsp default configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
hugocaillard committed May 4, 2023
1 parent b89afb6 commit 61792b6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 2 additions & 2 deletions components/clarity-lsp/src/common/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,10 +380,10 @@ pub fn process_mutating_request(
) -> Result<LspRequestResponse, String> {
match command {
LspRequest::Initialize(params) => {
let initialization_options: InitializationOptions = params
let initialization_options = params
.initialization_options
.and_then(|o| serde_json::from_str(o.as_str()?).ok())
.expect("failed to parse initialization options");
.unwrap_or(InitializationOptions::default());

match editor_state.try_write(|es| es.settings = initialization_options.clone()) {
Ok(_) => Ok(LspRequestResponse::Initialize(InitializeResult {
Expand Down
14 changes: 14 additions & 0 deletions components/clarity-lsp/src/common/requests/capabilities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,20 @@ pub struct InitializationOptions {
signature_help: bool,
}

impl InitializationOptions {
pub fn default() -> Self {
InitializationOptions {
completion: true,
completion_smart_parenthesis_wrap: true,
completion_include_native_placeholders: true,
document_symbols: false,
go_to_definition: true,
hover: true,
signature_help: true,
}
}
}

pub fn get_capabilities(initialization_options: &InitializationOptions) -> ServerCapabilities {
ServerCapabilities {
text_document_sync: Some(TextDocumentSyncCapability::Options(
Expand Down

0 comments on commit 61792b6

Please sign in to comment.