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:
1 parent
3e2779f447
commit
eaf9567a36
117 files changed
+19970
No files matched your search
@@ -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": "// " } }
|
||||
]
|
||||
}
|
||||
@@ -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": "\\?" }
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user