From 5279344dd070ab8900fa54991fe5443e0de251db Mon Sep 17 00:00:00 2001 From: Tim Fennis Date: Tue, 7 Jul 2026 15:02:04 +0200 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20add=20JetBrains=20IDE=20support=20v?= =?UTF-8?q?ia=20TextMate=20bundle=20and=20LSP4IJ=20=F0=9F=A7=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Fable 5 --- README.md | 8 + ext/lsp4ij-ndc/template.json | 17 ++ ext/textmate-ndc/README.md | 55 +++++ ext/textmate-ndc/language-configuration.json | 22 ++ ext/textmate-ndc/package.json | 36 ++++ ext/textmate-ndc/syntaxes/ndc.tmLanguage.json | 191 ++++++++++++++++++ 6 files changed, 329 insertions(+) create mode 100644 ext/lsp4ij-ndc/template.json create mode 100644 ext/textmate-ndc/README.md create mode 100644 ext/textmate-ndc/language-configuration.json create mode 100644 ext/textmate-ndc/package.json create mode 100644 ext/textmate-ndc/syntaxes/ndc.tmLanguage.json diff --git a/README.md b/README.md index 163b40d9..f6e28224 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,14 @@ The extension launches the LSP automatically using the `ndc` binary. If `ndc` is that VS Code uses (common when installed via a shell like fish), set the `andy-cpp.ndcPath` setting to the full path of the binary. +### JetBrains IDEs (RustRover, IntelliJ, …) + +JetBrains IDEs are supported through a TextMate bundle (syntax highlighting) and the +LSP4IJ plugin (diagnostics, hover, completion, inlay type hints, go to definition). +See [ext/textmate-ndc/README.md](ext/textmate-ndc/README.md) for setup instructions. + +### Other editors + If you prefer a different editor, you can start the language server manually over stdio: ```bash diff --git a/ext/lsp4ij-ndc/template.json b/ext/lsp4ij-ndc/template.json new file mode 100644 index 00000000..023a3f84 --- /dev/null +++ b/ext/lsp4ij-ndc/template.json @@ -0,0 +1,17 @@ +{ + "name": "Andy C++ (ndc)", + "programArgs": { + "default": "ndc lsp --stdio" + }, + "fileTypeMappings": [ + { + "fileType": { + "name": "ndc", + "patterns": [ + "*.ndc" + ] + }, + "languageId": "ndc" + } + ] +} diff --git a/ext/textmate-ndc/README.md b/ext/textmate-ndc/README.md new file mode 100644 index 00000000..fa0fefe7 --- /dev/null +++ b/ext/textmate-ndc/README.md @@ -0,0 +1,55 @@ +# Andy C++ support for JetBrains IDEs (RustRover, IntelliJ, …) + +Editor support for `.ndc` files in JetBrains IDEs comes in two independent parts: + +1. **Syntax highlighting** via the bundled *TextMate Bundles* plugin, using the grammar in + this directory. +2. **Language intelligence** (diagnostics, hover, completion, inlay type hints, go to + definition, document symbols) via the [LSP4IJ](https://plugins.jetbrains.com/plugin/23257-lsp4ij) + plugin talking to the `ndc lsp` language server. + +This directory is laid out as a VS Code-style extension (`package.json` + +`syntaxes/ndc.tmLanguage.json`), which the TextMate Bundles plugin can import directly. + +## 1. Syntax highlighting (TextMate bundle) + +1. Make sure the **TextMate Bundles** plugin is enabled + (*Settings → Plugins → Installed* — it ships with the IDE). +2. Go to *Settings → Editor → TextMate Bundles*, click **+**, and select this directory + (`ext/textmate-ndc`). +3. Open a `.ndc` file. It should highlight immediately. + +If `.ndc` files render as plain text, check *Settings → Editor → File Types* and make sure +`*.ndc` is not claimed by another file type (it should be associated with +"Files supported via TextMate bundles"). + +## 2. Language server (LSP4IJ) + +First build the `ndc` binary: + +```bash +cargo build --release # produces target/release/ndc +``` + +Then in the IDE: + +1. Install the **LSP4IJ** plugin from the marketplace. +2. Open the *Language Servers* tool window (*View → Tool Windows → Language Servers*), + click **+** to add a new language server, and pick the *New server* template. +3. Configure it: + - **Name**: `Andy C++ (ndc)` + - **Command**: `/path/to/andy-cpp/target/release/ndc lsp --stdio` + - In the **Mappings** tab, add a *File name patterns* mapping with pattern `*.ndc` + and language id `ndc`. +4. Open a `.ndc` file. The server starts automatically and provides diagnostics, hover, + completion, inlay type hints, go to definition, and document symbols. + +`ext/lsp4ij-ndc/template.json` contains the same configuration as an LSP4IJ template for +reference; adjust the command to the absolute path of your `ndc` binary if it is not on +the IDE's `PATH`. + +## Keeping the grammar up to date + +The grammar is written against the token definitions in `ndc_lexer/src/token.rs` and the +tree-sitter grammar in `ext/tree-sitter-andy-cpp/grammar.js`. When the language gains new +keywords, literals, or operators, update `syntaxes/ndc.tmLanguage.json` to match. diff --git a/ext/textmate-ndc/language-configuration.json b/ext/textmate-ndc/language-configuration.json new file mode 100644 index 00000000..3e2e17cd --- /dev/null +++ b/ext/textmate-ndc/language-configuration.json @@ -0,0 +1,22 @@ +{ + "comments": { + "lineComment": "//" + }, + "brackets": [ + ["{", "}"], + ["[", "]"], + ["(", ")"] + ], + "autoClosingPairs": [ + { "open": "{", "close": "}" }, + { "open": "[", "close": "]" }, + { "open": "(", "close": ")" }, + { "open": "\"", "close": "\"", "notIn": ["string", "comment"] } + ], + "surroundingPairs": [ + ["{", "}"], + ["[", "]"], + ["(", ")"], + ["\"", "\""] + ] +} diff --git a/ext/textmate-ndc/package.json b/ext/textmate-ndc/package.json new file mode 100644 index 00000000..18da4c9e --- /dev/null +++ b/ext/textmate-ndc/package.json @@ -0,0 +1,36 @@ +{ + "name": "ndc-syntax", + "displayName": "Andy C++ (ndc)", + "description": "Syntax highlighting for the Andy C++ (.ndc) language", + "version": "0.1.0", + "publisher": "timfennis", + "license": "MIT", + "engines": { + "vscode": "^1.0.0" + }, + "categories": [ + "Programming Languages" + ], + "contributes": { + "languages": [ + { + "id": "ndc", + "aliases": [ + "Andy C++", + "ndc" + ], + "extensions": [ + ".ndc" + ], + "configuration": "./language-configuration.json" + } + ], + "grammars": [ + { + "language": "ndc", + "scopeName": "source.ndc", + "path": "./syntaxes/ndc.tmLanguage.json" + } + ] + } +} diff --git a/ext/textmate-ndc/syntaxes/ndc.tmLanguage.json b/ext/textmate-ndc/syntaxes/ndc.tmLanguage.json new file mode 100644 index 00000000..96123d0a --- /dev/null +++ b/ext/textmate-ndc/syntaxes/ndc.tmLanguage.json @@ -0,0 +1,191 @@ +{ + "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json", + "name": "Andy C++", + "scopeName": "source.ndc", + "fileTypes": ["ndc"], + "patterns": [ + { "include": "#comments" }, + { "include": "#raw-strings" }, + { "include": "#strings" }, + { "include": "#numbers" }, + { "include": "#function-definitions" }, + { "include": "#keywords" }, + { "include": "#constants" }, + { "include": "#function-calls" }, + { "include": "#types" }, + { "include": "#map-open" }, + { "include": "#operators" }, + { "include": "#punctuation" } + ], + "repository": { + "comments": { + "patterns": [ + { + "name": "comment.line.double-slash.ndc", + "match": "//[^\\n]*" + }, + { + "name": "comment.line.shebang.ndc", + "match": "#![^\\n]*" + } + ] + }, + "raw-strings": { + "name": "string.quoted.other.raw.ndc", + "begin": "r(#*)\"", + "end": "\"\\1", + "beginCaptures": { + "0": { "name": "punctuation.definition.string.begin.ndc" } + }, + "endCaptures": { + "0": { "name": "punctuation.definition.string.end.ndc" } + } + }, + "strings": { + "name": "string.quoted.double.ndc", + "begin": "\"", + "end": "\"", + "beginCaptures": { + "0": { "name": "punctuation.definition.string.begin.ndc" } + }, + "endCaptures": { + "0": { "name": "punctuation.definition.string.end.ndc" } + }, + "patterns": [ + { + "name": "constant.character.escape.ndc", + "match": "\\\\[nrt0\\\\\"]" + }, + { + "name": "invalid.illegal.escape.ndc", + "match": "\\\\." + } + ] + }, + "numbers": { + "patterns": [ + { + "name": "constant.numeric.binary.ndc", + "match": "\\b0b[01][01_]*\\b" + }, + { + "name": "constant.numeric.octal.ndc", + "match": "\\b0o[0-7][0-7_]*\\b" + }, + { + "name": "constant.numeric.hex.ndc", + "match": "\\b0x[0-9A-Fa-f][0-9A-Fa-f_]*\\b" + }, + { + "name": "constant.numeric.radix.ndc", + "match": "\\b[0-9]+r[0-9A-Za-z][0-9A-Za-z_]*\\b" + }, + { + "name": "constant.numeric.complex.ndc", + "match": "\\b[0-9][0-9_]*(\\.[0-9][0-9_]*)?[ij]\\b" + }, + { + "name": "constant.numeric.float.ndc", + "match": "\\b[0-9][0-9_]*\\.[0-9][0-9_]*\\b" + }, + { + "name": "constant.numeric.integer.ndc", + "match": "\\b[0-9][0-9_]*\\b" + } + ] + }, + "function-definitions": { + "match": "\\b(fn)\\s+([A-Za-z_][A-Za-z0-9_]*\\??)", + "captures": { + "1": { "name": "storage.type.function.ndc" }, + "2": { "name": "entity.name.function.ndc" } + } + }, + "keywords": { + "patterns": [ + { + "name": "keyword.control.ndc", + "match": "\\b(if|else|while|for|return|break|continue)\\b" + }, + { + "name": "storage.type.function.ndc", + "match": "\\bfn\\b" + }, + { + "name": "keyword.declaration.let.ndc", + "match": "\\blet\\b" + }, + { + "name": "storage.modifier.pure.ndc", + "match": "\\bpure\\b" + }, + { + "name": "keyword.operator.word.ndc", + "match": "\\b(and|or|not|in)\\b" + } + ] + }, + "constants": { + "patterns": [ + { + "name": "constant.language.boolean.ndc", + "match": "\\b(true|false)\\b" + }, + { + "name": "constant.language.ndc", + "match": "\\b(Inf|NaN)\\b" + } + ] + }, + "function-calls": { + "match": "\\b([a-z_][A-Za-z0-9_]*\\??)(?=\\s*\\()", + "captures": { + "1": { "name": "entity.name.function.call.ndc" } + } + }, + "types": { + "name": "entity.name.type.ndc", + "match": "\\b[A-Z][A-Za-z0-9_]*\\b" + }, + "operators": { + "patterns": [ + { + "name": "keyword.operator.comparison.ndc", + "match": "<=>|>=<|==|!=|<=|>=|(?=!+\\-*/\\\\%^&|~])<(?![<=>])|(?=])>(?![>=<])" + }, + { + "name": "keyword.operator.assignment.ndc", + "match": "(\\+\\+|<>|<<|>>|%%|[-+*/\\\\%^&|~])=|(?!+\\-*/\\\\%^&|~])=(?![=>])" + }, + { + "name": "keyword.operator.range.ndc", + "match": "\\.\\.=|\\.\\." + }, + { + "name": "keyword.operator.arrow.ndc", + "match": "->|=>" + }, + { + "name": "keyword.operator.ndc", + "match": "\\+\\+|<>|<<|>>|%%|[-+*/\\\\%^&|~!]" + } + ] + }, + "map-open": { + "name": "punctuation.section.map.begin.ndc", + "match": "%\\{" + }, + "punctuation": { + "patterns": [ + { + "name": "punctuation.separator.ndc", + "match": "[,;:]" + }, + { + "name": "punctuation.section.brackets.ndc", + "match": "[()\\[\\]{}]" + } + ] + } + } +} From 0e55751ef30ec47fdefaa05728e8ad82d7746520 Mon Sep 17 00:00:00 2001 From: Tim Fennis Date: Tue, 7 Jul 2026 15:05:55 +0200 Subject: [PATCH 2/2] =?UTF-8?q?refactor:=20reuse=20the=20VS=20Code=20exten?= =?UTF-8?q?sion=20grammar=20instead=20of=20duplicating=20it=20=E2=99=BB?= =?UTF-8?q?=EF=B8=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Fable 5 --- README.md | 8 +- .../syntaxes/andy-cpp.tmLanguage.json | 12 +- ext/textmate-ndc/README.md | 55 ----- ext/textmate-ndc/language-configuration.json | 22 -- ext/textmate-ndc/package.json | 36 ---- ext/textmate-ndc/syntaxes/ndc.tmLanguage.json | 191 ------------------ manual/src/tooling/editor-support.md | 26 +++ 7 files changed, 42 insertions(+), 308 deletions(-) delete mode 100644 ext/textmate-ndc/README.md delete mode 100644 ext/textmate-ndc/language-configuration.json delete mode 100644 ext/textmate-ndc/package.json delete mode 100644 ext/textmate-ndc/syntaxes/ndc.tmLanguage.json diff --git a/README.md b/README.md index f6e28224..4144612e 100644 --- a/README.md +++ b/README.md @@ -61,9 +61,11 @@ to the full path of the binary. ### JetBrains IDEs (RustRover, IntelliJ, …) -JetBrains IDEs are supported through a TextMate bundle (syntax highlighting) and the -LSP4IJ plugin (diagnostics, hover, completion, inlay type hints, go to definition). -See [ext/textmate-ndc/README.md](ext/textmate-ndc/README.md) for setup instructions. +JetBrains IDEs are supported by importing `ext/andy-cpp` as a TextMate bundle (syntax +highlighting) and connecting the LSP4IJ plugin to `ndc lsp` (diagnostics, hover, +completion, inlay type hints, go to definition). See the +[editor support page](https://timfennis.github.io/andy-cpp/tooling/editor-support.html) +in the manual for setup instructions. ### Other editors diff --git a/ext/andy-cpp/syntaxes/andy-cpp.tmLanguage.json b/ext/andy-cpp/syntaxes/andy-cpp.tmLanguage.json index 04f801eb..2d68ee24 100644 --- a/ext/andy-cpp/syntaxes/andy-cpp.tmLanguage.json +++ b/ext/andy-cpp/syntaxes/andy-cpp.tmLanguage.json @@ -64,7 +64,7 @@ { "comment": "function definition", "name": "meta.function.definition.andy-cpp", - "begin": "\\b((pure)\\s)?(fn)\\s+([A-Za-z_][A-Za-z_0-9]*)", + "begin": "\\b((pure)\\s)?(fn)\\s+([A-Za-z_][A-Za-z_0-9]*\\??)", "patterns": [ { "include": "#expression" @@ -126,11 +126,21 @@ "begin": "(//)", "end": "$", "name": "comment.line.double-slash.andy-cpp" + }, + { + "begin": "(#!)", + "end": "$", + "name": "comment.line.shebang.andy-cpp" } ] }, "numbers": { "patterns": [ + { + "comment": "Complex literals (imaginary part), e.g. `3i` or `2.5j`", + "match": "\\b([0-9][0-9_]*(\\.[0-9][0-9_]*)?[ij])\\b", + "name": "constant.numeric.complex.andy-cpp" + }, { "comment": "Floats", "match": "\\b([0-9][0-9_]*\\.[0-9][0-9_]*)\\b", diff --git a/ext/textmate-ndc/README.md b/ext/textmate-ndc/README.md deleted file mode 100644 index fa0fefe7..00000000 --- a/ext/textmate-ndc/README.md +++ /dev/null @@ -1,55 +0,0 @@ -# Andy C++ support for JetBrains IDEs (RustRover, IntelliJ, …) - -Editor support for `.ndc` files in JetBrains IDEs comes in two independent parts: - -1. **Syntax highlighting** via the bundled *TextMate Bundles* plugin, using the grammar in - this directory. -2. **Language intelligence** (diagnostics, hover, completion, inlay type hints, go to - definition, document symbols) via the [LSP4IJ](https://plugins.jetbrains.com/plugin/23257-lsp4ij) - plugin talking to the `ndc lsp` language server. - -This directory is laid out as a VS Code-style extension (`package.json` + -`syntaxes/ndc.tmLanguage.json`), which the TextMate Bundles plugin can import directly. - -## 1. Syntax highlighting (TextMate bundle) - -1. Make sure the **TextMate Bundles** plugin is enabled - (*Settings → Plugins → Installed* — it ships with the IDE). -2. Go to *Settings → Editor → TextMate Bundles*, click **+**, and select this directory - (`ext/textmate-ndc`). -3. Open a `.ndc` file. It should highlight immediately. - -If `.ndc` files render as plain text, check *Settings → Editor → File Types* and make sure -`*.ndc` is not claimed by another file type (it should be associated with -"Files supported via TextMate bundles"). - -## 2. Language server (LSP4IJ) - -First build the `ndc` binary: - -```bash -cargo build --release # produces target/release/ndc -``` - -Then in the IDE: - -1. Install the **LSP4IJ** plugin from the marketplace. -2. Open the *Language Servers* tool window (*View → Tool Windows → Language Servers*), - click **+** to add a new language server, and pick the *New server* template. -3. Configure it: - - **Name**: `Andy C++ (ndc)` - - **Command**: `/path/to/andy-cpp/target/release/ndc lsp --stdio` - - In the **Mappings** tab, add a *File name patterns* mapping with pattern `*.ndc` - and language id `ndc`. -4. Open a `.ndc` file. The server starts automatically and provides diagnostics, hover, - completion, inlay type hints, go to definition, and document symbols. - -`ext/lsp4ij-ndc/template.json` contains the same configuration as an LSP4IJ template for -reference; adjust the command to the absolute path of your `ndc` binary if it is not on -the IDE's `PATH`. - -## Keeping the grammar up to date - -The grammar is written against the token definitions in `ndc_lexer/src/token.rs` and the -tree-sitter grammar in `ext/tree-sitter-andy-cpp/grammar.js`. When the language gains new -keywords, literals, or operators, update `syntaxes/ndc.tmLanguage.json` to match. diff --git a/ext/textmate-ndc/language-configuration.json b/ext/textmate-ndc/language-configuration.json deleted file mode 100644 index 3e2e17cd..00000000 --- a/ext/textmate-ndc/language-configuration.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "comments": { - "lineComment": "//" - }, - "brackets": [ - ["{", "}"], - ["[", "]"], - ["(", ")"] - ], - "autoClosingPairs": [ - { "open": "{", "close": "}" }, - { "open": "[", "close": "]" }, - { "open": "(", "close": ")" }, - { "open": "\"", "close": "\"", "notIn": ["string", "comment"] } - ], - "surroundingPairs": [ - ["{", "}"], - ["[", "]"], - ["(", ")"], - ["\"", "\""] - ] -} diff --git a/ext/textmate-ndc/package.json b/ext/textmate-ndc/package.json deleted file mode 100644 index 18da4c9e..00000000 --- a/ext/textmate-ndc/package.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "name": "ndc-syntax", - "displayName": "Andy C++ (ndc)", - "description": "Syntax highlighting for the Andy C++ (.ndc) language", - "version": "0.1.0", - "publisher": "timfennis", - "license": "MIT", - "engines": { - "vscode": "^1.0.0" - }, - "categories": [ - "Programming Languages" - ], - "contributes": { - "languages": [ - { - "id": "ndc", - "aliases": [ - "Andy C++", - "ndc" - ], - "extensions": [ - ".ndc" - ], - "configuration": "./language-configuration.json" - } - ], - "grammars": [ - { - "language": "ndc", - "scopeName": "source.ndc", - "path": "./syntaxes/ndc.tmLanguage.json" - } - ] - } -} diff --git a/ext/textmate-ndc/syntaxes/ndc.tmLanguage.json b/ext/textmate-ndc/syntaxes/ndc.tmLanguage.json deleted file mode 100644 index 96123d0a..00000000 --- a/ext/textmate-ndc/syntaxes/ndc.tmLanguage.json +++ /dev/null @@ -1,191 +0,0 @@ -{ - "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json", - "name": "Andy C++", - "scopeName": "source.ndc", - "fileTypes": ["ndc"], - "patterns": [ - { "include": "#comments" }, - { "include": "#raw-strings" }, - { "include": "#strings" }, - { "include": "#numbers" }, - { "include": "#function-definitions" }, - { "include": "#keywords" }, - { "include": "#constants" }, - { "include": "#function-calls" }, - { "include": "#types" }, - { "include": "#map-open" }, - { "include": "#operators" }, - { "include": "#punctuation" } - ], - "repository": { - "comments": { - "patterns": [ - { - "name": "comment.line.double-slash.ndc", - "match": "//[^\\n]*" - }, - { - "name": "comment.line.shebang.ndc", - "match": "#![^\\n]*" - } - ] - }, - "raw-strings": { - "name": "string.quoted.other.raw.ndc", - "begin": "r(#*)\"", - "end": "\"\\1", - "beginCaptures": { - "0": { "name": "punctuation.definition.string.begin.ndc" } - }, - "endCaptures": { - "0": { "name": "punctuation.definition.string.end.ndc" } - } - }, - "strings": { - "name": "string.quoted.double.ndc", - "begin": "\"", - "end": "\"", - "beginCaptures": { - "0": { "name": "punctuation.definition.string.begin.ndc" } - }, - "endCaptures": { - "0": { "name": "punctuation.definition.string.end.ndc" } - }, - "patterns": [ - { - "name": "constant.character.escape.ndc", - "match": "\\\\[nrt0\\\\\"]" - }, - { - "name": "invalid.illegal.escape.ndc", - "match": "\\\\." - } - ] - }, - "numbers": { - "patterns": [ - { - "name": "constant.numeric.binary.ndc", - "match": "\\b0b[01][01_]*\\b" - }, - { - "name": "constant.numeric.octal.ndc", - "match": "\\b0o[0-7][0-7_]*\\b" - }, - { - "name": "constant.numeric.hex.ndc", - "match": "\\b0x[0-9A-Fa-f][0-9A-Fa-f_]*\\b" - }, - { - "name": "constant.numeric.radix.ndc", - "match": "\\b[0-9]+r[0-9A-Za-z][0-9A-Za-z_]*\\b" - }, - { - "name": "constant.numeric.complex.ndc", - "match": "\\b[0-9][0-9_]*(\\.[0-9][0-9_]*)?[ij]\\b" - }, - { - "name": "constant.numeric.float.ndc", - "match": "\\b[0-9][0-9_]*\\.[0-9][0-9_]*\\b" - }, - { - "name": "constant.numeric.integer.ndc", - "match": "\\b[0-9][0-9_]*\\b" - } - ] - }, - "function-definitions": { - "match": "\\b(fn)\\s+([A-Za-z_][A-Za-z0-9_]*\\??)", - "captures": { - "1": { "name": "storage.type.function.ndc" }, - "2": { "name": "entity.name.function.ndc" } - } - }, - "keywords": { - "patterns": [ - { - "name": "keyword.control.ndc", - "match": "\\b(if|else|while|for|return|break|continue)\\b" - }, - { - "name": "storage.type.function.ndc", - "match": "\\bfn\\b" - }, - { - "name": "keyword.declaration.let.ndc", - "match": "\\blet\\b" - }, - { - "name": "storage.modifier.pure.ndc", - "match": "\\bpure\\b" - }, - { - "name": "keyword.operator.word.ndc", - "match": "\\b(and|or|not|in)\\b" - } - ] - }, - "constants": { - "patterns": [ - { - "name": "constant.language.boolean.ndc", - "match": "\\b(true|false)\\b" - }, - { - "name": "constant.language.ndc", - "match": "\\b(Inf|NaN)\\b" - } - ] - }, - "function-calls": { - "match": "\\b([a-z_][A-Za-z0-9_]*\\??)(?=\\s*\\()", - "captures": { - "1": { "name": "entity.name.function.call.ndc" } - } - }, - "types": { - "name": "entity.name.type.ndc", - "match": "\\b[A-Z][A-Za-z0-9_]*\\b" - }, - "operators": { - "patterns": [ - { - "name": "keyword.operator.comparison.ndc", - "match": "<=>|>=<|==|!=|<=|>=|(?=!+\\-*/\\\\%^&|~])<(?![<=>])|(?=])>(?![>=<])" - }, - { - "name": "keyword.operator.assignment.ndc", - "match": "(\\+\\+|<>|<<|>>|%%|[-+*/\\\\%^&|~])=|(?!+\\-*/\\\\%^&|~])=(?![=>])" - }, - { - "name": "keyword.operator.range.ndc", - "match": "\\.\\.=|\\.\\." - }, - { - "name": "keyword.operator.arrow.ndc", - "match": "->|=>" - }, - { - "name": "keyword.operator.ndc", - "match": "\\+\\+|<>|<<|>>|%%|[-+*/\\\\%^&|~!]" - } - ] - }, - "map-open": { - "name": "punctuation.section.map.begin.ndc", - "match": "%\\{" - }, - "punctuation": { - "patterns": [ - { - "name": "punctuation.separator.ndc", - "match": "[,;:]" - }, - { - "name": "punctuation.section.brackets.ndc", - "match": "[()\\[\\]{}]" - } - ] - } - } -} diff --git a/manual/src/tooling/editor-support.md b/manual/src/tooling/editor-support.md index d30a2ebc..fd2eff6a 100644 --- a/manual/src/tooling/editor-support.md +++ b/manual/src/tooling/editor-support.md @@ -27,6 +27,32 @@ launches it automatically. Any LSP-capable editor can use it by pointing at the variable declarations in the file. - **Go-to-definition** — jump from a variable or function usage to its declaration. +## JetBrains IDEs (RustRover, IntelliJ, …) + +JetBrains IDEs are supported without a dedicated plugin, in two independent parts. + +**Syntax highlighting** — the bundled *TextMate Bundles* plugin can import the VS Code +extension directory directly: + +1. Go to *Settings → Editor → TextMate Bundles*, click **+**, and select the + `ext/andy-cpp` directory from the repository. +2. Open a `.ndc` file — it should highlight immediately. If it renders as plain text, + check *Settings → Editor → File Types* and make sure `*.ndc` is not claimed by + another file type. + +**Language intelligence** — the [LSP4IJ](https://plugins.jetbrains.com/plugin/23257-lsp4ij) +plugin connects the IDE to the language server: + +1. Build the binary with `cargo build --release`, then install **LSP4IJ** from the + plugin marketplace. +2. Open the *Language Servers* tool window, click **+**, and configure a new server: + - **Command**: `/path/to/andy-cpp/target/release/ndc lsp --stdio` + - In the **Mappings** tab, add a *File name patterns* mapping with pattern `*.ndc` + and language id `ndc`. +3. Open a `.ndc` file. The server starts automatically and provides everything listed + above. `ext/lsp4ij-ndc/template.json` in the repository contains the same + configuration as a reference. + ## Notes - The server uses full-document synchronisation and re-analyses on each edit.