|
|
@ -31,6 +31,7 @@ pub struct Client {
|
|
|
|
pub(crate) capabilities: OnceCell<lsp::ServerCapabilities>,
|
|
|
|
pub(crate) capabilities: OnceCell<lsp::ServerCapabilities>,
|
|
|
|
offset_encoding: OffsetEncoding,
|
|
|
|
offset_encoding: OffsetEncoding,
|
|
|
|
config: Option<Value>,
|
|
|
|
config: Option<Value>,
|
|
|
|
|
|
|
|
root_markers: Vec<String>,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
impl Client {
|
|
|
|
impl Client {
|
|
|
@ -39,6 +40,7 @@ impl Client {
|
|
|
|
cmd: &str,
|
|
|
|
cmd: &str,
|
|
|
|
args: &[String],
|
|
|
|
args: &[String],
|
|
|
|
config: Option<Value>,
|
|
|
|
config: Option<Value>,
|
|
|
|
|
|
|
|
root_markers: Vec<String>,
|
|
|
|
id: usize,
|
|
|
|
id: usize,
|
|
|
|
) -> Result<(Self, UnboundedReceiver<(usize, Call)>, Arc<Notify>)> {
|
|
|
|
) -> Result<(Self, UnboundedReceiver<(usize, Call)>, Arc<Notify>)> {
|
|
|
|
let process = Command::new(cmd)
|
|
|
|
let process = Command::new(cmd)
|
|
|
@ -68,6 +70,7 @@ impl Client {
|
|
|
|
capabilities: OnceCell::new(),
|
|
|
|
capabilities: OnceCell::new(),
|
|
|
|
offset_encoding: OffsetEncoding::Utf8,
|
|
|
|
offset_encoding: OffsetEncoding::Utf8,
|
|
|
|
config,
|
|
|
|
config,
|
|
|
|
|
|
|
|
root_markers,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Ok((client, server_rx, initialize_notify))
|
|
|
|
Ok((client, server_rx, initialize_notify))
|
|
|
@ -225,7 +228,8 @@ impl Client {
|
|
|
|
|
|
|
|
|
|
|
|
pub(crate) async fn initialize(&self) -> Result<lsp::InitializeResult> {
|
|
|
|
pub(crate) async fn initialize(&self) -> Result<lsp::InitializeResult> {
|
|
|
|
// TODO: delay any requests that are triggered prior to initialize
|
|
|
|
// 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() {
|
|
|
|
if self.config.is_some() {
|
|
|
|
log::info!("Using custom LSP config: {}", self.config.as_ref().unwrap());
|
|
|
|
log::info!("Using custom LSP config: {}", self.config.as_ref().unwrap());
|
|
|
|