Editor support
Lingua Tungga ships a tree-sitter grammar and integrations for VS Code, Zed, Neovim, Helix, and Emacs. The language server is lt lsp over stdio.
Everything here is built on two things that already exist in the compiler:
editors/tree-sitter-lingua-tungga— the grammar and highlight queries.lt lsp— diagnostics, hover, go-to-definition, references, completion, signature help, document/workspace symbols, highlights, formatting, rename and import quick fixes over stdio.lt fmt— formatting.
The grammar lives in this workspace so the same corpus the conformance suite
runs can be parsed by it (scripts/grammar-drift.sh).
Status. Verified on the development machine (VS Code 1.123, Zed 1.30, Neovim 0.12.7 headless):
- Grammar generates with tree-sitter 0.27.2,
scripts/grammar-drift.shparses 114 files (1 documented exception) and every query compiles.- The VS Code extension compiles (
tsc), packages (vsce), activates on a.ltfile, spawnslt lsp --stdio, and the TextMate grammar tokenizesexamples/words.ltinto 29 scopes when run through vscode-textmate.- Neovim 0.12.7 sets
filetype=lingua-tungga, startslt lsponce per project, and answersprepareRename(verified headless; highlighting needs a parser that was not built in that run).- Zed 1.30 loads the language and instantiates the grammar in a throwaway data directory:
extensions updated. loading 2, no query errors. Highlighting is therefore live; the language server is not (see below).- Helix and Emacs were not launched at all; their files are conventional but unrun.
ltmust be onPATHfor every editor below. Eithercargo install --path crates/lt-clior export the built binary:export PATH="$PWD/target/release:$PATH".
tree-sitter grammar
cd editors/tree-sitter-lingua-tungga
npm install
npx tree-sitter generate # writes src/parser.c (not committed)
Drift check against the repository corpus (conformance, examples, playground, bench):
scripts/grammar-drift.sh # parses every *.lt and fails on ERROR nodes
The script uses a global tree-sitter if present, otherwise
editors/tree-sitter-lingua-tungga/node_modules/.bin/tree-sitter, and skips
with a message when neither exists (so CI without node still passes). Files
that the grammar cannot parse yet are listed with their reason in
editors/tree-sitter-lingua-tungga/known-failures.txt; that list must stay
short and explained.
Notes and known gaps:
- Lingua Tungga has contextual keywords:
from,to,inandasare legal field/function/binding names (tests/conformance/keywords.lt). The grammar therefore does not setword: $ => $.identifier; tree-sitter’s state-dependent lexer resolves the ambiguity. If a corpus file fails to parse, that is the first thing to adjust. - JSX children are expression children in braces (
<Label value="x">{x}</Label>), not raw expressions. - Template strings (
\a ${b}`) and tagged templates (``tag…``) have separate rules; interpolations are re-parsed by the same grammar throughinjections.scm`. - Newlines end statements. The compiler stops a
returnvalue and a statement at a line break; tree-sitter has no newline token, sox = 100followed by a line starting with[parses as an index expression. This is whytests/conformance/closures.ltis inknown-failures.txt. A proper fix needs an external scanner that makes newlines significant. playground/contains deliberate syntax-error cases; the drift script parses them too, so a file that is meant to fail may need an allowlist.
VS Code
cd editors/vscode
npm install
npm run compile
code --extensionDevelopmentPath="$PWD" # or: npx vsce package
Provides: TextMate highlighting, snippets, and the LSP client (lt lsp), so
completion, hover, go-to-definition, references, rename, import quick fixes and
symbols come from the server. Formatting comes from the server
(textDocument/formatting), so format-on-save needs no external command.
Settings: linguaTungga.server.path (default lt),
linguaTungga.trace.server.
Verified here: npm run compile, npx vsce package, and launching with
--extensionDevelopmentPath activates the extension (onLanguage:lingua-tungga)
and spawns lt lsp --stdio. Still worth a human check: open a .lt file from
examples/, confirm colours, hover a binding, F12 on a struct/function name,
and Format Document.
Zed
Zed clones grammars from a repository root, so publish
editors/tree-sitter-lingua-tungga as its own repo
(gntrees/tree-sitter-lingua-tungga) or split it:
git subtree split --prefix editors/tree-sitter-lingua-tungga -b ts-lingua-tungga
Point [grammars.lingua_tungga] in extension.toml at that repo and a commit
SHA, then install it as a dev extension (zed: install dev extension) and
choose the editors/zed directory.
Two details that cost real time when wiring it by hand:
-
The grammar key is
lingua_tungga, notlingua-tungga. Zed looks up the exported symboltree_sitter_<key>in the compiled wasm, and dashes cannot appear in a C symbol.config.tomlmust saygrammar = "lingua_tungga"and the wasm must begrammars/lingua_tungga.wasm. -
tree-sitter build --wasm(CLI 0.27) fails withFailed to run wasi-sdk clang. Build it directly instead:cd editors/tree-sitter-lingua-tungga && npx tree-sitter generate ~/.cache/tree-sitter/wasi-sdk/bin/clang \ --target=wasm32-wasip1 -std=c11 -O2 -fPIC -fno-exceptions -I src \ -shared -nostartfiles -Wl,--no-entry -Wl,--export=tree_sitter_lingua_tungga \ -o grammars/lingua_tungga.wasm src/parser.c
Language server. src/lib.rs is the Rust half: it answers
language_server_command with lt lsp (resolved through worktree.which, so
PATH must contain lt; an explicit lsp.lingua-tungga.binary.path in
settings overrides it). Build it:
rustup target add wasm32-wasip2
cd editors/zed && cargo build --release --target wasm32-wasip2
cp target/wasm32-wasip2/release/lingua_tungga.wasm extension.wasm
scripts/zed-dev-extension.sh does all of it: snapshots the grammar (including
the generated src/parser.c) into a local git repo under out/zed-grammar,
copies the crate sources and languages/ into out/zed-extension, and points
its extension.toml at that repo. Install out/zed-extension with
zed: install dev extension — Zed then compiles both the Rust crate and the
grammar itself, which is why the crate sources and src/parser.c must be in
those directories.
Do not copy the extension into
~/.local/share/zed/extensions/installed/ by hand: that loads the language and
grammar but not the Rust lib, so no server starts and nothing is logged.
Status: the crate compiles and exports language-server-command, but the
server was not observed starting here. Copying the extension into a
throwaway extensions/installed/ directory loads the language and grammar but
not the Rust lib (no lt lsp process, and no error either), because only the
UI’s install path registers the lib. Use zed: install dev extension once to
verify; if it fails, Zed’s log (zed: open log) now names the reason.
Without the server Zed still gives highlighting, brackets and outline. For hover/definition without extra setup, use VS Code.
Verify: zed <file>.lt → the tab shows Lingua Tungga, ctrl-shift-o lists
functions/structs, and the log (zed: open log) has no failed to load language.
Neovim
The plugin directory is a normal runtimepath entry:
-- lazy.nvim
{ dir = "path/to/lingua-tungga/editors/neovim" }
-- or, without a plugin manager
vim.opt.runtimepath:append("path/to/lingua-tungga/editors/neovim")
It registers the .lt filetype, maps the tree-sitter language name, starts
lt lsp (root markers: lt.lock, vendor, .git), and adds buffer-local K
(hover), gd (definition) and <leader>lf (lt fmt).
The ftplugin file is ftplugin/lingua-tungga.lua, matching the filetype.
It used to be lingua_tungga.lua, which Neovim never loads for a dashed
filetype, so the server silently never started.
Headless check (no parser needed, proves the LSP half):
nvim --headless -u NONE \
-c 'set rtp+=path/to/lingua-tungga/editors/neovim' \
-c 'edit main.lt' \
-c 'lua vim.wait(15000, function() return #vim.lsp.get_clients({bufnr=0}) > 0 end, 100)' \
-c 'lua print(vim.bo.filetype, #vim.lsp.get_clients({bufnr=0}))' \
-c 'qa!'
lingua-tungga 1 means the filetype was detected and the client attached.
Highlighting needs a parser built from the grammar. With nvim-treesitter:
require("nvim-treesitter.parsers").lingua_tungga = {
install_info = {
url = "https://github.com/gntrees/tree-sitter-lingua-tungga",
files = { "src/parser.c" },
},
}
Verify: :set ft? shows lingua-tungga, :Inspect shows treesitter captures,
:checkhealth vim.lsp lists lingua_tungga, K on a binding shows its type.
Helix
Append editors/helix/languages.toml to ~/.config/helix/languages.toml,
copy editors/helix/runtime/queries/lingua-tungga to
~/.config/helix/runtime/queries/lingua-tungga, and build the grammar:
cd editors/tree-sitter-lingua-tungga && npm install && npx tree-sitter generate
hx --grammar build editors/tree-sitter-lingua-tungga
Verify: hx examples/words.lt, then :lsp-workspace-symbol/hover (space k)
and gd.
Emacs
(add-to-list 'load-path "path/to/lingua-tungga/editors/emacs")
(require 'lingua-tungga-mode)
(add-hook 'lingua-tungga-mode-hook #'eglot-ensure)
Install the grammar once from Emacs 29+:
(add-to-list 'treesit-language-source-alist
'(lingua-tungga "https://github.com/gntrees/tree-sitter-lingua-tungga"))
M-x treesit-install-language-grammar RET lingua-tungga RET
eglot-server-programs is extended with ("lt" "lsp") when Eglot loads.
Verify: open a .lt file, M-x treesit-explore-mode, hover with eldoc,
M-x xref-find-definitions.
What is missing
- Helix and Emacs have never been launched. Their files and instructions exist here, but treat their “Verify” lines as a checklist, not as a claim. Neovim and VS Code have been run; see the status box above.
lt lspanalyses the graph reachable from the file the editor opened. A file that nothing imports, and that imports nothing, is checked on its own, so a name living in a module outside that graph has no quick fix to offer.- Rename covers functions, structs, enums, bindings and locals. Struct fields, enum variants and import aliases are deliberately rejected instead of being renamed partially.
- No
semanticTokens,inlayHint,documentLink(URL imports are not clickable) or workspace-wide diagnostics yet. - Sync is full-text on every change, debounced by 150 ms on a worker thread; no
incremental
contentChangesranges. - Grammar and queries are shared by copy, not by symlink, because not every
editor can follow links outside its runtime directory. Update
editors/tree-sitter-lingua-tungga/queriesfirst, then copy.