Skip to content

Commit a8ade8c

Browse files
committed
Updated READMEs and deps. Implemented Go to References.
1 parent 5c250a4 commit a8ade8c

File tree

22 files changed

+2588
-3
lines changed

22 files changed

+2588
-3
lines changed

.github/workflows/lsp-ci.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: LSP CI
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- 'lsp/**'
7+
- '.github/workflows/lsp-ci.yml'
8+
push:
9+
branches:
10+
- master
11+
paths:
12+
- 'lsp/**'
13+
- '.github/workflows/lsp-ci.yml'
14+
15+
jobs:
16+
fmt:
17+
name: Rustfmt (lsp)
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
23+
- name: Setup Rust (stable)
24+
uses: dtolnay/rust-toolchain@stable
25+
with:
26+
components: rustfmt
27+
28+
- name: Check formatting
29+
working-directory: lsp
30+
run: cargo fmt --all -- --check
31+
32+
clippy:
33+
name: Clippy (lsp)
34+
runs-on: ubuntu-latest
35+
steps:
36+
- name: Checkout
37+
uses: actions/checkout@v4
38+
39+
- name: Setup Rust (stable)
40+
uses: dtolnay/rust-toolchain@stable
41+
with:
42+
components: clippy
43+
44+
- name: Run clippy
45+
working-directory: lsp
46+
run: cargo clippy --all-targets --all-features
47+
48+
tests:
49+
name: Tests (lsp)
50+
runs-on: ubuntu-latest
51+
steps:
52+
- name: Checkout
53+
uses: actions/checkout@v4
54+
55+
- name: Setup Rust (stable)
56+
uses: dtolnay/rust-toolchain@stable
57+
58+
- name: Run tests
59+
working-directory: lsp
60+
run: cargo test --all-features -- --nocapture
61+
62+

.github/workflows/publish-lsp.yml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
name: Publish simplicityhl-lsp
2+
3+
on:
4+
push:
5+
tags:
6+
- 'simplicityhl-lsp-v*'
7+
workflow_dispatch: {}
8+
release:
9+
types: [published]
10+
11+
jobs:
12+
lint:
13+
name: Lint (lsp)
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
19+
- name: Setup Rust (stable)
20+
uses: dtolnay/rust-toolchain@stable
21+
with:
22+
components: clippy, rustfmt
23+
24+
- name: Rustfmt check
25+
working-directory: lsp
26+
run: cargo fmt --all -- --check
27+
28+
- name: Clippy
29+
working-directory: lsp
30+
run: cargo clippy --all-targets --all-features -D warnings
31+
32+
tests:
33+
name: Tests (lsp)
34+
runs-on: ubuntu-latest
35+
steps:
36+
- name: Checkout
37+
uses: actions/checkout@v4
38+
39+
- name: Setup Rust (stable)
40+
uses: dtolnay/rust-toolchain@stable
41+
42+
- name: Run tests
43+
working-directory: lsp
44+
run: cargo test --all-features -- --nocapture
45+
46+
publish:
47+
name: Publish simplicityhl-lsp to crates.io
48+
needs: [lint, tests]
49+
runs-on: ubuntu-latest
50+
environment: release
51+
concurrency:
52+
group: publish-lsp-${{ github.ref }}
53+
cancel-in-progress: false
54+
permissions:
55+
id-token: write
56+
contents: read
57+
58+
steps:
59+
- name: Checkout
60+
uses: actions/checkout@v4
61+
62+
- name: Setup Rust (stable)
63+
uses: actions-rust-lang/setup-rust-toolchain@v1
64+
with:
65+
toolchain: stable
66+
67+
- name: Verify tag matches crate version
68+
shell: bash
69+
run: |
70+
set -euo pipefail
71+
TAG="${GITHUB_REF##*/}"
72+
VERSION_TAG="${TAG#simplicityhl-lsp-v}"
73+
CRATE_VERSION=$(cargo metadata --manifest-path lsp/Cargo.toml --no-deps --format-version=1 | jq -r '.packages[] | select(.name=="simplicityhl-lsp").version')
74+
echo "Tag version: $VERSION_TAG"
75+
echo "Crate version: $CRATE_VERSION"
76+
if [ "$VERSION_TAG" != "$CRATE_VERSION" ]; then
77+
echo "Tag version ($VERSION_TAG) does not match crate version ($CRATE_VERSION)"
78+
exit 1
79+
fi
80+
81+
- name: Check package
82+
working-directory: lsp
83+
run: cargo package
84+
85+
- name: Authenticate with crates.io
86+
id: auth
87+
uses: rust-lang/crates-io-auth-action@v1
88+
89+
- name: Publish
90+
env:
91+
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
92+
working-directory: lsp
93+
run: cargo publish
94+
95+

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ getrandom = { version = "0.2", features = ["js"] }
3939

4040
[workspace]
4141
members = ["codegen"]
42-
exclude = ["fuzz", "bitcoind-tests"]
42+
exclude = ["fuzz", "bitcoind-tests", "lsp"]
4343

4444
[lints.clippy]
4545
# Exclude lints we don't think are valuable.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Take a look at the [example programs](https://github.com/BlockstreamResearch/Sim
2020

