On this page
Language Server & Editor Setup
Halyard provides IDE support through the Language Server Protocol (LSP) and tree-sitter grammar for syntax highlighting.
Language Server Features
The Halyard Language Server provides:
| Feature | Description |
|---|---|
| Diagnostics | Lex, parse, name and type errors with accurate source positions |
| Completion | Variables, functions, enums, modules, keywords, type signatures, doc comments; dot-completion for stdlib and user modules |
| Advanced completions | File paths, pattern matching, imports, record fields, function args, type annotations, dict keys |
| Go-to-definition | Jump to declarations within files |
| Find references | Locate all occurrences of a symbol in the current file |
| Rename | Rename a symbol and all its references (with validation) |
| Hover | Type signatures, stdlib documentation with examples, user doc comments, module overviews |
| Signature help | Parameter information when calling functions |
| Semantic tokens | Parser-driven syntax highlighting (keywords, types, strings, numbers, operators) |
| Code lens | Reference counts displayed above declarations |
| Document symbols | Functions, enums, modules, newtypes, let bindings |
| Workspace symbols | Search across all .hly files in the workspace |
| Folding ranges | Functions, case/if expressions, modules, enums, block comments |
Tree-Sitter Grammar
The halyard-tree-sitter grammar provides syntax highlighting for:
- Keywords, functions, types, constructors
- Operators including pipes (
|>) and composition (>>) - Pattern matching syntax
- Comments (line
--and block{- -})
Editor Setup
Helix
Helix has built-in support for tree-sitter grammars. Add the following to ~/.config/helix/languages.toml:
[[language]]
name = "halyard"
scope = "source.hly"
injection-regex = "halyard"
file-types = ["hly"]
comment-token = "--"
indent = { tab-width = 2, unit = " " }
language-servers = ["halyard-lsp"]
roots = ["halyard.toml"]
[language.auto-pairs]
'(' = ')'
'{' = '}'
'[' = ']'
'"' = '"'
[[grammar]]
name = "halyard"
source = { git = "https://codeberg.org/halyard/halyard-tree-sitter", rev = "main" }
[language-server.hly-lsp]
command = "halyard"
args = ["lsp"]
Then fetch and build the grammar:
helix --grammar fetch
helix --grammar build
If using the standalone halyard-lsp binary instead of the unified CLI:
[language-server.hly-lsp]
command = "halyard-lsp"
Neovim
Tree-sitter Setup
Add Halyard to your nvim-treesitter configuration:
local parser_config = require("nvim-treesitter.parsers").get_parser_configs()
parser_config.hly = {
install_info = {
url = "https://codeberg.org/halyard/halyard-tree-sitter",
files = { "src/parser.c" },
branch = "main",
},
filetype = "halyard",
}
vim.filetype.add({
extension = {
hly = "halyard",
},
})
Then install the parser:
:TSInstall halyard
LSP Setup
Using the unified CLI (recommended):
vim.api.nvim_create_autocmd("FileType", {
pattern = "halyard",
callback = function()
vim.lsp.start({ name = "halyard-lsp", cmd = { "halyard", "lsp" } })
end,
})
Or using the standalone halyard-lsp binary:
local lspconfig = require("lspconfig")
local configs = require("lspconfig.configs")
if not configs.halyard_lsp then
configs.halyard_lsp = {
default_config = {
cmd = { "halyard-lsp" },
filetypes = { "halyard" },
root_dir = lspconfig.util.root_pattern("halyard.toml", ".git"),
settings = {},
},
}
end
lspconfig.halyard_lsp.setup({})
Emacs
Emacs support is planned for a future release. Contributions welcome!
Building from Source
Recommended: Unified CLI
git clone https://codeberg.org/halyard/halyard-cli.git
cd halyard-cli
cargo install --path .
This provides halyard lsp along with the formatter, REPL, and runner.
Standalone Language Server
git clone https://codeberg.org/halyard/halyard-lsp.git
cd halyard-lsp
cargo build --release
The binary will be at target/release/halyard-lsp. Add it to your PATH.
Tree-sitter Grammar
git clone https://codeberg.org/halyard/halyard-tree-sitter.git
cd halyard-tree-sitter
tree-sitter generate
Using with Nix
If you use Nix, halyard lsp and tree-sitter support are included in the halyard-cli flake:
nix develop git+https://codeberg.org/halyard/halyard-cli
This provides a development shell with all tools pre-configured.
Related Projects
- halyard-cli — Unified CLI (language server, formatter, REPL, runner)
- halyard-lsp — Standalone language server
- halyard-jupyter-kernel — Jupyter kernel for Halyard
- halyard-tree-sitter — Tree-sitter grammar