Skip to content

Commit 8d0ea4b

Browse files
Add initialization options
1 parent eada06e commit 8d0ea4b

File tree

2 files changed

+48
-14
lines changed

2 files changed

+48
-14
lines changed

package.json

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
"sponsor": {
1919
"url": "https://github.com/sponsors/ChrisChinchilla"
2020
},
21-
"version": "0.21.0",
21+
"version": "0.23.1",
2222
"engines": {
23-
"vscode": "^1.89.0"
23+
"vscode": "^1.91.0"
2424
},
2525
"categories": [
2626
"Linters"
@@ -51,12 +51,31 @@
5151
"default": "off",
5252
"description": "Traces the communication between VS Code and the language server."
5353
},
54-
"vale.valeCLI.config": {
54+
"vale.valeCLI.configPath": {
5555
"scope": "resource",
5656
"type": "string",
5757
"default": null,
5858
"description": "Absolute path to a Vale config file. If not specified, the default search process will be used (relative to the current file)."
5959
},
60+
"vale.valeCLI.syncOnStartup": {
61+
"scope": "resource",
62+
"type": "boolean",
63+
"default": false,
64+
"description": "Runs `vale sync` upon starting the language server"
65+
},
66+
"vale.valeCLI.filter": {
67+
"scope": "resource",
68+
"type": "string",
69+
"default": null,
70+
"description": "An output filter to apply when calling Vale."
71+
},
72+
"vale.valeCLI.installVale": {
73+
"scope": "resource",
74+
"type": "boolean",
75+
"default": false,
76+
"description": "Automatically install and update Vale. If false, the vale executable needs to be available on the user’s $PATH."
77+
},
78+
6079
"vale.valeCLI.path": {
6180
"scope": "resource",
6281
"type": "string",

src/lsp.ts

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ const TAG = "v0.3.7";
1515
const URL =
1616
"https://github.com/errata-ai/vale-ls/releases/download/{tag}/vale-ls-{arch}-{platform}.zip";
1717

18+
type valeConfigOptions = "configPath" | "syncOnStartup" | "filter" | "installVale";
19+
20+
interface valeArgs {
21+
value: string;
22+
}
23+
1824
export function getArch(): String {
1925
if (process.arch == "x64") return "x86_64";
2026
if (process.arch == "arm64") return "aaarch64";
@@ -31,28 +37,37 @@ export function activate(context: ExtensionContext) {
3137
// Not possible when using `command`?
3238
// let debugOptions = { execArgv: ['--nolazy', '--inspect=6009'] };
3339
const valePath = context.extensionPath + "/tmp-bin/vale-ls";
34-
let valeArgs: any = new Object();
40+
//let valeArgs: any = new Object();
3541

3642
// TODO: Factor in https://vale.sh/docs/integrations/guide/#vale-ls
3743
// Has the user defined a config file manually?
38-
const configuration = vscode.workspace.getConfiguration();
39-
let customConfigPath = configuration.get<string>("vale.valeCLI.config");
40-
if (customConfigPath) {
41-
console.log("Using config: " + customConfigPath);
44+
const configuration = vscode.workspace.getConfiguration();
45+
// let customConfigPath = configuration.get<string>("vale.valeCLI.config");
46+
// if (customConfigPath) {
47+
// console.log("Using config: " + customConfigPath);
4248

43-
valeArgs = {configPath: customConfigPath};
44-
}
45-
console.log(valeArgs)
49+
// valeArgs = {configPath: customConfigPath};
50+
// }
51+
// console.log(valeArgs)
4652
console.log("Using binary: " + valePath);
47-
53+
let valeConfig: Record<valeConfigOptions, valeArgs> = {
54+
configPath: configuration.get("vale.valeCLI.configPath") as valeArgs,
55+
syncOnStartup: configuration.get("vale.valeCLI.syncOnStartup") as valeArgs,
56+
filter: configuration.get("vale.valeCLI.filter") as valeArgs,
57+
installVale: configuration.get("vale.valeCLI.installVale") as valeArgs,
58+
}
59+
console.log(valeConfig)
60+
// TODO: So do I need the below?
61+
let tempArgs: never[] = [];
4862
let serverOptions: ServerOptions = {
49-
run: { command: valePath, args: valeArgs },
50-
debug: { command: valePath, args: valeArgs},
63+
run: { command: valePath, args: tempArgs},
64+
debug: { command: valePath, args: tempArgs},
5165
};
5266

5367
// Options to control the language client
5468
let clientOptions: LanguageClientOptions = {
5569
// TODO: Refine
70+
initializationOptions: valeConfig,
5671
documentSelector: [{ scheme: "file", language: "*" }],
5772
synchronize: {
5873
fileEvents: workspace.createFileSystemWatcher("**/.clientrc"),

0 commit comments

Comments
 (0)