Skip to content

Commit

Permalink
feat!: Implement plugin as only an LSP client (#100)
Browse files Browse the repository at this point in the history
feat: Support multiple workspaces & individual files
chore!: Upgrade dependencies & require much newer VSCode
feat: Build extension into a single JS file
chore: Update LSP debugging instructions and setup
chore!: Remove unused plugin options
chore!: Rename settings namespace to just "grain"
feat: Add LSP restart command

Co-authored-by: Marcus Roberts <marcus@marcusr.com>
Co-authored-by: Blaine Bublitz <blaine.bublitz@gmail.com>
  • Loading branch information
3 people committed Jun 2, 2022
1 parent 7b82c96 commit 8c12b49
Show file tree
Hide file tree
Showing 31 changed files with 5,808 additions and 2,245 deletions.
6 changes: 0 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,3 @@ node_modules
dist/
*.gr
.DS_Store

# VSCode stuff
*.vsix
editor-extensions/vscode/client/out
editor-extensions/vscode/server/out
editor-extensions/vscode/syntaxes/grain-type.json
3 changes: 3 additions & 0 deletions editor-extensions/vscode/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.vsix
out
syntaxes/grain-type.json
2 changes: 1 addition & 1 deletion editor-extensions/vscode/.prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
node_modules
dist
out/
CHANGELOG.md
1 change: 0 additions & 1 deletion editor-extensions/vscode/.prettierrc.json

This file was deleted.

35 changes: 3 additions & 32 deletions editor-extensions/vscode/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,11 @@
{
"type": "extensionHost",
"request": "launch",
"name": "Launch Client",
"name": "Launch Extension",
"runtimeExecutable": "${execPath}",
"args": ["--extensionDevelopmentPath=${workspaceRoot}"],
"outFiles": ["${workspaceRoot}/client/out/**/*.js"],
"preLaunchTask": {
"type": "npm",
"script": "watch"
}
},
{
"type": "node",
"request": "attach",
"name": "Attach to Server",
"port": 6009,
"restart": true,
"outFiles": ["${workspaceRoot}/server/out/**/*.js"]
},
{
"name": "Language Server E2E Test",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceRoot}",
"--extensionTestsPath=${workspaceRoot}/client/out/test/index",
"${workspaceRoot}/client/testFixture"
],
"outFiles": ["${workspaceRoot}/client/out/test/**/*.js"]
}
],
"compounds": [
{
"name": "Client + Server",
"configurations": ["Launch Client", "Attach to Server"]
"outFiles": ["${workspaceRoot}/out/**/*.js"],
"preLaunchTask": "${defaultBuildTask}"
}
]
}
1 change: 0 additions & 1 deletion editor-extensions/vscode/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"editor.insertSpaces": false,
"tslint.enable": true,
"typescript.tsc.autoDetect": "off",
"typescript.preferences.quoteStyle": "single",
"editor.codeActionsOnSave": {
Expand Down
50 changes: 33 additions & 17 deletions editor-extensions/vscode/.vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,43 @@
"tasks": [
{
"type": "npm",
"script": "compile",
"group": "build",
"presentation": {
"panel": "dedicated",
"reveal": "never"
},
"problemMatcher": ["$tsc"]
},
{
"type": "npm",
"script": "watch",
"isBackground": true,
"script": "esbuild-watch",
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"panel": "dedicated",
"reveal": "never"
},
"problemMatcher": ["$tsc-watch"]
// https://github.com/connor4312/esbuild-problem-matchers/blob/0cd222036a0f0dcccda4df35d094d2882b93ddc1/package.json#L28-L67
"problemMatcher": [
{
"severity": "error",
"applyTo": "closedDocuments",
"source": "esbuild",
"owner": "typescript",
"fileLocation": "relative",
"pattern": [
{
"regexp": "> (.*?):([0-9]+):([0-9]+): (warning|error): (.+)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
],
"background": {
"activeOnStart": true,
"beginsPattern": {
"regexp": "\\[watch\\] build started"
},
"endsPattern": {
"regexp": "\\[watch\\] build finished"
}
}
}
],
"label": "npm: esbuild-watch",
"detail": "npm run esbuild-base -- --sourcemap --watch",
"isBackground": true
}
]
}
26 changes: 12 additions & 14 deletions editor-extensions/vscode/.vscodeignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
.vscode/**
**/*.ts
**/*.map
.vscode/
node_modules/
out/*.js.map
scripts/
src/
test/
.gitignore
**/tsconfig.json
**/tsconfig.base.json
contributing.md
.travis.yml
client/node_modules/**
!client/node_modules/vscode-jsonrpc/**
!client/node_modules/vscode-languageclient/**
!client/node_modules/vscode-languageserver-protocol/**
!client/node_modules/vscode-languageserver-types/**
!client/node_modules/semver/**

.npmrc
.prettierignore
CHANGELOG.md
package-lock.json
tsconfig.json
*.vsix
35 changes: 0 additions & 35 deletions editor-extensions/vscode/README-LSP.md

This file was deleted.

32 changes: 32 additions & 0 deletions editor-extensions/vscode/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# VSCode extension for Grain

The VSCode extension for the [Grain programming language](https://github.com/grain-lang/grain).

**Requires:** vscode 1.67+

## Functionality

This LSP Protocol client provides the the following language features for grain (`.gr`) files:

- Show compilation warnings and errors
- Code lenses
- Hover support

## Running the extension

- Run `npm ci` in this folder.
- Open VSCode inside this folder.
- Switch to the "Run and Debug" pane.
- Select "Launch Extension" from the drop down.
- Press the ▶️ button next to "Launch Extension", which will start a TypeScript watcher and launch a new VSCode instance titled `[Extension Development Host]`.
- The Grain CLI needs to be on your path. If not, set the `cliPath` setting inside the `[Extension Development Host]` instance to the location of your Grain CLI.
- In the `[Extension Development Host]` instance of VSCode, open a document in 'grain' language mode.
- After a code change, you'll likely need to trigger a "Developer: Reload Window" action in the `[Extension Development Host]` instance before the extension will pick up the changes.

## Useful files

- `package.json` - this is the manifest file in which you declare your language support and define
the location of the grammar file that has been copied into your extension.
- `syntaxes/grain.tmLanguage.json` - this is the Text mate grammar file that is used for tokenization.
- `language-configuration.json` - this the language configuration, defining the tokens that are used for
comments and brackets.
Loading

0 comments on commit 8c12b49

Please sign in to comment.