lyng textmate bundle idea-compatible
This commit is contained in:
parent
ea0ecb1db3
commit
f0fc7ddd84
66
editors/lyng-textmate/README.md
Normal file
66
editors/lyng-textmate/README.md
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
Lyng TextMate grammar
|
||||||
|
======================
|
||||||
|
|
||||||
|
This folder contains a TextMate grammar for the Lyng language so you can get syntax highlighting quickly in:
|
||||||
|
|
||||||
|
- JetBrains IDEs (IntelliJ IDEA, Fleet, etc.) via “TextMate Bundles”
|
||||||
|
- VS Code (via “Install from VSIX” or by adding as an extension folder)
|
||||||
|
|
||||||
|
Files
|
||||||
|
-----
|
||||||
|
- `package.json` — VS Code–style wrapper that JetBrains IDEs can import as a TextMate bundle.
|
||||||
|
- `syntaxes/lyng.tmLanguage.json` — the grammar. It highlights:
|
||||||
|
- Line and block comments (`//`, `/* */`)
|
||||||
|
- Shebang line at file start (`#!...`)
|
||||||
|
- Strings: single and double quotes with escapes
|
||||||
|
- Char literals `'x'` with escapes
|
||||||
|
- Numbers: decimal with underscores and exponents, and hex (`0x...`)
|
||||||
|
- Keywords (control and declarations), boolean operator words (`and`, `or`, `not`, `in`, `is`, `as`, `as?`)
|
||||||
|
- Composite textual operators: `not in`, `not is`
|
||||||
|
- Constants: `true`, `false`, `null`, `this`
|
||||||
|
- Annotations: `@name` (Unicode identifiers supported)
|
||||||
|
- Labels: `name:` (Unicode identifiers supported)
|
||||||
|
- Declarations: highlights declared names in `fun|fn name`, `class|enum Name`, `val|var name`
|
||||||
|
- Types: built-ins (`Int|Real|String|Bool|Char|Regex`) and Capitalized identifiers (heuristic)
|
||||||
|
- Operators including ranges (`..`, `..<`, `...`), null-safe (`?.`, `?[`, `?(`, `?{`, `?:`, `??`), arrows (`->`, `=>`, `::`), match operators (`=~`, `!~`), bitwise, arithmetic, etc.
|
||||||
|
- Shuttle operator `<=>`
|
||||||
|
- Division operator `/` (note: Lyng has no regex literal syntax; `/` is always division)
|
||||||
|
|
||||||
|
Install in IntelliJ IDEA (and other JetBrains IDEs)
|
||||||
|
---------------------------------------------------
|
||||||
|
1. Open Settings / Preferences → Editor → TextMate Bundles.
|
||||||
|
2. Click “+” and select this folder `editors/lyng-textmate/` (the folder that contains `package.json`).
|
||||||
|
3. Ensure `*.lyng` is associated with the Lyng grammar (IntelliJ usually picks this up from `fileTypes`).
|
||||||
|
4. Optional: customize colors with Settings → Editor → Color Scheme → TextMate.
|
||||||
|
|
||||||
|
Enable Markdown code-fence highlighting in IntelliJ
|
||||||
|
--------------------------------------------------
|
||||||
|
1. Settings / Preferences → Languages & Frameworks → Markdown → Code style → Code fences → Languages.
|
||||||
|
2. Add mapping: language id `lyng` → “Lyng (TextMate)”.
|
||||||
|
3. Now blocks like
|
||||||
|
```
|
||||||
|
```lyng
|
||||||
|
// Lyng code here
|
||||||
|
```
|
||||||
|
```
|
||||||
|
will be highlighted.
|
||||||
|
|
||||||
|
Install in VS Code
|
||||||
|
------------------
|
||||||
|
Fastest local install without packaging:
|
||||||
|
1. Copy or symlink this folder somewhere stable (or keep it in your workspace).
|
||||||
|
2. Use “Developer: Install Extension from Location…” (Insiders) or package with `vsce package` and install the resulting `.vsix`.
|
||||||
|
3. VS Code will auto-associate `*.lyng` via this extension; if needed, check File Associations.
|
||||||
|
|
||||||
|
Notes and limitations
|
||||||
|
---------------------
|
||||||
|
- Type highlighting is heuristic (Capitalized identifiers). The IntelliJ plugin will use language semantics and avoid false positives.
|
||||||
|
- If your language adds or changes tokens, please update patterns in `lyng.tmLanguage.json`. The Kotlin sources in `lynglib/src/commonMain/kotlin/net/sergeych/lyng/highlight/` are a good reference for token kinds.
|
||||||
|
|
||||||
|
Lyng specifics
|
||||||
|
--------------
|
||||||
|
- There are no regex literal tokens in Lyng at the moment; the slash character `/` is always treated as the division operator. The grammar intentionally does not define a `/.../` regex rule to avoid mis-highlighting lines like `a / b`.
|
||||||
|
|
||||||
|
Contributing
|
||||||
|
------------
|
||||||
|
Pull requests to refine patterns and add tests/samples are welcome. You can place test snippets in `sample_texts/` and visually verify.
|
||||||
25
editors/lyng-textmate/package.json
Normal file
25
editors/lyng-textmate/package.json
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
{
|
||||||
|
"name": "lyng-textmate",
|
||||||
|
"displayName": "Lyng",
|
||||||
|
"description": "TextMate grammar for the Lyng language (for JetBrains IDEs via TextMate Bundles and VS Code).",
|
||||||
|
"version": "0.0.2",
|
||||||
|
"publisher": "lyng",
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"engines": { "vscode": "^1.0.0" },
|
||||||
|
"contributes": {
|
||||||
|
"languages": [
|
||||||
|
{
|
||||||
|
"id": "lyng",
|
||||||
|
"aliases": ["Lyng", "lyng"],
|
||||||
|
"extensions": [".lyng"]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"grammars": [
|
||||||
|
{
|
||||||
|
"language": "lyng",
|
||||||
|
"scopeName": "source.lyng",
|
||||||
|
"path": "./syntaxes/lyng.tmLanguage.json"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
53
editors/lyng-textmate/syntaxes/lyng.tmLanguage.json
Normal file
53
editors/lyng-textmate/syntaxes/lyng.tmLanguage.json
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
|
||||||
|
"name": "Lyng",
|
||||||
|
"scopeName": "source.lyng",
|
||||||
|
"fileTypes": ["lyng"],
|
||||||
|
"patterns": [
|
||||||
|
{ "include": "#shebang" },
|
||||||
|
{ "include": "#comments" },
|
||||||
|
{ "include": "#strings" },
|
||||||
|
{ "include": "#char" },
|
||||||
|
{ "include": "#numbers" },
|
||||||
|
{ "include": "#declarations" },
|
||||||
|
{ "include": "#keywords" },
|
||||||
|
{ "include": "#constants" },
|
||||||
|
{ "include": "#types" },
|
||||||
|
{ "include": "#annotations" },
|
||||||
|
{ "include": "#labels" },
|
||||||
|
{ "include": "#directives" },
|
||||||
|
{ "include": "#operators" },
|
||||||
|
{ "include": "#punctuation" }
|
||||||
|
],
|
||||||
|
"repository": {
|
||||||
|
"shebang": { "patterns": [ { "name": "comment.line.shebang.lyng", "match": "^#!.*$" } ] },
|
||||||
|
"comments": {
|
||||||
|
"patterns": [
|
||||||
|
{ "name": "comment.line.double-slash.lyng", "match": "//.*$" },
|
||||||
|
{ "name": "comment.block.lyng", "begin": "/\\*", "end": "\\*/" }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"strings": {
|
||||||
|
"patterns": [
|
||||||
|
{ "name": "string.quoted.double.lyng", "begin": "\"", "end": "\"", "patterns": [ { "match": "\\\\.", "name": "constant.character.escape.lyng" } ] },
|
||||||
|
{ "name": "string.quoted.single.lyng", "begin": "'", "end": "'", "patterns": [ { "match": "\\\\.", "name": "constant.character.escape.lyng" } ] }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"char": { "patterns": [ { "name": "constant.character.lyng", "match": "'(?:[^\\\\']|\\\\.)'" } ] },
|
||||||
|
"numbers": {
|
||||||
|
"patterns": [
|
||||||
|
{ "name": "constant.numeric.hex.lyng", "match": "0x[0-9A-Fa-f_]+" },
|
||||||
|
{ "name": "constant.numeric.decimal.lyng", "match": "(?<![A-Za-z_])(?:[0-9][0-9_]*)\\.(?:[0-9_]+)(?:[eE][+-]?[0-9_]+)?|(?<![A-Za-z_])(?:[0-9][0-9_]*)(?:[eE][+-]?[0-9_]+)?" }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"annotations": { "patterns": [ { "name": "entity.name.label.at.lyng", "match": "@[\\p{L}_][\\p{L}\\p{N}_]*:" }, { "name": "storage.modifier.annotation.lyng", "match": "@[\\p{L}_][\\p{L}\\p{N}_]*" } ] },
|
||||||
|
"labels": { "patterns": [ { "name": "entity.name.label.lyng", "match": "[\\p{L}_][\\p{L}\\p{N}_]*:" } ] },
|
||||||
|
"directives": { "patterns": [ { "name": "meta.directive.lyng", "match": "^\\s*#[_A-Za-z][_A-Za-z0-9]*" } ] },
|
||||||
|
"declarations": { "patterns": [ { "name": "meta.function.declaration.lyng", "match": "\\b(?:fun|fn)\\s+([\\p{L}_][\\p{L}\\p{N}_]*)", "captures": { "1": { "name": "entity.name.function.lyng" } } }, { "name": "meta.type.declaration.lyng", "match": "\\b(?:class|enum)\\s+([\\p{L}_][\\p{L}\\p{N}_]*)", "captures": { "1": { "name": "entity.name.type.lyng" } } }, { "name": "meta.variable.declaration.lyng", "match": "\\b(?:val|var)\\s+([\\p{L}_][\\p{L}\\p{N}_]*)", "captures": { "1": { "name": "variable.other.declaration.lyng" } } } ] },
|
||||||
|
"keywords": { "patterns": [ { "name": "keyword.control.lyng", "match": "\\b(?:if|else|when|while|do|for|try|catch|finally|throw|return|break|continue)\\b" }, { "name": "keyword.declaration.lyng", "match": "\\b(?:fun|fn|class|enum|val|var|import|package|constructor|property|open|extern|private|protected|static)\\b" }, { "name": "keyword.operator.word.lyng", "match": "\\bnot\\s+(?:in|is)\\b" }, { "name": "keyword.operator.word.lyng", "match": "\\b(?:and|or|not|in|is|as|as\\?)\\b" } ] },
|
||||||
|
"constants": { "patterns": [ { "name": "constant.language.lyng", "match": "(?:\\b(?:true|false|null|this)\\b|π)" } ] },
|
||||||
|
"types": { "patterns": [ { "name": "storage.type.lyng", "match": "\\b(?:Int|Real|String|Bool|Char|Regex)\\b" }, { "name": "entity.name.type.lyng", "match": "\\b[A-Z][A-Za-z0-9_]*\\b(?!\\s*\\()" } ] },
|
||||||
|
"operators": { "patterns": [ { "name": "keyword.operator.comparison.lyng", "match": "===|!==|==|!=|<=|>=|<|>" }, { "name": "keyword.operator.shuttle.lyng", "match": "<=>" }, { "name": "keyword.operator.arrow.lyng", "match": "=>|->|::" }, { "name": "keyword.operator.range.lyng", "match": "\\.\\.\\.|\\.\\.<|\\.\\." }, { "name": "keyword.operator.nullsafe.lyng", "match": "\\?\\.|\\?\\[|\\?\\(|\\?\\{|\\?:|\\?\\?" }, { "name": "keyword.operator.assignment.lyng", "match": "(?:\\+=|-=|\\*=|/=|%=|=)" }, { "name": "keyword.operator.logical.lyng", "match": "&&|\\|\\|" }, { "name": "keyword.operator.bitwise.lyng", "match": "<<|>>|&|\\||\\^|~" }, { "name": "keyword.operator.match.lyng", "match": "=~|!~" }, { "name": "keyword.operator.arithmetic.lyng", "match": "\\+\\+|--|[+\\-*/%]" }, { "name": "keyword.operator.other.lyng", "match": "[!?]" } ] },
|
||||||
|
"punctuation": { "patterns": [ { "name": "punctuation.separator.comma.lyng", "match": "," }, { "name": "punctuation.terminator.statement.lyng", "match": ";" }, { "name": "punctuation.section.block.begin.lyng", "match": "[(]{1}|[{]{1}|\\[" }, { "name": "punctuation.section.block.end.lyng", "match": "[)]{1}|[}]{1}|\\]" }, { "name": "punctuation.accessor.dot.lyng", "match": "\\." }, { "name": "punctuation.separator.colon.lyng", "match": ":" } ] }
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user