2121
## MSRV
2222

23-
This crate should compile with any feature combination on **Rust 1.78.0** or higher.
23+
This crate should compile with any feature combination on **Rust 1.79.0** or higher.
2424

2525
## Simplicity's need for a high-level language
2626

clippy.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
msrv = "1.78.0"
1+
msrv = "1.79.0"
22
# We have an error type, `RichError`, of size 144. This is pushing it but probably fine.
33
large-error-threshold = 145
44

lsp/.gitignore

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

lsp/Cargo.toml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
[package]
2+
name = "simplicityhl-lsp"
3+
version = "0.2.0"
4+
edition = "2021"
5+
rust-version = "1.79"
6+
description = "Language Server Protocol (LSP) server for SimplicityHL."
7+
license = "MIT OR Apache-2.0"
8+
repository = "https://github.com/BlockstreamResearch/SimplicityHL"
9+
homepage = "https://github.com/BlockstreamResearch/SimplicityHL/tree/master/lsp"
10+
readme = "README.md"
11+
documentation = "https://docs.rs/simplicityhl-lsp"
12+
keywords = ["simplicity", "liquid", "bitcoin", "elements", "lsp"]
13+
14+
[dependencies]
15+
tokio = { version = "1.47.1", features = ["full"] }
16+
serde_json = "1.0.143"
17+
tower-lsp-server = "0.22.1"
18+
19+
env_logger = "0.11.8"
20+
thiserror = "2.0.17"
21+
22+
ropey = "1.6.1"
23+
miniscript = "12"
24+
simplicityhl = { version = "0.3.0" }
25+
26+
[lints.rust]
27+
unsafe_code = "deny"
28+
unused_variables = "warn"
29+
dead_code = "warn"
30+
unreachable_code = "warn"
31+
unused_mut = "warn"
32+
33+
[lints.clippy]
34+
pedantic = "warn"

lsp/README.md

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# SimplicityHL LSP
2+
3+
Language Server for [SimplicityHL language](https://simplicity-lang.org/).
4+
5+
## Features
6+
7+
- Basic diagnostic for SimplicityHL code
8+
9+
![diagnostics](assets/diagnostics.gif)
10+
11+
- Completions of built-ins, jets and functions
12+
13+
![completion](assets/completion.gif)
14+
15+
- Hover for built-ins, jets and functions, with support of documentation
16+
17+
![hover](assets/hover.gif)
18+
19+
- Go to definition for functions
20+
21+
![goto-definition](assets/goto-definition.gif)
22+
23+
## Installation
24+
25+
Clone this repository and install using Cargo:
26+
27+
```bash
28+
https://github.com/distributed-lab/simplicityhl-lsp
29+
cd simplicityhl-lsp
30+
cargo install --path .
31+
```
32+
33+
## Integration with editors
34+
35+
### Neovim
36+
37+
#### LSP
38+
39+
0. Install `simplicityhl-lsp` to your `PATH`.
40+
41+
1. Include this Lua snippet to your Neovim config:
42+
43+
```lua
44+
vim.filetype.add({
45+
extension = {
46+
simf = "simf",
47+
},
48+
})
49+
50+
vim.lsp.config["simplicityhl-lsp"] = { cmd = { "simplicityhl-lsp" }, filetypes = { "simf" }, settings = {} }
51+
vim.lsp.enable("simplicityhl-lsp")
52+
```
53+
54+
2. Open `.simf` file and check that LSP is active ("attached"):
55+
56+
```vim
57+
:checkhealth vim.lsp
58+
```
59+
60+
#### Tree-sitter (Highlighting)
61+
62+
Currently, the Language Server does not provide any syntax highlighting on its own, but you can install tree-sitter for SimplicityHL:
63+
64+
0. Set up the [`nvim-treesitter`](https://github.com/nvim-treesitter/nvim-treesitter/tree/main) plugin.
65+
66+
1. Include this Lua snippet in your Neovim config to register parser:
67+
68+
```lua
69+
vim.api.nvim_create_autocmd("User", {
70+
pattern = "TSUpdate",
71+
callback = function()
72+
require("nvim-treesitter.parsers").simplicityhl = {
73+
install_info = {
74+
url = "https://github.com/distributed-lab/tree-sitter-simplicityhl",
75+
queries = "queries",
76+
},
77+
filetype = "simf",
78+
tier = 0,
79+
}
80+
end,
81+
})
82+
83+
vim.treesitter.language.register("simplicityhl", { "simf" })
84+
85+
vim.api.nvim_create_autocmd("FileType", {
86+
pattern = { "simf" },
87+
callback = function()
88+
vim.treesitter.start()
89+
end,
90+
})
91+
```
92+
93+
2. Restart Neovim and run:
94+
95+
```vim
96+
:TSInstall simplicityhl
97+
```
98+
99+
If everything is working correctly, you should see syntax highlighting in `.simf` files.
100+
101+
**Note:** This method is compatible only with `nvim-treesitter` v0.10 or newer.
102+

lsp/assets/completion.gif

752 KB
Loading

lsp/assets/diagnostics.gif

1.59 MB
Loading

0 commit comments

Comments
 (0)