Grayscale is a small compiled language that is still in development but promises
a simple approach to programming, taking syntactical inspiration from Go and Lua
(I think). I wanted a break from Rust and a chance to work with something less
familiar.
In this post, I'll walk through how I got it running in Neovim, what the
language server can do right now, and where I think the language still needs
work for editor tooling to feel solid. I'll mostly show the Neovim side, but Zed
and VS Code support exists too but is not documented here.
Setting up file support
The demos will use changes in my grayls
and tree-sitter-gray forks.
Writing the queries and minor refactoring was handled with coding agents.
The first step was telling Neovim that .gray and .grayscale files belong to
the gray filetype. That way ,tree-sitter and the language server know when
to attach to the buffer.
The current language server uses Node but I wanted to run a native binary
directly instead of relying on a separate runtime, that drains the battery too
quick.
For diagnostics and formatting to work, the gray CLI also needs to be on
$PATH. grayls shells out to gray check and gray fmt.
Formatting and diagnostics
Formatting (handled by conform.nvim) falls back to the language server,
grayls which type-checks before formatting. This means formatting can fail on
invalid code, and it can be a bit slow on cold starts:
Diagnostics come from gray check. I kept them simple to avoid noisy virtual
text (unless it's an error).
lua
1vim.diagnostic.config({2 signs ={ priority =9999, severity ={ min ="WARN", max ="ERROR"}},3 underline ={ severity ={ min ="HINT", max ="ERROR"}},4 virtual_lines =false,5 virtual_text ={6 current_line =true,7 severity ={ min ="ERROR", max ="ERROR"},8},9 update_in_insert =false,10})
So what changed ?
This fork adds the native entry point, a larger LSP surface, workspace indexing,
and tests around those features.
The upstream server currently focuses on the core basics: diagnostics,
completion, hover, go-to definition, and the Node-based server entry. My fork
keeps that Node path, but builds a lot more on top of it.
Here are the changes I made:
Support for document symbols, references, rename with prepareRename,
formatting through gray fmt, signature help, inlay hints, semantic tokens,
code actions, document highlight, folding and selection ranges, and workspace
symbols. Most of the code lives under
src/features/
in the fork.
A shared, protocol-neutral core - Instead of tying everything to
vscode-languageserver, I moved shared shapes into
src/types.ts
and kept the feature modules reusable. The Node server in
src/server.ts
still exists, but it now wires into the same feature set as the native path.
A native scriptc binary.src/native.ts,
which implements the JSON-RPC/LSP stdio flow directly. That lets scriptc
compile GrayLS into a standalone binary without dragging along the Node
language-server runtime boundary.
Better symbol handling - Hover and definition used to be easier to confuse on
locals and parameters. A few changes made this more position and scope aware,
so they resolve the symbol you're actually on instead of just the first match.
Workspace indexing - Top-level definition, references, rename, and workspace
symbol search now work across indexed .gray files. I also had to defer
indexing so it wouldn't block initialize, which made startup feel much
better.
Diagnostics and test UX - These come from gray check output. I also added
inlay hints for diagnostics and test status, so feedback stays localized to
the code.
Getting richer editor tooling
This is the part I care about most, getting a language to "work in Neovim" is
one thing. Making it feel good is another.
A few areas still need attention:
Compiler-backed tooling - A lot of LSP features right now are careful
heuristics. That's fine for testing, but hover, completion, rename, and
semantic tokens will get much better when they can lean on richer compiler or
type information.
Stable diagnostics output - We currently depend on gray check output, but
tooling will get easier when the compiler has a stable, structured interface
for diagnostics and symbols.
Module and import resolution - Cross-file features work through indexing, but
real module awareness is still limited. As projects grow, editor features need
to understand imports, packages, and symbol ownership more deeply.
Formatter ergonomics - gray fmt being in-place and type-check-first is
understandable, but it makes editor integration less smooth. A
stdin/stdout mode or a format mode that can work on incomplete buffers
would help a lot.
Grammar coverage - The highlighting is good for a start, but it still needs
more editor-facing queries like folds, indents, injections, and locals. Those
are the kinds of files that make a language feel native in an editor.
Benchmark: Node server vs native binary
A small naive benchmark comparing the Node server (node out/server.js --stdio)
against the native scriptc binary (out/grayls --stdio). Same machine, same
main.gray, Neovim-like LSP session, 3 runs with the mean shown.
All the latency numbers are grouped into one benchmark and all the resource
numbers into the next.
The native binary was faster across the measured requests, including the 10×
edit+hover burst, and it stayed much lighter on memory and CPU. But to be
honest, the major win for me was losing node. Tested against grayc v0.14.1:
benchmark
ms
—LSP latency by implementation (ms)
initialize — native (scriptc)
0.0
initialize — server.js (Node)
0.0
hover — native (scriptc)
0.0
hover — server.js (Node)
0.0
completion — native (scriptc)
0.0
completion — server.js (Node)
0.0
member completion — native (scriptc)
0.0
member completion — server.js (Node)
0.0
definition — native (scriptc)
0.0
definition — server.js (Node)
0.0
document symbols — native (scriptc)
0.0
document symbols — server.js (Node)
0.0
references — native (scriptc)
0.0
references — server.js (Node)
0.0
inlay hints — native (scriptc)
0.0
inlay hints — server.js (Node)
0.0
formatting — native (scriptc)
0.0
formatting — server.js (Node)
0.0
edit burst 10x — native (scriptc)
0.0
edit burst 10x — server.js (Node)
0.0
lower is better★ initialize — native (scriptc)
Summary
initialize — native (scriptc) leads at 2.8 ms.
170.1× faster than edit burst 10x — server.js (Node) (476.2).
20 entries compared (476.2 – 2.8).
benchmark
—Resource usage by implementation
peak RSS (MB) — native (scriptc)
0.00
peak RSS (MB) — server.js (Node)
0.00
average RSS (MB) — native (scriptc)
0.00
average RSS (MB) — server.js (Node)
0.00
CPU time (s) — native (scriptc)
0.00
CPU time (s) — server.js (Node)
0.00
lower is better★ CPU time (s) — native (scriptc)
Summary
CPU time (s) — native (scriptc) leads at 0.43.
239.5× faster than peak RSS (MB) — server.js (Node) (102.97).