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
28 changes: 28 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: CI

on:
push:
pull_request:
branches:
- main
workflow_dispatch:

permissions:
contents: read

jobs:
query_checks:
name: Query checks
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6

- name: Set up ts_query_ls
run: curl -fL https://github.com/ribru17/ts_query_ls/releases/latest/download/ts_query_ls-x86_64-unknown-linux-gnu.tar.gz | tar -xz

- name: Lint query files
run: ./ts_query_ls lint languages --config '{"language_retrieval_patterns":["languages/([^/]+)/[^/]+\\.scm$"]}'

- name: Check Zed highlight captures
run: python3 scripts/lint_zed_captures.py
8 changes: 4 additions & 4 deletions extension.toml
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
id = "objectscript"
name = "InterSystems ObjectScript"
version = "1.3.0"
version = "1.4.0"
schema_version = 1
authors = ["Dave McCaldon <davem@intersystems.com>","Hannah Kimura <hannah.kimura@intersystems.com>"]
description = "InterSystems IRIS ObjectScript Extension"
repository = "https://github.com/intersystems/zed-objectscript"

[grammars.objectscript_udl]
repository = "https://github.com/intersystems/tree-sitter-objectscript"
commit = "bd68f926f0b3451421be3b60387d0dce901aebe7"
commit = "7aa01969d0fea2e75dc69f2be2244b13d8269d6f"
path = "udl"

[grammars.objectscript_core]
repository = "https://github.com/intersystems/tree-sitter-objectscript"
commit = "bd68f926f0b3451421be3b60387d0dce901aebe7"
commit = "7aa01969d0fea2e75dc69f2be2244b13d8269d6f"
path = "core"

[grammars.objectscript]
repository = "https://github.com/intersystems/tree-sitter-objectscript"
commit = "bd68f926f0b3451421be3b60387d0dce901aebe7"
commit = "7aa01969d0fea2e75dc69f2be2244b13d8269d6f"
path = "objectscript"

[grammars.xml]
Expand Down
4 changes: 1 addition & 3 deletions languages/objectscript/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@
"#"
"|"
"||"
"/"
"/"
"$$"
] @punctuation

Expand Down Expand Up @@ -165,4 +163,4 @@ keyword: (_) @keyword
(property_type) @type.builtin
(index_property_type) @type.builtin

(identifier) @variable
(identifier) @variable
3 changes: 0 additions & 3 deletions languages/objectscript_core/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@
"#"
"|"
"||"
"/"
"/"
"$$"
] @punctuation

Expand Down Expand Up @@ -121,4 +119,3 @@ keyword: (_) @keyword
"##;"
"$"
] @punctuation

26 changes: 9 additions & 17 deletions languages/objectscript_udl/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
(objectscript_identifier) @variable

(method_arg) @variable.parameter
; I didn't include ( or ) in this, because they are often grouped
; I didn't include '(' or ')' in this, because they are often grouped
; as part of a sequence that gets turned into a single token, so they
; don't get matched, and one ends up getting colored differently than the other.
[
Expand All @@ -47,9 +47,13 @@
"#"
"|"
"||"
"/"
"/"
"$$"
"--"
";"
"//"
"#;"
"##;"
"$"
] @punctuation

[
Expand All @@ -68,13 +72,13 @@
"="
">"
">="
"@"
"@"
"*"
"**"
"'"
"'!"
"'?"
"!"
"!"
"?"
] @operator

Expand All @@ -83,8 +87,6 @@
(json_number_literal) @number
(json_null_literal) @string
(bracket) @punctuation.bracket

;; inherits: objectscript_expr
(locktype) @variable

(macro_arg) @variable
Expand Down Expand Up @@ -113,16 +115,6 @@ keyword: (_) @keyword

(tag) @tag

[
"--"
";"
"//"
"#;"
"##;"
"$"
] @punctuation

;; inherits: objectscript_core
; ------------------ UDL -------------------

