Esc
Start typing to search...

Language Server & Editor Setup

Keel provides IDE support through the Language Server Protocol (LSP) and tree-sitter grammar for syntax highlighting.

Language Server Features

The Keel Language Server provides:

FeatureDescription
DiagnosticsLex and parse 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, type aliases, let bindings
Workspace symbolsSearch across all .kl files in the workspace
Folding rangesFunctions, case/if expressions, modules, enums, block comments

Tree-Sitter Grammar

The keel-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

VS Code / Positron

The keel-vscode extension provides full IDE support including tree-sitter syntax highlighting, LSP features, code formatting, REPL integration, Jupyter notebooks, and data science features.

See the VS Code & Positron page for installation and configuration.

Helix

Helix has built-in support for tree-sitter grammars. Add the following to ~/.config/helix/languages.toml:

[[language]]
name = "keel"
scope = "source.kl"
injection-regex = "keel"
file-types = ["kl"]
comment-token = "--"
indent = { tab-width = 2, unit = "  " }
language-servers = ["keel-lsp"]
roots = ["keel.toml"]

[language.auto-pairs]
'(' = ')'
'{' = '}'
'[' = ']'
'"' = '"'

[[grammar]]
name = "keel"
source = { git = "https://codeberg.org/Keel/keel-tree-sitter", rev = "main" }

[language-server.kl-lsp]
command = "keel"
args = ["lsp"]

Then fetch and build the grammar:

helix --grammar fetch
helix --grammar build

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

[language-server.kl-lsp]
command = "keel-lsp"

Zed

Install the Keel extension from the Zed Extensions panel, or see keel-zed-extension for manual installation.

The extension provides:

  • Syntax highlighting via tree-sitter
  • Auto-indentation — Smart indent/dedent for functions, modules, case expressions
  • Format on save via keel-fmt
  • Comment support — Line (--) and block ({- -}) comments
  • Symbol navigation — Tags for functions, types, and modules

LSP support is not yet available in the Zed extension.

Neovim

Tree-sitter Setup

Add Keel to your nvim-treesitter configuration:

local parser_config = require("nvim-treesitter.parsers").get_parser_configs()

parser_config.kl = {
  install_info = {
    url = "https://codeberg.org/Keel/keel-tree-sitter",
    files = { "src/parser.c" },
    branch = "main",
  },
  filetype = "keel",
}

vim.filetype.add({
  extension = {
    kl = "keel",
  },
})

Then install the parser:

:TSInstall keel

LSP Setup

Using the unified CLI (recommended):

vim.api.nvim_create_autocmd("FileType", {
  pattern = "keel",
  callback = function()
    vim.lsp.start({ name = "keel-lsp", cmd = { "keel", "lsp" } })
  end,
})

Or using the standalone keel-lsp binary:

local lspconfig = require("lspconfig")
local configs = require("lspconfig.configs")

if not configs.keel_lsp then
  configs.keel_lsp = {
    default_config = {
      cmd = { "keel-lsp" },
      filetypes = { "keel" },
      root_dir = lspconfig.util.root_pattern("keel.toml", ".git"),
      settings = {},
    },
  }
end

lspconfig.keel_lsp.setup({})

Emacs

Emacs support is planned for a future release. Contributions welcome!

Building from Source

git clone https://codeberg.org/Keel/keel-cli
cd keel-cli
cargo install --path .

This provides keel lsp along with the formatter, REPL, and runner.

Standalone Language Server

git clone https://codeberg.org/Keel/keel-lsp
cd keel-lsp
cargo build --release

The binary will be at target/release/keel-lsp. Add it to your PATH.

Tree-sitter Grammar

git clone https://codeberg.org/Keel/keel-tree-sitter
cd keel-tree-sitter
tree-sitter generate

Using with Nix

If you use Nix, keel lsp and tree-sitter support are included in the keel-cli flake:

nix develop git+https://codeberg.org/Keel/keel-cli

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