lsp: Add initial LSP support (#16)

This commit is contained in:
Tyler Wilding 2022-07-24 22:53:37 -04:00 committed by GitHub
parent f6c7dc9b3a
commit 410ce616e6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 30943 additions and 412 deletions

13
.eslintrc.yml Normal file
View file

@ -0,0 +1,13 @@
env:
browser: true
es2021: true
extends:
- eslint:recommended
- plugin:@typescript-eslint/recommended
parser: "@typescript-eslint/parser"
parserOptions:
ecmaVersion: latest
sourceType: module
plugins:
- "@typescript-eslint"
rules: {}

10
.github/dependabot.yml vendored Normal file
View file

@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"

30
.github/workflows/build.yaml vendored Normal file
View file

@ -0,0 +1,30 @@
name: 🔨 Build
on:
push:
branches:
- "*"
tags:
- v*
pull_request:
branches:
- master
jobs:
build:
name: Extension
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 16
cache: npm
- name: Install NPM Dependencies and Build Extension
run: |
npm ci
npm run compile

45
.github/workflows/lint.yaml vendored Normal file
View file

@ -0,0 +1,45 @@
name: 📝 Lint
on:
push:
branches:
- "*"
pull_request:
branches:
- master
jobs:
lint:
name: ESLint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 16
cache: npm
- name: Install Dependencies and Check Formatting
run: |
npm ci
npm run lint
formatting:
name: Formatting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 16
cache: npm
- name: Install Dependencies and Check Formatting
run: |
npm ci
npm run format:check

3
.gitignore vendored
View file

@ -1,3 +1,6 @@
node_modules
*.vsix
out/
*.log
*.exe
*.bin

6
.prettierignore Normal file
View file

@ -0,0 +1,6 @@
node_modules
*.vsix
out/
*.log
*.exe
*.bin

0
.prettierrc.json Normal file
View file

28
.vscode/launch.json vendored
View file

@ -3,20 +3,16 @@
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
{
"version": "0.2.0",
"configurations": [
{
"name": "Extension",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}"
],
"outFiles": [
"${workspaceFolder}/out/**/*.js"
],
"preLaunchTask": "npm: watch"
}
]
"version": "0.2.0",
"configurations": [
{
"name": "Extension",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": ["--extensionDevelopmentPath=${workspaceFolder}"],
"outFiles": ["${workspaceFolder}/out/**/*.js"],
"preLaunchTask": "npm: watch"
}
]
}

32
.vscode/tasks.json vendored
View file

@ -1,20 +1,20 @@
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
{
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "watch",
"problemMatcher": "$tsc-watch",
"isBackground": true,
"presentation": {
"reveal": "never"
},
"group": {
"kind": "build",
"isDefault": true
}
}
]
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "watch",
"problemMatcher": "$tsc-watch",
"isBackground": true,
"presentation": {
"reveal": "never"
},
"group": {
"kind": "build",
"isDefault": true
}
}
]
}

407
package-lock.json generated
View file

