Skip to content

Commit 3e4ac03

Browse files
Merge pull request #1 from elasticdotventures/feature/lsp-integration
feature/lsp integration
2 parents 04bec9c + cbca631 commit 3e4ac03

36 files changed

+5487
-441
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,7 @@ node_modules
77
logs/
88
context_portal/
99
*~
10+
justlang_lsp.log
11+
scripts/read-*.ts
12+
scripts/test-*.js
13+
*.ignore

.vscode-test.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,8 @@ import { defineConfig } from '@vscode/test-cli';
22

33
export default defineConfig({
44
files: 'out/test/**/*.test.js',
5+
mocha: {
6+
ui: 'bdd',
7+
timeout: 20000,
8+
}
59
});

.vscodeignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,7 @@ vsc-extension-quickstart.md
1212
**/*.map
1313
**/*.ts
1414
**/.vscode-test.*
15+
logs/
16+
context_portal/
17+
**/*~
18+

CLAUDE.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
3+
three repos are provided.
4+
justlang-lsp is the current target repo. it's an existing vscode extension for justlang offering *some* language functionality. i.e. it should properly register the just language
5+
6+
../just-lsp.subrepo is a rust lsp provider, the lsp provider is design for zed editor which also has LSP support but it has never been ported or tested wtih vscode.
7+
8+
../vscode-languageserver-node-just is a heavily documented sample language service provider (code reference)
9+
10+
use sequential thinking mcp tool and context7 to plan the integration of just-lsp.subrepo into justlang-lsp using the vscode-languageserver-node as a reference.
11+
12+
don't re-create files, it's better to copy files and the modify attribution in the header.
13+
14+
develop a plan, then send to orchestrator, use code agents. instruct each code agent session to always run `just test` and validate the new behaviors.
15+
16+
there is a custom packaging script scripts/package.js that is used to include files since we're using pnpm and vsce doesn't support that.
17+
18+
after reviewing the code make a step by step plan, start with making sure you have a plan for detecting if the rust-lsp binary is installed (and for installing it into the tests early, probably first thing)
19+
20+
change name from justlang-lsp.justlang-lsp to promptexecution.justlang-lsp
21+
22+
File renamed without changes.

README.md

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,59 @@
1-
justlang type support for justfile
1+
# JustLang-LSP Extension
22

3-
justfiles can be: justfile, *.just, Justfile (any capitalization), .justfile
3+
## Overview
4+
JustLang-LSP is a Visual Studio Code extension designed to enhance the development experience by providing task automation and integration with JustLang syntax. It supports `Justfile` (any capitalization), `.justfile`, and `*.just` formats. This extension leverages the VS Code API to register commands and task providers, enabling seamless execution of tasks defined in JustLang files.
45

5-
* https://just.systems/man/en/visual-studio-code.html
6+
This extension now includes a language client for the `just-lsp` language server, providing features like completion, diagnostics, and more.
67

8+
## Features
9+
- **Language Server Integration**: Connects to the `just-lsp` language server for advanced language features.
10+
- **Task Provider Integration**: Automatically detects and registers tasks from JustLang files (`Justfile`, `.justfile`, or `*.just`).
11+
- **Command Registration**: Includes a sample command (`justlang-lsp.helloWorld`) for demonstration purposes.
12+
- **Compatibility**: Ensures proper integration with VS Code's command and subscription mechanisms.
13+
- **Syntax Highlighting**: Provides syntax highlighting for JustLang files using TextMate grammar (`syntaxes/just.tmLanguage.yaml`).
14+
- **Language Configuration**: Adds language configuration for JustLang files (`language-configuration.json`), including comments, brackets, and auto-closing pairs.
715

16+
## Requirements
817

18+
This extension requires the `just-lsp` language server to be installed on your system. You can install it by following the instructions in the [just-lsp repository](https://github.com/your-repo/just-lsp).
919

20+
Once installed, you can either add the `just-lsp` executable to your system's `PATH` or specify the path to the executable in your VS Code settings using the `justlang-lsp.server.path` setting.
21+
22+
## How to Use
23+
1. Install the extension in Visual Studio Code.
24+
2. Install the `just-lsp` language server.
25+
3. Open a workspace containing a JustLang file (`Justfile`, `.justfile`, or `*.just`).
26+
4. Run tasks directly from the VS Code task interface.
27+
28+
## Development
29+
### Prerequisites
30+
- Node.js
31+
- TypeScript
32+
- PNPM
33+
- Rust and Cargo
34+
35+
### Setup
36+
1. Clone the repository.
37+
2. Run `pnpm install` to install dependencies.
38+
3. Use `pnpm run compile` to build the extension.
39+
40+
### Testing
41+
Run `npm test` to execute the test suite.
42+
open a justfile
43+
Developer: Inspect Editor Tokens and Scopes
44+
45+
46+
## References
47+
48+
* https://code.visualstudio.com/api/references/contribution-points#contributes.languages
49+
50+
## License
51+
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
52+
53+
54+
### Attribution
55+
Syntax highlighting and language configuration features were adapted from the [wolfmah-vscode.just-syntax](https://github.com/wolfmah-vscode/just-syntax) repository under the Mozilla Public License 2.0 (MPL 2.0). See the [LICENSE](LICENSE) file for details.
56+
57+
## Thanks
58+
* skellock
59+
*

esbuild.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const esbuildProblemMatcherPlugin = {
2626
async function main() {
2727
const ctx = await esbuild.context({
2828
entryPoints: [
29-
'src/extension.ts'
29+
'src/lsp.ts'
3030
],
3131
bundle: true,
3232
format: 'cjs',
@@ -36,6 +36,7 @@ async function main() {
3636
platform: 'node',
3737
outfile: 'dist/extension.js',
3838
external: ['vscode'],
39+
mainFields: ['module', 'main'],
3940
logLevel: 'silent',
4041
plugins: [
4142
/* add to the end of plugins array */

