aboutsummaryrefslogtreecommitdiff
path: root/helix-lsp
diff options
context:
space:
mode:
authorAlexis Mousset2021-12-31 08:06:54 +0000
committerGitHub2021-12-31 08:06:54 +0000
commit8a019b423f5d51bcfc107da9cb50aa90eacff19d (patch)
tree2f5dfede14f1566ecafc5651767f9e2306f81c53 /helix-lsp
parent8fda87af2bb0625c502a23ddbd78a7447ada7bcb (diff)
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 <blaz@mxxn.io> * Update helix-core/src/lib.rs Co-authored-by: Kirawi <67773714+kirawi@users.noreply.github.com> Co-authored-by: Blaž Hrastnik <blaz@mxxn.io> Co-authored-by: Kirawi <67773714+kirawi@users.noreply.github.com>
Diffstat (limited to 'helix-lsp')
-rw-r--r--helix-lsp/src/client.rs6
-rw-r--r--helix-lsp/src/lib.rs1
2 files changed, 6 insertions, 1 deletions
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<lsp::ServerCapabilities>,
offset_encoding: OffsetEncoding,
config: Option<Value>,
+ root_markers: Vec<String>,
}
impl Client {
@@ -39,6 +40,7 @@ impl Client {
cmd: &str,
args: &[String],
config: Option<Value>,
+ root_markers: Vec<String>,
id: usize,
) -> Result<(Self, UnboundedReceiver<(usize, Call)>, Arc<Notify>)> {
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<lsp::InitializeResult> {
// 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());
diff --git a/helix-lsp/src/lib.rs b/helix-lsp/src/lib.rs
index 8fb321bc..1eb1c151 100644
--- a/helix-lsp/src/lib.rs
+++ b/helix-lsp/src/lib.rs
@@ -326,6 +326,7 @@ impl Registry {
&config.command,
&config.args,
language_config.config.clone(),
+ language_config.roots.clone(),
id,
)?;
self.incoming.push(UnboundedReceiverStream::new(incoming));