@ -8,7 +8,13 @@
"name": "opengoal",
"version": "0.0.2",
"license": "ISC",
"dependencies": {
"follow-redirects": "^1.15.1",
"open": "^8.4.0",
"vscode-languageclient": "^8.0.1"
},
"devDependencies": {
"@types/follow-redirects": "^1.14.1",
"@types/node": "^12.12.0",
"@types/vscode": "^1.34.0",
"@typescript-eslint/eslint-plugin": "^5.19.0",
@ -95,6 +101,15 @@
"node": ">= 8"
}
},
"node_modules/@types/follow-redirects": {
"version": "1.14.1",
"resolved": "https://registry.npmjs.org/@types/follow-redirects/-/follow-redirects-1.14.1.tgz",
"integrity": "sha512-THBEFwqsLuU/K62B5JRwab9NW97cFmL4Iy34NTMX0bMycQVzq2q7PKOkhfivIwxdpa/J72RppgC42vCHfwKJ0Q==",
"dev": true,
"dependencies": {
"@types/node": "*"
}
},
"node_modules/@types/json-schema": {
"version": "7.0.11",
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.11.tgz",
@ -114,19 +129,19 @@
"dev": true
},
"node_modules/@typescript-eslint/eslint-plugin": {
"version": "5.19.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.19.0.tgz",
"integrity": "sha512-w59GpFqDYGnWFim9p6TGJz7a3qWeENJuAKCqjGSx+Hq/bwq3RZwXYqy98KIfN85yDqz9mq6QXiY5h0FjGQLyEg==",
"version": "5.30.7",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.30.7.tgz",
"integrity": "sha512-l4L6Do+tfeM2OK0GJsU7TUcM/1oN/N25xHm3Jb4z3OiDU4Lj8dIuxX9LpVMS9riSXQs42D1ieX7b85/r16H9Fw==",
"dev": true,
"dependencies": {
"@typescript-eslint/scope-manager": "5.19.0",
"@typescript-eslint/type-utils": "5.19.0",
"@typescript-eslint/utils": "5.19.0",
"debug": "^4.3.2",
"@typescript-eslint/scope-manager": "5.30.7",
"@typescript-eslint/type-utils": "5.30.7",
"@typescript-eslint/utils": "5.30.7",
"debug": "^4.3.4",
"functional-red-black-tree": "^1.0.1",
"ignore": "^5.1.8",
"ignore": "^5.2.0",
"regexpp": "^3.2.0",
"semver": "^7.3.5",
"semver": "^7.3.7",
"tsutils": "^3.21.0"
},
"engines": {
@ -147,15 +162,15 @@
}
},
"node_modules/@typescript-eslint/parser": {
"version": "5.19.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.19.0.tgz",
"integrity": "sha512-yhktJjMCJX8BSBczh1F/uY8wGRYrBeyn84kH6oyqdIJwTGKmzX5Qiq49LRQ0Jh0LXnWijEziSo6BRqny8nqLVQ==",
"version": "5.30.7",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.30.7.tgz",
"integrity": "sha512-Rg5xwznHWWSy7v2o0cdho6n+xLhK2gntImp0rJroVVFkcYFYQ8C8UJTSuTw/3CnExBmPjycjmUJkxVmjXsld6A==",
"dev": true,
"dependencies": {
"@typescript-eslint/scope-manager": "5.19.0",
"@typescript-eslint/types": "5.19.0",
"@typescript-eslint/typescript-estree": "5.19.0",
"debug": "^4.3.2"
"@typescript-eslint/scope-manager": "5.30.7",
"@typescript-eslint/types": "5.30.7",
"@typescript-eslint/typescript-estree": "5.30.7",
"debug": "^4.3.4"
},
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
@ -174,13 +189,13 @@
}
},
"node_modules/@typescript-eslint/scope-manager": {
"version": "5.19.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.19.0.tgz",
"integrity": "sha512-Fz+VrjLmwq5fbQn5W7cIJZ066HxLMKvDEmf4eu1tZ8O956aoX45jAuBB76miAECMTODyUxH61AQM7q4/GOMQ5g==",
"version": "5.30.7",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.30.7.tgz",
"integrity": "sha512-7BM1bwvdF1UUvt+b9smhqdc/eniOnCKxQT/kj3oXtj3LqnTWCAM0qHRHfyzCzhEfWX0zrW7KqXXeE4DlchZBKw==",
"dev": true,
"dependencies": {
"@typescript-eslint/types": "5.19.0",
"@typescript-eslint/visitor-keys": "5.19.0"
"@typescript-eslint/types": "5.30.7",
"@typescript-eslint/visitor-keys": "5.30.7"
},
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
@ -191,13 +206,13 @@
}
},
"node_modules/@typescript-eslint/type-utils": {
"version": "5.19.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.19.0.tgz",
"integrity": "sha512-O6XQ4RI4rQcBGshTQAYBUIGsKqrKeuIOz9v8bckXZnSeXjn/1+BDZndHLe10UplQeJLXDNbaZYrAytKNQO2T4Q==",
"version": "5.30.7",
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.30.7.tgz",
"integrity": "sha512-nD5qAE2aJX/YLyKMvOU5jvJyku4QN5XBVsoTynFrjQZaDgDV6i7QHFiYCx10wvn7hFvfuqIRNBtsgaLe0DbWhw==",
"dev": true,
"dependencies": {
"@typescript-eslint/utils": "5.19.0",
"debug": "^4.3.2",
"@typescript-eslint/utils": "5.30.7",
"debug": "^4.3.4",
"tsutils": "^3.21.0"
},
"engines": {
@ -217,9 +232,9 @@
}
},
"node_modules/@typescript-eslint/types": {
"version": "5.19.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.19.0.tgz",
"integrity": "sha512-zR1ithF4Iyq1wLwkDcT+qFnhs8L5VUtjgac212ftiOP/ZZUOCuuF2DeGiZZGQXGoHA50OreZqLH5NjDcDqn34w==",
"version": "5.30.7",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.30.7.tgz",
"integrity": "sha512-ocVkETUs82+U+HowkovV6uxf1AnVRKCmDRNUBUUo46/5SQv1owC/EBFkiu4MOHeZqhKz2ktZ3kvJJ1uFqQ8QPg==",
"dev": true,
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
@ -230,17 +245,17 @@
}
},
"node_modules/@typescript-eslint/typescript-estree": {
"version": "5.19.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.19.0.tgz",
"integrity": "sha512-dRPuD4ocXdaE1BM/dNR21elSEUPKaWgowCA0bqJ6YbYkvtrPVEvZ+zqcX5a8ECYn3q5iBSSUcBBD42ubaOp0Hw==",
"version": "5.30.7",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.30.7.tgz",
"integrity": "sha512-tNslqXI1ZdmXXrHER83TJ8OTYl4epUzJC0aj2i4DMDT4iU+UqLT3EJeGQvJ17BMbm31x5scSwo3hPM0nqQ1AEA==",
"dev": true,
"dependencies": {
"@typescript-eslint/types": "5.19.0",
"@typescript-eslint/visitor-keys": "5.19.0",
"debug": "^4.3.2",
"globby": "^11.0.4",
"@typescript-eslint/types": "5.30.7",
"@typescript-eslint/visitor-keys": "5.30.7",
"debug": "^4.3.4",
"globby": "^11.1.0",
"is-glob": "^4.0.3",
"semver": "^7.3.5",
"semver": "^7.3.7",
"tsutils": "^3.21.0"
},
"engines": {
@ -257,15 +272,15 @@
}
},
"node_modules/@typescript-eslint/utils": {
"version": "5.19.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.19.0.tgz",
"integrity": "sha512-ZuEckdupXpXamKvFz/Ql8YnePh2ZWcwz7APICzJL985Rp5C2AYcHO62oJzIqNhAMtMK6XvrlBTZeNG8n7gS3lQ==",
"version": "5.30.7",
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.30.7.tgz",
"integrity": "sha512-Z3pHdbFw+ftZiGUnm1GZhkJgVqsDL5CYW2yj+TB2mfXDFOMqtbzQi2dNJIyPqPbx9mv2kUxS1gU+r2gKlKi1rQ==",
"dev": true,
"dependencies": {
"@types/json-schema": "^7.0.9",
"@typescript-eslint/scope-manager": "5.19.0",
"@typescript-eslint/types": "5.19.0",
"@typescript-eslint/typescript-estree": "5.19.0",
"@typescript-eslint/scope-manager": "5.30.7",
"@typescript-eslint/types": "5.30.7",
"@typescript-eslint/typescript-estree": "5.30.7",
"eslint-scope": "^5.1.1",
"eslint-utils": "^3.0.0"
},
@ -281,13 +296,13 @@
}
},
"node_modules/@typescript-eslint/visitor-keys": {
"version": "5.19.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.19.0.tgz",
"integrity": "sha512-Ym7zZoMDZcAKWsULi2s7UMLREdVQdScPQ/fKWMYefarCztWlHPFVJo8racf8R0Gc8FAEJ2eD4of8As1oFtnQlQ==",
"version": "5.30.7",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.30.7.tgz",
"integrity": "sha512-KrRXf8nnjvcpxDFOKej4xkD7657+PClJs5cJVSG7NNoCNnjEdc46juNAQt7AyuWctuCgs6mVRc1xGctEqrjxWw==",
"dev": true,
"dependencies": {
"@typescript-eslint/types": "5.19.0",
"eslint-visitor-keys": "^3.0.0"
"@typescript-eslint/types": "5.30.7",
"eslint-visitor-keys": "^3.3.0"
},
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
@ -376,14 +391,12 @@
"node_modules/balanced-match": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
"integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==",
"dev": true
"integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw=="
},
"node_modules/brace-expansion": {
"version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
"dev": true,
"dependencies": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
@ -447,8 +460,7 @@
"node_modules/concat-map": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
"dev": true
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s="
},
"node_modules/cross-spawn": {
"version": "7.0.3",
@ -487,6 +499,14 @@
"integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==",
"dev": true
},
"node_modules/define-lazy-prop": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/define-lazy-prop/-/define-lazy-prop-2.0.0.tgz",
"integrity": "sha512-Ds09qNh8yw3khSjiJjiUInaGX9xlqZDY7JVryGxdxV7NPeuqQfplOpQ66yJFZut3jLa5zOwkXw1g9EI2uKh4Og==",
"engines": {
"node": ">=8"
}
},
"node_modules/dir-glob": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz",
@ -818,6 +838,25 @@
"integrity": "sha512-WIWGi2L3DyTUvUrwRKgGi9TwxQMUEqPOPQBVi71R96jZXJdFskXEmf54BoZaS1kknGODoIGASGEzBUYdyMCBJg==",
"dev": true
},
"node_modules/follow-redirects": {
"version": "1.15.1",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.1.tgz",
"integrity": "sha512-yLAMQs+k0b2m7cVxpS1VKJVvoz7SS9Td1zss3XRwXj+ZDH00RJgnuLx7E44wx02kQLrdM3aOOy+FpzS7+8OizA==",
"funding": [
{
"type": "individual",
"url": "https://github.com/sponsors/RubenVerborgh"
}
],
"engines": {
"node": ">=4.0"
},
"peerDependenciesMeta": {
"debug": {
"optional": true
}
}
},
"node_modules/fs.realpath": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
@ -956,6 +995,20 @@
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
"dev": true
},
"node_modules/is-docker": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.2.1.tgz",
"integrity": "sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ==",
"bin": {
"is-docker": "cli.js"
},
"engines": {
"node": ">=8"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/is-extglob": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz",
@ -986,6 +1039,17 @@
"node": ">=0.12.0"
}
},
"node_modules/is-wsl": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz",
"integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==",
"dependencies": {
"is-docker": "^2.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/isexe": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
@ -1039,7 +1103,6 @@
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz",
"integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==",
"dev": true,
"dependencies": {
"yallist": "^4.0.0"
},
@ -1073,7 +1136,6 @@
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
"integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==",
"dev": true,
"dependencies": {
"brace-expansion": "^1.1.7"
},
@ -1102,6 +1164,22 @@
"wrappy": "1"
}
},
"node_modules/open": {
"version": "8.4.0",
"resolved": "https://registry.npmjs.org/open/-/open-8.4.0.tgz",
"integrity": "sha512-XgFPPM+B28FtCCgSb9I+s9szOC1vZRSwgWsRUA5ylIxRTgKozqjOCrVOqGsYABPYK5qnfqClxZTFBa8PKt2v6Q==",
"dependencies": {
"define-lazy-prop": "^2.0.0",
"is-docker": "^2.1.1",
"is-wsl": "^2.2.0"
},
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/optionator": {
"version": "0.9.1",
"resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.1.tgz",
@ -1281,7 +1359,6 @@
"version": "7.3.7",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz",
"integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==",
"dev": true,
"dependencies": {
"lru-cache": "^6.0.0"
},
@ -1449,6 +1526,41 @@
"integrity": "sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA==",
"dev": true
},
"node_modules/vscode-jsonrpc": {
"version": "8.0.2",
"resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-8.0.2.tgz",
"integrity": "sha512-RY7HwI/ydoC1Wwg4gJ3y6LpU9FJRZAUnTYMXthqhFXXu77ErDd/xkREpGuk4MyYkk4a+XDWAMqe0S3KkelYQEQ==",
"engines": {
"node": ">=14.0.0"
}
},
"node_modules/vscode-languageclient": {
"version": "8.0.2",
"resolved": "https://registry.npmjs.org/vscode-languageclient/-/vscode-languageclient-8.0.2.tgz",
"integrity": "sha512-lHlthJtphG9gibGb/y72CKqQUxwPsMXijJVpHEC2bvbFqxmkj9LwQ3aGU9dwjBLqsX1S4KjShYppLvg1UJDF/Q==",
"dependencies": {
"minimatch": "^3.0.4",
"semver": "^7.3.5",
"vscode-languageserver-protocol": "3.17.2"
},
"engines": {
"vscode": "^1.67.0"
}
},
"node_modules/vscode-languageserver-protocol": {
"version": "3.17.2",
"resolved": "https://registry.npmjs.org/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.17.2.tgz",
"integrity": "sha512-8kYisQ3z/SQ2kyjlNeQxbkkTNmVFoQCqkmGrzLH6A9ecPlgTbp3wDTnUNqaUxYr4vlAcloxx8zwy7G5WdguYNg==",
"dependencies": {
"vscode-jsonrpc": "8.0.2",
"vscode-languageserver-types": "3.17.2"
}
},
"node_modules/vscode-languageserver-types": {
"version": "3.17.2",
"resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.17.2.tgz",
"integrity": "sha512-zHhCWatviizPIq9B7Vh9uvrH6x3sK8itC84HkamnBWoDFJtzBf7SWlpLCZUit72b3os45h6RWQNC9xHRDF8dRA=="
},
"node_modules/which": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
@ -1482,8 +1594,7 @@
"node_modules/yallist": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
"integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==",
"dev": true
"integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A=="
}
},
"dependencies": {
@ -1547,6 +1658,15 @@
"fastq": "^1.6.0"
}
},
"@types/follow-redirects": {
"version": "1.14.1",
"resolved": "https://registry.npmjs.org/@types/follow-redirects/-/follow-redirects-1.14.1.tgz",
"integrity": "sha512-THBEFwqsLuU/K62B5JRwab9NW97cFmL4Iy34NTMX0bMycQVzq2q7PKOkhfivIwxdpa/J72RppgC42vCHfwKJ0Q==",
"dev": true,
"requires": {
"@types/node": "*"
}
},
"@types/json-schema": {
"version": "7.0.11",
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.11.tgz",
@ -1566,98 +1686,98 @@
"dev": true
},
"@typescript-eslint/eslint-plugin": {
"version": "5.19.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.19.0.tgz",
"integrity": "sha512-w59GpFqDYGnWFim9p6TGJz7a3qWeENJuAKCqjGSx+Hq/bwq3RZwXYqy98KIfN85yDqz9mq6QXiY5h0FjGQLyEg==",
"version": "5.30.7",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.30.7.tgz",
"integrity": "sha512-l4L6Do+tfeM2OK0GJsU7TUcM/1oN/N25xHm3Jb4z3OiDU4Lj8dIuxX9LpVMS9riSXQs42D1ieX7b85/r16H9Fw==",
"dev": true,
"requires": {
"@typescript-eslint/scope-manager": "5.19.0",
"@typescript-eslint/type-utils": "5.19.0",
"@typescript-eslint/utils": "5.19.0",
"debug": "^4.3.2",
"@typescript-eslint/scope-manager": "5.30.7",
"@typescript-eslint/type-utils": "5.30.7",
"@typescript-eslint/utils": "5.30.7",
"debug": "^4.3.4",
"functional-red-black-tree": "^1.0.1",
"ignore": "^5.1.8",
"ignore": "^5.2.0",
"regexpp": "^3.2.0",
"semver": "^7.3.5",
"semver": "^7.3.7",
"tsutils": "^3.21.0"
}
},
"@typescript-eslint/parser": {
"version": "5.19.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.19.0.tgz",
"integrity": "sha512-yhktJjMCJX8BSBczh1F/uY8wGRYrBeyn84kH6oyqdIJwTGKmzX5Qiq49LRQ0Jh0LXnWijEziSo6BRqny8nqLVQ==",
"version": "5.30.7",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.30.7.tgz",
"integrity": "sha512-Rg5xwznHWWSy7v2o0cdho6n+xLhK2gntImp0rJroVVFkcYFYQ8C8UJTSuTw/3CnExBmPjycjmUJkxVmjXsld6A==",
"dev": true,
"requires": {
"@typescript-eslint/scope-manager": "5.19.0",
"@typescript-eslint/types": "5.19.0",
"@typescript-eslint/typescript-estree": "5.19.0",
"debug": "^4.3.2"
"@typescript-eslint/scope-manager": "5.30.7",
"@typescript-eslint/types": "5.30.7",
"@typescript-eslint/typescript-estree": "5.30.7",
"debug": "^4.3.4"
}
},
"@typescript-eslint/scope-manager": {
"version": "5.19.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.19.0.tgz",
"integrity": "sha512-Fz+VrjLmwq5fbQn5W7cIJZ066HxLMKvDEmf4eu1tZ8O956aoX45jAuBB76miAECMTODyUxH61AQM7q4/GOMQ5g==",
"version": "5.30.7",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.30.7.tgz",
"integrity": "sha512-7BM1bwvdF1UUvt+b9smhqdc/eniOnCKxQT/kj3oXtj3LqnTWCAM0qHRHfyzCzhEfWX0zrW7KqXXeE4DlchZBKw==",
"dev": true,
"requires": {
"@typescript-eslint/types": "5.19.0",
"@typescript-eslint/visitor-keys": "5.19.0"
"@typescript-eslint/types": "5.30.7",
"@typescript-eslint/visitor-keys": "5.30.7"
}
},
"@typescript-eslint/type-utils": {
"version": "5.19.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.19.0.tgz",
"integrity": "sha512-O6XQ4RI4rQcBGshTQAYBUIGsKqrKeuIOz9v8bckXZnSeXjn/1+BDZndHLe10UplQeJLXDNbaZYrAytKNQO2T4Q==",
"version": "5.30.7",
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.30.7.tgz",
"integrity": "sha512-nD5qAE2aJX/YLyKMvOU5jvJyku4QN5XBVsoTynFrjQZaDgDV6i7QHFiYCx10wvn7hFvfuqIRNBtsgaLe0DbWhw==",
"dev": true,
"requires": {
"@typescript-eslint/utils": "5.19.0",
"debug": "^4.3.2",
"@typescript-eslint/utils": "5.30.7",
"debug": "^4.3.4",
"tsutils": "^3.21.0"
}
},
"@typescript-eslint/types": {
"version": "5.19.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.19.0.tgz",
"integrity": "sha512-zR1ithF4Iyq1wLwkDcT+qFnhs8L5VUtjgac212ftiOP/ZZUOCuuF2DeGiZZGQXGoHA50OreZqLH5NjDcDqn34w==",
"version": "5.30.7",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.30.7.tgz",
"integrity": "sha512-ocVkETUs82+U+HowkovV6uxf1AnVRKCmDRNUBUUo46/5SQv1owC/EBFkiu4MOHeZqhKz2ktZ3kvJJ1uFqQ8QPg==",
"dev": true
},
"@typescript-eslint/typescript-estree": {
"version": "5.19.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.19.0.tgz",
"integrity": "sha512-dRPuD4ocXdaE1BM/dNR21elSEUPKaWgowCA0bqJ6YbYkvtrPVEvZ+zqcX5a8ECYn3q5iBSSUcBBD42ubaOp0Hw==",
"version": "5.30.7",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-5.30.7.tgz",
"integrity": "sha512-tNslqXI1ZdmXXrHER83TJ8OTYl4epUzJC0aj2i4DMDT4iU+UqLT3EJeGQvJ17BMbm31x5scSwo3hPM0nqQ1AEA==",
"dev": true,
"requires": {
"@typescript-eslint/types": "5.19.0",
"@typescript-eslint/visitor-keys": "5.19.0",
"debug": "^4.3.2",
"globby": "^11.0.4",
"@typescript-eslint/types": "5.30.7",
"@typescript-eslint/visitor-keys": "5.30.7",
"debug": "^4.3.4",
"globby": "^11.1.0",
"is-glob": "^4.0.3",
"semver": "^7.3.5",
"semver": "^7.3.7",
"tsutils": "^3.21.0"
}
},
"@typescript-eslint/utils": {
"version": "5.19.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.19.0.tgz",
"integrity": "sha512-ZuEckdupXpXamKvFz/Ql8YnePh2ZWcwz7APICzJL985Rp5C2AYcHO62oJzIqNhAMtMK6XvrlBTZeNG8n7gS3lQ==",
"version": "5.30.7",
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.30.7.tgz",
"integrity": "sha512-Z3pHdbFw+ftZiGUnm1GZhkJgVqsDL5CYW2yj+TB2mfXDFOMqtbzQi2dNJIyPqPbx9mv2kUxS1gU+r2gKlKi1rQ==",
"dev": true,
"requires": {
"@types/json-schema": "^7.0.9",
"@typescript-eslint/scope-manager": "5.19.0",
"@typescript-eslint/types": "5.19.0",
"@typescript-eslint/typescript-estree": "5.19.0",
"@typescript-eslint/scope-manager": "5.30.7",
"@typescript-eslint/types": "5.30.7",
"@typescript-eslint/typescript-estree": "5.30.7",
"eslint-scope": "^5.1.1",
"eslint-utils": "^3.0.0"
}
},
"@typescript-eslint/visitor-keys": {
"version": "5.19.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.19.0.tgz",
"integrity": "sha512-Ym7zZoMDZcAKWsULi2s7UMLREdVQdScPQ/fKWMYefarCztWlHPFVJo8racf8R0Gc8FAEJ2eD4of8As1oFtnQlQ==",
"version": "5.30.7",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.30.7.tgz",
"integrity": "sha512-KrRXf8nnjvcpxDFOKej4xkD7657+PClJs5cJVSG7NNoCNnjEdc46juNAQt7AyuWctuCgs6mVRc1xGctEqrjxWw==",
"dev": true,
"requires": {
"@typescript-eslint/types": "5.19.0",
"eslint-visitor-keys": "^3.0.0"
"@typescript-eslint/types": "5.30.7",
"eslint-visitor-keys": "^3.3.0"
}
},
"acorn": {
@ -1715,14 +1835,12 @@
"balanced-match": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
"integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==",
"dev": true
"integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw=="
},
"brace-expansion": {
"version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
"dev": true,
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
@ -1771,8 +1889,7 @@
"concat-map": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
"dev": true
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s="
},
"cross-spawn": {
"version": "7.0.3",
@ -1800,6 +1917,11 @@
"integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==",
"dev": true
},
"define-lazy-prop": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/define-lazy-prop/-/define-lazy-prop-2.0.0.tgz",
"integrity": "sha512-Ds09qNh8yw3khSjiJjiUInaGX9xlqZDY7JVryGxdxV7NPeuqQfplOpQ66yJFZut3jLa5zOwkXw1g9EI2uKh4Og=="
},
"dir-glob": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz",
@ -2060,6 +2182,11 @@
"integrity": "sha512-WIWGi2L3DyTUvUrwRKgGi9TwxQMUEqPOPQBVi71R96jZXJdFskXEmf54BoZaS1kknGODoIGASGEzBUYdyMCBJg==",
"dev": true
},
"follow-redirects": {
"version": "1.15.1",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.1.tgz",
"integrity": "sha512-yLAMQs+k0b2m7cVxpS1VKJVvoz7SS9Td1zss3XRwXj+ZDH00RJgnuLx7E44wx02kQLrdM3aOOy+FpzS7+8OizA=="
},
"fs.realpath": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
@ -2162,6 +2289,11 @@
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
"dev": true
},
"is-docker": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.2.1.tgz",
"integrity": "sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ=="
},
"is-extglob": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz",
@ -2183,6 +2315,14 @@
"integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==",
"dev": true
},
"is-wsl": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz",
"integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==",
"requires": {
"is-docker": "^2.0.0"
}
},
"isexe": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
@ -2230,7 +2370,6 @@
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz",
"integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==",
"dev": true,
"requires": {
"yallist": "^4.0.0"
}
@ -2255,7 +2394,6 @@
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
"integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==",
"dev": true,
"requires": {
"brace-expansion": "^1.1.7"
}
@ -2281,6 +2419,16 @@
"wrappy": "1"
}
},
"open": {
"version": "8.4.0",
"resolved": "https://registry.npmjs.org/open/-/open-8.4.0.tgz",
"integrity": "sha512-XgFPPM+B28FtCCgSb9I+s9szOC1vZRSwgWsRUA5ylIxRTgKozqjOCrVOqGsYABPYK5qnfqClxZTFBa8PKt2v6Q==",
"requires": {
"define-lazy-prop": "^2.0.0",
"is-docker": "^2.1.1",
"is-wsl": "^2.2.0"
}
},
"optionator": {
"version": "0.9.1",
"resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.1.tgz",
@ -2386,7 +2534,6 @@
"version": "7.3.7",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz",
"integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==",
"dev": true,
"requires": {
"lru-cache": "^6.0.0"
}
@ -2502,6 +2649,35 @@
"integrity": "sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA==",
"dev": true
},
"vscode-jsonrpc": {
"version": "8.0.2",
"resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-8.0.2.tgz",
"integrity": "sha512-RY7HwI/ydoC1Wwg4gJ3y6LpU9FJRZAUnTYMXthqhFXXu77ErDd/xkREpGuk4MyYkk4a+XDWAMqe0S3KkelYQEQ=="
},
"vscode-languageclient": {
"version": "8.0.2",
"resolved": "https://registry.npmjs.org/vscode-languageclient/-/vscode-languageclient-8.0.2.tgz",
"integrity": "sha512-lHlthJtphG9gibGb/y72CKqQUxwPsMXijJVpHEC2bvbFqxmkj9LwQ3aGU9dwjBLqsX1S4KjShYppLvg1UJDF/Q==",
"requires": {
"minimatch": "^3.0.4",
"semver": "^7.3.5",
"vscode-languageserver-protocol": "3.17.2"
}
},
"vscode-languageserver-protocol": {
"version": "3.17.2",
"resolved": "https://registry.npmjs.org/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.17.2.tgz",
"integrity": "sha512-8kYisQ3z/SQ2kyjlNeQxbkkTNmVFoQCqkmGrzLH6A9ecPlgTbp3wDTnUNqaUxYr4vlAcloxx8zwy7G5WdguYNg==",
"requires": {
"vscode-jsonrpc": "8.0.2",
"vscode-languageserver-types": "3.17.2"
}
},
"vscode-languageserver-types": {
"version": "3.17.2",
"resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.17.2.tgz",
"integrity": "sha512-zHhCWatviizPIq9B7Vh9uvrH6x3sK8itC84HkamnBWoDFJtzBf7SWlpLCZUit72b3os45h6RWQNC9xHRDF8dRA=="
},
"which": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
@ -2526,8 +2702,7 @@
"yallist": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
"integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==",
"dev": true
"integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A=="
}
}
}

