Skip to content

Commit d8006bd

Browse files
authored
feat(extension): VSCode extension (#19)
This is a rough draft but it appears to work pretty well.
1 parent 0b6bad5 commit d8006bd

20 files changed

+3593
-0
lines changed

.github/workflows/release.yml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
on:
2+
push:
3+
tags:
4+
- '*'
5+
jobs:
6+
build:
7+
name: Build vscode extension
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: setup node
11+
uses: actions/setup-node@v4
12+
- name: get deps
13+
run: npm ci
14+
- name: get vsce
15+
run: npm i -g @vscode/vsce
16+
- name: build extension
17+
run: npm run compile
18+
- name: package extension
19+
run: vsce package -o gwirl-vscode-${{ github.ref }}.vsix
20+
- name: upload artifact
21+
uses: actions/upload-release-asset@v1
22+
env:
23+
GITHUB_TOKEN: ${{ github.token }}
24+
with:
25+
upload_url: ${{ steps.create_release.outputs.upload_url }}
26+
asset_path: ./gwirl-vscode-${{ github.ref }}.vsix
27+
asset_name: gwirl-vscode-${{ github.ref }}.vsix
28+
asset_content_type: application/zip

vscode-extension/.eslintignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules/**
2+
client/node_modules/**
3+
client/out/**
4+
server/node_modules/**
5+
server/out/**

vscode-extension/.eslintrc.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**@type {import('eslint').Linter.Config} */
2+
// eslint-disable-next-line no-undef
3+
module.exports = {
4+
root: true,
5+
parser: '@typescript-eslint/parser',
6+
plugins: [
7+
'@typescript-eslint',
8+
],
9+
extends: [
10+
'eslint:recommended',
11+
'plugin:@typescript-eslint/recommended',
12+
],
13+
rules: {
14+
'semi': [2, "always"],
15+
'@typescript-eslint/no-unused-vars': 0,
16+
'@typescript-eslint/no-explicit-any': 0,
17+
'@typescript-eslint/explicit-module-boundary-types': 0,
18+
'@typescript-eslint/no-non-null-assertion': 0,
19+
}
20+
};

vscode-extension/.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
out
2+
node_modules
3+
client/server
4+
.vscode-test
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
// See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
3+
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
4+
5+
// List of extensions which should be recommended for users of this workspace.
6+
"recommendations": [
7+
"dbaeumer.vscode-eslint"
8+
]
9+
}

vscode-extension/.vscode/launch.json

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// A launch configuration that compiles the extension and then opens it inside a new window
2+
{
3+
"version": "0.2.0",
4+
"configurations": [
5+
{
6+
"type": "extensionHost",
7+
"request": "launch",
8+
"name": "Launch Client",
9+
"runtimeExecutable": "${execPath}",
10+
"args": ["--extensionDevelopmentPath=${workspaceRoot}"],
11+
"outFiles": [
12+
"${workspaceRoot}/client/out/**/*.js",
13+
"${workspaceRoot}/server/out/**/*.js"
14+
],
15+
"autoAttachChildProcesses": true,
16+
"preLaunchTask": {
17+
"type": "npm",
18+
"script": "watch"
19+
}
20+
},
21+
{
22+
"name": "Language Server E2E Test",
23+
"type": "extensionHost",
24+
"request": "launch",
25+
"runtimeExecutable": "${execPath}",
26+
"args": [
27+
"--extensionDevelopmentPath=${workspaceRoot}",
28+
"--extensionTestsPath=${workspaceRoot}/client/out/test/index",
29+
"${workspaceRoot}/client/testFixture"
30+
],
31+
"outFiles": ["${workspaceRoot}/client/out/test/**/*.js"]
32+
}
33+
]
34+
}
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"editor.insertSpaces": false,
3+
"typescript.tsc.autoDetect": "off",
4+
"typescript.preferences.quoteStyle": "single",
5+
"editor.codeActionsOnSave": {
6+
"source.fixAll.eslint": "explicit"
7+
}
8+
}

vscode-extension/.vscode/tasks.json

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"type": "npm",
6+
"script": "compile",
7+
"group": "build",
8+
"presentation": {
9+
"panel": "dedicated",
10+
"reveal": "never"
11+
},
12+
"problemMatcher": [
13+
"$tsc"
14+
]
15+
},
16+
{
17+
"type": "npm",
18+
"script": "watch",
19+
"isBackground": true,
20+
"group": {
21+
"kind": "build",
22+
"isDefault": true
23+
},
24+
"presentation": {
25+
"panel": "dedicated",
26+
"reveal": "never"
27+
},
28+
"problemMatcher": [
29+
"$tsc-watch"
30+
]
31+
}
32+
]
33+
}

vscode-extension/.vscodeignore

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
.vscode/**
2+
**/*.ts
3+
**/*.map
4+
.gitignore
5+
**/tsconfig.json
6+
**/tsconfig.base.json
7+
contributing.md
8+
.travis.yml
9+
client/node_modules/**
10+
!client/node_modules/vscode-jsonrpc/**
11+
!client/node_modules/vscode-languageclient/**
12+
!client/node_modules/vscode-languageserver-protocol/**
13+
!client/node_modules/vscode-languageserver-types/**
14+
!client/node_modules/{minimatch,brace-expansion,concat-map,balanced-match}/**
15+
!client/node_modules/{semver,lru-cache,yallist}/**

vscode-extension/README.md

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Gwirl VSCode Extension
2+
3+
This extension connects to the `gwirl-lsp` language server for the Gwirl template
4+
language used in Go projects. It provides autocomplete, semantic highlighting,
5+
diagnostics, and more.
6+
7+
## Structure
8+
9+
```
10+
.
11+
├── client // Language Client
12+
│ ├── src
13+
│ │ └── extension.ts // Language Client entry point
14+
├── package.json // The extension manifest.
15+
```
16+
17+
## Developing
18+
19+
- Run `npm install` in this folder. This installs all necessary npm modules in both the client and server folder
20+
- Open VS Code on this folder.
21+
- Press Ctrl+Shift+B to start compiling the client and server in [watch mode](https://code.visualstudio.com/docs/editor/tasks#:~:text=The%20first%20entry%20executes,the%20HelloWorld.js%20file.).
22+
- Switch to the Run and Debug View in the Sidebar (Ctrl+Shift+D).
23+
- Select `Launch Client` from the drop down (if it is not already).
24+
- Press ▷ to run the launch config (F5).
25+
- In the [Extension Development Host](https://code.visualstudio.com/api/get-started/your-first-extension#:~:text=Then%2C%20inside%20the%20editor%2C%20press%20F5.%20This%20will%20compile%20and%20run%20the%20extension%20in%20a%20new%20Extension%20Development%20Host%20window.) instance of VSCode, open a document in 'plain text' language mode.
26+
- Type `j` or `t` to see `Javascript` and `TypeScript` completion.
27+
- Enter text content such as `AAA aaa BBB`. The extension will emit diagnostics for all words in all-uppercase.

vscode-extension/client/package-lock.json

+196
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)