aboutsummaryrefslogtreecommitdiff
path: root/helix-lsp/src
diff options
context:
space:
mode:
Diffstat (limited to 'helix-lsp/src')
-rw-r--r--helix-lsp/src/client.rs4
-rw-r--r--helix-lsp/src/lib.rs10
2 files changed, 10 insertions, 4 deletions
diff --git a/helix-lsp/src/client.rs b/helix-lsp/src/client.rs
index 94e99489..29a67988 100644
--- a/helix-lsp/src/client.rs
+++ b/helix-lsp/src/client.rs
@@ -4,7 +4,7 @@ use crate::{
Call, Error, OffsetEncoding, Result,
};
-use helix_core::{find_workspace, ChangeSet, Rope};
+use helix_core::{find_workspace, path, ChangeSet, Rope};
use helix_loader::{self, VERSION_AND_GIT_HASH};
use lsp::{
notification::DidChangeWorkspaceFolders, DidChangeWorkspaceFoldersParams, OneOf,
@@ -66,6 +66,7 @@ impl Client {
may_support_workspace: bool,
) -> bool {
let (workspace, workspace_is_cwd) = find_workspace();
+ let workspace = path::get_normalized_path(&workspace);
let root = find_lsp_workspace(
doc_path
.and_then(|x| x.parent().and_then(|x| x.to_str()))
@@ -201,6 +202,7 @@ impl Client {
let (server_rx, server_tx, initialize_notify) =
Transport::start(reader, writer, stderr, id);
let (workspace, workspace_is_cwd) = find_workspace();
+ let workspace = path::get_normalized_path(&workspace);
let root = find_lsp_workspace(
doc_path
.and_then(|x| x.parent().and_then(|x| x.to_str()))
diff --git a/helix-lsp/src/lib.rs b/helix-lsp/src/lib.rs
index c3a5d816..c206ac1d 100644
--- a/helix-lsp/src/lib.rs
+++ b/helix-lsp/src/lib.rs
@@ -10,7 +10,10 @@ pub use lsp::{Position, Url};
pub use lsp_types as lsp;
use futures_util::stream::select_all::SelectAll;
-use helix_core::syntax::{LanguageConfiguration, LanguageServerConfiguration};
+use helix_core::{
+ path,
+ syntax::{LanguageConfiguration, LanguageServerConfiguration},
+};
use tokio::sync::mpsc::UnboundedReceiver;
use std::{
@@ -888,12 +891,13 @@ pub fn find_lsp_workspace(
workspace_is_cwd: bool,
) -> Option<PathBuf> {
let file = std::path::Path::new(file);
- let file = if file.is_absolute() {
+ let mut file = if file.is_absolute() {
file.to_path_buf()
} else {
let current_dir = std::env::current_dir().expect("unable to determine current directory");
current_dir.join(file)
};
+ file = path::get_normalized_path(&file);
if !file.starts_with(workspace) {
return None;
@@ -910,7 +914,7 @@ pub fn find_lsp_workspace(
if root_dirs
.iter()
- .any(|root_dir| root_dir == ancestor.strip_prefix(workspace).unwrap())
+ .any(|root_dir| path::get_normalized_path(&workspace.join(root_dir)) == ancestor)
{
// if the worskapce is the cwd do not search any higher for workspaces
// but specify