View file

@ -21,7 +21,23 @@
"vscode:prepublish": "npm run compile",
"compile": "tsc -p ./",
"lint": "eslint . --ext .ts,.tsx",
"watch": "tsc -watch -p ./"
"watch": "tsc -watch -p ./",
"format": "npx prettier --write .",
"format:check": "npx prettier --check ."
},
"devDependencies": {
"@types/follow-redirects": "^1.14.1",
"@types/node": "^12.12.0",
"@types/vscode": "^1.34.0",
"@typescript-eslint/eslint-plugin": "^5.19.0",
"@typescript-eslint/parser": "^5.19.0",
"eslint": "^8.13.0",
"typescript": "^4.6.3"
},
"dependencies": {
"follow-redirects": "^1.15.1",
"open": "^8.4.0",
"vscode-languageclient": "^8.0.1"
},
"activationEvents": [
"onLanguage:opengoal",
@ -277,13 +293,5 @@
"path": "./snippets/opengoal.json"
}
]
},
"devDependencies": {
"@types/node": "^12.12.0",
"@types/vscode": "^1.34.0",
"@typescript-eslint/eslint-plugin": "^5.19.0",
"@typescript-eslint/parser": "^5.19.0",
"eslint": "^8.13.0",
"typescript": "^4.6.3"
}
}

