Skip to content

Commit 03e5bc3

Browse files
authored
Integrate starlark language server (#19)
1 parent 22c86eb commit 03e5bc3

17 files changed

Lines changed: 413 additions & 32 deletions

.github/workflows/release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
run: npm install
3939
- name: Release
4040
env:
41-
GITHUB_TOKEN: ${{ secrets.PERSONAL_GITHUB_TOKEN }}
41+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4242
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
4343
run: npx semantic-release
4444
- name: Vscode release plugin

.vscodeignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
out/test/**
44
src/**
55
.gitignore
6+
ext.vsix
67
vsc-extension-quickstart.md
78
**/tsconfig.json
89
**/.eslintrc.json

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Change Log
22

3+
## 0.4.0 (Sat Aug 1 2020)
4+
5+
- Initial release of Starlark Language Server with HoverProvider implementation.
6+
37
## 0.3.5 (Mon July 27 2020)
48

59
- Relax vscode version compatibility to 1.39.0 (Sept 2019).

README.md

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ Bazel Support for Visual Studio Code.
77
<td style="width: 120px; text-align: center"><img src="https://user-images.githubusercontent.com/50580/78734740-486ba400-7906-11ea-89fa-f207544de185.png" height="100"/></td>
88
<td style="width: 120px; text-align: center"><img src="https://user-images.githubusercontent.com/29654835/27530004-e789a11e-5a13-11e7-8a34-870da7e678ac.PNG" height="90"/></td>
99
</tr><tr>
10-
<td style="width: 120px; text-align: center">Bazel</td>
11-
<td style="width: 120px; text-align: center">Stack</td>
12-
<td style="width: 120px; text-align: center">VSCode</td>
10+
<td style="text-align: center">Bazel</td>
11+
<td style="text-align: center">Stack</td>
12+
<td style="text-align: center">VSCode</td>
1313
</tr></table>
1414

15+
1516
<table border-collapse="collapse" style="margin: 1rem 0">
1617
<tr><td style="border: 1px solid rgba(255,255,255,0.16)">
1718

@@ -74,19 +75,50 @@ This extension contributes a HoverProvider that looks for built-in symbols in st
7475
</tr></tr>
7576
</table>
7677

78+
79+
80+
<table border-collapse="collapse" style="margin: 1rem 0">
81+
<tr><td style="border: 1px solid rgba(255,255,255,0.16)">
82+
83+
## Starlark Language Server (Experimental)
84+
85+
This extension contributes a language server for bazel & starlark files.
86+
87+
> NOTE: currently this feature is **Disabled** by default. To enable it, visit the extension settings and set `feature.starlark.lsp.enabled: true`.
88+
89+
The Starlark Language Server implements a hoverProvider for builtin starlark
90+
language functions (e.g. `len`, `print`, etc), builtin bazel functions (e.g.
91+
`select`, `attr.string`, ...) in addition to builtin rules like `java_library`.
92+
93+
![starlark-ls-hover](https://user-images.githubusercontent.com/50580/89113148-551e8580-d42a-11ea-990e-04be3a90b77c.gif)
94+
95+
</tr></tr>
96+
</table>
97+
98+
7799
## Requirements
78100

79101
Portions of this plugin may rely on the [bzl tool](https://build.bzl.io). You
80102
can install & use the plugin without Bzl but some features will not be
81103
available.
82104

83-
## Extension Settings
84-
85-
None currently.
86105

87106
## Known Issues
88107

89108
**Github Rate Limits**: This extension makes requests to the github v3 API. If
90109
you experience errors due to rate limits, `export
91110
GITHUB_TOKEN={MY_PERSONAL_TOKEN}` and relaunch vscode to get higher rate
92111
limits.
112+
113+
**Language Server Spawn Error on Windows** If you observe this error on windows upon initial download of the executable, please reload the vscode window (`> Developer: Reload Window`).
114+
115+
```
116+
[Error - 2:38:35 AM] Starting client failed
117+
Error: spawn EBUSY
118+
at ChildProcess.spawn (internal/child_process.js:394:11)
119+
at Object.spawn (child_process.js:553:9)
120+
at c:\Users\develop\.vscode\extensions\stackbuild.bazel-stack-vscode-0.4.0\node_modules\vscode-languageclient\lib\main.js:376:40
121+
```
122+
123+
> NOTE: portions of this extension were adapted from
124+
> https://github.com/bazelbuild/vscode-bazel (Apache 2.0).

media/bazel-icon.svg

Lines changed: 15 additions & 0 deletions
Loading

media/bazel-wireframe.svg

Lines changed: 28 additions & 0 deletions
Loading

media/stackb.svg

Lines changed: 8 additions & 0 deletions
Loading

package-lock.json

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

package.json

Lines changed: 55 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "bazel-stack-vscode",
33
"displayName": "bazel-stack-vscode",
44
"description": "Bazel Support for Visual Studio Code",
5-
"version": "0.3.5",
5+
"version": "0.4.0",
66
"publisher": "StackBuild",
77
"license": "Apache-2.0",
88
"icon": "stackb-full.png",
@@ -35,34 +35,75 @@
3535
"type": "object",
3636
"title": "Bzl",
3737
"properties": {
38+
"feature.starlark.lsp.enabled": {
39+
"type": "boolean",
40+
"default": false,
41+
"description": "Flag to enable/disable this feature"
42+
},
43+
"feature.starlark.lsp.verbose": {
44+
"type": "number",
45+
"default": 0,
46+
"description": "The verbosity level for extra diagnostics"
47+
},
48+
"feature.starlark.lsp.server.executable": {
49+
"type": "string",
50+
"description": "Path to a pre-installed LSP executable\n\n> if set, this prevents downloading a LSP binary from github"
51+
},
52+
"feature.starlark.lsp.github-release": {
53+
"type": "string",
54+
"default": "0.3.5",
55+
"description": "The github release tag of the starlark-lsp release to download"
56+
},
57+
"feature.starlark.lsp.github-owner": {
58+
"type": "string",
59+
"default": "stackb",
60+
"description": "The github owner for the starlark.lsp repository"
61+
},
62+
"feature.starlark.lsp.github-repo": {
63+
"type": "string",
64+
"default": "bazel-stack-vscode",
65+
"description": "The github repo name for the starlark-lsp repository"
66+
},
67+
"feature.starlark.lsp.server.command": {
68+
"type": "array",
69+
"description": "The command (and optional arguments) to start the lsp server.",
70+
"items": {
71+
"type": "string"
72+
},
73+
"default": [
74+
"lsp",
75+
"serve",
76+
"--log_level=info"
77+
]
78+
},
3879
"feature.buildifier.enabled": {
3980
"type": "boolean",
4081
"default": true,
41-
"markdownDescription": "Feature flag to enable (checked) or disable (unchecked)"
82+
"description": "Flag to enable/disable this feature"
4283
},
4384
"feature.buildifier.verbose": {
4485
"type": "number",
4586
"default": 0,
46-
"markdownDescription": "The verbosity level for extra diagnostics"
87+
"description": "The verbosity level for extra diagnostics"
4788
},
4889
"feature.buildifier.github-release": {
4990
"type": "string",
5091
"default": "3.4.0",
51-
"markdownDescription": "The github release tag of the Buildifier release to download"
92+
"description": "The github release tag of the Buildifier release to download"
5293
},
5394
"feature.buildifier.github-owner": {
5495
"type": "string",
5596
"default": "bazelbuild",
56-
"markdownDescription": "The github owner for the buildifier repository"
97+
"description": "The github owner for the buildifier repository"
5798
},
5899
"feature.buildifier.github-repo": {
59100
"type": "string",
60101
"default": "buildtools",
61-
"markdownDescription": "The github repo name for the buildifier repository"
102+
"description": "The github repo name for the buildifier repository"
62103
},
63104
"feature.buildifier.executable": {
64105
"type": "string",
65-
"markdownDescription": "Path to a pre-installed buildifier executable.\n\n If set, this prevents downloading a buildifier binary from github"
106+
"description": "Path to a pre-installed buildifier executable\n\n> if set, this prevents downloading a buildifier binary from github"
66107
},
67108
"feature.buildifier.fix-on-format": {
68109
"type": "boolean",
@@ -72,17 +113,17 @@
72113
"feature.bazeldoc.enabled": {
73114
"type": "boolean",
74115
"default": true,
75-
"markdownDescription": "Feature flag to enable (checked) or disable (unchecked)"
116+
"description": "Flag to enable/disable this feature"
76117
},
77118
"feature.bazeldoc.verbose": {
78119
"type": "number",
79120
"default": 0,
80-
"markdownDescription": "The verbosity level for extra diagnostics"
121+
"description": "The verbosity level for extra diagnostics"
81122
},
82123
"feature.bazeldoc.base-url": {
83124
"type": "string",
84125
"default": "https://docs.bazel.build/versions/master",
85-
"markdownDescription": "The base-url of the documentation site"
126+
"description": "The base-url of the documentation site"
86127
}
87128
}
88129
},
@@ -163,12 +204,14 @@
163204
"lint": "eslint src --ext ts",
164205
"watch": "tsc -watch -p ./",
165206
"pretest": "npm run compile && npm run lint",
166-
"test": "node ./out/test/runTest.js"
207+
"test": "node ./out/test/runTest.js",
208+
"vscode-install": "vsce package --out ext.vsix && code --install-extension ext.vsix"
167209
},
168210
"dependencies": {
169211
"@octokit/rest": "18.0.3",
170212
"fs-extra": "9.0.1",
171-
"request": "2.88.2"
213+
"request": "2.88.2",
214+
"vscode-languageclient": "6.1.3"
172215
},
173216
"devDependencies": {
174217
"@octokit/types": "5.2.0",

src/bazeldoc/configuration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export const builtInGroups = [
9191
items: ["http_archive", "http_file", "http_jar"],
9292
},
9393
{
94-
name: "special globals",
94+
name: "language keywords",
9595
path: "build-ref.html",
9696
items: ["load"],
9797
},

0 commit comments

Comments
 (0)