Skip to content
Halyard
Project
Source code on Codeberg (opens in new tab)

Search

Menu

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:

FeatureDescription
DiagnosticsLex, parse, name and type errors with accurate source positions
CompletionVariables, functions, enums, modules, keywords, type signatures, doc comments; dot-completion for stdlib and user modules
Advanced completionsFile paths, pattern matching, imports, record fields, function args, type annotations, dict keys
Go-to-definitionJump to declarations within files
Find referencesLocate all occurrences of a symbol in the current file
RenameRename a symbol and all its references (with validation)
HoverType signatures, stdlib documentation with examples, user doc comments, module overviews
Signature helpParameter information when calling functions
Semantic tokensParser-driven syntax highlighting (keywords, types, strings, numbers, operators)
Code lensReference counts displayed above declarations
Document symbolsFunctions, enums, modules, newtypes, let bindings
Workspace symbolsSearch across all .hly files in the workspace
Folding rangesFunctions, 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:

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:

bash
helix --grammar fetch
helix --grammar build

If using the standalone halyard-lsp binary instead of the unified CLI:

toml
[language-server.hly-lsp]
command = "halyard-lsp"

Neovim

Tree-sitter Setup

Add Halyard to your nvim-treesitter configuration:

lua
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:

vim
:TSInstall halyard

LSP Setup

Using the unified CLI (recommended):

lua
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:

lua
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

bash
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

bash
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

bash
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:

bash
nix develop git+https://codeberg.org/halyard/halyard-cli

This provides a development shell with all tools pre-configured.