View file

@ -1,11 +1,7 @@
{
"defun": {
"prefix": "defun",
"body": [
"(defun ${1:name} (${2:vars})",
"\t\"${3:doc-string}\"",
"\t$0)"
],
"description": "Create a new function"
}
"defun": {
"prefix": "defun",
"body": ["(defun ${1:name} (${2:vars})", "\t\"${3:doc-string}\"", "\t$0)"],
"description": "Create a new function"
}
}

View file

@ -1,5 +1,4 @@
import * as vscode from "vscode";
import * as path from "path";
export class RecentFiles {
recentFiles: Array<string> = [];
@ -11,11 +10,9 @@ export class RecentFiles {
}
addFile(filePath: string) {
console.log(`Adding - ${filePath}`);
// dont add duplicates
// if it exists, take it out and put it on the top
const idx = this.indexOf(filePath);
console.log(idx);
if (idx !== -1) {
this.recentFiles.splice(idx, 1);
}

10
src/config/config.ts Normal file
View file

@ -0,0 +1,10 @@
import * as vscode from "vscode";
export function getConfig() {
const configOptions = vscode.workspace.getConfiguration("opengoal");
return {
opengoalLspVersion: configOptions.get<string>("opengoalLspVersion"),
opengoalLspPath: configOptions.get<string>("opengoalLspPath"),
};
}

View file

@ -3,6 +3,7 @@
import * as vscode from "vscode";
import { RecentFiles } from "./RecentFiles";
import * as fileUtils from "./utils/FileUtils";
import * as lsp from "./lsp/main";
let recentFiles: RecentFiles;
@ -34,4 +35,11 @@ export function activate(context: vscode.ExtensionContext) {
}
})
);
// Start the LSP
lsp.activate(context);
}
export function deactivate(): Promise<void> | undefined {
return lsp.deactivate();
}

