Skip to content

Commit f250506

Browse files
Initial release
0 parents  commit f250506

8 files changed

Lines changed: 422 additions & 0 deletions

File tree

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/*.wasm
2+
/target
3+
grammars/
4+

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 InterSystems Corporation
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Zed ObjectScript
2+
3+
An [ObjectScript](https://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=GCOS_intro) extension for [Zed](https://zed.dev) to support development for the InterSystems IRIS product.
4+
5+
[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-%23FE5196?logo=conventionalcommits6logoColor=white)](https://conventionalcommits.org)
6+
7+
# Introduction
8+
9+
This Zed extension uses the [tree-sitter-objectscript](https://github.com/intersystems/tree-sitter-objectscript) grammar to provide syntax highlighting and code injections for `.cls` files containing ObjectScript. Since ObjectScripts supports a number of embedded languages, you should install grammars for the following languages otherwise you may see areas that appear to lack syntax coloring.
10+
11+
- SQL
12+
- HTML
13+
- Python
14+
- JavaScript
15+
- CSS
16+
- XML
17+
- Markdown
18+
19+
**NOTE**: The ObjectScript `.cls` syntax supports some sophisticated constructs and as such it can take 15-60 seconds for Zed's WASM machinery to build the parser before syntax coloring becomes available.
20+
21+
Currently this extension only provides syntax coloring support.
22+
23+
## Reporting Issues
24+
25+
Please report issues via [GitHub Issues](https://github.com/intersystems/zed-objectscript/issues).
26+
27+
## Contributing
28+
29+
Contributions are welcome. Please submit changes via Pull Requests. Our preference is to use [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) for commit messages in order to keep the summaries terse, but allowing for more detail on the subsequent lines of the commit message.
30+
31+
### Development
32+
33+
To develop this extension, see the [Developing Extensions](https://zed.dev/docs/extensions/developing-extensions) section of the Zed docs.
34+
35+
#### Notes
36+
37+
To enable log output for Zed, set `RUST_LOG` as follows before starting `zed` from the command line:
38+
39+
```ps
40+
$env:RUST_LOG = "language,extension=trace"
41+
```
42+
43+
```bash
44+
RUST_LOG = "language,extension=trace"
45+
```
46+
47+
Cloning and the building a debug Zed with these `RUST_LOG` settings gives fairly detailed log output including diagnosing
48+
bad `.scm` rules.
49+

extension.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
id = "zed-objectscript"
2+
name = "InterSystems ObjectScript"
3+
version = "1.0.0"
4+
schema_version = 1
5+
authors = ["Dave McCaldon <davem@intersystems.com>"]
6+
description = "InterSystems IRIS ObjectScript Extension"
7+
repository = "https://github.com/intersystems/zed-objectscript"
8+
9+
[grammars.objectscript_udl]
10+
repository = "https://github.com/intersystems/tree-sitter-objectscript"
11+
commit = "f53770ad22dfdebbecfaedb05c32f6f4924fcba7"
12+
path = "udl"
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name = "objectscript_udl"
2+
grammar = "objectscript_udl"
3+
path_suffixes = ["cls"]
4+
line_comments = ["// ", ";", ";;", "#;"]
5+
autoclose_before = ";:.,=}])>` \n\t\""
6+
brackets = [
7+
{ start = "{", end = "}", close = true, newline = true },
8+
{ start = "[", end = "]", close = true, newline = false },
9+
{ start = "(", end = ")", close = true, newline = false },
10+
]
Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
; -------------- Objectscript -------------
2+
3+
4+
; Variables
5+
; ^| e.g. '^||ppg', 'do', 'D'
6+
; -----------------------------------------
7+
(gvn) @variable.special
8+
(ssvn) @variable.special
9+
(lvn) @variable
10+
(instance_variable) @variable.special
11+
12+
; String literals
13+
; e.g. "Fo345349*_)(*_)8023841-40"" "
14+
; -----------------------------------------
15+
(string_literal) @string
16+
(pattern_expression) @string.regex
17+
18+
; Operators
19+
(_ operator: _ @operator)
20+
21+
; Numeric literals
22+
; e.g. 12345
23+
(integer_literal) @number
24+
(decimal_literal) @float
25+
26+
; System variable name
27+
; e.g. $IO, $SY[SYTEM]
28+
(system_defined_variable) @function.builtin
29+
30+
; System defined functions
31+
; e.g. $ASCII(62)
32+
(system_defined_function) @function.builtin
33+
34+
(dollarsf
35+
; $SYSTEM.Foo.Bar()
36+
(dollar_system_keyword) @function.builtin
37+
)
38+
39+
(property_name) @property
40+
(parameter_name) @constant
41+
(_ parameter: _ @variable.parameter)
42+
43+
; Method invcoations
44+
(instance_method_call) @function.method.call
45+
(class_method_call
46+
(class_ref (class_name) @type.definition)
47+
(method_name) @function.method.call
48+
)
49+
(oref_method (method_name) @function.method.call)
50+
51+
(_ preproc_keyword: (_) @keyword.directive)
52+
(_ modifier: (_) @keyword.directive)
53+
54+
55+
; User-defined functions
56+
(extrinsic_function) @function.call
57+
58+
; Goto labels and locations
59+
(_ label: (_) @label)
60+
(_ offset: (_) @number)
61+
(_ routine: (_) @namespace)
62+
63+
; JSON literals
64+
(json_boolean_literal) @boolean
65+
(json_null_literal) @constant.builtin
66+
(json_number_literal) @number
67+
(json_string_literal) @string.escape
68+
69+
; Macros
70+
(macro (macro_constant)) @constant.macro
71+
(macro (macro_function)) @function.macro
72+
73+
74+
; -------------- Objectscript Core -------------
75+
; Commands
76+
; e.g. 'set', 'do', 'D'
77+
; -----------------------------------------
78+
(_ command_name: (_) @keyword)
79+
80+
(_ macro_name: (_) @keyword.macro)
81+
(_ macro_arg: (_) @constant.macro)
82+
(_ mnemonic: (_) @constant.macro)
83+
84+
; Functions that can be on the LHS of a SET
85+
(doable_dollar_functions) @function.builtin
86+
87+
; non-extrinsic routine call
88+
(routine_tag_call) @function.call
89+
90+
;; Technically elseif and else_block are not statements,
91+
;; so we need ot query them explicitly
92+
;(elseif_block command_name: (_) @keyword)
93+
;(else_block command_name: (_) @keyword)
94+
95+
"{" @punctuation.bracket
96+
"}" @punctuation.bracket
97+
98+
; Comments
99+
; e.g. '// fj;lkasdfj', '#; sklfjas;k', '; sklfjas','/* sdfs */'
100+
[
101+
(line_comment_1)
102+
(line_comment_2)
103+
(line_comment_3)
104+
(block_comment)
105+
] @comment
106+
107+
(embedded_html
108+
(keyword_embedded_html) @keyword.directive
109+
"<" @keyword.directive
110+
">" @keyword.directive
111+
)
112+
; (embedded_sql_hash
113+
; (keyword_embedded_sql_hash) @keyword.directive
114+
; )
115+
; (embedded_sql_amp
116+
; (keyword_embedded_sql_amp) @keyword.directive
117+
; "(" @keyword.directive
118+
; ")" @keyword.directive
119+
; (embedded_sql_reverse_marker) @keyword.directive
120+
; )
121+
122+
(embedded_sql_amp
123+
(keyword_embedded_sql_amp) @keyword.directive
124+
"(" @keyword.directive
125+
")" @keyword.directive
126+
)
127+
128+
(embedded_sql_hash
129+
(keyword_embedded_sql_hash) @keyword.directive
130+
"(" @keyword.directive
131+
")" @keyword.directive
132+
)
133+
134+
(embedded_js
135+
(keyword_embedded_js) @keyword.directive
136+
"<" @keyword.directive
137+
">" @keyword.directive
138+
)
139+
140+
(embedded_xml
141+
(keyword_embedded_xml) @keyword.directive
142+
"<" @keyword.directive
143+
">" @keyword.directive
144+
)
145+
146+
(tag) @label
147+
148+
; Lock type specifications
149+
(locktype) @type.qualifier
150+
151+
152+
(_ keyword: (_) @keyword)
153+
154+
; (identifier) @variable
155+
156+
157+
; Alternatively
158+
; (class_statement (_ class_statement_keyword: (_) @keyword ) .)
159+
"{" @punctuation.bracket
160+
"}" @punctuation.bracket
161+
162+
; @class.name capture group is not suppported in nvim highlighter
163+
; (class_definition class_name: (identifier) @class.name)
164+
(include_clause (identifier) @keyword.import)
165+
(property (identifier) @property)
166+
(parameter (identifier) @constant)
167+
(projection (identifier) @type.definition)
168+
(trigger (identifier) @type.definition)
169+
(index (identifier) @type.definition)
170+
(relationship (identifier) @type.definition)
171+
(foreignkey (identifier) @type.definition)
172+
(xdata (identifier) @constant)
173+
(typename) @type
174+
(class_definition
175+
class_name: (identifier) @type
176+
(class_extends (identifier) @type))
177+
(method_definition (identifier (identifier)) @function)
178+
(query (identifier) @function)
179+
180+
(argument (identifier) @variable.parameter)
181+
182+
(keyword_name) @keyword
183+
184+
(class_keywords (_ rhs: _ @constant.builtin))
185+
(parameter_keywords (_ rhs: _ @constant.builtin))
186+
(property_keywords (_ rhs: _ @constant.builtin))
187+
(xdata_keywords (_ rhs: _ @constant.builtin))
188+
(method_keywords (_ rhs: _ @constant.builtin))
189+
(trigger_keywords (_ rhs: _ @constant.builtin))
190+
(query_keywords (_ rhs: _ @constant.builtin))
191+
(index_keywords (_ rhs: _ @constant.builtin))
192+
(foreignkey_keywords (_ rhs: _ @constant.builtin))
193+
(projection_keywords (_ rhs: _ @constant.builtin))
194+
(relationship_keywords (_ rhs: _ @constant.builtin))
195+
196+
(documatic_line) @comment.doc
197+

0 commit comments

Comments
 (0)