Skip to content

Commit

Permalink
feat: Allow ${workspaceFolder} in vala.languageServerPath configu…
Browse files Browse the repository at this point in the history
…ration

The predefined VSCode variables [1] are not automatically substituted for configuration options. The Vala extension must do the substitution to allow the Vala language server to be relative to the workspace folder.

This patch is a simplified version of the substitution in the Rust extension [2].

[1]: https://code.visualstudio.com/docs/editor/variables-reference#_predefined-variables
[2]: https://github.com/rust-lang/rust-analyzer/blob/884dd8c966e29d48bd9f8e5f22440cd238aa7cf1/editors/code/src/config.ts#L399

Signed-off-by: Casper Meijn <casper@meijn.net>
Signed-off-by: Princeton Ferro <princetonferro@gmail.com>
  • Loading branch information
caspermeijn authored and Prince781 committed Oct 28, 2023
1 parent c773625 commit f526ecf
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 18 deletions.
31 changes: 17 additions & 14 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
# Changelog

## 1.0.4
- Updated grammars

## 1.0.3
- Add option to start server in debug mode
- Add option for server to fail on critical messages

## 1.0.2
- Support latest GVLS

## 1.0.0
- Initial release
# Changelog

## 1.1.0
- Allow `${workspaceFolder}` in `vala.languageServerPath` configuration

## 1.0.4
- Updated grammars

## 1.0.3
- Add option to start server in debug mode
- Add option for server to fail on critical messages

## 1.0.2
- Support latest GVLS

## 1.0.0
- Initial release
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "vala",
"displayName": "Vala",
"description": "Syntax highlighting and language support for the Vala / Genie languages",
"version": "1.0.8",
"version": "1.1.0",
"publisher": "prince781",
"author": {
"name": "Princeton Ferro",
Expand Down
15 changes: 14 additions & 1 deletion src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,19 @@ import {

import * as which from 'which'

const VarRegex = new RegExp(/\$\{(\w+)\}/g);
function substituteVSCodeVariableInString(val: string): string {
return val.replace(VarRegex, (substring: string, varName) => {
if (varName === "workspaceFolder") {
const folders = workspace.workspaceFolders ?? [];
if (folders.length >= 1) {
return folders[0].uri.fsPath;
}
}
return substring;
});
}

export class ValaLanguageClient {

config: WorkspaceConfiguration
Expand Down Expand Up @@ -79,7 +92,7 @@ export class ValaLanguageClient {
}

get languageServerPath(): string | null {
return this.config.languageServerPath
return substituteVSCodeVariableInString(this.config.languageServerPath)
|| which.sync('vala-language-server', { nothrow: true })
|| which.sync('org.gnome.gvls.stdio.Server', { nothrow: true })
|| which.sync('gvls', { nothrow: true }) // for legacy GVLS
Expand Down

0 comments on commit f526ecf

Please sign in to comment.