Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions ext/tree-sitter-andy-cpp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,18 +156,30 @@ args = ["lsp"]

[[grammar]]
name = "andy-cpp"
source = { git = "https://github.com/timfennis/andy-cpp", subpath = "ext/tree-sitter-andy-cpp" }
# A git source must include `rev`. If you have the repo checked out, a local
# path is simpler: source = { path = "/abs/path/to/ext/tree-sitter-andy-cpp" }
source = { git = "https://github.com/timfennis/andy-cpp", rev = "master", subpath = "ext/tree-sitter-andy-cpp" }
```

Fetch and build the grammar, then install the queries:
Build the grammar into Helix's runtime and install the queries. Rather than
`hx --grammar build` (which rebuilds every grammar and needs the output
directory to already exist), build just this one with the tree-sitter CLI — the
output file must be named `andy-cpp.so` to match the grammar name:

```bash
hx --grammar fetch
hx --grammar build
mkdir -p ~/.config/helix/runtime/queries/andy-cpp
cp ext/tree-sitter-andy-cpp/queries/*.scm ~/.config/helix/runtime/queries/andy-cpp/
cd ext/tree-sitter-andy-cpp
npm install
mkdir -p ~/.config/helix/runtime/grammars ~/.config/helix/runtime/queries/andy-cpp
npx tree-sitter build -o ~/.config/helix/runtime/grammars/andy-cpp.so

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Use Helix’s platform-specific grammar extension

For macOS or Windows users following this Helix setup, hard-coding andy-cpp.so installs the parser under a name Helix will not load. I checked Helix’s loader: it sets DYLIB_EXTENSION to dylib on macOS and dll on Windows, then loads runtime/grammars/<name>.<ext> in get_language (see helix-loader/src/grammar.rs), so hx --health andy-cpp and highlighting will still report no parser off Linux unless the instructions mention the platform-specific extension or use Helix’s build path.

Useful? React with 👍 / 👎.

cp queries/*.scm ~/.config/helix/runtime/queries/andy-cpp/
```

Check it with `hx --health andy-cpp` (Tree-sitter parser, Highlight queries, and
the `ndc-lsp` server should all be ✓).

> The binary is `hx` in most installs but may be `helix` (e.g. some distro
> packages); use whichever your install provides.

## Known limitations

- **Doubly-nested generics** in type annotations (`List<List<Int>>`) can
Expand Down
4 changes: 3 additions & 1 deletion ext/tree-sitter-andy-cpp/queries/injections.scm
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
; Highlight the leading `#!...` shebang line as bash.
; `#match?` (regex) is portable across Neovim and Helix; `#lua-match?` is
; Neovim-only and breaks Helix's combined query compilation.
((comment) @injection.content
(#lua-match? @injection.content "^#!")
(#match? @injection.content "^#!")
(#set! injection.language "bash"))
Loading