24
src/lsp/LICENSE Normal file
View file

@ -0,0 +1,24 @@
Code heavily borrowed from https://github.com/BetterThanTomorrow/calva/tree/v2.0.289/src/lsp
MIT License
Parts of the software are Copyright (c) 2016-2018 Stian Sivertsen
Other parts are Copyright (c) 2018 -> Better than Tomorrow
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

28
src/lsp/download.ts Normal file
View file

@ -0,0 +1,28 @@
import { getLspReleaseAssetName, writeLspMetadata } from "./util";
import * as path from "path";
import * as fs from "fs";
import { downloadFromUrl } from "../utils/download";
export async function downloadLsp(
extensionPath: string,
version: string
): Promise<string | undefined> {
const assetName = getLspReleaseAssetName(extensionPath, version);
if (assetName === undefined) {
return undefined;
}
const url = `https://github.com/open-goal/jak-project/releases/download/${version}/${assetName}`;
const savePath = path.join(extensionPath, assetName);
try {
await downloadFromUrl(url, savePath);
if (path.extname(savePath) === ".bin") {
fs.chmodSync(savePath, 0o775);
}
writeLspMetadata(extensionPath, version);
} catch (e: any) {
console.log("Error downloading opengoal-lsp", e);
// TODO - backup existing and return that path
return;
}
return savePath;
}

