Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
6CA62EAB29F9D36700785B11 /* TreeSitterTSX in Frameworks */ = {isa = PBXBuildFile; productRef = 6CA62EAA29F9D36700785B11 /* TreeSitterTSX */; };
6CEC70FE29C3A85000B61C7A /* TreeSitterRegex in Frameworks */ = {isa = PBXBuildFile; productRef = 6CEC70FD29C3A85000B61C7A /* TreeSitterRegex */; };
7DB18E9729FDC51C00F8EC00 /* TreeSitterScala in Frameworks */ = {isa = PBXBuildFile; productRef = 7DB18E9629FDC51C00F8EC00 /* TreeSitterScala */; };
9D0F66222A3F522700E0F4B7 /* TreeSitterTOML in Frameworks */ = {isa = PBXBuildFile; productRef = 9D0F66212A3F522700E0F4B7 /* TreeSitterTOML */; };
9D6E74512A2B9B2A0070701E /* TreeSitterOCaml in Frameworks */ = {isa = PBXBuildFile; productRef = 9D6E74502A2B9B2A0070701E /* TreeSitterOCaml */; };
9DB1B4362A2C0DAA0027B04E /* TreeSitterJSDoc in Frameworks */ = {isa = PBXBuildFile; productRef = 9DB1B4352A2C0DAA0027B04E /* TreeSitterJSDoc */; };
9DFDC3662A02D9BE0023B3BC /* TreeSitterMarkdown in Frameworks */ = {isa = PBXBuildFile; productRef = 9DFDC3652A02D9BE0023B3BC /* TreeSitterMarkdown */; };
Expand Down Expand Up @@ -69,6 +70,7 @@
28B3F03C290C363E000CD04D /* TreeSitterGo in Frameworks */,
7DB18E9729FDC51C00F8EC00 /* TreeSitterScala in Frameworks */,
28B3F05D290C3709000CD04D /* TreeSitterSwift in Frameworks */,
9D0F66222A3F522700E0F4B7 /* TreeSitterTOML in Frameworks */,
28B9F7AA290DDAC900245748 /* TreeSitterBash in Frameworks */,
28B3F030290C35F9000CD04D /* TreeSitterCPP in Frameworks */,
28B3F04E290C3698000CD04D /* TreeSitterJSON in Frameworks */,
Expand Down Expand Up @@ -196,6 +198,7 @@
9DFDC3652A02D9BE0023B3BC /* TreeSitterMarkdown */,
9D6E74502A2B9B2A0070701E /* TreeSitterOCaml */,
9DB1B4352A2C0DAA0027B04E /* TreeSitterJSDoc */,
9D0F66212A3F522700E0F4B7 /* TreeSitterTOML */,
);
productName = "CodeLanguages-Container";
productReference = 28B3F00C290C207D000CD04D /* CodeLanguages_Container.framework */;
Expand Down Expand Up @@ -258,6 +261,7 @@
9DFDC3642A02D9BE0023B3BC /* XCRemoteSwiftPackageReference "tree-sitter-markdown" */,
9D6E744F2A2B9B2A0070701E /* XCRemoteSwiftPackageReference "tree-sitter-ocaml" */,
9DB1B4342A2C0DA90027B04E /* XCRemoteSwiftPackageReference "tree-sitter-jsdoc" */,
9D0F66202A3F522700E0F4B7 /* XCRemoteSwiftPackageReference "tree-sitter-toml" */,
);
productRefGroup = 28B3F00D290C207D000CD04D /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -739,6 +743,14 @@
kind = branch;
};
};
9D0F66202A3F522700E0F4B7 /* XCRemoteSwiftPackageReference "tree-sitter-toml" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/cengelbart39/tree-sitter-toml.git";
requirement = {
branch = feature/spm;
kind = branch;
};
};
9D6E744F2A2B9B2A0070701E /* XCRemoteSwiftPackageReference "tree-sitter-ocaml" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/tree-sitter/tree-sitter-ocaml.git";
Expand Down Expand Up @@ -916,6 +928,11 @@
package = 7DB18E9529FDC51C00F8EC00 /* XCRemoteSwiftPackageReference "tree-sitter-scala" */;
productName = TreeSitterScala;
};
9D0F66212A3F522700E0F4B7 /* TreeSitterTOML */ = {
isa = XCSwiftPackageProductDependency;
package = 9D0F66202A3F522700E0F4B7 /* XCRemoteSwiftPackageReference "tree-sitter-toml" */;
productName = TreeSitterTOML;
};
9D6E74502A2B9B2A0070701E /* TreeSitterOCaml */ = {
isa = XCSwiftPackageProductDependency;
package = 9D6E744F2A2B9B2A0070701E /* XCRemoteSwiftPackageReference "tree-sitter-ocaml" */;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ extern TSLanguage *tree_sitter_rust();
extern TSLanguage *tree_sitter_scala();
extern TSLanguage *tree_sitter_sql();
extern TSLanguage *tree_sitter_swift();
extern TSLanguage *tree_sitter_toml();
extern TSLanguage *tree_sitter_tsx();
extern TSLanguage *tree_sitter_typescript();
extern TSLanguage *tree_sitter_yaml();
Expand Down
Binary file modified CodeLanguagesContainer.xcframework.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ In order to add support for additional languages we have a complete guide on how
| [Scala](https://github.com/tree-sitter/tree-sitter-scala) | ✅ | ✅ |
| [Sql](https://github.com/lukepistrol/tree-sitter-sql/tree/feature/spm) | ✅ | ✅ |
| [Swift](https://github.com/alex-pinkus/tree-sitter-swift/tree/with-generated-files) | ✅ | ✅ |
| [TOML](https://github.com/ikatyang/tree-sitter-toml) | | |
| [TOML](https://github.com/cengelbart39/tree-sitter-toml/tree/feature/spm) | | |
| [TypeScript/TSX](https://github.com/tree-sitter/tree-sitter-typescript) | ✅ | ✅ |
| [Verilog](https://github.com/tree-sitter/tree-sitter-verilog) | | _not available_ |
| [YAML](https://github.com/lukepistrol/tree-sitter-yaml/tree/feature/spm) | ✅ | ✅ |
Expand Down
8 changes: 8 additions & 0 deletions Sources/CodeEditLanguages/CodeLanguage+Definitions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public extension CodeLanguage {
.scala,
.sql,
.swift,
.toml,
.tsx,
.typescript,
.yaml,
Expand Down Expand Up @@ -286,6 +287,13 @@ public extension CodeLanguage {
extensions: ["swift"]
)

/// A language structure for `TOML`
static let toml: CodeLanguage = .init(
id: .toml,
tsName: "toml",
extensions: ["toml"]
)

/// A language structure for `TSX`
static let tsx: CodeLanguage = .init(
id: .tsx,
Expand Down
2 changes: 2 additions & 0 deletions Sources/CodeEditLanguages/CodeLanguage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ public struct CodeLanguage {
return tree_sitter_sql()
case .swift:
return tree_sitter_swift()
case .toml:
return tree_sitter_toml()
case .tsx:
return tree_sitter_tsx()
case .typescript:
Expand Down
2 changes: 2 additions & 0 deletions Sources/CodeEditLanguages/Documentation.docc/CodeLanguage.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ let language = CodeLanguage.detectLanguageFrom(url: fileURL)
- Scala
- SQL
- Swift
- TOML
- YAML
- Zig

Expand Down Expand Up @@ -100,6 +101,7 @@ let language = CodeLanguage.detectLanguageFrom(url: fileURL)
- ``scala``
- ``sql``
- ``swift``
- ``toml``
- ``yaml``
- ``zig``

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,6 @@ let query = TreeSitterModel.shared.swiftQuery
- ``scalaQuery``
- ``sqlQuery``
- ``swiftQuery``
- ``tomlQuery``
- ``yamlQuery``
- ``zigQuery``
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
; Properties
;-----------

(bare_key) @property
(quoted_key) @string

; Literals
;---------

(boolean) @constant.builtin
(comment) @comment
(string) @string
(integer) @number
(float) @number
(offset_date_time) @string.special
(local_date_time) @string.special
(local_date) @string.special
(local_time) @string.special

; Punctuation
;------------

"." @punctuation.delimiter
"," @punctuation.delimiter

"=" @operator

"[" @punctuation.bracket
"]" @punctuation.bracket
"[[" @punctuation.bracket
"]]" @punctuation.bracket
"{" @punctuation.bracket
"}" @punctuation.bracket
1 change: 1 addition & 0 deletions Sources/CodeEditLanguages/TreeSitterLanguage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public enum TreeSitterLanguage: String {
case scala
case sql
case swift
case toml
case tsx
case typescript
case yaml
Expand Down
7 changes: 7 additions & 0 deletions Sources/CodeEditLanguages/TreeSitterModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ public class TreeSitterModel {
return sqlQuery
case .swift:
return swiftQuery
case .toml:
return tomlQuery
case .tsx:
return tsxQuery
case .typescript:
Expand Down Expand Up @@ -257,6 +259,11 @@ public class TreeSitterModel {
return queryFor(.swift)
}()

/// Query for `TOML` files.
public private(set) lazy var tomlQuery: Query? = {
return queryFor(.toml)
}()

/// Query for `TSX` files.
public private(set) lazy var tsxQuery: Query? = {
return queryFor(.tsx)
Expand Down
19 changes: 19 additions & 0 deletions Tests/CodeEditLanguagesTests/CodeEditLanguagesTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,25 @@ final class CodeEditLanguagesTests: XCTestCase {
XCTAssertNotNil(query)
XCTAssertNotEqual(query?.patternCount, 0)
}

// MARK: - TOML

func test_CodeLanguageTOML() throws {
let url = URL(fileURLWithPath: "~/path/to/file.toml")
let language = CodeLanguage.detectLanguageFrom(url: url)

XCTAssertEqual(language.id, .toml)
}

func test_FetchQueryTOML() throws {
var language = CodeLanguage.toml
language.resourceURL = bundleURL

let data = try Data(contentsOf: language.queryURL!)
let query = try? Query(language: language.language!, data: data)
XCTAssertNotNil(query)
XCTAssertNotEqual(query?.patternCount, 0)
}

// MARK: - TSX

Expand Down