Skip to content

Commit 552683b

Browse files
committed
Merge BlockstreamResearch#148: VSCode extension with LSP support
1c11594 Update project configuration and README (Volodymyr Herashchenko) bb2d30f Add server discovery and verbose notification (Volodymyr Herashchenko) b59ed7e Add main files for LSP functionality support (Volodymyr Herashchenko) Pull request description: This pull request introduces optional support for the SimplicityHL language server, which was discussed in BlockstreamResearch#147. Essentially, it works like this: - When opening a `.simf` or `.wit` file, the language server starts automatically. - If the language server is not found in `PATH` or other common locations, the extension offers to install it. - Users may dismiss this notification by selecting **“Don't show again”**, after which it will no longer appear. Also, some additional changes have been made: - Updated the **README** to describe and showcase the capabilities of the language server. - Changed the language identifier in `package.json` from `simfony` to `simplicityhl` for both `.simf` and `.wit` files, and added the required dependencies. - Added `esbuild.js` to bundle Typescript files. ACKs for top commit: apoelstra: ACK 1c11594; successfully ran local tests Tree-SHA512: e4f72dd0967f0e625ac294a74b0cf8e89bd6cb4ef8b608a2dbb4fead6040e25119ee8783634213934be6965424e39ac807b82a31e9f354025e0f38bd61379594
2 parents e68e1c6 + 1c11594 commit 552683b

File tree

9 files changed

+4478
-354
lines changed

9 files changed

+4478
-354
lines changed

vscode/.gitignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
# client executables files
3+
node_modules/
4+
out/
5+
6+
.pnpm-debug.log
7+
8+
*.ast
9+
dist/
10+
11+
# vscode package
12+
*.vsix
13+
14+
# lock files
15+
Cargo.lock
16+
**/pnpm-lock.yaml

vscode/.vscodeignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@ node_modules/
33
.git/
44
.gitignore
55
npm-debug.log
6-
*.ts
6+
**/*.ts
77
*.map
8+
tsconfig.json
9+
.github
810
test/
911
tests/
1012
README.md
13+
esbuild.js
1114
bitcoind-tests/
1215
flake.*
1316
Cargo.*

vscode/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@ SimplicityHL is a high-level language for writing Simplicity smart contracts. Si
1111
- Syntax highlighting for .simf and .wit files
1212
- Basic language configuration (brackets, comments)
1313

14+
Also, you can install the [SimplicityHL language server](https://github.com/distributed-lab/simplicityhl-lsp), which enables several features:
15+
- Error diagnostics
16+
![diagnostics](https://github.com/user-attachments/assets/54315645-464b-40c3-bb72-c6e8c4bc0ad5)
17+
18+
- Completion of user-defined functions and jets
19+
![completion](https://github.com/user-attachments/assets/bbc2b9de-c286-4d31-b47e-ac95885f8916)
20+
21+
22+
23+
1424
### Development
1525

1626
To install the extension manually or hack on the source code see [development.md](docs/development.md)

vscode/esbuild.js

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
const esbuild = require("esbuild");
2+
3+
const production = process.argv.includes("--production");
4+
const watch = process.argv.includes("--watch");
5+
6+
async function main() {
7+
const ctx = await esbuild.context({
8+
entryPoints: ["src/extension.ts"],
9+
bundle: true,
10+
format: "cjs",
11+
minify: production,
12+
sourcemap: !production,
13+
sourcesContent: false,
14+
platform: "node",
15+
outfile: "dist/extension.js",
16+
external: ["vscode"],
17+
logLevel: "warning",
18+
plugins: [
19+
/* add to the end of plugins array */
20+
esbuildProblemMatcherPlugin,
21+
],
22+
});
23+
if (watch) {
24+
await ctx.watch();
25+
} else {
26+
await ctx.rebuild();
27+
await ctx.dispose();
28+
}
29+
}
30+
31+
/**
32+
* @type {import('esbuild').Plugin}
33+
*/
34+
const esbuildProblemMatcherPlugin = {
35+
name: "esbuild-problem-matcher",
36+
37+
setup(build) {
38+
build.onStart(() => {
39+
console.log("[watch] build started");
40+
});
41+
build.onEnd((result) => {
42+
result.errors.forEach(({ text, location }) => {
43+
console.error(`✘ [ERROR] ${text}`);
44+
if (location == null) return;
45+
console.error(
46+
` ${location.file}:${location.line}:${location.column}:`,
47+
);
48+
});
49+
console.log("[watch] build finished");
50+
});
51+
},
52+
};
53+
54+
main().catch((e) => {
55+
console.error(e);
56+
process.exit(1);
57+
});

0 commit comments

Comments
 (0)