diff --git a/README.md b/README.md index 163b40d9..4144612e 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,16 @@ 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 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 + If you prefer a different editor, you can start the language server manually over stdio: ```bash 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/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/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.