|
| 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 | + |
| 10 | + |
| 11 | +- Completions of built-ins, jets and functions |
| 12 | + |
| 13 | + |
| 14 | + |
| 15 | +- Hover for built-ins, jets and functions, with support of documentation |
| 16 | + |
| 17 | + |
| 18 | + |
| 19 | +- Go to definition for functions |
| 20 | + |
| 21 | + |
| 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 | + |
0 commit comments