From 66579787b8cbcb17031667e8afc54fda2bd9bef9 Mon Sep 17 00:00:00 2001 From: panekj Date: Mon, 5 Sep 2022 08:49:21 +0200 Subject: [PATCH] fix: pass vec with args for lsp server --- src/main.rs | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 53202d1..ad4ab82 100644 --- a/src/main.rs +++ b/src/main.rs @@ -16,18 +16,32 @@ struct State {} const LANGUAGE_ID: &str = "language_id"; fn initialize(params: InitializeParams) -> Result<()> { + let mut server_args = vec![]; + // Check for user specified LSP server path // ``` // [lapce-plugin-name.lsp] // serverPath = "[path or filename]" + // serverArgs = ["--arg1", "--arg2"] // ``` if let Some(options) = params.initialization_options.as_ref() { if let Some(lsp) = options.get("lsp") { + if let Some(args) = lsp.get("serverArgs") { + if let Some(args) = args.as_array() { + for arg in args { + if let Some(arg) = arg.as_str() { + server_args.push(arg.to_string()); + } + } + } + } + if let Some(server_path) = lsp.get("serverPath") { if let Some(server_path) = server_path.as_str() { if !server_path.is_empty() { PLUGIN_RPC.start_lsp( Url::parse(&format!("urn:{}", server_path))?, + server_args, LANGUAGE_ID, params.initialization_options, ); @@ -67,11 +81,16 @@ fn initialize(params: InitializeParams) -> Result<()> { // Plugin working directory let volt_uri = VoltEnvironment::uri()?; - let exec_path = Url::parse(&volt_uri)?.join("[filename]")?; + let server_path = Url::parse(&volt_uri)?.join("[filename]")?; // Available language IDs // https://github.com/lapce/lapce/blob/HEAD/lapce-proxy/src/buffer.rs#L173 - PLUGIN_RPC.start_lsp(exec_path, LANGUAGE_ID, params.initialization_options); + PLUGIN_RPC.start_lsp( + server_path, + server_args, + LANGUAGE_ID, + params.initialization_options, + ); Ok(()) }