Skip to content

Commit 6cdff62

Browse files
authored
Allow LSP settings to be set independently (#913)
* clarify the readme There is no longer a .envrc file, so `direnv allow` does not work, and `nix develop` (if you use Nix) is required. * allow LSP settings to be set individually Previously, all four settings needed to be provided for any to have an effect. Now, missing settings are filled in with defaults. * chore: simplify logic
1 parent 55f042c commit 6cdff62

File tree

2 files changed

+25
-18
lines changed

2 files changed

+25
-18
lines changed

readme.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ This requires [Rust](https://www.rust-lang.org/tools/install) (>=1.75) to be ins
4848
cargo build # to build latest debug version of uiua
4949
cargo run repl # to get uiua repl
5050
```
51-
`nix develop` is not necessary if you have direnv active, in that case `direnv allow` will activate the flake devshell.
52-
51+
5352
*Note:* If you encounter errors such as rustc or any other package
5453
version mismatch, it is most likely that flake.lock file needs to be
5554
updated to pull in updated dependencies for nix shell.

src/lsp.rs

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2210,22 +2210,30 @@ mod server {
22102210
)
22112211
.await
22122212
.unwrap_or_default();
2213-
let (binding_sigs, inline_sigs, min_length, show_values) = if let [
2214-
serde_json::Value::Bool(binding_sigs),
2215-
serde_json::Value::Bool(inline_sigs),
2216-
serde_json::Value::Number(min_length),
2217-
serde_json::Value::Bool(show_values),
2218-
] = config.as_slice()
2219-
{
2220-
(
2221-
*binding_sigs,
2222-
*inline_sigs,
2223-
min_length.as_u64().unwrap_or(1) as usize,
2224-
*show_values,
2225-
)
2226-
} else {
2227-
(true, true, 3, true)
2228-
};
2213+
let default_binding_sigs = true;
2214+
let default_inline_sigs = true;
2215+
let default_min_length = 3;
2216+
let default_show_values = true;
2217+
let (binding_sigs, inline_sigs, min_length, show_values) =
2218+
if let [m_binding_sigs, m_inline_sigs, m_min_length, m_show_values] =
2219+
config.as_slice()
2220+
{
2221+
(
2222+
m_binding_sigs.as_bool().unwrap_or(default_binding_sigs),
2223+
m_inline_sigs.as_bool().unwrap_or(default_inline_sigs),
2224+
m_min_length
2225+
.as_u64()
2226+
.map_or(default_min_length, |u| u as usize),
2227+
m_show_values.as_bool().unwrap_or(default_show_values),
2228+
)
2229+
} else {
2230+
(
2231+
default_binding_sigs,
2232+
default_inline_sigs,
2233+
default_min_length,
2234+
default_show_values,
2235+
)
2236+
};
22292237
let path = uri_path(&params.text_document.uri);
22302238
// Signature hints
22312239
let mut hints = Vec::new();

0 commit comments

Comments
 (0)