Skip to content

Commit

Permalink
Add support for CSS (#24)
Browse files Browse the repository at this point in the history
* Add support for CSS

* Add "css" in the `RootLanguage` init
  • Loading branch information
unnamedd authored Nov 22, 2024
1 parent 2606ec3 commit 4ee600f
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 @@ -9,6 +9,7 @@ OTHER_SWIFT_FLAGS = $(inherited) -Xcc -fmodule-map-file=$(GENERATED_MODULEMAP_DI
// All the tree-sitter parsers
OTHER_SWIFT_FLAGS = $(inherited) -Xcc -fmodule-map-file=$(GENERATED_MODULEMAP_DIR)/TreeSitterBash.modulemap
OTHER_SWIFT_FLAGS = $(inherited) -Xcc -fmodule-map-file=$(GENERATED_MODULEMAP_DIR)/TreeSitterC.modulemap
OTHER_SWIFT_FLAGS = $(inherited) -Xcc -fmodule-map-file=$(GENERATED_MODULEMAP_DIR)/TreeSitterCSS.modulemap
OTHER_SWIFT_FLAGS = $(inherited) -Xcc -fmodule-map-file=$(GENERATED_MODULEMAP_DIR)/TreeSitterClojure.modulemap
OTHER_SWIFT_FLAGS = $(inherited) -Xcc -fmodule-map-file=$(GENERATED_MODULEMAP_DIR)/TreeSitterElixir.modulemap
OTHER_SWIFT_FLAGS = $(inherited) -Xcc -fmodule-map-file=$(GENERATED_MODULEMAP_DIR)/TreeSitterGo.modulemap
Expand Down
2 changes: 2 additions & 0 deletions Dependencies/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ let package = Package(
dependencies: [
.package(url: "https://github.com/tree-sitter/tree-sitter-bash", branch: "master"),
.package(url: "https://github.com/tree-sitter/tree-sitter-c", branch: "master"),
.package(url: "https://github.com/tree-sitter/tree-sitter-css", 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"),
Expand All @@ -34,6 +35,7 @@ let package = Package(
dependencies: [
.product(name: "TreeSitterBash", package: "tree-sitter-bash"),
.product(name: "TreeSitterC", package: "tree-sitter-c"),
.product(name: "TreeSitterCSS", package: "tree-sitter-css"),
.product(name: "TreeSitterClojure", package: "tree-sitter-clojure"),
.product(name: "TreeSitterElixir", package: "tree-sitter-elixir"),
.product(name: "TreeSitterGo", package: "tree-sitter-go"),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@_exported import TreeSitterBash
@_exported import TreeSitterC
@_exported import TreeSitterCSS
@_exported import TreeSitterClojure
@_exported import TreeSitterElixir
@_exported import TreeSitterGo
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 @@ -15,6 +15,10 @@ extension LanguageProfile {
if utType.conforms(to: .cSource) || utType.conforms(to: .cHeader) {
return LanguageProfile.cProfile
}

if utType.conforms(to: .cssSource) {
return LanguageProfile.cssProfile
}

if utType.conforms(to: .clojureSource) {
return LanguageProfile.clojureProfile
Expand Down Expand Up @@ -83,6 +87,11 @@ extension LanguageProfile {
language: Language(tree_sitter_c())
)

static let cssProfile = LanguageProfile(
RootLanguage.css,
language: Language(tree_sitter_css())
)

static let clojureProfile = LanguageProfile(
RootLanguage.clojure,
language: Language(tree_sitter_clojure())
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 @@ -9,6 +9,7 @@ import ChimeKit
public enum RootLanguage: Hashable, CaseIterable, Sendable {
case bash
case c
case css
case clojure
case elixir
case go
Expand All @@ -28,6 +29,7 @@ public enum RootLanguage: Hashable, CaseIterable, Sendable {
switch self {
case .bash: .shellScript
case .c: .cSource
case .css: .cssSource
case .clojure: .clojureSource
case .elixir: .elixirSource
case .go: .goSource
Expand Down Expand Up @@ -57,6 +59,8 @@ extension RootLanguage: RawRepresentable {
self = .bash
case "c":
self = .c
case "css":
self = .css
case "clojure":
self = .clojure
case "elixir":
Expand Down Expand Up @@ -96,6 +100,8 @@ extension RootLanguage: RawRepresentable {
"Bash"
case .c:
"C"
case .css:
"CSS"
case .clojure:
"Clojure"
case .elixir:
Expand Down
1 change: 1 addition & 0 deletions EditIntents/HighlightIntent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ extension RootLanguage: AppEnum {
[
.bash: "Bash",
.c: "C",
.css: "CSS",
.clojure: "Clojure",
.elixir: "Elixir",
.go: "Go",
Expand Down
1 change: 1 addition & 0 deletions QuickLookPreview/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<array>
<string>public.c-header</string>
<string>public.c-source</string>
<string>public.css</string>
<string>org.clojure.source</string>
<string>org.cocoapods.specification</string>
<string>org.elixir-lang.source</string>
Expand Down

0 comments on commit 4ee600f

Please sign in to comment.