Skip to content

Offline, privacy-first grammar checker. Fast, open-source, Rust-powered

feat(vscode-plugin): add `harper-ls.userDictPath` setting

Matthew Espinoa3aebb77bc7f
diff --git a/harper-ls/src/config.rs b/harper-ls/src/config.rs
index 79c9601cd..34fc65a7c 100644
--- a/harper-ls/src/config.rs
+++ b/harper-ls/src/config.rs
@@ -85,11 +85,14 @@ impl Config {
};
if let Some(v) = value.get("userDictPath") {
- if let Value::String(path) = v {
- base.user_dict_path = path.try_resolve()?.to_path_buf();
- } else {
+ if !v.is_string() {
bail!("userDict path must be a string.");
}
+
+ let path = v.as_str().unwrap();
+ if !path.is_empty() {
+ base.user_dict_path = path.try_resolve()?.to_path_buf();
+ }
}
if let Some(v) = value.get("fileDictPath") {
diff --git a/packages/vscode-plugin/package.json b/packages/vscode-plugin/package.json
index 6df6b7515..dae7e99c6 100644
--- a/packages/vscode-plugin/package.json
+++ b/packages/vscode-plugin/package.json
@@ -105,6 +105,11 @@
"default": false,
"description": "Skip linting link titles."
},
+ "harper-ls.userDictPath": {
+ "scope": "resource",
+ "type": "string",
+ "description": "Optional path to a global dictionary file to use."
+ },
"harper-ls.linters.amazon_names": {
"scope": "resource",
"type": "boolean",