Refingere for VS Code
Language support for .rfn files, from the compiler itself (src/lsp/): errors as you type in
every file of the open folder, the outline, go to definition, hover with a definition's ///
comment, completion, and formatting (Shift+Alt+F, or on every save with "[refingere]": { "editor.formatOnSave": true }) - which only ever moves whitespace, and checks the result still
means the same. It runs on Bun, like the compiler - set
refingere.bunPath if Bun isn't on your PATH.
And syntax highlighting: keywords, definitions, strings and string macros
(#format"... #{ expr } ..."), embedded languages (#SQL {{{ ... }}} is highlighted as SQL,
likewise #HTML, #CSS, #SVG, #JSON, #YAML, #MARKDOWN and #SHELL), attributes, context values
(&stdout), paths, numbers and operators. Also comment toggling (///, /* */), bracket
matching and auto-closing, and the Refingere logo as the file icon for .rfn files (shown by any
file icon theme that doesn't have its own icon for them, like the default Seti).
Unicode symbols
The symbol operators with a Unicode spelling - != <= >= - * / as ≠ ≤ ≥ − ×
÷ - can be switched over as you go:
- As you type: a space typed right after one replaces it (on-type formatting, turned on for
.rfn files; refingere.unicode.replaceAsYouType turns it off).
- Suggestions: each ASCII one gets a faint hint, with a quick fix (Ctrl+.) to replace it
(
refingere.unicode.suggest hides them).
- All at once: Refingere: Use Unicode Symbols replaces every one in the selection, or the
whole file with nothing selected. It's also the
source.useUnicodeSymbols source action, so
"editor.codeActionsOnSave": { "source.useUnicodeSymbols": "explicit" } does it on save.
- Backslash abbreviations:
\ne \le \ge \minus \times \div, the word operators'
\and \or \xor \iff \not, \lambda for λ, \sqrt for √, and \^2 / \_i for
superscripts and subscripts - pick one from the completion list.
Strings, comments and macro bodies are never touched.
Color themes
Refingere Light and Refingere Dark match the docs site's code blocks: keywords in bold
purple, names in indigo, strings and numbers in teal, on the same gray backgrounds. Pick one with
Preferences: Color Theme (Ctrl+K Ctrl+T). They color other languages too, including the ones
embedded in #SQL {{{ ... }}} and friends. The colors are Tailwind's, as the docs use them -
regenerate after the docs' palette changes with bun editors/vscode/build-themes.ts.
Install
Build a .vsix - one file holding the whole extension - and drag it onto VS Code's Extensions
view, or install it from the command line:
bun run vscode:package # from the repository root
code --install-extension editors/vscode/refingere-0.4.0.vsix
Or, while working on the extension itself, bundle its code and link this folder into VS Code's
extensions folder, then reload the window:
bun editors/vscode/build.ts # dist/extension.js and dist/server.js - again after each change
ln -s "$(pwd)/editors/vscode" ~/.vscode/extensions/refingere
Keeping it in sync
The grammar in syntaxes/ is generated from the docs' Keyword Index
(docs/src/lib/index/keywords.ts) - the same word lists the docs site highlights with. After a
keyword, type or embedded language is added to the docs, regenerate it:
bun editors/vscode/build-grammar.ts
grammar.test.ts fails while the committed grammar is out of date.
The language server
src/extension.ts starts the language server, the repository's src/lsp/server.ts, and connects
VS Code to it. bun run vscode:package bundles both into dist/ first (see build.ts), so the
.vsix needs nothing else installed but Bun.