icons/robot.png

19.1 KB
Loading

justfile

Lines changed: 52 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,78 @@
11
# Justfile for building, testing, packaging, and installing the VSCode Justfile LSP provider
22

3+
34
# 🤓 export display for GUI applications, ALWAYS Use this, it is set correctly on init.
4-
DISPLAY:="localhost:10.0"
5+
# TODO: only set $DISPLAY if the env $env:DISPALY
6+
#DISPLAY:="localhost:10.0"
7+
DISPLAY := env("DISPLAY", "localhost:10.0")
58
VSCODE:="~/.dotfiles/vscode.sh"
69

710
EXT_VER := `jq -r .version package.json`
811

12+
bump-patch:
13+
git add -u .
14+
git commit -m "Bump patch version v{{EXT_VER}}"
15+
pnpm version patch
16+
917
run-debug-extension:
1018
pnpm run compile && DISPLAY={{DISPLAY}} pnpm run test
1119

1220
# Build the VSCode extension
1321
build:
1422
. $HOME/.nvm/nvm.sh
15-
pnpm install
1623
pnpm run compile
1724

25+
package-clean:
26+
rm -rf out && pnpm run compile-tests
27+
1828
# Test the VSCode extension
1929
test:
20-
# this will appear on operators screen (useful for debugging)
30+
# Upgrade everything to TypeScript and precompile tests
31+
just build
32+
NODE_OPTIONS='--import=tsx' pnpm exec mocha ./src/test/language-configuration-accessibility.test.ts
33+
pnpm run compile-tests || (echo "Precompiled tests failed. Skipping extension host tests." && exit 1)
34+
# Run extension host tests only if precompiled tests pass
2135
just package
22-
just install
23-
export DISPLAY={{DISPLAY}} && pnpm run test
36+
export DISPLAY={{DISPLAY}} && pnpm exec vscode-test
37+
38+
test-lsp:
39+
#!/bin/bash
40+
# MUST BE RUN AS /bin/bash so that {} aren't interpolated by lsp
41+
# THIS WONT WORK: no content header
42+
# echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"capabilities":{}}}' | just-lsp
43+
rm foo || true
44+
echo -e 'Content-Length: 76\r\n\r\n{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"capabilities":{}}}' | just-lsp --log foo
45+
cat foo
2446

2547
# Package the VSCode extension into a .vsix file
2648
package:
2749
. $HOME/.nvm/nvm.sh
2850
pnpm run compile
29-
pnpm install -g @vscode/vsce
30-
vsce package
51+
node scripts/package.js
52+
@just package-check
53+
54+
55+
package-check:
56+
#!/bin/bash
57+
# check if the extension file is less than 1 minute old using {{EXT_VER}}
58+
FILENAME="./justlang-lsp-{{EXT_VER}}.vsix"
59+
if [ -f "$FILENAME" ] && [ $(($(date +%s) - $(stat -c %Y "$FILENAME"))) -lt 60 ]; then \
60+
echo "👍🏻 file $FILENAME"
61+
else \
62+
echo "😭 file $FILENAME missing or too old"; \
63+
fi
64+
65+
66+
package-inspect:
67+
unzip justlang-lsp-{{EXT_VER}}.vsix -d vsix-content
68+
tree vsix-content
69+
@echo "🤔 remember to cleanup ./vsix-content when finished"
70+
3171

3272
# Install the VSCode extension
3373
install:
34-
{{VSCODE}} --install-extension ./vscode-just-lsp-*.vsix
74+
pnpm install
75+
76+
package-install:
77+
{{VSCODE}} --install-extension ./justlang-lsp-{{EXT_VER}}.vsix
78+

language-configuration.json

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
// 1. Comment settings
3+
"comments": {
4+
"lineComment": "#"
5+
},
6+
7+
// 2. Bracket pairs for matching & navigation
8+
"brackets": [
9+
["{", "}"],
10+
["[", "]"],
11+
["(", ")"]
12+
],
13+
14+
// 3. Auto‑closing on typing the open character
15+
"autoClosingPairs": [
16+
{ "open": "{", "close": "}" },
17+
{ "open": "[", "close": "]" },
18+
{ "open": "(", "close": ")" },
19+
{ "open": "\"", "close": "\"" },
20+
{ "open": "'", "close": "'" },
21+
{ "open": "`", "close": "`" }
22+
],
23+
24+
// 4. When you select a region and type an opener, wrap with these pairs
25+
"surroundingPairs": [
26+
{ "open": "{", "close": "}" },
27+
{ "open": "[", "close": "]" },
28+
{ "open": "(", "close": ")" },
29+
{ "open": "\"", "close": "\"" },
30+
{ "open": "'", "close": "'" },
31+
{ "open": "`", "close": "`" }
32+
],
33+
34+
// 5. Define what VS Code considers a “word” for double‑click, etc.
35+
"wordPattern": "(-?\\d*\\.\\d\\w*)|([^\\`\\~\\!\\@\\#\\%\\^\\&\\*\\(\\)\\=\\+\\[\\{\\]\\}\\\\\\|\\;\\:\\'\\\",\\.\\<\\>\\/\\?\\s]+)",
36+
37+
// 6. Folding by indentation and region markers
38+
"folding": {
39+
"offSide": true,
40+
"markers": {
41+
"start": "^\\s*#region\\b",
42+
"end": "^\\s*#endregion\\b"
43+
}
44+
}
45+
}

0 commit comments

Comments
 (0)