Skip to content

Commit

Permalink
Add support to JSON (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
unnamedd authored Nov 22, 2024
1 parent 4ee600f commit 31227c2
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions Configurations/NonSwiftWorkaround.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ OTHER_SWIFT_FLAGS = $(inherited) -Xcc -fmodule-map-file=$(GENERATED_MODULEMAP_DI
OTHER_SWIFT_FLAGS = $(inherited) -Xcc -fmodule-map-file=$(GENERATED_MODULEMAP_DIR)/TreeSitterGosum.modulemap
OTHER_SWIFT_FLAGS = $(inherited) -Xcc -fmodule-map-file=$(GENERATED_MODULEMAP_DIR)/TreeSitterGoWork.modulemap
OTHER_SWIFT_FLAGS = $(inherited) -Xcc -fmodule-map-file=$(GENERATED_MODULEMAP_DIR)/TreeSitterHTML.modulemap
OTHER_SWIFT_FLAGS = $(inherited) -Xcc -fmodule-map-file=$(GENERATED_MODULEMAP_DIR)/TreeSitterJSON.modulemap
OTHER_SWIFT_FLAGS = $(inherited) -Xcc -fmodule-map-file=$(GENERATED_MODULEMAP_DIR)/TreeSitterMarkdown.modulemap
OTHER_SWIFT_FLAGS = $(inherited) -Xcc -fmodule-map-file=$(GENERATED_MODULEMAP_DIR)/TreeSitterMarkdownInline.modulemap
OTHER_SWIFT_FLAGS = $(inherited) -Xcc -fmodule-map-file=$(GENERATED_MODULEMAP_DIR)/TreeSitterOCaml.modulemap
Expand Down
2 changes: 2 additions & 0 deletions Dependencies/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ let package = Package(
.package(url: "https://github.com/camdencheek/tree-sitter-go-mod", branch: "main"),
.package(url: "https://github.com/tree-sitter-grammars/tree-sitter-go-sum", branch: "master"),
.package(url: "https://github.com/mattmassicotte/tree-sitter-go-work", branch: "feature/spm"),
.package(url: "https://github.com/tree-sitter/tree-sitter-json", branch: "master"),
.package(url: "https://github.com/tree-sitter-grammars/tree-sitter-markdown", branch: "split_parser"),
.package(url: "https://github.com/tree-sitter/tree-sitter-ocaml", branch: "master"),
.package(url: "https://github.com/tree-sitter/tree-sitter-python", branch: "master"),
Expand All @@ -43,6 +44,7 @@ let package = Package(
.product(name: "TreeSitterGosum", package: "tree-sitter-go-sum"),
.product(name: "TreeSitterGoWork", package: "tree-sitter-go-work"),
.product(name: "TreeSitterHTML", package: "tree-sitter-html"),
.product(name: "TreeSitterJSON", package: "tree-sitter-json"),
.product(name: "TreeSitterMarkdown", package: "tree-sitter-markdown"),
.product(name: "TreeSitterOCaml", package: "tree-sitter-ocaml"),
.product(name: "TreeSitterPython", package: "tree-sitter-python"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
@_exported import TreeSitterGosum
@_exported import TreeSitterGoWork
@_exported import TreeSitterHTML
@_exported import TreeSitterJSON
@_exported import TreeSitterMarkdown
@_exported import TreeSitterMarkdownInline
@_exported import TreeSitterOCaml
Expand Down
9 changes: 9 additions & 0 deletions Edit/Modules/SyntaxService/LanguageProfile+Profiles.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ extension LanguageProfile {
return LanguageProfile.htmlProfile
}

if utType.conforms(to: .json) {
return LanguageProfile.jsonProfile
}

if utType.conforms(to: .markdown) {
return LanguageProfile.markdownProfile
}
Expand Down Expand Up @@ -127,6 +131,11 @@ extension LanguageProfile {
language: Language(tree_sitter_html())
)

static let jsonProfile = LanguageProfile(
RootLanguage.json,
language: Language(tree_sitter_json())
)

static let markdownProfile = LanguageProfile(
RootLanguage.markdown,
language: Language(tree_sitter_markdown())
Expand Down
6 changes: 6 additions & 0 deletions Edit/Modules/SyntaxService/RootLanguage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public enum RootLanguage: Hashable, CaseIterable, Sendable {
case goSum
case goWork
case html
case json
case markdown
case ocaml
case ocamlInterface
Expand All @@ -37,6 +38,7 @@ public enum RootLanguage: Hashable, CaseIterable, Sendable {
case .goSum: .goSumFile
case .goWork: .goWorkFile
case .html: .html
case .json: .json
case .markdown: .markdown
case .ocaml: .ocamlSource
case .ocamlInterface: .ocamlInterface
Expand Down Expand Up @@ -75,6 +77,8 @@ extension RootLanguage: RawRepresentable {
self = .goWork
case "html":
self = .html
case "json":
self = .json
case "markdown":
self = .markdown
case "ocaml":
Expand Down Expand Up @@ -116,6 +120,8 @@ extension RootLanguage: RawRepresentable {
"Go Work"
case .html:
"HTML"
case .json:
"JSON"
case .markdown:
"Markdown"
case .ocaml:
Expand Down
1 change: 1 addition & 0 deletions EditIntents/HighlightIntent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ extension RootLanguage: AppEnum {
.goSum: "Go Sum",
.goWork: "Go Work",
.html: "HTML",
.json: "JSON",
.markdown: "Markdown",
.ocaml: "OCaml",
.ocamlInterface: "OCaml Interface",
Expand Down
1 change: 1 addition & 0 deletions QuickLookPreview/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<string>dev.go.go-work</string>
<string>dev.go.go-sum</string>
<string>public.html</string>
<string>public.json</string>
<string>org.ocaml.ocaml</string>
<string>org.ocaml.ocaml-interface</string>
<string>public.python-script</string>
Expand Down

0 comments on commit 31227c2

Please sign in to comment.