diff options
| author | Daniel Gavin <danielgavin5@hotmail.com> | 2021-05-05 16:22:27 +0200 |
|---|---|---|
| committer | Daniel Gavin <danielgavin5@hotmail.com> | 2021-05-05 16:22:27 +0200 |
| commit | 0d9d8f9cfdb0a60302fc2bcadc93c4187c33d439 (patch) | |
| tree | d2291c291bc2b108fc242d01c169c30467599e00 | |
| parent | 09cc33bffd08e16fadafebe11aa16183207e9090 (diff) | |
add grammar to extension
| -rw-r--r-- | editors/vscode/fileicons/odin_file.svg | 13 | ||||
| -rw-r--r-- | editors/vscode/language-configuration.json | 7 | ||||
| -rw-r--r-- | editors/vscode/package.json | 36 | ||||
| -rw-r--r-- | editors/vscode/src/extension.ts | 4 | ||||
| -rw-r--r-- | editors/vscode/syntaxes/odin.tmLanguage.json | 339 |
5 files changed, 395 insertions, 4 deletions
diff --git a/editors/vscode/fileicons/odin_file.svg b/editors/vscode/fileicons/odin_file.svg new file mode 100644 index 0000000..f628d9e --- /dev/null +++ b/editors/vscode/fileicons/odin_file.svg @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> +<svg width="100%" height="100%" viewBox="0 0 260 260" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;"> + <g transform="matrix(0.074119,0,0,0.104825,-6.73026e-13,-2.84217e-14)"> + <path d="M3507.87,248.031C3507.87,111.139 3350.69,0 3157.09,0L350.787,0C157.183,0 0,111.139 0,248.031L0,2232.28C0,2369.18 157.183,2480.32 350.787,2480.32L3157.09,2480.32C3350.69,2480.32 3507.87,2369.18 3507.87,2232.28L3507.87,248.031Z" style="fill:url(#_Radial1);"/> + </g> + <g transform="matrix(0.23131,0,0,0.231311,-26.4611,-156.862)"> + <path d="M430.516,1595.76C413.94,1584.38 400.839,1573.36 400.839,1573.36L827.125,835.012C827.125,835.012 844.672,841.52 859.166,848.469C877.436,857.226 892.569,865.763 892.569,865.763C1099.2,985.063 1170.11,1249.68 1050.81,1456.31C931.507,1662.95 666.89,1733.85 460.256,1614.55C460.256,1614.55 445.783,1606.23 430.516,1595.76ZM856.543,928.162L496.282,1552.15C668.477,1651.57 888.991,1592.48 988.408,1420.29C1087.82,1248.09 1028.74,1027.58 856.543,928.162ZM321.659,1487.36C307.172,1466.38 302.015,1456.32 302.015,1456.32C227.54,1326.96 222.078,1162.46 302.018,1024C381.958,885.54 527.146,808.023 676.415,807.839C676.415,807.839 696.568,807.787 713.348,809.394C738.628,811.816 755.435,815.078 755.435,815.078L347.771,1521.17C347.771,1521.17 338.1,1511.16 321.659,1487.36ZM633.291,882.532C524.653,895.735 423.297,958.044 364.417,1060.03C305.537,1162.01 302.255,1280.94 345.139,1381.63L633.291,882.532Z" style="fill:white;"/> + </g> + <defs> + <radialGradient id="_Radial1" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="matrix(3507.87,0,0,2480.31,0,0)"><stop offset="0" style="stop-color:rgb(24,156,255);stop-opacity:1"/><stop offset="0.58" style="stop-color:rgb(19,142,235);stop-opacity:1"/><stop offset="0.8" style="stop-color:rgb(9,113,191);stop-opacity:1"/><stop offset="1" style="stop-color:rgb(0,84,147);stop-opacity:1"/></radialGradient> + </defs> +</svg> diff --git a/editors/vscode/language-configuration.json b/editors/vscode/language-configuration.json index d676f80..56f675c 100644 --- a/editors/vscode/language-configuration.json +++ b/editors/vscode/language-configuration.json @@ -23,5 +23,10 @@ ["\"", "\""], ["'", "'"], ["`", "`"] - ] + ], + "indentationRules": { + "increaseIndentPattern": "^.*\\{[^}\"']*$|^.*\\([^\\)\"']*$", + "decreaseIndentPattern": "^\\s*(\\s*\\/[*].*[*]\\/\\s*)*[})]" + }, + }
\ No newline at end of file diff --git a/editors/vscode/package.json b/editors/vscode/package.json index 51e75be..e5e6028 100644 --- a/editors/vscode/package.json +++ b/editors/vscode/package.json @@ -7,9 +7,9 @@ "type": "git", "url": "git://github.com/DanielGavin/ols.git" }, - "version": "0.0.1", + "version": "0.0.2", "engines": { - "vscode": "^1.55.0" + "vscode": "^1.55.2" }, "categories": [ "Programming Languages" @@ -17,6 +17,7 @@ "activationEvents": [ "onLanguage:odin" ], + "main": "./out/extension.js", "contributes": { "commands": [ @@ -81,14 +82,43 @@ } } }, + "icons_PROPOSED": [ + { + "id": "odin-fileicon", + "description": "Odin file icon", + "default": { + "fontId": "odin-icon-font", + "fontCharacter": "\\E000" + } + } + ], + "iconFonts_PROPOSED": [ + { + "id": "odin-icon-font", + "src": [ + { + "path": "./fileicons/odin_file.svg", + "format": "svg" + } + ] + } + ], "languages": [ { "id": "odin", + "icon_PROPOSED": "odin-fileicon", "extensions": [ ".odin" ], "configuration": "./language-configuration.json" } + ], + "grammars": [ + { + "language": "odin", + "scopeName": "source.odin", + "path": "./syntaxes/odin.tmLanguage.json" + } ] }, "scripts": { @@ -124,4 +154,4 @@ "editor.semanticHighlighting.enabled": true } } -} +}
\ No newline at end of file diff --git a/editors/vscode/src/extension.ts b/editors/vscode/src/extension.ts index 57279a7..158178c 100644 --- a/editors/vscode/src/extension.ts +++ b/editors/vscode/src/extension.ts @@ -310,6 +310,10 @@ async function getServer(config: Config, state: PersistentState): Promise<string /* Temp: right now it doesn't check for versions, since ols has no versioning right now */ + + if (exists && state.lastCheck !== undefined && state.lastCheck + (3 * 60 * 60 * 1000) < Date.now()) { + return destExecutable; + } const release = await downloadWithRetryDialog(state, async () => { return await fetchRelease("nightly", state.githubToken, config.httpProxy); diff --git a/editors/vscode/syntaxes/odin.tmLanguage.json b/editors/vscode/syntaxes/odin.tmLanguage.json new file mode 100644 index 0000000..026aa15 --- /dev/null +++ b/editors/vscode/syntaxes/odin.tmLanguage.json @@ -0,0 +1,339 @@ +{ + "comment": "Modification of https://github.com/fivemoreminix/odin-vscode", + "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json", + "name": "Odin", + "patterns": [ + { + "include": "#comments" + }, + { + "include": "#keywords" + }, + { + "include": "#types" + }, + { + "include": "#functions-and-declarations" + }, + { + "include": "#strings" + }, + { + "include": "#string-escaped-char" + }, + { + "include": "#punctuation" + }, + { + "include": "#variables" + } + ], + "repository": { + "identifier": { + "patterns": [{ + "match": "\\b[[:alpha:]_][[:alnum:]_]*\\b" + }] + }, + "type-chars": { + "patterns": [{ + "match": "[[:alnum:]\\s,._^<>\\[\\]-]" + }] + }, + "screaming-identifier": { + "patterns": [{ + "match": "\\b[A-Z_](?![a-z])[A-Z_0-9]+\\b" + }] + }, + + "block-comment": { + "patterns": [ + { + "name": "comment.block.odin", + "begin": "/\\*", + "end": "\\*/", + "patterns": [{ + "include": "#block-comment" + }] + } + ] + }, + "comments": { + "patterns": [ + { + "include": "#block-comment" + }, + { + "name": "comment.line.double-slash.odin", + "begin": "//", + "end": "\n" + } + ] + }, + "variables": { + "patterns": [ + { + "name": "variable.name.odin", + "match": "\\b([A-Za-z_][A-Za-z0-9_]*)\\b" + } + ] + }, + "keywords": { + "patterns": [ + { + "name": "keyword.tag.odin", + "comment": "Use #name to use a pattern", + "match": "\\b([#@]\\s*[A-Za-z_][A-Za-z0-9_]*)\\b" + }, + { + "name": "keyword.control.odin", + "match": "\\b(import|export|foreign|package)\\b" + }, + { + "name": "keyword.control.odin", + "match": "\\b(if|else|when|for|in|defer|switch|return)\\b" + }, + { + "name": "keyword.control.odin", + "match": "\\b(fallthrough|break|continue|case|dynamic)\\b" + }, + { + "name": "keyword.control.odin", + "match": "\\b(using|do|force_inline|no_inline)\\b" + }, + { + "name": "keyword.control.odin", + "match": "\\b(asm)\\b" + }, + { + "name": "keyword.operator.odin", + "match": "\\b(distinct|context)\\b" + }, + { + "name": "constant.language.odin", + "match": "\\b(nil|true|false)\\b" + }, + { + "name": "constant.numeric.odin", + "match": "\\b(\\d(\\d|_)*(.\\d(\\d|_)*)?)((e|E)(\\+|-)?\\d+)?[ijk]?\\b" + }, + { + "name": "constant.numeric.odin", + "match": "\\b((0b(0|1|_)+)|(0o(\\d|_)+)|(0d(\\d|_)+)|(0[xXh](\\h|_)+))[i]?\\b" + }, + { + "name": "constant.numeric.odin", + "match": "---" + }, + { + "name": "storage.type.odin", + "match": "\\b(struct|enum|union|map|set|bit_set|typeid)\\b" + }, + { + "name": "keyword.function.odin", + "match": "\\b(cast|transmute|auto_cast)\\b" + }, + { + "name": "keyword.operator.odin", + "match": "@|(\\||\\!|:|\\+|-\\>?|\\*|/|\\<\\<?|\\>\\>?|\\~)=?|=|::?|\\.\\." + }, + { + "name": "keyword.other.odin", + "match": "#[A-Za-z_][A-Za-z_0-9]*" + } + ] + }, + "functions-and-declarations": { + "patterns": [ + { + "captures": { + "1": { + "name": "entity.name.function.odin" + }, + "2": { + "name": "punctuation.odin" + }, + "3": { + "name": "punctuation.odin" + }, + "4": { + "name": "storage.type.odin" + } + }, + "match": "\\b([A-Za-z_][A-Za-z0-9_]*)\\s*([:])\\s*([:])\\s*(proc)" + }, + { + "captures": { + "1": { + "name": "keyword.function.odin" + } + }, + "match": "\\b(size_of|align_of|offset_of|type_of|type_info_of|typeid_of)\\b\\s*\\(" + }, + { + "captures": { + "1": { + "name": "support.function.builtin.odin" + }, + "2": { + "name": "punctuation.odin" + } + }, + "match": "\\b(len|cap|make|resize|reserve|append|delete|assertf?|panicf?)\\b\\s*(\\()" + }, + { + "captures": { + "1": { + "name": "storage.type.odin" + }, + "2": { + "name": "punctuation.odin" + } + }, + "match": "(proc)\\s*([\\(])" + }, + { + "captures": { + "1": { + "name": "support.function.odin" + }, + "2": { + "name": "punctuation.odin" + } + }, + "match": "([A-Za-z_][A-Za-z0-9_]*)\\s*[!]?\\s*([\\(])" + }, + { + "captures": { + "1": { + "name": "meta.type.name.odin" + }, + "2": { + "name": "storage.type.odin" + } + }, + "match": "\\b([A-Za-z_][A-Za-z0-9_]*)\\s*[:]\\s*[:]\\s*(struct|union|enum|bit_set)" + } + ] + }, + "types": { + "patterns": [ + { + "captures": { + "1": { + "name": "storage.type.odin" + }, + "2": { + "name": "meta.block.odin" + }, + "3": { + "name": "meta.block.odin" + } + }, + "match": "\\b(struct|enum|union|bit_set)\\b(?:(\\{)(\\}))?" + }, + { + "name": "storage.type.odin", + "match": "\\b(proc|type)\\b" + }, + { + "name": "meta.brackets.odin", + "captures": { + "1": { + "name": "punctuation.definition.brackets.begin.odin" + }, + "2": { + "name": "constant.numeric.odin" + }, + "3": { + "name": "punctuation.definition.brackets.end.odin" + } + }, + "match": "(\\[)(\\d*)(\\])(?=[[:alpha:]_])" + }, + { + "name": "storage.type.odin", + "match": "\\$\\s*({{identifier}})" + }, + { + "include": "#basic-types" + } + ] + }, + "basic-types": { + "patterns": [ + { + "name": "support.type.odin", + "match": "\\b((i8|i16|i32|i64|i128|int)|(u8|u16|u32|u64|u128|uint|uintptr))\\b" + }, + { + "name": "support.type.odin", + "match": "\\b((f16|f32|f64)|(complex32|complex64|complex128))\\b" + }, + { + "name": "support.type.odin", + "match": "\\b(bool|b8|b16|b32|b64)\\b" + }, + { + "name": "support.type.odin", + "match": "\\b(string|rune|rawptr|any)\\b" + }, + { + "name": "support.type.odin", + "match": "\\b(byte|cstring)\\b" + } + ] + }, + "strings": { + "patterns": [ + { + "name": "string.quoted.double.odin", + "begin": "\"", + "end": "\"", + "patterns": [ + { + "include": "#string-escaped-char" + } + ] + }, + { + "name": "string.quoted.double.odin", + "begin": "`", + "end": "`" + }, + { + "name": "string.quoted.single.odin", + "begin": "'", + "end": "'", + "patterns": [ + { + "include": "#string-escaped-char" + } + ] + } + ], + "repository": { + "string-escaped-char": { + "patterns": [ + { + "name": "constant.character.escape.odin", + "match": "\\\\(\\\\|[abfnrutv''\"]|x\\h{2}|u\\h{4}|U\\h{8}|[0-7]{3})" + }, + { + "name": "invalid.illegal.unknown-escape.odin", + "match": "\\\\." + } + ] + } + } + }, + "punctuation": { + "patterns": [ + { + "name": "punctuation.odin", + "match": "\\(|\\)|\\{|\\}|;|\\[|\\]|\\.|," + } + ] + } + }, + "scopeName": "source.odin" +}
\ No newline at end of file |