Skip to content

Commit

Permalink
Add Support for JSONC (helix-editor#9906)
Browse files Browse the repository at this point in the history
* Added `jsonc` language with support for comments

The `vscode-json-language-server` accepts `jsonc` as a language id.
Allowing the use of comments within JSON files.

* fix: Update `injdection-rejex` to be unique

* fix: use includes to remove redundant queries

* ci: Generate language-support docs
  • Loading branch information
RiyeUK authored and Vulpesx committed Jun 7, 2024
1 parent 4860109 commit 7cbb3ef
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions book/src/generated/lang-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
| jsdoc || | | |
| json || || `vscode-json-language-server` |
| json5 || | | |
| jsonc || || `vscode-json-language-server` |
| jsonnet || | | `jsonnet-language-server` |
| jsx |||| `typescript-language-server` |
| julia |||| `julia` |
Expand Down
10 changes: 9 additions & 1 deletion languages.toml
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,6 @@ scope = "source.json"
injection-regex = "json"
file-types = [
"json",
"jsonc",
"arb",
"ipynb",
"geojson",
Expand Down Expand Up @@ -396,6 +395,15 @@ indent = { tab-width = 2, unit = " " }
name = "json"
source = { git = "https://github.com/tree-sitter/tree-sitter-json", rev = "73076754005a460947cafe8e03a8cf5fa4fa2938" }

[[language]]
name = "jsonc"
scope = "source.json"
injection-regex = "jsonc"
file-types = ["jsonc"]
grammar = "json"
language-servers = [ "vscode-json-language-server" ]
auto-format = true
indent = { tab-width = 2, unit = " " }

[[language]]
name = "json5"
Expand Down
2 changes: 2 additions & 0 deletions runtime/queries/jsonc/highlights.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
; inherits: json
(comment) @comment
1 change: 1 addition & 0 deletions runtime/queries/jsonc/indents.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
; inherits: json

0 comments on commit 7cbb3ef

Please sign in to comment.