Skip to content

Commit

Permalink
Add initialization options
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisChinchilla committed Jul 19, 2024
1 parent eada06e commit 8d0ea4b
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 14 deletions.
25 changes: 22 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
"sponsor": {
"url": "https://github.com/sponsors/ChrisChinchilla"
},
"version": "0.21.0",
"version": "0.23.1",
"engines": {
"vscode": "^1.89.0"
"vscode": "^1.91.0"
},
"categories": [
"Linters"
Expand Down Expand Up @@ -51,12 +51,31 @@
"default": "off",
"description": "Traces the communication between VS Code and the language server."
},
"vale.valeCLI.config": {
"vale.valeCLI.configPath": {
"scope": "resource",
"type": "string",
"default": null,
"description": "Absolute path to a Vale config file. If not specified, the default search process will be used (relative to the current file)."
},
"vale.valeCLI.syncOnStartup": {
"scope": "resource",
"type": "boolean",
"default": false,
"description": "Runs `vale sync` upon starting the language server"
},
"vale.valeCLI.filter": {
"scope": "resource",
"type": "string",
"default": null,
"description": "An output filter to apply when calling Vale."
},
"vale.valeCLI.installVale": {
"scope": "resource",
"type": "boolean",
"default": false,
"description": "Automatically install and update Vale. If false, the vale executable needs to be available on the user’s $PATH."
},

"vale.valeCLI.path": {
"scope": "resource",
"type": "string",
Expand Down
37 changes: 26 additions & 11 deletions src/lsp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ const TAG = "v0.3.7";
const URL =
"https://github.com/errata-ai/vale-ls/releases/download/{tag}/vale-ls-{arch}-{platform}.zip";

type valeConfigOptions = "configPath" | "syncOnStartup" | "filter" | "installVale";

interface valeArgs {
value: string;
}

export function getArch(): String {
if (process.arch == "x64") return "x86_64";
if (process.arch == "arm64") return "aaarch64";
Expand All @@ -31,28 +37,37 @@ export function activate(context: ExtensionContext) {
// Not possible when using `command`?
// let debugOptions = { execArgv: ['--nolazy', '--inspect=6009'] };
const valePath = context.extensionPath + "/tmp-bin/vale-ls";
let valeArgs: any = new Object();
//let valeArgs: any = new Object();

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

valeArgs = {configPath: customConfigPath};
}
console.log(valeArgs)
// valeArgs = {configPath: customConfigPath};
// }
// console.log(valeArgs)
console.log("Using binary: " + valePath);

let valeConfig: Record<valeConfigOptions, valeArgs> = {
configPath: configuration.get("vale.valeCLI.configPath") as valeArgs,
syncOnStartup: configuration.get("vale.valeCLI.syncOnStartup") as valeArgs,
filter: configuration.get("vale.valeCLI.filter") as valeArgs,
installVale: configuration.get("vale.valeCLI.installVale") as valeArgs,
}
console.log(valeConfig)
// TODO: So do I need the below?
let tempArgs: never[] = [];
let serverOptions: ServerOptions = {
run: { command: valePath, args: valeArgs },
debug: { command: valePath, args: valeArgs},
run: { command: valePath, args: tempArgs},
debug: { command: valePath, args: tempArgs},
};

// Options to control the language client
let clientOptions: LanguageClientOptions = {
// TODO: Refine
initializationOptions: valeConfig,
documentSelector: [{ scheme: "file", language: "*" }],
synchronize: {
fileEvents: workspace.createFileSystemWatcher("**/.clientrc"),
Expand Down

0 comments on commit 8d0ea4b

Please sign in to comment.