Skip to content

Commit

Permalink
Basic tmTheme support
Browse files Browse the repository at this point in the history
  • Loading branch information
mattmassicotte committed Apr 19, 2024
1 parent aef66f7 commit d812fe3
Show file tree
Hide file tree
Showing 7 changed files with 446 additions and 16 deletions.
27 changes: 25 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,14 +1,37 @@
// swift-tools-version: 5.7
// swift-tools-version: 5.9

import PackageDescription

let package = Package(
name: "ThemePark",
platforms: [
.macOS(.v10_15),
.iOS(.v13),
.tvOS(.v13),
.watchOS(.v6),
.macCatalyst(.v13),
.visionOS(.v1),
],
products: [
.library(name: "ThemePark", targets: ["ThemePark"]),
],
targets: [
.target(name: "ThemePark"),
.testTarget(name: "ThemeParkTests", dependencies: ["ThemePark"]),
.testTarget(
name: "ThemeParkTests",
dependencies: ["ThemePark"],
resources: [.copy("Resources")]
),
]
)

let swiftSettings: [SwiftSetting] = [
.enableExperimentalFeature("StrictConcurrency"),
.enableUpcomingFeature("DisableOutwardActorInference"),
]

for target in package.targets {
var settings = target.swiftSettings ?? []
settings.append(contentsOf: swiftSettings)
target.swiftSettings = settings
}
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ A Swift library for working with syntax highlighting/IDE themes

Pretty much every editor has its own theming system. I'd love a package that could be used to intrepret a bunch of different themes for interoperability. I'm not sure how feasible this would be for all the things a theme can control, but I thought at a minimum it could be handy for syntax highlighting.

Supports:

- TextMate `.tmTheme` with `UTType.textMateTheme`

> [!WARNING]
> This is currently very WIP.
Expand All @@ -21,6 +25,14 @@ dependencies: [
],
```

## Usage

```swift
import ThemePark


```

## Contributing and Collaboration

I would love to hear from you! Issues, Discussions, or pull requests work great.
Expand Down
30 changes: 30 additions & 0 deletions Sources/ThemePark/TextMateTheme.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import Foundation

#if canImport(UniformTypeIdentifiers)
import UniformTypeIdentifiers

@available(macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0, *)
extension UTType {
public static let textMateTheme = UTType(importedAs: "com.macromates.textmate.theme", conformingTo: .propertyList)
}
#endif

public struct TextMateTheme: Codable {
public struct Setting: Codable {
public let name: String?
public let scope: String?
public let settings: [String: String]
}

public let author: String
public let name: String
public let semanticClass: String
public let uuid: UUID
public let settings: [Setting]

public init(with data: Data) throws {
let decoder = PropertyListDecoder()

self = try decoder.decode(Self.self, from: data)
}
}
2 changes: 0 additions & 2 deletions Sources/ThemePark/ThemePark.swift

This file was deleted.

Loading

0 comments on commit d812fe3

Please sign in to comment.