Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for JavaScript #26

Merged
merged 1 commit into from
Nov 22, 2024
Merged
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
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
Loading