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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ To update:
### Useful Commands

```sh
# Sync query files from grammar to languages
# Sync the generated Zed highlight query from the grammar
just sync-queries

# Clean build artifacts
Expand Down
2 changes: 1 addition & 1 deletion extension.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ languages = ["languages/roc"]

[grammars.roc]
repository = "https://github.com/faldor20/tree-sitter-roc"
commit = "edc18052a9d7382ac9f9f5bf413db3a78d5ea12c"
commit = "fc80e44f452314518550d947bcfdde6c3001a405"

[language_servers.roc]
language = "Roc"
Expand Down
14 changes: 11 additions & 3 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,29 @@ check:
cargo test
cargo build --target wasm32-wasip2

# Sync query files from the tree-sitter-roc commit in extension.toml.
# Sync the generated highlight query from the tree-sitter-roc commit in extension.toml.
# Other editor queries are maintained here because Zed's behavior differs.
sync-queries:
mkdir -p grammars
if [ ! -d grammars/roc/.git ]; then git clone {{grammar_repository}} grammars/roc; fi
cd grammars/roc && git remote set-url origin {{grammar_repository}}
cd grammars/roc && git fetch origin && git checkout {{grammar_commit}}
cp -v grammars/roc/queries/*.scm languages/roc/
cp -v grammars/roc/queries-generated/zed/queries/highlights.scm languages/roc/
just check-highlight-captures
rm -f grammars/roc.wasm

# Reject highlight captures that Zed themes do not support.
check-highlight-captures:
scripts/check-highlight-captures.sh

# Update grammar to a specific commit and sync queries
update-grammar COMMIT:
mkdir -p grammars
if [ ! -d grammars/roc/.git ]; then git clone {{grammar_repository}} grammars/roc; fi
cd grammars/roc && git remote set-url origin {{grammar_repository}}
cd grammars/roc && git fetch origin && git checkout {{COMMIT}}
cp -v grammars/roc/queries/*.scm languages/roc/
cp -v grammars/roc/queries-generated/zed/queries/highlights.scm languages/roc/
just check-highlight-captures
rm -f grammars/roc.wasm
@echo "Done. Click 'Rebuild' in Zed to recompile the grammar."

Expand Down
7 changes: 7 additions & 0 deletions languages/roc/brackets.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
("(" @open ")" @close)
("[" @open "]" @close)
("{" @open "}" @close)

(nominal_methods
".{" @open
"}" @close)
1 change: 1 addition & 0 deletions languages/roc/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ brackets = [
{ start = "(", end = ")", close = true, newline = true },
{ start = "\"", end = "\"", close = true, newline = false, not_in = [
"string",
"comment",
] },
{ start = "'", end = "'", close = true, newline = false, not_in = [
"string",
Expand Down
Loading
Loading