306
src/lsp/main.ts Normal file
View file

@ -0,0 +1,306 @@
import * as vscode from "vscode";
import * as path from "path";
import {
LanguageClient,
LanguageClientOptions,
ServerOptions,
TransportKind,
} from "vscode-languageclient/node";
import { getConfig } from "../config/config";
import { downloadLsp } from "./download";
import { getLatestVersion, getVersionFromMetaFile } from "./util";
let extensionContext: vscode.ExtensionContext;
let opengoalLspPath: string | undefined;
let activeClient: LanguageClient | undefined;
const lspStatusItem = vscode.window.createStatusBarItem(
vscode.StatusBarAlignment.Left,
0
);
export type LspStatus =
| "stopped"
| "starting"
| "started"
| "downloading"
| "error";
export let lspStatus: LspStatus = "stopped";
function updateStatus(status: LspStatus, extraInfo?: string) {
lspStatus = status;
switch (status) {
case "stopped":
lspStatusItem.text = "$(circle-outline) opengoal-lsp";
lspStatusItem.tooltip = "opengoal-lsp is not active, click to get a menu";
lspStatusItem.command = "opengoal.lsp.showLspStoppedMenu";
break;
case "starting":
lspStatusItem.text = "$(rocket) opengoal-lsp";
lspStatusItem.tooltip = "opengoal-lsp is starting";
lspStatusItem.command = undefined;
break;
case "started":
lspStatusItem.text = "$(circle-filled) opengoal-lsp";
lspStatusItem.tooltip = "opengoal-lsp is active";
lspStatusItem.command = "opengoal.lsp.showLspStartedMenu";
break;
case "downloading":
lspStatusItem.text = "$(sync~spin) opengoal-lsp downloading";
lspStatusItem.tooltip = `OpenGOAL is downloading opengoal-lsp version: ${extraInfo}`;
lspStatusItem.command = undefined;
break;
case "error":
lspStatusItem.text = "$(error) opengoal-lsp";
lspStatusItem.tooltip =
"opengoal-lsp is not running because of some error";
lspStatusItem.command = "opengoal.lsp.showLspStoppedMenu";
break;
default:
break;
}
}
async function ensureServerDownloaded(): Promise<string | undefined> {
const installedVersion = getVersionFromMetaFile(
extensionContext.extensionPath
);
const configuredVersion = getConfig().opengoalLspVersion;
// See if we have the right version
// - either its the latest
// - or we have the one that's configured
let needDownload = false;
let versionToDownload = "";
if (
configuredVersion !== undefined &&
configuredVersion !== installedVersion
) {
needDownload = true;
versionToDownload = configuredVersion;
} else {
const latestVersion = await getLatestVersion();
if (latestVersion !== installedVersion) {
needDownload = true;
versionToDownload = latestVersion;
}
}
if (!needDownload) {
return;
}
// Install the LSP and update the version metadata file
updateStatus("downloading", versionToDownload);
const newLspPath = await downloadLsp(
extensionContext.extensionPath,
versionToDownload
);
if (newLspPath === undefined) {
updateStatus("error");
} else {
updateStatus("stopped");
}
return newLspPath;
}
async function maybeDownloadLspServer(): Promise<void> {
const userConfiguredOpengoalLspPath = getConfig().opengoalLspPath;
if (
userConfiguredOpengoalLspPath !== "" &&
userConfiguredOpengoalLspPath !== undefined
) {
opengoalLspPath = userConfiguredOpengoalLspPath;
} else {
opengoalLspPath = await ensureServerDownloaded();
}
}
function createClient(lspPath: string): LanguageClient {
const serverOptions: ServerOptions = {
run: {
command: lspPath,
transport: TransportKind.stdio,
args: ["--log", path.join(extensionContext.extensionPath, "lsp.log")],
},
debug: {
command: lspPath,
transport: TransportKind.stdio,
args: [
"--verbose",
"--log",
path.join(extensionContext.extensionPath, "lsp.log"),
],
},
};
const clientOptions: LanguageClientOptions = {
documentSelector: [
{ scheme: "file", language: "opengoal-ir" },
{ scheme: "file", language: "opengoal" },
],
synchronize: {
fileEvents: [
vscode.workspace.createFileSystemWatcher("**/*_ir2.asm"),
vscode.workspace.createFileSystemWatcher("**/all-types.gc"),
],
},
progressOnInitialization: true,
initializationOptions: {
"dependency-scheme": "jar",
"auto-add-ns-to-new-files?": true,
"document-formatting?": false,
"document-range-formatting?": false,
"keep-require-at-start?": true,
},
middleware: {
async provideHover(document, position, token, next) {
return next(document, position, token);
},
},
};
return new LanguageClient(
"opengoal-lsp",
"OpenGOAL LSP",
serverOptions,
clientOptions
);
}
async function stopClient() {
updateStatus("stopped");
if (activeClient !== undefined) {
console.log("Stopping opengoal-lsp");
return await activeClient
.stop()
.then(() => {
activeClient = undefined;
})
.catch((e: any) => {
console.error("Stopping client error:", e);
});
}
}
async function startClient(): Promise<void> {
if (opengoalLspPath === undefined) {
return;
}
const client = createClient(opengoalLspPath);
console.log("Starting opengoal-lsp at", opengoalLspPath);
// TODO - some form of startup test would be nice
try {
updateStatus("starting");
await client.start();
activeClient = client;
updateStatus("started");
} catch (error) {
console.error("opengoal-lsp:", error);
updateStatus("error");
lspStatusItem.hide();
await stopClient();
}
}
export async function startClientCommand() {
lspStatusItem.show();
await maybeDownloadLspServer();
if (opengoalLspPath !== undefined) {
await startClient();
}
}
async function restartClient() {
await stopClient();
await startClientCommand();
}
function showMenu(
items: vscode.QuickPickItem[],
commands: Record<string, string>
) {
void vscode.window
.showQuickPick(items, { title: "clojure-lsp" })
.then((v) => {
if (v !== undefined && commands[v.label]) {
void vscode.commands.executeCommand(commands[v.label]);
}
});
}
function stoppedMenuCommand() {
const START_OPTION = "Start";
const START_COMMAND = "opengoal.lsp.start";
const commands: any = {};
commands[START_OPTION] = START_COMMAND;
const items: vscode.QuickPickItem[] = [
{
label: START_OPTION,
description: "Start the clojure-lsp server",
},
];
showMenu(items, commands);
}
function startedMenuCommand() {
const STOP_OPTION = "Stop";
const STOP_COMMAND = "opengoal.lsp.stop";
const RESTART_OPTION = "Restart";
const RESTART_COMMAND = "opengoal.lsp.restart";
// TODO - add info and open log file options
const commands = {
[STOP_OPTION]: STOP_COMMAND,
[RESTART_OPTION]: RESTART_COMMAND,
};
const items: vscode.QuickPickItem[] = [
{
label: STOP_OPTION,
description: "Stop the clojure-lsp server",
},
{
label: RESTART_OPTION,
description: "Restart the clojure-lsp server",
},
];
showMenu(items, commands);
}
function registerLifeCycleCommands(context: vscode.ExtensionContext): void {
context.subscriptions.push(
vscode.commands.registerCommand("opengoal.lsp.start", startClientCommand)
);
context.subscriptions.push(
vscode.commands.registerCommand("opengoal.lsp.stop", stopClient)
);
context.subscriptions.push(
vscode.commands.registerCommand("opengoal.lsp.restart", restartClient)
);
context.subscriptions.push(
vscode.commands.registerCommand(
"opengoal.lsp.showLspStoppedMenu",
stoppedMenuCommand
)
);
context.subscriptions.push(
vscode.commands.registerCommand(
"opengoal.lsp.showLspStartedMenu",
startedMenuCommand
)
);
}
export async function activate(
context: vscode.ExtensionContext
): Promise<void> {
extensionContext = context;
registerLifeCycleCommands(context);
// TODO - add info and open log file options
// registerDiagnosticsCommands(context);
updateStatus("stopped");
lspStatusItem.show();
await startClientCommand();
}
export function deactivate(): Promise<void> {
return stopClient();
}

