Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
120 changes: 117 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ tokio = { version = "1.47.1", features = [
"io-util",
"sync",
] }
serde = { version = "1.0.228", features = ["derive"] }
serde_json = "1.0.143"
# Deserialize-only: the server reads Simplex.toml and never writes it.
toml = { version = "1.1", default-features = false, features = ["parse", "serde"] }
tower-lsp-server = "0.22.1"

env_logger = { version = "0.11.8", default-features = false }
Expand All @@ -30,6 +33,9 @@ miniscript = "12"
simplicityhl = {version = "0.6.0", features = ["docs"]}
nom = "8.0.0"

[dev-dependencies]
tempfile = "3.23.0"

[profile.release]
lto = "thin"
strip = true
Expand Down
62 changes: 61 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,57 @@ Language Server for [SimplicityHL language](https://simplicity-lang.org/).

![goto-definition](assets/goto-definition.gif)

## Configuration

Editors send settings under the `simplicityhl` section. Every field is optional; the
defaults below are what the server uses when a client sends nothing.

```json
{
"simplicityhl": {
"experimentalFeatures": {
"imports": false
},
"project": {
"simplex": {
"enabled": true,
"manifestPath": ""
},
"sourceDirectory": "",
"dependencies": {}
}
}
}
```

- `experimentalFeatures.imports` enables the compiler's unstable `use` / `mod` / `pub`
syntax. It is off by default because the feature is unstable in the compiler itself.
- `project.simplex.enabled` looks for the nearest `Simplex.toml` (or `simplex.toml`)
in the file's ancestors and honours its `build.src_dir` and `[dependencies]`, resolving
path dependencies recursively and locating installed git dependencies under `deps/`.
- `project.simplex.manifestPath` pins an explicit manifest instead of searching. Relative
values resolve from the containing workspace folder. A path that does not exist is
reported as a diagnostic rather than silently ignored.
- `project.sourceDirectory` overrides the package root when there is no manifest, or when
the manifest's `src_dir` is not what the editor should use.
- `project.dependencies` adds import roots by hand. They supplement the manifest and win
on a colliding alias:

```json
{
"std": "../simplicityhl-std/simf",
"math": { "path": "../math/simf", "context": "simf/contracts" }
}
```

The shorthand form maps an alias for the whole package. The detailed form restricts the
mapping to files under `context`, matching how the compiler scopes dependencies per
package.

Configuration changes take effect immediately: the server re-analyses open documents on
`workspace/didChangeConfiguration`, on workspace-folder changes, and when a watched
`.simf` file or Simplex manifest changes on disk.

## Installation

Install Language Server using `cargo`:
Expand All @@ -47,7 +98,16 @@ vim.filetype.add({
},
})

vim.lsp.config["simplicityhl-lsp"] = { cmd = { "simplicityhl-lsp" }, filetypes = { "simf" }, settings = {} }
vim.lsp.config["simplicityhl-lsp"] = {
cmd = { "simplicityhl-lsp" },
filetypes = { "simf" },
settings = {
simplicityhl = {
experimentalFeatures = { imports = true },
project = { simplex = { enabled = true, manifestPath = "" } },
},
},
}
vim.lsp.enable("simplicityhl-lsp")
```

Expand Down
Loading
Loading