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 to HTML #23

Merged
merged 4 commits 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 @@ -15,6 +15,7 @@ OTHER_SWIFT_FLAGS = $(inherited) -Xcc -fmodule-map-file=$(GENERATED_MODULEMAP_DI
OTHER_SWIFT_FLAGS = $(inherited) -Xcc -fmodule-map-file=$(GENERATED_MODULEMAP_DIR)/TreeSitterGoMod.modulemap
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)/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 @@ -16,6 +16,7 @@ let package = Package(
.package(url: "https://github.com/tree-sitter/tree-sitter-c", branch: "master"),
.package(url: "https://github.com/mattmassicotte/tree-sitter-clojure", branch: "feature/spm"),
.package(url: "https://github.com/elixir-lang/tree-sitter-elixir", branch: "main"),
.package(url: "https://github.com/tree-sitter/tree-sitter-html", branch: "master"),
.package(url: "https://github.com/tree-sitter/tree-sitter-go", branch: "master"),
.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"),
Expand All @@ -39,6 +40,7 @@ let package = Package(
.product(name: "TreeSitterGoMod", package: "tree-sitter-go-mod"),
.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: "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 @@ -6,6 +6,7 @@
@_exported import TreeSitterGoMod
@_exported import TreeSitterGosum
@_exported import TreeSitterGoWork
@_exported import TreeSitterHTML
@_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 @@ -32,6 +32,10 @@ extension LanguageProfile {
return LanguageProfile.goSumProfile
}

if utType.conforms(to: .html) {
return LanguageProfile.htmlProfile
}

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

static let htmlProfile = LanguageProfile(
RootLanguage.html,
language: Language(tree_sitter_html())
)

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 @@ -15,6 +15,7 @@ public enum RootLanguage: Hashable, CaseIterable, Sendable {
case goMod
case goSum
case goWork
case html
case markdown
case ocaml
case ocamlInterface
Expand All @@ -33,6 +34,7 @@ public enum RootLanguage: Hashable, CaseIterable, Sendable {
case .goMod: .goModFile
case .goSum: .goSumFile
case .goWork: .goWorkFile
case .html: .html
case .markdown: .markdown
case .ocaml: .ocamlSource
case .ocamlInterface: .ocamlInterface
Expand Down Expand Up @@ -67,6 +69,8 @@ extension RootLanguage: RawRepresentable {
self = .goSum
case "gowork":
self = .goWork
case "html":
self = .html
case "markdown":
self = .markdown
case "ocaml":
Expand Down Expand Up @@ -104,6 +108,8 @@ extension RootLanguage: RawRepresentable {
"Go Sum"
case .goWork:
"Go Work"
case .html:
"HTML"
case .markdown:
"Markdown"
case .ocaml:
Expand Down
1 change: 1 addition & 0 deletions Edit/Modules/TextSystem/TextViewSystem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ extension TextViewSystem {
public func reload(from url: URL, attributes: [NSAttributedString.Key: Any]) throws {
let options: [NSAttributedString.DocumentReadingOptionKey: Any] = [
.defaultAttributes: attributes,
.documentType: NSAttributedString.DocumentType.plain,
]

let storage = try TSYTextStorage(url: url, options: options, documentAttributes: nil)
Expand Down
1 change: 1 addition & 0 deletions EditIntents/HighlightIntent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ extension RootLanguage: AppEnum {
.goMod: "Go Mod",
.goSum: "Go Sum",
.goWork: "Go Work",
.html: "HTML",
.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 @@ -20,6 +20,7 @@
<string>dev.go.go-module</string>
<string>dev.go.go-work</string>
<string>dev.go.go-sum</string>
<string>public.html</string>
<string>org.ocaml.ocaml</string>
<string>org.ocaml.ocaml-interface</string>
<string>public.python-script</string>
Expand Down
Loading