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 Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "graphcal-zed"
version = "0.0.7"
version = "0.0.8"
edition = "2021"
publish = false

Expand Down
4 changes: 2 additions & 2 deletions extension.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
id = "graphcal"
name = "Graphcal"
version = "0.0.7"
version = "0.0.8"
schema_version = 1
authors = ["shunichironomura"]
description = "Graphcal language support for Zed"
repository = "https://github.com/graphcal-lang/zed-graphcal"

[grammars.graphcal]
repository = "https://github.com/graphcal-lang/tree-sitter-graphcal"
rev = "d5669fea8fd9b5e75cc057acd040ed41bdae6e6f"
rev = "1716206afb62acc20b3f2261bfe99dcfc2864b74"

[language_servers.graphcal-lsp]
name = "Graphcal LSP"
Expand Down
84 changes: 40 additions & 44 deletions languages/graphcal/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@
[ "{" "}" ] @punctuation.bracket
[ "[" "]" ] @punctuation.bracket

[ ";" "," ":" "." "|" ] @punctuation.delimiter
[ ";" "," ":" "." "::" "|" ] @punctuation.delimiter
"#" @punctuation.special

; ---------------------------------------------------------------
; Declarations — names
Expand All @@ -118,10 +119,10 @@
(index_declaration name: (identifier) @type)


; import nasa.rocket.{delta_v}
; import nasa.rocket::{delta_v}
(import_declaration path: (module_path) @module)

; include nasa.rocket(params).{delta_v}
; include nasa.rocket(params)::{delta_v}
(include_declaration path: (module_path) @module)

; Highlight individual identifiers in a module path so the
Expand Down Expand Up @@ -170,7 +171,7 @@
; Types in annotations
; ---------------------------------------------------------------

; Type applications and indexed type index names: module.Vec3<Length>, Velocity[module.Maneuver]
; Type applications and indexed type index names: module::Vec3<Length>, Velocity[module::Maneuver]
(type_application name: (ident_path (identifier) @type))
(indexed_type (ident_path (identifier) @type))

Expand All @@ -193,38 +194,31 @@
(nat_add_expr (identifier) @type)
(nat_mul_expr (identifier) @type)

; Dimension terms in type annotations (Length, module.Time, Mass, etc.)
; Dimension terms in type annotations (Length, module::Time, Mass, etc.)
(dim_term (ident_path (identifier) @type))

; Unit terms in unit expressions: the leaf is the unit, an optional
; single qualifier is a module alias (u.mile)
(unit_term name: (identifier) @type)
(unit_term module: (identifier) @module)
; Unit terms use local or explicit namespace-member paths (u::mile).
(unit_term name: (ident_path (identifier) @type))

; ---------------------------------------------------------------
; Function calls and definitions
; ---------------------------------------------------------------


; fn/constructor calls: sqrt(x), Pick(...), module.Pick(...).
(fn_call name: (identifier) @function.call)
(fn_call path_segment: (identifier) @function.call)
; fn calls: sqrt(x), module::function(...).
(fn_call name: (ident_path (identifier) @function.call))

; ---------------------------------------------------------------
; Graph references: @name, @dag(args).out, @module.dag(args).out
; Graph references: @name, @instance::out, @dag(args)::out, @module.dag(args)::out
; ---------------------------------------------------------------

(graph_ref "@" @operator name: (identifier) @variable)
(graph_ref "@" @operator name: (ident_path (identifier) @variable))

; Inline DAG invocation: `@<name>(args).<out>` or
; `@<name>(.<seg>)+ (args).<out>`. The leaf segment of the path (the DAG
; name in call position) is highlighted as a function reference; any
; preceding segments are module aliases brought into scope by `import`;
; the projected output name after the closing `).` is highlighted as a
; variable.
; Inline DAG invocation: `@<name>(args)::<out>` or
; `@<name>(.<seg>)+(args)::<out>`. Dotted path segments name DAGs; the
; projected output after `)::` is a variable.
(inline_dag_call "@" @operator)
(inline_dag_call name: (identifier) @function.call !path_segment)
(inline_dag_call name: (identifier) @module path_segment: (identifier) @function.call)
(inline_dag_call path: (dag_call_path (identifier) @function.call))
(inline_dag_call output: (identifier) @variable)

; ---------------------------------------------------------------
Expand All @@ -251,17 +245,17 @@
; include nasa.rocket(args) as alias;
(include_declaration alias: (identifier) @module)

