Skip to content

Commit f526ecf

Browse files
caspermeijnPrince781
authored andcommitted
feat: Allow ${workspaceFolder} in vala.languageServerPath configuration
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>
1 parent c773625 commit f526ecf

File tree

4 files changed

+34
-18
lines changed

4 files changed

+34
-18
lines changed

CHANGELOG.md

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1-
# Changelog
2-
3-
## 1.0.4
4-
- Updated grammars
5-
6-
## 1.0.3
7-
- Add option to start server in debug mode
8-
- Add option for server to fail on critical messages
9-
10-
## 1.0.2
11-
- Support latest GVLS
12-
13-
## 1.0.0
14-
- Initial release
1+
# Changelog
2+
3+
## 1.1.0
4+
- Allow `${workspaceFolder}` in `vala.languageServerPath` configuration
5+
6+
## 1.0.4
7+
- Updated grammars
8+
9+
## 1.0.3
10+
- Add option to start server in debug mode
11+
- Add option for server to fail on critical messages
12+
13+
## 1.0.2
14+
- Support latest GVLS
15+
16+
## 1.0.0
17+
- Initial release

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "vala",
33
"displayName": "Vala",
44
"description": "Syntax highlighting and language support for the Vala / Genie languages",
5-
"version": "1.0.8",
5+
"version": "1.1.0",
66
"publisher": "prince781",
77
"author": {
88
"name": "Princeton Ferro",

src/client.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,19 @@ import {
2424

2525
import * as which from 'which'
2626

27+
const VarRegex = new RegExp(/\$\{(\w+)\}/g);
28+
function substituteVSCodeVariableInString(val: string): string {
29+
return val.replace(VarRegex, (substring: string, varName) => {
30+
if (varName === "workspaceFolder") {
31+
const folders = workspace.workspaceFolders ?? [];
32+
if (folders.length >= 1) {
33+
return folders[0].uri.fsPath;
34+
}
35+
}
36+
return substring;
37+
});
38+
}
39+
2740
export class ValaLanguageClient {
2841

2942
config: WorkspaceConfiguration
@@ -79,7 +92,7 @@ export class ValaLanguageClient {
7992
}
8093

8194
get languageServerPath(): string | null {
82-
return this.config.languageServerPath
95+
return substituteVSCodeVariableInString(this.config.languageServerPath)
8396
|| which.sync('vala-language-server', { nothrow: true })
8497
|| which.sync('org.gnome.gvls.stdio.Server', { nothrow: true })
8598
|| which.sync('gvls', { nothrow: true }) // for legacy GVLS

0 commit comments

Comments
 (0)