64
src/lsp/util.ts Normal file
View file

@ -0,0 +1,64 @@
import { fetchFromUrl } from "../utils/download";
import * as path from "path";
import * as fs from "fs";
import * as process from "process";
const artifactNameTemplates: any = {
darwin: undefined,
linux: "opengoal-lsp-linux-__VERSION__.bin",
win32: "opengoal-lsp-windows-__VERSION__.exe",
};
const versionFileName = "lsp-metadata.json";
export function getLspReleaseAssetName(
extensionPath: string,
version: string,
platform: string = process.platform
): string | undefined {
if (!(platform in artifactNameTemplates)) {
console.log(`Unsupported platform '${platform}'`);
return undefined;
}
const nameTemplate = artifactNameTemplates[platform];
if (nameTemplate === undefined) {
console.log(`Unsupported platform '${platform}'`);
return undefined;
}
return nameTemplate.replace("__VERSION__", version);
}
export async function getLatestVersion(): Promise<string> {
try {
const releasesJSON = await fetchFromUrl(
"https://api.github.com/repos/open-goal/jak-project/releases"
);
const releases = JSON.parse(releasesJSON);
return releases[0].tag_name;
} catch (err) {
return "";
}
}
export function getVersionFromMetaFile(extensionPath: string): string {
const filePath = path.join(extensionPath, versionFileName);
try {
const meta = JSON.parse(fs.readFileSync(filePath, "utf8"));
return meta.version;
} catch (e: any) {
console.log("Could not read lsp metadata version file.", e.message);
return "";
}
}
export function writeLspMetadata(extensionPath: string, version: string): void {
const filePath = path.join(extensionPath, versionFileName);
try {
fs.writeFileSync(filePath, {
version: version,
});
} catch (e: any) {
console.log("Could not write lsp metadata file.", e.message);
}
}

