From 8a019b423f5d51bcfc107da9cb50aa90eacff19d Mon Sep 17 00:00:00 2001 From: Alexis Mousset Date: Fri, 31 Dec 2021 09:06:54 +0100 Subject: Detect workspace root using language markers (#1370) * Detect workspace root using language markers * Avoid allocating root_markers * Update helix-core/src/lib.rs Co-authored-by: Blaž Hrastnik * Update helix-core/src/lib.rs Co-authored-by: Kirawi <67773714+kirawi@users.noreply.github.com> Co-authored-by: Blaž Hrastnik Co-authored-by: Kirawi <67773714+kirawi@users.noreply.github.com>--- helix-lsp/src/client.rs | 6 +++++- 1 file changed, 5 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 43804daa..c80f70b5 100644 --- a/helix-lsp/src/client.rs +++ b/helix-lsp/src/client.rs @@ -31,6 +31,7 @@ pub struct Client { pub(crate) capabilities: OnceCell, offset_encoding: OffsetEncoding, config: Option, + root_markers: Vec, } impl Client { @@ -39,6 +40,7 @@ impl Client { cmd: &str, args: &[String], config: Option, + root_markers: Vec, id: usize, ) -> Result<(Self, UnboundedReceiver<(usize, Call)>, Arc)> { let process = Command::new(cmd) @@ -68,6 +70,7 @@ impl Client { capabilities: OnceCell::new(), offset_encoding: OffsetEncoding::Utf8, config, + root_markers, }; Ok((client, server_rx, initialize_notify)) @@ -225,7 +228,8 @@ impl Client { pub(crate) async fn initialize(&self) -> Result { // 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()); + let root = find_root(None, &self.root_markers) + .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()); -- cgit v1.2.3-70-g09d2