Skip to content
Open
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ Cargo.lock
vscode/
objectscript-lsp/objectscript-tests/local/
objectscript-lsp/documentation/code-changes-AI
objectscript-lsp/documentation/local
objectscript-lsp/claude-code-objectscript-lsp/
objectscript-lsp/.claude-plugin/
30 changes: 29 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,41 @@ An [ObjectScript](https://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Pa

# Introduction

This Zed extension uses the [tree-sitter-objectscript](https://github.com/intersystems/tree-sitter-objectscript) grammars and the `objectscript-lsp` crate (local to this repo) to provide syntax highlighting, code injections, and language support for `.cls`, `.mac`, `.rtn`, `.inc`, `.int` and `.xml` files containing ObjectScript. Install the following extensions below to get syntax highlighting for any code injected into objectscript that is `sql` or `html`.
This Zed extension uses the [tree-sitter-objectscript](https://github.com/intersystems/tree-sitter-objectscript) grammars and the `objectscript-lsp` crate (local to this repo) to provide syntax highlighting, code injections, and language support for `.cls`, `.mac`, `.rtn`, `.inc`, `.int` and `.xml` files containing ObjectScript. Install the following extensions below to get syntax highlighting for any code injected into objectscript that is `sql`, `html`, or special comments (TODO, NOTE, etc).

- [SQL](https://zed.dev/extensions/sql)
- [HTML](https://zed.dev/extensions/html)
- [Comment](https://zed.dev/extensions/comment)

The current features supported in the `ObjectScript language server` are `goto_definition`, `goto_implementation`, `refactor`, and `diagnostics`. These features are described in detail in the `objectscript-lsp/documentation/features` folder.

# Setup Dev Extension
If you want the most up-to-date version of this extension (including experimental parts that have not yet been merged into [zed-industries/extensions](https://github.com/zed-industries/extensions), follow these steps:
1. Make sure you have [rust](https://rust-lang.org/tools/install/) installed.
2. Clone this repository into your local folders and cd into the objectscript-lsp folder (`cd zed-objectscript/objectscript-lsp`).
3. Build a local copy of the binary: `cargo b && cargo install --path . --force`
4. Go to Zed, and do `Cmd + Shift + P`, and then choose `zed:Extensions`. Then choose `Install Dev Extension` and point it at your local copy of this directory.
5. NOTE: If rebuilding, sometimes you have to quit out of Zed and re-enter it for the changes to show.


# User Config Settings
Right now we have a `strict mode` setting. If true, diagnostics will send warnings for any class or method not defined in the current workspace. Additionally, duplicate class names/ method names in the same class will be filed as a diagnostic. If false, only syntax errors will be filed in diagnostics.

The default is true. To set it to false, go to the Zed settings.json: (Cmd + Shift + P -> settings -> open settings.json)
and add this:
```json
"lsp": {
"objectscript-lsp": {
"initialization_options": {
"enableStrictMode": false
},
"settings": {
"enableStrictMode": false
}
}
},
```

## Reporting Issues

Please report issues via [GitHub Issues](https://github.com/intersystems/zed-objectscript/issues).
Expand Down
6 changes: 3 additions & 3 deletions extension.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ repository = "https://github.com/intersystems/zed-objectscript"

[grammars.objectscript_udl]
repository = "https://github.com/intersystems/tree-sitter-objectscript"
commit = "30cfb7addc4c6fdfcf1550180eef2cdcd1fdb202"
commit = "58432d03bfba25efad3059a52d0916d714739b09"
path = "udl"

[grammars.objectscript_routine]
repository = "https://github.com/intersystems/tree-sitter-objectscript"
commit = "30cfb7addc4c6fdfcf1550180eef2cdcd1fdb202"
commit = "58432d03bfba25efad3059a52d0916d714739b09"
path = "objectscript_routine"

[grammars.objectscript]
repository = "https://github.com/intersystems/tree-sitter-objectscript"
commit = "30cfb7addc4c6fdfcf1550180eef2cdcd1fdb202"
commit = "58432d03bfba25efad3059a52d0916d714739b09"
path = "objectscript"

[grammars.xml]
Expand Down
17 changes: 3 additions & 14 deletions languages/objectscript/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
[
(json_boolean_literal)
(json_null_literal)
(false)
(true)
] @boolean

(json_object_literal_pair
Expand Down Expand Up @@ -250,18 +252,6 @@
(html_marker_reversed)
] @punctuation.special

[
(line_comment_1)
(line_comment_2)
(line_comment_3)
(line_comment_4)
(block_comment)
(inline_comment)
(argumentless_inline_comment)
(pound_if_special_case_else)
(pound_if_special_case)
] @comment

(tag) @function

"--" @operator
Expand Down Expand Up @@ -337,9 +327,8 @@
(xdata_keyword)
(xdata_keyword_mimetype)
(property_keyword)
] @attribute
] @type.builtin

(documatic_line) @comment.doc

[
(query_name)
Expand Down
22 changes: 14 additions & 8 deletions languages/objectscript/injections.scm
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,8 @@
; Keywords, one of type language = "python", none of type codemode
; External method body injection based on [ Language = ... ]
(method_definition
(method_keyword_external_language
(typename) @_lang)
(external_method_body_content) @injection.content
(python_method_body_content) @injection.content
(#set! injection.include-children "true")
(#any-of? @_lang "python" "Python" "PYTHON")
(#set! injection.language "python"))

(method_definition
Expand All @@ -51,11 +48,8 @@
(#set! injection.language "ispl"))

(trigger
(method_keyword_external_language
(typename) @_lang)
(external_method_body_content) @injection.content
(python_method_body_content) @injection.content
(#set! injection.include-children "true")
(#any-of? @_lang "python" "Python" "PYTHON")
(#set! injection.language "python"))

(trigger
Expand Down Expand Up @@ -147,4 +141,16 @@
(#set! injection.language "xml")
(#set! injection.include-children "true"))

([
(line_comment_1)
(line_comment_2)
(line_comment_3)
(line_comment_4)
(block_comment)
(inline_comment)
(argumentless_inline_comment)
(documatic_line)
] @injection.content
(#set! injection.language "comment"))

; === END LOCAL ===
7 changes: 0 additions & 7 deletions languages/objectscript_routine/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -253,13 +253,6 @@
] @punctuation.special

[
(line_comment_1)
(line_comment_2)
(line_comment_3)
(line_comment_4)
(block_comment)
(inline_comment)
(argumentless_inline_comment)
(pound_if_special_case_else)
(pound_if_special_case)
] @comment
Expand Down
11 changes: 11 additions & 0 deletions languages/objectscript_routine/injections.scm
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,14 @@
(embedded_xml
(angled_bracket_fenced_text) @injection.content
(#set! injection.language "xml"))

([
(line_comment_1)
(line_comment_2)
(line_comment_3)
(line_comment_4)
(block_comment)
(inline_comment)
(argumentless_inline_comment)
] @injection.content
(#set! injection.language "comment"))
25 changes: 14 additions & 11 deletions languages/objectscript_udl/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
[
(json_boolean_literal)
(json_null_literal)
(false)
(true)
] @boolean

(json_object_literal_pair
Expand Down Expand Up @@ -84,7 +86,15 @@
] @variant

(method_arg) @variable.parameter

[(line_comment_1)
(line_comment_2)
(line_comment_3)
(line_comment_4)
(block_comment)
(inline_comment)
(argumentless_inline_comment)
] @comment
(documatic_line) @comment.doc
; 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 Down Expand Up @@ -251,13 +261,6 @@
] @punctuation.special

[
(line_comment_1)
(line_comment_2)
(line_comment_3)
(line_comment_4)
(block_comment)
(inline_comment)
(argumentless_inline_comment)
(pound_if_special_case_else)
(pound_if_special_case)
] @comment
Expand Down Expand Up @@ -297,6 +300,8 @@
; === BEGIN LOCAL ===
(iris_username) @preproc

(keyword_class) @attribute

[
(keyword_import)
(keyword_include)
Expand Down Expand Up @@ -337,9 +342,7 @@
(xdata_keyword)
(xdata_keyword_mimetype)
(property_keyword)
] @attribute

(documatic_line) @comment.doc
] @type.builtin

[
(query_name)
Expand Down
22 changes: 14 additions & 8 deletions languages/objectscript_udl/injections.scm
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,8 @@
; Keywords, one of type language = "python", none of type codemode
; External method body injection based on [ Language = ... ]
(method_definition
(method_keyword_external_language
(typename) @_lang)
(external_method_body_content) @injection.content
(python_method_body_content) @injection.content
(#set! injection.include-children "true")
(#any-of? @_lang "python" "Python" "PYTHON")
(#set! injection.language "python"))

(method_definition
Expand All @@ -51,11 +48,8 @@
(#set! injection.language "ispl"))

(trigger
(method_keyword_external_language
(typename) @_lang)
(external_method_body_content) @injection.content
(python_method_body_content) @injection.content
(#set! injection.include-children "true")
(#any-of? @_lang "python" "Python" "PYTHON")
(#set! injection.language "python"))

(trigger
Expand Down Expand Up @@ -148,3 +142,15 @@
(#set! injection.include-children "true"))

; === END LOCAL ===

([
(line_comment_1)
(line_comment_2)
(line_comment_3)
(line_comment_4)
(block_comment)
(inline_comment)
(argumentless_inline_comment)
(documatic_line)
] @injection.content
(#set! injection.language "comment"))
7 changes: 4 additions & 3 deletions objectscript-lsp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ objectscript-core = { path = "crates/objectscript-core" }
tower-lsp = "0.20.0"
tokio = { version = "1", features = ["rt-multi-thread", "macros", "io-std", "fs"] }
tree-sitter = "0.26.6"
tree-sitter-objectscript = "1.9.13"
tree-sitter-objectscript-routine = "1.9.13"
tree-sitter-objectscript-playground = "1.9.13"
tree-sitter-objectscript = "1.9.16"
tree-sitter-objectscript-routine = "1.9.16"
tree-sitter-objectscript-playground = "1.9.16"
tree-sitter-xml = "0.7.0"
serde = "1.0.228"
serde_json = "1.0.145"
parking_lot = "0.12.5"
Expand Down
18 changes: 12 additions & 6 deletions objectscript-lsp/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# ObjectScript LSP

Language Server Protocol implementation for InterSystems ObjectScript using `tower-lsp` and `tree-sitter`.
Language Server & Language Server Protocol implementation for InterSystems ObjectScript using `tower-lsp` and `tree-sitter`.

Goal: provide editor-independent ObjectScript semantics for VS Code, Zed, Neovim, and other LSP clients without requiring a live InterSystems server connection.
We built this language server to provide editor-independent ObjectScript semantics for VS Code, Zed, Neovim, and other LSP clients without requiring a live InterSystems server connection.

## Current Features

- Workspace indexing for `.cls`, `.inc`, `.rtn`, `.mac`, and `.int`
- Everything is rebuilt incrementally.
- Multi-workspace support through LSP workspace folders, with deepest-parent routing per document
- Go-to-definition for ObjectScript variables with ProcedureBlock-aware private/public resolution
- Go-to-definition for ObjectScript variables, orefs, methods, properties, classes, parameters with ProcedureBlock-aware private/public resolution
- Go-to-implementation for inherited and overridden methods and classes
- Syntax diagnostics for tracked ObjectScript documents
- Mixed-language diagnostics for ObjectScript captured from XML `Implementation` blocks
Expand All @@ -18,6 +19,7 @@ Goal: provide editor-independent ObjectScript semantics for VS Code, Zed, Neovim
- Legacy `FOR` rewrites
- document-scoped and workspace-scoped edits
- Inheritance modeling and override index build
- Dependency modeling and dependencyGraph build (shows all paths to a given method)


## Architecture Summary
Expand All @@ -44,6 +46,10 @@ Goal: provide editor-independent ObjectScript semantics for VS Code, Zed, Neovim
- `textDocument/diagnostic`
- Code actions and execute commands for refactor rewrites

## Configuration

Editor-specific configuration examples for Zed, Neovim, and VS Code are documented in [documentation/configuration.md](documentation/configuration.md).


## Build and Test

Expand All @@ -70,9 +76,9 @@ In this case, the `DependencyGraph` is used to determine all possible paths to t
## Grammar Baseline

- `tree-sitter = 0.26.6`
- `tree-sitter-objectscript = 1.9.13`
- `tree-sitter-objectscript-routine = 1.9.13`
- `tree-sitter-objectscript-playground = 1.9.13`
- `tree-sitter-objectscript = 1.9.16`
- `tree-sitter-objectscript-routine = 1.9.16`
- `tree-sitter-objectscript-playground = 1.9.16`
- `tree-sitter-xml = 0.7.0`

## Roadmap
Expand Down
16 changes: 14 additions & 2 deletions objectscript-lsp/crates/objectscript-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,21 @@ authors = ["Hannah Kimura <hannah.kimura@intersystems.com>"]
license = "MIT"
description = "Language Server for ObjectScript"

[features]
update-bench = []

[[bench]]
name = "update_document"
harness = false
required-features = ["update-bench"]

[dependencies]
tower-lsp = "0.20.0"
tokio = { version = "1", features = ["rt-multi-thread", "macros", "io-std", "fs"] }
tree-sitter = "0.26.6"
tree-sitter-objectscript = "1.9.13"
tree-sitter-objectscript-routine = "1.9.13"
tree-sitter-objectscript = "1.9.16"
tree-sitter-objectscript-routine = "1.9.16"
tree-sitter-objectscript-playground = "1.9.16"
tree-sitter-xml = "0.7.0"
serde = "1.0.228"
serde_json = "1.0.145"
Expand All @@ -20,3 +29,6 @@ walkdir = "2.5.0"
regex = "1.12.3"
petgraph = "0.8.3"
evalexpr = "13.1.0"

[dev-dependencies]
criterion = { version = "0.5", features = ["html_reports"] }
Loading