mirror of https://github.com/lapce/lapce.git
Merge pull request #850 from MinusGix/pwd-lsp
Set the current directory when starting the LSP
This commit is contained in:
commit
20b9d05119
|
@ -3,7 +3,7 @@
|
||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
io::{BufRead, BufReader, BufWriter, Write},
|
io::{BufRead, BufReader, BufWriter, Write},
|
||||||
path::Path,
|
path::{Path, PathBuf},
|
||||||
process::{self, Child, ChildStderr, ChildStdout, Command, Stdio},
|
process::{self, Child, ChildStderr, ChildStdout, Command, Stdio},
|
||||||
sync::{
|
sync::{
|
||||||
atomic::{AtomicBool, Ordering},
|
atomic::{AtomicBool, Ordering},
|
||||||
|
@ -800,7 +800,8 @@ pub fn new(
|
||||||
dispatcher: Dispatcher,
|
dispatcher: Dispatcher,
|
||||||
) -> Arc<LspClient> {
|
) -> Arc<LspClient> {
|
||||||
//TODO: better handling of binary args in plugin
|
//TODO: better handling of binary args in plugin
|
||||||
let mut process = Self::process(exec_path, args.clone());
|
let workspace = dispatcher.workspace.lock().clone();
|
||||||
|
let mut process = Self::process(workspace, exec_path, args.clone());
|
||||||
let writer = Box::new(BufWriter::new(process.stdin.take().unwrap()));
|
let writer = Box::new(BufWriter::new(process.stdin.take().unwrap()));
|
||||||
let stdout = process.stdout.take().unwrap();
|
let stdout = process.stdout.take().unwrap();
|
||||||
let stderr = process.stderr.take().unwrap();
|
let stderr = process.stderr.take().unwrap();
|
||||||
|
@ -875,8 +876,15 @@ fn handle_stderr(&self, stderr: ChildStderr, language_id: String) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn process(exec_path: &str, args: Vec<String>) -> Child {
|
fn process(
|
||||||
|
workspace: Option<PathBuf>,
|
||||||
|
exec_path: &str,
|
||||||
|
args: Vec<String>,
|
||||||
|
) -> Child {
|
||||||
let mut process = Command::new(exec_path);
|
let mut process = Command::new(exec_path);
|
||||||
|
if let Some(workspace) = workspace {
|
||||||
|
process.current_dir(&workspace);
|
||||||
|
}
|
||||||
|
|
||||||
process.args(args);
|
process.args(args);
|
||||||
|
|
||||||
|
@ -892,7 +900,11 @@ fn process(exec_path: &str, args: Vec<String>) -> Child {
|
||||||
|
|
||||||
fn reload(&self) {
|
fn reload(&self) {
|
||||||
//TODO: avoid clone using a &[String] ?
|
//TODO: avoid clone using a &[String] ?
|
||||||
let mut process = Self::process(&self.exec_path, self.args.clone());
|
let mut process = Self::process(
|
||||||
|
self.dispatcher.workspace.lock().clone(),
|
||||||
|
&self.exec_path,
|
||||||
|
self.args.clone(),
|
||||||
|
);
|
||||||
let writer = Box::new(BufWriter::new(process.stdin.take().unwrap()));
|
let writer = Box::new(BufWriter::new(process.stdin.take().unwrap()));
|
||||||
let stdout = process.stdout.take().unwrap();
|
let stdout = process.stdout.take().unwrap();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue