Skip to content

Commit 945a5ef

Browse files
authored
New VS Code extension (Work in progress) (#168)
* Dump non-working extension * First pass * No dist * Add license, metadata fixup * Add WIP readme notice
1 parent caf87b7 commit 945a5ef

26 files changed

+1576
-2185
lines changed

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,28 @@ Then, add the following to your Neovim configuration:
8888
vim.lsp.enable('cookbook')
8989
```
9090

91+
### VS Code (Unreleased)
92+
93+
A VS Code extension lives in `editors/vscode`. The extension manages
94+
the `codebook-lsp` binary for you, starts it with the right flags, and exposes a
95+
few configuration toggles (`codebook.binaryPath`, `codebook.enablePrerelease`,
96+
and `codebook.logLevel`).
97+
98+
To try it locally:
99+
100+
```sh
101+
cd editors/vscode
102+
bun install # or npm install
103+
bun run build
104+
bun run package # or npm run package
105+
code --install-extension codebook-vscode-*.vsix
106+
```
107+
108+
Once the extension is installed it will activate automatically for every
109+
supported language.
110+
111+
**Note**: This extension is a work in progress and is not in the Marketplace yet. If you try it out, we'd love feedback!
112+
91113
### Other Editors
92114

93115
Any editor that implements the Language Server Protocol should be compatible with Codebook. To get started, follow the [installation instructions](#installation), then consult your editor's documentation to learn how to configure and enable a new language server. For your reference, the following command starts the server such that it listens on `STDIN` and emits on `STDOUT`:

editors/vscode/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
dist
2+
*.vsix

editors/vscode/.vscodeignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.github/
2+
.gitignore
3+
.vscode/
4+
.vscode-test/
5+
src/
6+
tsconfig.json
7+
bun.lock

editors/vscode/LICENSE

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Copyright 2025 @blopker
2+
3+
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:
4+
5+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6+
7+
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.

editors/vscode/README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Codebook VS Code Extension (Unreleased)
2+
3+
**Note** This extension is a work in progress and is not released on the VS Code marketplace yet. However, it is functional. Follow the Development instructions to install if you'd like to provide feedback!
4+
5+
This extension wires the Codebook language server into VS Code so code-specific
6+
spell check diagnostics and quick fixes appear automatically.
7+
8+
## Features
9+
10+
- Automatically launches `codebook-lsp` for supported languages.
11+
- Downloads, caches, and updates the Codebook language server without requiring any manual installation.
12+
- Supports custom binary locations and optional pre-release builds via
13+
`codebook.*` settings.
14+
15+
## Development
16+
17+
```
18+
cd editors/vscode
19+
bun install # or npm install / pnpm install
20+
bun run build # or npm run build
21+
bun run package # builds dist/ and emits a .vsix via vsce
22+
```
23+
24+
The emitted JavaScript lives in `dist/` and can be loaded into VS Code via the
25+
`Extension Tests / Run Extension` launch configuration or by using the bundled
26+
`vsce` CLI via `bun run package`.
27+
28+
Set `codebook.logLevel` to `debug` to see verbose logs from the language server
29+
inside the `Codebook` output channel.

editors/vscode/bun.lock

Lines changed: 729 additions & 0 deletions
Large diffs are not rendered by default.

editors/vscode/package.json

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
{
2+
"name": "codebook-vscode",
3+
"displayName": "Codebook Spell Checker",
4+
"description": "A fast, code-aware spell checker.",
5+
"version": "0.0.1",
6+
"publisher": "blopker",
7+
"license": "MIT",
8+
"repository": {
9+
"type": "git",
10+
"url": "https://github.com/blopker/codebook"
11+
},
12+
"bugs": {
13+
"url": "https://github.com/blopker/codebook/issues"
14+
},
15+
"homepage": "https://github.com/blopker/codebook",
16+
"engines": {
17+
"vscode": "^1.80.0"
18+
},
19+
"categories": [
20+
"Linters",
21+
"Other"
22+
],
23+
"extensionKind": [
24+
"workspace"
25+
],
26+
"activationEvents": [
27+
"onLanguage:c",
28+
"onLanguage:cpp",
29+
"onLanguage:css",
30+
"onLanguage:elixir",
31+
"onLanguage:go",
32+
"onLanguage:html",
33+
"onLanguage:haskell",
34+
"onLanguage:java",
35+
"onLanguage:javascript",
36+
"onLanguage:latex",
37+
"onLanguage:lua",
38+
"onLanguage:markdown",
39+
"onLanguage:php",
40+
"onLanguage:plaintext",
41+
"onLanguage:python",
42+
"onLanguage:ruby",
43+
"onLanguage:rust",
44+
"onLanguage:toml",
45+
"onLanguage:typescript",
46+
"onLanguage:typst",
47+
"onLanguage:zig",
48+
"onLanguage:csharp"
49+
],
50+
"main": "./dist/extension.js",
51+
"scripts": {
52+
"build": "tsc -p .",
53+
"watch": "tsc -w -p .",
54+
"package": "bun run build && vsce package --no-dependencies",
55+
"publish": "bun run build && vsce publish --no-dependencies"
56+
},
57+
"contributes": {
58+
"commands": [
59+
{
60+
"command": "codebook.restart",
61+
"title": "Codebook: Restart Language Server"
62+
}
63+
],
64+
"configuration": {
65+
"title": "Codebook",
66+
"properties": {
67+
"codebook.binaryPath": {
68+
"type": "string",
69+
"default": "",
70+
"description": "Absolute path to an existing codebook-lsp binary. Leave empty to allow the extension to manage the download."
71+
},
72+
"codebook.enablePrerelease": {
73+
"type": "boolean",
74+
"default": false,
75+
"description": "Allow downloading pre-release builds when managing the language server binary."
76+
},
77+
"codebook.logLevel": {
78+
"type": "string",
79+
"enum": [
80+
"error",
81+
"warn",
82+
"info",
83+
"debug"
84+
],
85+
"default": "info",
86+
"description": "Value assigned to the RUST_LOG environment variable for the language server."
87+
}
88+
}
89+
}
90+
},
91+
"dependencies": {
92+
"@types/adm-zip": "^0.5.7",
93+
"@types/tar": "^6.1.13",
94+
"@types/which": "^3.0.4",
95+
"adm-zip": "^0.5.12",
96+
"tar": "^6.2.1",
97+
"vscode-languageclient": "^9.0.1",
98+
"which": "^4.0.0"
99+
},
100+
"devDependencies": {
101+
"@types/node": "^20.12.7",
102+
"@types/vscode": "^1.80.0",
103+
"@vscode/vsce": "^3.7.0",
104+
"typescript": "^5.4.0"
105+
}
106+
}

0 commit comments

Comments
 (0)