Skip to content

Commit

Permalink
fix(spec compliance): settings are now consistent with other language…
Browse files Browse the repository at this point in the history
… servers
  • Loading branch information
elijah-potter committed Mar 3, 2024
1 parent 6c4f492 commit 8639c9b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 3 additions & 1 deletion harper-ls/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ If you use Neovim, you can set the location of the dictionary with the `userDict
```lua
lspconfig.harper_ls.setup {
settings = {
userDictPath = "~/dict.txt"
["harper-ls"] = {
userDictPath = "~/dict.txt"
}
},
}
```
Expand Down
10 changes: 8 additions & 2 deletions harper-ls/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use serde_json::Value;
#[derive(Debug, Clone)]
pub struct Config {
pub user_dict_path: PathBuf,
pub file_dict_path: PathBuf
pub file_dict_path: PathBuf,
}

impl Config {
Expand All @@ -18,6 +18,12 @@ impl Config {
return Err(anyhow::format_err!("Settings must be an object."));
};

let Some(Value::Object(value)) = value.get("harper-ls") else {
return Err(anyhow::format_err!(
"Settings must contain a \"harper-ls\" key."
));
};

if let Some(v) = value.get("userDictPath") {
if let Value::String(path) = v {
base.user_dict_path = path.try_resolve()?.to_path_buf();
Expand All @@ -36,7 +42,7 @@ impl Default for Config {
user_dict_path: config_dir().unwrap().join("harper-ls/dictionary.txt"),
file_dict_path: data_local_dir()
.unwrap()
.join("harper-ls/file_dictionaries/")
.join("harper-ls/file_dictionaries/"),
}
}
}

0 comments on commit 8639c9b

Please sign in to comment.