Skip to content

Commit

Permalink
Add support for JavaScript (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
unnamedd authored Nov 22, 2024
1 parent 31227c2 commit 853a51f
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)/TreeSitterJavaScript.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
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-javascript", branch: "master"),
.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"),
Expand All @@ -44,6 +45,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: "TreeSitterJavaScript", package: "tree-sitter-javascript"),
.product(name: "TreeSitterJSON", package: "tree-sitter-json"),
.product(name: "TreeSitterMarkdown", package: "tree-sitter-markdown"),
.product(name: "TreeSitterOCaml", package: "tree-sitter-ocaml"),
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 TreeSitterJavaScript
@_exported import TreeSitterJSON
@_exported import TreeSitterMarkdown
@_exported import TreeSitterMarkdownInline
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: .javaScript) {
return LanguageProfile.javaScriptProfile
}

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

static let javaScriptProfile = LanguageProfile(
RootLanguage.javaScript,
language: Language(tree_sitter_javascript())
)

static let jsonProfile = LanguageProfile(
RootLanguage.json,
language: Language(tree_sitter_json())
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 javaScript
case json
case markdown
case ocaml
Expand All @@ -38,6 +39,7 @@ public enum RootLanguage: Hashable, CaseIterable, Sendable {
case .goSum: .goSumFile
case .goWork: .goWorkFile
case .html: .html
case .javaScript: .javaScript
case .json: .json
case .markdown: .markdown
case .ocaml: .ocamlSource
Expand Down Expand Up @@ -77,6 +79,8 @@ extension RootLanguage: RawRepresentable {
self = .goWork
case "html":
self = .html
case "javascript":
self = .javaScript
case "json":
self = .json
case "markdown":
Expand Down Expand Up @@ -120,6 +124,8 @@ extension RootLanguage: RawRepresentable {
"Go Work"
case .html:
"HTML"
case .javaScript:
"JavaScript"
case .json:
"JSON"
case .markdown:
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",
.javaScript: "JavaScript",
.json: "JSON",
.markdown: "Markdown",
.ocaml: "OCaml",
Expand Down
1 change: 1 addition & 0 deletions QuickLookPreview/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
<string>org.rust-lang.rust-script</string>
<string>public.shell-script</string>
<string>public.swift-source</string>
<string>com.netscape.javascript-source</string>
</array>
<key>QLSupportsSearchableItems</key>
<false/>
Expand Down

0 comments on commit 853a51f

Please sign in to comment.