allow specifying environment for language servers in language.toml (#4004)
Signed-off-by: Stephen Wakely <fungus.humungus@gmail.com> Co-authored-by: Stephen Wakely <fungus.humungus@gmail.com> Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
This commit is contained in:
parent
2ea20a23e2
commit
16e13b9789
4 changed files with 8 additions and 1 deletions
|
@ -39,7 +39,7 @@ injection-regex = "^mylang$"
|
||||||
file-types = ["mylang", "myl"]
|
file-types = ["mylang", "myl"]
|
||||||
comment-token = "#"
|
comment-token = "#"
|
||||||
indent = { tab-width = 2, unit = " " }
|
indent = { tab-width = 2, unit = " " }
|
||||||
language-server = { command = "mylang-lsp", args = ["--stdio"] }
|
language-server = { command = "mylang-lsp", args = ["--stdio"], environment = { "ENV1" = "value1", "ENV2" = "value2" } }
|
||||||
formatter = { command = "mylang-formatter" , args = ["--stdin"] }
|
formatter = { command = "mylang-formatter" , args = ["--stdin"] }
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -99,6 +99,7 @@ The `language-server` field takes the following keys:
|
||||||
| `args` | A list of arguments to pass to the language server binary |
|
| `args` | A list of arguments to pass to the language server binary |
|
||||||
| `timeout` | The maximum time a request to the language server may take, in seconds. Defaults to `20` |
|
| `timeout` | The maximum time a request to the language server may take, in seconds. Defaults to `20` |
|
||||||
| `language-id` | The language name to pass to the language server. Some language servers support multiple languages and use this field to determine which one is being served in a buffer |
|
| `language-id` | The language name to pass to the language server. Some language servers support multiple languages and use this field to determine which one is being served in a buffer |
|
||||||
|
| `environment` | Any environment variables that will be used when starting the language server `{ "KEY1" = "Value1", "KEY2" = "Value2" }` |
|
||||||
|
|
||||||
The top-level `config` field is used to configure the LSP initialization options. A `format`
|
The top-level `config` field is used to configure the LSP initialization options. A `format`
|
||||||
sub-table within `config` can be used to pass extra formatting options to
|
sub-table within `config` can be used to pass extra formatting options to
|
||||||
|
|
|
@ -207,6 +207,8 @@ pub struct LanguageServerConfiguration {
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
#[serde(skip_serializing_if = "Vec::is_empty")]
|
#[serde(skip_serializing_if = "Vec::is_empty")]
|
||||||
pub args: Vec<String>,
|
pub args: Vec<String>,
|
||||||
|
#[serde(default, skip_serializing_if = "HashMap::is_empty")]
|
||||||
|
pub environment: HashMap<String, String>,
|
||||||
#[serde(default = "default_timeout")]
|
#[serde(default = "default_timeout")]
|
||||||
pub timeout: u64,
|
pub timeout: u64,
|
||||||
pub language_id: Option<String>,
|
pub language_id: Option<String>,
|
||||||
|
|
|
@ -42,10 +42,12 @@ pub struct Client {
|
||||||
|
|
||||||
impl Client {
|
impl Client {
|
||||||
#[allow(clippy::type_complexity)]
|
#[allow(clippy::type_complexity)]
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub fn start(
|
pub fn start(
|
||||||
cmd: &str,
|
cmd: &str,
|
||||||
args: &[String],
|
args: &[String],
|
||||||
config: Option<Value>,
|
config: Option<Value>,
|
||||||
|
server_environment: HashMap<String, String>,
|
||||||
root_markers: &[String],
|
root_markers: &[String],
|
||||||
id: usize,
|
id: usize,
|
||||||
req_timeout: u64,
|
req_timeout: u64,
|
||||||
|
@ -55,6 +57,7 @@ impl Client {
|
||||||
let cmd = which::which(cmd).map_err(|err| anyhow::anyhow!(err))?;
|
let cmd = which::which(cmd).map_err(|err| anyhow::anyhow!(err))?;
|
||||||
|
|
||||||
let process = Command::new(cmd)
|
let process = Command::new(cmd)
|
||||||
|
.envs(server_environment)
|
||||||
.args(args)
|
.args(args)
|
||||||
.stdin(Stdio::piped())
|
.stdin(Stdio::piped())
|
||||||
.stdout(Stdio::piped())
|
.stdout(Stdio::piped())
|
||||||
|
|
|
@ -550,6 +550,7 @@ fn start_client(
|
||||||
&ls_config.command,
|
&ls_config.command,
|
||||||
&ls_config.args,
|
&ls_config.args,
|
||||||
config.config.clone(),
|
config.config.clone(),
|
||||||
|
ls_config.environment.clone(),
|
||||||
&config.roots,
|
&config.roots,
|
||||||
id,
|
id,
|
||||||
ls_config.timeout,
|
ls_config.timeout,
|
||||||
|
|
Loading…
Add table
Reference in a new issue