[
Expand Down
2 changes: 1 addition & 1 deletion languages/objectscript_udl/injections.scm
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@



; UDL injections
; UDL grammar injections
;; Keywords, one of type language = "python", none of type codemode
; External method body injection based on [ Language = ... ]
(method_definition
Expand Down
12 changes: 5 additions & 7 deletions languages/xml/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@

(PubidLiteral) @string.special

(SystemLiteral (URI) @markup.link)
(SystemLiteral (URI) @link_uri)

;; Processing instructions

Expand Down Expand Up @@ -154,15 +154,13 @@

;; Text

(CharData) @markup
(CharData) @text

(CDSect
(CDStart) @markup.heading
(CData) @markup.raw
"]]>" @markup.heading)
(CDStart) @punctuation.markup
(CData) @text.literal
"]]>" @punctuation.markup)

;; Misc

(Comment) @comment

(ERROR) @error
107 changes: 107 additions & 0 deletions scripts/lint_zed_captures.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
#!/usr/bin/env python3

"""Validate highlight captures against Zed's syntax capture names."""

from __future__ import annotations

import re
import sys
from pathlib import Path


CAPTURE_PATTERN = re.compile(r"@([A-Za-z0-9_.-]+)")
ALLOWED_ZED_CAPTURES = {
"attribute",
"boolean",
"comment",
"comment.doc",
"constant",
"constructor",
"embedded",
"emphasis",
"emphasis.strong",
"enum",
"function",
"function.builtin",
"hint",
"keyword",
"label",
"link_text",
"link_uri",
"namespace",
"number",
"operator",
"predictive",
"preproc",
"primary",
"property",
"punctuation",
"punctuation.bracket",
"punctuation.delimiter",
"punctuation.list_marker",
"punctuation.markup",
"punctuation.special",
"selector",
"selector.pseudo",
"string",
"string.escape",
"string.regex",
"string.special",
"string.special.symbol",
"tag",
"text",
"text.literal",
"title",
"type",
"variable",
"variable.special",
"variant",
}


def is_allowed(capture: str) -> bool:
if capture.startswith("_"):
return True

parts = capture.split(".")
for i in range(len(parts), 0, -1):
prefix = ".".join(parts[:i])
if prefix in ALLOWED_ZED_CAPTURES:
return True
return False


def collect_highlight_files(root: Path) -> list[Path]:
return sorted(root.glob("languages/*/highlights.scm"))


def main() -> int:
root = Path.cwd()
highlight_files = collect_highlight_files(root)
if not highlight_files:
print("No highlights.scm files found under languages/*/")
return 1

failures: list[tuple[Path, int, str]] = []
for highlight_file in highlight_files:
text = highlight_file.read_text(encoding="utf-8")
for line_number, line in enumerate(text.splitlines(), start=1):
for match in CAPTURE_PATTERN.finditer(line):
capture = match.group(1)
if not is_allowed(capture):
failures.append((highlight_file, line_number, capture))

if failures:
print("Unsupported highlight captures detected:")
for path, line_number, capture in failures:
relative_path = path.relative_to(root)
print(f"- {relative_path}:{line_number} uses @{capture}")
print("\nUse Zed capture names (or subscopes of them) for highlights.")
return 1

print("All highlight captures are compatible with Zed capture names.")
return 0


if __name__ == "__main__":
sys.exit(main())
3 changes: 3 additions & 0 deletions themes/tokyonight-day.json
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,9 @@
"variable": {
"color": "#3760bf"
},
"variable.special": {
"color": "#c64343"
},
"variable.builtin": {
"color": "#f52a65"
},
Expand Down
6 changes: 6 additions & 0 deletions themes/tokyonight-light.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@
"variable": {
"color": "#3760bf"
},
"variable.special": {
"color": "#bf3a4c"
},
"variable.parameter": {
"color": "#8f5e15"
},
"constant": {
"color": "#8f3f71"
},
Expand Down