View file

@ -16,9 +16,9 @@ export function switchFile() {
for (const [key, value] of Object.entries(fileSwitchingAssoc)) {
if (currName.endsWith(key)) {
// Get everything before the suffix, check if a file with the associated suffix exists
let prefix = currName.slice(0, -key.length);
let switchFileName = prefix + value;
let switchFilePath = path.join(path.dirname(currPath), switchFileName);
const prefix = currName.slice(0, -key.length);
const switchFileName = prefix + value;
const switchFilePath = path.join(path.dirname(currPath), switchFileName);
vscode.window.showTextDocument(vscode.Uri.file(switchFilePath));
return;
}

57
src/utils/download.ts Normal file
View file

@ -0,0 +1,57 @@
import * as url from "url";
import { https } from "follow-redirects";
import * as fs from "fs";
export async function fetchFromUrl(fullUrl: string): Promise<string> {
const q = url.parse(fullUrl);
return new Promise((resolve, reject) => {
https
.get(
{
host: q.hostname,
path: q.pathname,
port: q.port,
headers: { "user-agent": "node.js" },
},
(res: any) => {
let data = "";
res.on("data", (chunk: any) => {
data += chunk;
});
res.on("end", () => {
resolve(data);
});
}
)
.on("error", (err: any) => {
console.error(`Error downloading file from ${url}: ${err.message}`);
reject(err);
});
});
}
export async function downloadFromUrl(
url: string,
filePath: string
): Promise<void> {
console.log("Downloading file from", url);
return new Promise((resolve, reject) => {
https
.get(url, (response) => {
if (response.statusCode === 200) {
const writeStream = fs.createWriteStream(filePath);
response
.on("end", () => {
writeStream.close();
console.log("file downloaded to", filePath);
resolve();
})
.pipe(writeStream);
} else {
response.resume(); // Consume response to free up memory
reject(new Error(response.statusMessage));
}
})
.on("error", reject);
});
}

File diff suppressed because it is too large Load diff

View file

@ -1,12 +1,13 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es2020",
"lib": ["es2020"],
"outDir": "out",
"sourceMap": true,
"strict": true,
"rootDir": "src"
},
"exclude": ["node_modules", ".vscode-test"]
"compilerOptions": {
"module": "commonjs",
"target": "es2020",
"lib": ["es2020"],
"outDir": "out",
"sourceMap": true,
"strict": true,
"rootDir": "src",
"resolveJsonModule": true
},
"exclude": ["node_modules", ".vscode-test"]
}