Language Server
LSP features and how to set it up in your editor.
Features
The Loon language server speaks the standard Language Server Protocol, so it works with any editor that has LSP support. Here is what you get out of the box.
Diagnostics
Real-time type errors and warnings as you type.
Hover Types
Hover over any expression to see its inferred type.
Go to Definition
Jump to the definition of any binding or function.
Completions
Context-aware suggestions for names, keywords, and builtins.
Inlay Hints
Inline type annotations displayed next to let bindings and function parameters.
VS Code Setup
The easiest path. Install the Loon extension from the VS Code marketplace and you are done. The extension handles starting the language server automatically, so there is nothing else to configure.
SHELL
code --install-extension loon-lang.loon-vscodeNeovim Setup
Neovim has excellent LSP support built in. Add this to your config and Loon files will get full language server features as soon as you open them.
LUA
vim.api.nvim_create_autocmd('FileType', {
pattern = 'loon',
callback = function()
vim.lsp.start({
name = 'loon',
cmd = { 'loon', 'lsp' },
root_dir = vim.fs.dirname(
vim.fs.find({ 'main.loon' }, { upward = true })[1]
),
}})
end,
}})Set filetype detection with: vim.filetype.add({ extension = { loon = 'loon' } })
Generic LSP Setup
If you use a different editor, you can still get full LSP support as long as it has an LSP client. Point it at the Loon binary with these settings.
Command
loon lsp
Transport
stdio (stdin/stdout)
File types
.loon
The server communicates over standard input/output using the LSP JSON-RPC protocol. No special flags or initialization options are required.