From 0aa43902cab5dbcddb72ddf5d3b825ef874dc620 Mon Sep 17 00:00:00 2001 From: Cor Peters Date: Sun, 18 Jul 2021 09:56:25 +0200 Subject: Added option to provide a custom config file to the lsp. (#460) * Added option to provide a custom config file to the lsp. * Simplified lsp loading routine with anyhow * Moved config to language.toml * Fixed test case * Cargo fmt * Revert now-useless changes * Renamed custom_config to config Co-authored-by: Cor --- helix-lsp/src/client.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'helix-lsp/src/client.rs') diff --git a/helix-lsp/src/client.rs b/helix-lsp/src/client.rs index 7f136fe8..1c2a49b5 100644 --- a/helix-lsp/src/client.rs +++ b/helix-lsp/src/client.rs @@ -24,12 +24,14 @@ pub struct Client { request_counter: AtomicU64, capabilities: Option, offset_encoding: OffsetEncoding, + config: Option, } impl Client { pub fn start( cmd: &str, args: &[String], + config: Option, id: usize, ) -> Result<(Self, UnboundedReceiver<(usize, Call)>)> { let process = Command::new(cmd) @@ -57,6 +59,7 @@ impl Client { request_counter: AtomicU64::new(0), capabilities: None, offset_encoding: OffsetEncoding::Utf8, + config, }; // TODO: async client.initialize() @@ -214,13 +217,17 @@ impl Client { // TODO: delay any requests that are triggered prior to initialize let root = find_root(None).and_then(|root| lsp::Url::from_file_path(root).ok()); + if self.config.is_some() { + log::info!("Using custom LSP config: {}", self.config.as_ref().unwrap()); + } + #[allow(deprecated)] let params = lsp::InitializeParams { process_id: Some(std::process::id()), // root_path is obsolete, use root_uri root_path: None, root_uri: root, - initialization_options: None, + initialization_options: self.config.clone(), capabilities: lsp::ClientCapabilities { text_document: Some(lsp::TextDocumentClientCapabilities { completion: Some(lsp::CompletionClientCapabilities { -- cgit v1.2.3-70-g09d2