; Param bindings in include declarations: include "path"(name: expr) { ... }
; DAG input bindings: unmarked params or explicitly marked Static inputs.
(include_param_binding category: (input_binding_category) @keyword)
(include_param_binding name: (identifier) @variable)
(include_param_binding ":" @operator)

; ---------------------------------------------------------------
; Struct and index usage
; ---------------------------------------------------------------

; Struct construction: TransferResult(field: expr, ...) or module.TransferResult(...)
(struct_construction type: (identifier) @type)
(struct_construction path_segment: (identifier) @type)
; Struct construction: TransferResult(field: expr, ...) or module::TransferResult(...)
(struct_construction type: (ident_path (identifier) @type))

; Field access: @transfer.dv1
(field_access field: (identifier) @property)
Expand All @@ -272,9 +266,9 @@
; Field initializer: dv1: expr
(field_init name: (identifier) @property)

; Qualified variant: Maneuver.Departure or module.Maneuver.Departure.
; The parser preserves the full path; semantic resolution decides owner vs leaf.
(qualified_variant path: (identifier) @constant)
; Owner-qualified index label: Maneuver#Departure or module::Maneuver#Departure.
(qualified_variant index: (ident_path (identifier) @type))
(qualified_variant variant: (identifier) @constant)

; Tagged-union constructor names: type Foo { A(...), B }
(constructor_declaration name: (identifier) @type)
Expand All @@ -286,7 +280,7 @@
; Match expressions
; ---------------------------------------------------------------

; Match pattern path: Impulsive(...) =>, Maneuver.Departure =>, module.Pick(...) =>
; Match patterns: Impulsive(...) =>, Maneuver#Departure =>, module::Pick(...) =>
(match_pattern path: (ident_path (identifier) @type))

; Wildcard pattern: _
Expand Down Expand Up @@ -323,28 +317,30 @@
; Key introduction forms
; ---------------------------------------------------------------

(key_form_expr "key" @function.builtin)
(key_form_expr "fin_key" @function.builtin)
(key_form_expr "floor_key" @function.builtin)
(key_form_expr "ceil_key" @function.builtin)
(key_form_expr "nearest_key" @function.builtin)
(key_form_expr [
"key"
"fin_key"
"floor_key"
"ceil_key"
"nearest_key"
] @function.builtin)
(key_form_expr axis: (ident_path (identifier) @type))

; ---------------------------------------------------------------
; Attributes
; ---------------------------------------------------------------

; #[assumes(x, y)], #[expected_fail(Mode.Boost)]
; #[assumes(x, y)], #[expected_fail(Mode#Boost)]
(attribute "#" @punctuation.special)
(attribute "[" @punctuation.special)
(attribute "]" @punctuation.special)
(attribute name: (identifier) @attribute)
(attribute_finite_position "#" @punctuation.special)

; Attribute path arguments: ident, Index.Variant
(attribute_path (identifier) @variable)
; Attribute path arguments: ident, Index#Variant
(attribute_path (ident_path (identifier) @variable))

; Attribute group arguments: (Index.A, Index.B)
; Attribute group arguments: (Index#A, Index#B)
(attribute_group "(" @punctuation.bracket)
(attribute_group ")" @punctuation.bracket)

Expand Down Expand Up @@ -398,7 +394,7 @@
; Table expressions
; ---------------------------------------------------------------

; Index names in table[Index1, module.Index2]: highlighted as types
; Index names in table[Index1, module::Index2]: highlighted as types
(table_expr index: (ident_path (identifier) @type))
(table_slice_label "#" @punctuation.special)

Expand All @@ -410,15 +406,15 @@

; Multi-decl (issue #481) surface form — mirror single-decl highlights.

; Shared axis names in table[I1, module.I2, ..., (slots)]: highlighted as types
; Shared axis names in table[I1, module::I2, ..., (slots)]: highlighted as types
(multi_table_expr shared_axis: (ident_path (identifier) @type))

; Extra-axis names inside the slot tuple `(_, _, module.ExtraAxis)`: highlighted
; Extra-axis names inside the slot tuple `(_, _, module::ExtraAxis)`: highlighted
; as types. (`_` placeholders are a literal token, not an identifier.)
(slot_axis_entry (ident_path (identifier) @type))

; Heterogeneous header labels use qualified `Axis.Variant` syntax and are
; covered by the `qualified_variant` rule above. `_` remains a literal token.
; Heterogeneous header labels are contextual bare identifiers; `_` remains a
; literal token.

; Row labels in multi-decl data rows.
(multi_data_row row_label: (identifier) @constant)