From b9644a24bf0be5bf41de61bda681b28492dd3112 Mon Sep 17 00:00:00 2001 From: 27Onion Nebell <57032603+onion108@users.noreply.github.com> Date: Sun, 22 Dec 2024 20:19:57 +0800 Subject: [PATCH] fix: incorrect initialization for `initializationOptions`, remove unused `documentationFormat` field (fix #145) (#146) --- src/lsp/completion.v | 1 - src/lsp/initialize.v | 14 +++++++++----- src/server/general.v | 5 ++++- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/lsp/completion.v b/src/lsp/completion.v index a3134970..50ecb7b4 100644 --- a/src/lsp/completion.v +++ b/src/lsp/completion.v @@ -9,7 +9,6 @@ pub mut: pub struct CompletionItemSettings { snippet_support bool @[json: snippetSupport] commit_characters_support bool @[json: commitCharactersSupport] - documentation_format bool @[json: documentationFormat] preselect_support bool @[json: preselectSupport] deprecated_support bool @[json: deprecatedSupport] tag_support ValueSet @[json: tag_support] diff --git a/src/lsp/initialize.v b/src/lsp/initialize.v index a501124e..ada1b1de 100644 --- a/src/lsp/initialize.v +++ b/src/lsp/initialize.v @@ -1,14 +1,18 @@ module lsp +// TODO: These LSPAny need to change to `?LSPAny` too. +type LSPAny = []LSPAny | map[string]LSPAny | f64 | bool | string + // method: ‘initialize’ // response: InitializeResult pub struct InitializeParams { pub mut: - process_id int = -2 @[json: processId] - client_info ClientInfo @[json: clientInfo] - root_uri DocumentUri @[json: rootUri] - root_path DocumentUri @[json: rootPath] - initialization_options string @[json: initializationOptions] + process_id int = -2 @[json: processId] + client_info ClientInfo @[json: clientInfo] + root_uri DocumentUri @[json: rootUri] + root_path DocumentUri @[json: rootPath] + // TODO: Change this to `?LSPAny` once V fixed its JSON decoder codegen. (or shall we use json2?) + initialization_options LSPAny @[json: initializationOptions] capabilities ClientCapabilities trace string workspace_folders []WorkspaceFolder @[skip] diff --git a/src/server/general.v b/src/server/general.v index 7ecc1a36..d7f2f935 100644 --- a/src/server/general.v +++ b/src/server/general.v @@ -25,7 +25,10 @@ pub fn (mut ls LanguageServer) initialize(params lsp.InitializeParams, mut wr Re ls.status = .initialized ls.progress.support_work_done_progress = params.capabilities.window.work_done_progress - ls.initialization_options = params.initialization_options.fields() + options := params.initialization_options + if options is string { + ls.initialization_options = options.fields() + } ls.print_info(params.process_id, params.client_info) ls.setup()