Dino compiler: language, formatter, language server, docs, editor support

Compiler in Rust (lexer, parser, checker, C codegen), maps, chars,
dino fmt, dino lsp (diagnostics, formatting, outline, definition,
hover, completion, signature help), docs, examples, VS Code/Vim files.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Your NameandClaude Sonnet 5.5 committed 2026-11-07 23:46:12 +01:00
1 parent 3e2779f447
commit eaf9567a36
117 files changed
+19970

No files matched your search

+111
View File
@@ -0,0 +1,111 @@
# Editor support for Dino
Everything here talks to the compiler itself, so what you see in the editor is exactly what
`dino run` would tell you.
| You get | How |
|---------|-----|
| Syntax colours | a grammar file (VS Code, Neovim, Vim) |
| Errors underlined as you type | the language server, `dino lsp` |
| Format the file (and on save) | the same server, using `dino fmt` |
| Outline, go to definition, hover, completion, parameter hints | the same server (reads the file's names; no type checking) |
First put the `dino` program on your `PATH`:
```text
cargo build --release
cp target/release/dino ~/.local/bin/ # or anywhere on your PATH
```
## VS Code
The extension is in `editors/vscode/`.
```text
cd editors/vscode
npm install # downloads the small language-client library
npx @vscode/vsce package # makes dino-0.1.0.vsix
code --install-extension dino-0.1.0.vsix
```
To try it without installing, open the `editors/vscode` folder in VS Code and press **F5**.
If `dino` is not on your `PATH`, set **Dino: Server Path** in the settings to the full path.
Format-on-save and 4-space indents are switched on for `.dino` files by default.
## Neovim
Put the `vim/` folder on your runtime path to get file detection and colours, for example
(with a plugin manager that takes a local path), or copy the two files:
```text
mkdir -p ~/.config/nvim/syntax ~/.config/nvim/ftdetect
cp vim/syntax/dino.vim ~/.config/nvim/syntax/
cp vim/ftdetect/dino.vim ~/.config/nvim/ftdetect/
```
Then in `init.lua` (Neovim 0.8 or newer):
```lua
vim.api.nvim_create_autocmd("FileType", {
pattern = "dino",
callback = function(args)
vim.lsp.start({
name = "dino",
cmd = { "dino", "lsp" },
root_dir = vim.fs.dirname(args.file),
})
vim.bo.shiftwidth = 4
vim.bo.expandtab = true
end,
})
-- format when saving
vim.api.nvim_create_autocmd("BufWritePre", {
pattern = "*.dino",
callback = function() vim.lsp.buf.format({ async = false }) end,
})
```
Plain Vim gets the colours from the same two files (no language server).
## Helix
Add this to `~/.config/helix/languages.toml`:
```toml
[language-server.dino]
command = "dino"
args = ["lsp"]
[[language]]
name = "dino"
scope = "source.dino"
file-types = ["dino"]
comment-token = "//"
indent = { tab-width = 4, unit = " " }
language-servers = ["dino"]
auto-format = true
```
## Any other editor
Anything that can run a language server works: start `dino lsp` (it speaks the standard
protocol over stdin/stdout) for files ending in `.dino`. It supports diagnostics and
whole-file formatting. The grammar for colours is the TextMate file
`vscode/syntaxes/dino.tmLanguage.json`, which Sublime Text, Zed and many others can read.
## What the server does (and doesn't) do yet
- Checks the file every time you type, including the files it imports (from disk, or from
unsaved changes in other open files). The compiler stops at the first error, so you see
one underline at a time.
- An error inside an imported file is shown at the top of the file that imports it.
- Formats the whole file; a file that doesn't parse is left alone.
- Not yet: hover, go to definition, completion, rename.
## Opcode
Opcode (the C++ editor in `~/Desktop/Porn/Linux/Clean/opcode`) knows Dino out of the box: colours,
`//` comments, snippets, the outline, format with `dino fmt -`, and the language server
(`dino lsp`) for errors, go to definition, hover, completion and parameter hints. It only needs
`dino` on your `PATH` (see the top of this page).
+1
View File
@@ -0,0 +1 @@
autocmd BufRead,BufNewFile *.dino setfiletype dino
+37
View File
@@ -0,0 +1,37 @@
" Vim / Neovim syntax highlighting for Dino
if exists("b:current_syntax")
finish
endif
syn keyword dinoControl if else for in step match return break continue
syn keyword dinoDeclare func var const import struct enum interface pub
syn keyword dinoModifier shared weak
syn keyword dinoConstant true false nil
syn keyword dinoType int float bool char string error map i8 i16 i32 i64 u8 u16 u32 u64 f32 f64
syn match dinoTypeName "\<[A-Z][A-Za-z0-9_]*\>"
syn match dinoNumber "\<[0-9][0-9_]*\(\.[0-9][0-9_]*\)\?\>"
syn match dinoCall "\<[a-z_][A-Za-z0-9_]*\ze\s*("
syn match dinoOperator "=>\|\.\.\|==\|!=\|<=\|>=\|&&\|||\|[-+*/%]=\?\|[<>!?=]"
syn match dinoEscape "\\." contained
syn region dinoInterp matchgroup=dinoInterpEdge start="{" end="}" contained contains=TOP
syn region dinoString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=dinoEscape,dinoInterp
syn match dinoChar "'\(\\.\|[^'\\]\)'"
syn region dinoComment start="/\*" end="\*/"
syn match dinoComment "//.*$"
hi def link dinoControl Conditional
hi def link dinoDeclare Keyword
hi def link dinoModifier StorageClass
hi def link dinoConstant Constant
hi def link dinoType Type
hi def link dinoTypeName Type
hi def link dinoNumber Number
hi def link dinoCall Function
hi def link dinoOperator Operator
hi def link dinoEscape SpecialChar
hi def link dinoInterpEdge Delimiter
hi def link dinoString String
hi def link dinoChar Character
hi def link dinoComment Comment
let b:current_syntax = "dino"
+26
View File
@@ -0,0 +1,26 @@
// Starts `dino lsp` and connects the editor to it. All the work is done by the compiler.
const vscode = require('vscode');
const { LanguageClient } = require('vscode-languageclient/node');
let client;
function activate() {
const command = vscode.workspace.getConfiguration('dino').get('serverPath') || 'dino';
client = new LanguageClient(
'dino',
'Dino Language Server',
{ command, args: ['lsp'] },
{ documentSelector: [{ scheme: 'file', language: 'dino' }] }
);
client.start().catch((err) => {
vscode.window.showErrorMessage(
`Could not start "${command} lsp": ${err.message}. Put the dino program on your PATH or set "dino.serverPath".`
);
});
}
function deactivate() {
return client ? client.stop() : undefined;
}
module.exports = { activate, deactivate };
@@ -0,0 +1,19 @@
{
"comments": { "lineComment": "//", "blockComment": ["/*", "*/"] },
"brackets": [["{", "}"], ["[", "]"], ["(", ")"]],
"autoClosingPairs": [
{ "open": "{", "close": "}" },
{ "open": "[", "close": "]" },
{ "open": "(", "close": ")" },
{ "open": "\"", "close": "\"", "notIn": ["string"] },
{ "open": "'", "close": "'", "notIn": ["string", "comment"] }
],
"surroundingPairs": [["{", "}"], ["[", "]"], ["(", ")"], ["\"", "\""], ["'", "'"]],
"indentationRules": {
"increaseIndentPattern": "[\\{\\[\\(]\\s*(//.*)?$",
"decreaseIndentPattern": "^\\s*[\\}\\]\\)]"
},
"onEnterRules": [
{ "beforeText": "^\\s*//.*$", "action": { "indent": "none", "appendText": "// " } }
]
}
+47
View File
@@ -0,0 +1,47 @@
{
"name": "dino",
"displayName": "Dino",
"description": "Syntax highlighting, error checking and formatting for the Dino language",
"version": "0.1.0",
"publisher": "dino-lang",
"license": "MIT",
"engines": { "vscode": "^1.75.0" },
"categories": ["Programming Languages", "Formatters"],
"activationEvents": ["onLanguage:dino"],
"main": "./extension.js",
"dependencies": { "vscode-languageclient": "^9.0.1" },
"contributes": {
"languages": [
{
"id": "dino",
"aliases": ["Dino", "dino"],
"extensions": [".dino"],
"configuration": "./language-configuration.json"
}
],
"grammars": [
{
"language": "dino",
"scopeName": "source.dino",
"path": "./syntaxes/dino.tmLanguage.json"
}
],
"configuration": {
"title": "Dino",
"properties": {
"dino.serverPath": {
"type": "string",
"default": "dino",
"description": "The `dino` program that provides the language server (it is started as `dino lsp`)."
}
}
},
"configurationDefaults": {
"[dino]": {
"editor.insertSpaces": true,
"editor.tabSize": 4,
"editor.formatOnSave": true
}
}
}
}
@@ -0,0 +1,103 @@
{
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
"name": "Dino",
"scopeName": "source.dino",
"patterns": [
{ "include": "#comments" },
{ "include": "#strings" },
{ "include": "#chars" },
{ "include": "#declarations" },
{ "include": "#keywords" },
{ "include": "#constants" },
{ "include": "#numbers" },
{ "include": "#types" },
{ "include": "#calls" },
{ "include": "#operators" }
],
"repository": {
"comments": {
"patterns": [
{ "name": "comment.line.double-slash.dino", "match": "//.*$" },
{ "name": "comment.block.dino", "begin": "/\\*", "end": "\\*/" }
]
},
"strings": {
"name": "string.quoted.double.dino",
"begin": "\"",
"end": "\"",
"patterns": [
{ "name": "constant.character.escape.dino", "match": "\\\\." },
{
"name": "meta.interpolation.dino",
"begin": "\\{",
"end": "\\}",
"beginCaptures": { "0": { "name": "punctuation.section.interpolation.begin.dino" } },
"endCaptures": { "0": { "name": "punctuation.section.interpolation.end.dino" } },
"patterns": [{ "include": "$self" }]
}
]
},
"chars": {
"name": "string.quoted.single.dino",
"match": "'(?:\\\\.|[^'\\\\])'",
"captures": {}
},
"declarations": {
"patterns": [
{
"match": "\\b(func)\\s+([A-Za-z_][A-Za-z0-9_]*)",
"captures": {
"1": { "name": "keyword.declaration.function.dino" },
"2": { "name": "entity.name.function.dino" }
}
},
{
"match": "\\b(struct|enum|interface)\\s+([A-Za-z_][A-Za-z0-9_]*)",
"captures": {
"1": { "name": "keyword.declaration.type.dino" },
"2": { "name": "entity.name.type.dino" }
}
}
]
},
"keywords": {
"patterns": [
{ "name": "keyword.control.dino", "match": "\\b(if|else|for|in|step|match|return|break|continue)\\b" },
{ "name": "keyword.declaration.dino", "match": "\\b(func|var|const|import|struct|enum|interface|pub)\\b" },
{ "name": "storage.modifier.dino", "match": "\\b(shared|weak)\\b" }
]
},
"constants": {
"name": "constant.language.dino",
"match": "\\b(true|false|nil)\\b"
},
"numbers": {
"name": "constant.numeric.dino",
"match": "\\b[0-9][0-9_]*(?:\\.[0-9][0-9_]*)?\\b"
},
"types": {
"patterns": [
{
"name": "support.type.builtin.dino",
"match": "\\b(int|float|bool|char|string|error|map|i8|i16|i32|i64|u8|u16|u32|u64|f32|f64)\\b"
},
{ "name": "entity.name.type.dino", "match": "\\b[A-Z][A-Za-z0-9_]*\\b" }
]
},
"calls": {
"name": "entity.name.function.call.dino",
"match": "\\b[a-z_][A-Za-z0-9_]*(?=\\s*\\()"
},
"operators": {
"patterns": [
{ "name": "keyword.operator.arrow.dino", "match": "=>" },
{ "name": "keyword.operator.range.dino", "match": "\\.\\." },
{ "name": "keyword.operator.comparison.dino", "match": "==|!=|<=|>=|<|>" },
{ "name": "keyword.operator.logical.dino", "match": "&&|\\|\\||!" },
{ "name": "keyword.operator.assignment.dino", "match": "[-+*/%]?=" },
{ "name": "keyword.operator.arithmetic.dino", "match": "[-+*/%]" },
{ "name": "keyword.operator.optional.dino", "match": "\\?" }
]
}
}
}