Skip to content

Commit

Permalink
extension: first cut of lsp-aware extension
Browse files Browse the repository at this point in the history
This gives the vscode-cue extension the basic capabilities to start an
instance of 'cue lsp'. The code is heavily commented to:

* caveat my poor handle on TypeScript;
* capture my understanding and assumptions about the behaviour of VSCode
  and an extension instance in relation to a running LSP server;
* state opinions/assumptions about error handling style in code.
* state understanding about the best method of handling runtime errors,
  and how/when to report those to the user.

Signed-off-by: Paul Jolly <[email protected]>
Change-Id: I6a1879a603ff2db693f045d26fe14018c01c6332
Dispatch-Trailer: {"type":"trybot","CL":1201041,"patchset":90,"ref":"refs/changes/41/1201041/90","targetBranch":"master"}
  • Loading branch information
myitcv authored and cueckoo committed Nov 29, 2024
1 parent 9bd3235 commit 7cb3c64
Show file tree
Hide file tree
Showing 5 changed files with 795 additions and 43 deletions.
53 changes: 47 additions & 6 deletions extension/extension.cue
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ extension: npm: {
icon: "media/white_circle_128.png"
license: "MIT"
publisher: "cuelangorg"
engines: vscode: ">=1.63.0"
engines: vscode: ">=\(devDependencies["@types/vscode"])"
categories: [
"Programming Languages",
]
activationEvents: []
activationEvents: [
"onLanguage:cue",
]
main: "./dist/main.js"
contributes: {
languages: [{
Expand All @@ -30,10 +32,49 @@ extension: npm: {
path: "./syntaxes/cue.tmLanguage.json"
embeddedLanguages: "source.cue.embedded": "source.cue"
}]
commands: [{
command: "vscode-cue.welcome"
title: "CUE: Welcome"
}]
commands: [
{
command: "vscode-cue.welcome"
title: "CUE: Welcome"
},
{
command: "vscode-cue.startlsp"
title: "CUE: Start CUE LSP"
},
{
command: "vscode-cue.stoplsp"
title: "CUE: Stop CUE LSP"
},
// TODO: see comment above reference to cmdToggleAutoRestartLSP
// reference in activate function.
// {
// command: "vscode-cue.toggleautorestart"
// title: "CUE: Toggle CUE LSP auto-restart"
// },
]

// TODO: switch to being the result of a JSON Schema "export"
configuration: {
type: "object"
title: "CUE"
properties: {
"cue.useLanguageServer": {
type: "boolean"
default: true
description: "Enable cuepls, the language server for CUE."
}
"cue.languageServerCommand": {
type: "array"
default: []
description: "The command to run to launch the language server."
}
"cue.languageServerFlags": {
type: "array"
default: []
description: "Flags like -rpc.trace and -logfile to be used while running the language server."
}
}
}
}
scripts: {
"vscode:prepublish": "cue cmd genPackageJSON && npm run clean && npm run buildpackage"
Expand Down
5 changes: 4 additions & 1 deletion extension/npm.cue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package extension
extension: npm: devDependencies: {
"@types/mocha": "10.0.7"
"@types/node": "22.9.1"
"@types/vscode": "1.63.0"
"@types/vscode": "1.85.0"
"@typescript-eslint/eslint-plugin": "7.14.1"
"@typescript-eslint/parser": "7.11.0"
"@vscode/test-cli": "0.0.9"
Expand All @@ -13,4 +13,7 @@ extension: npm: devDependencies: {
eslint: "8.57.0"
"npm-run-all": "4.1.5"
typescript: "5.4.5"
"@types/which": "3.0.4"
"vscode-languageclient": "9.0.1"
which: "5.0.0"
}
116 changes: 104 additions & 12 deletions extension/package-lock.json

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

44 changes: 39 additions & 5 deletions extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
"license": "MIT",
"publisher": "cuelangorg",
"engines": {
"vscode": ">=1.63.0"
"vscode": ">=1.85.0"
},
"categories": [
"Programming Languages"
],
"activationEvents": [],
"activationEvents": [
"onLanguage:cue"
],
"main": "./dist/main.js",
"contributes": {
"languages": [
Expand Down Expand Up @@ -43,8 +45,37 @@
{
"command": "vscode-cue.welcome",
"title": "CUE: Welcome"
},
{
"command": "vscode-cue.startlsp",
"title": "CUE: Start CUE LSP"
},
{
"command": "vscode-cue.stoplsp",
"title": "CUE: Stop CUE LSP"
}
],
"configuration": {
"type": "object",
"title": "CUE",
"properties": {
"cue.useLanguageServer": {
"type": "boolean",
"default": true,
"description": "Enable cuepls, the language server for CUE."
},
"cue.languageServerCommand": {
"type": "array",
"default": [],
"description": "The command to run to launch the language server."
},
"cue.languageServerFlags": {
"type": "array",
"default": [],
"description": "Flags like -rpc.trace and -logfile to be used while running the language server."
}
}
]
}
},
"scripts": {
"vscode:prepublish": "cue cmd genPackageJSON && npm run clean && npm run buildpackage",
Expand All @@ -67,7 +98,7 @@
"devDependencies": {
"@types/mocha": "10.0.7",
"@types/node": "22.9.1",
"@types/vscode": "1.63.0",
"@types/vscode": "1.85.0",
"@typescript-eslint/eslint-plugin": "7.14.1",
"@typescript-eslint/parser": "7.11.0",
"@vscode/test-cli": "0.0.9",
Expand All @@ -76,6 +107,9 @@
"esbuild": "0.21.5",
"eslint": "8.57.0",
"npm-run-all": "4.1.5",
"typescript": "5.4.5"
"typescript": "5.4.5",
"@types/which": "3.0.4",
"vscode-languageclient": "9.0.1",
"which": "5.0.0"
}
}
Loading

0 comments on commit 7cb3c64

Please sign in to comment.