Skip to content

Commit

Permalink
Change TreeSitter provider to tree-sitter-xcframework
Browse files Browse the repository at this point in the history
  • Loading branch information
krzyzanowskim committed Aug 26, 2023
1 parent a127043 commit 9fc098c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ let package = Package(
dependencies: [
.package(url: "https://github.com/krzyzanowskim/STTextView", from: "0.8.10"),
.package(url: "https://github.com/ChimeHQ/Neon.git", from: "0.5.1"),
.package(url: "https://github.com/alex-pinkus/tree-sitter-swift.git", commit: "eda05af7ac41adb4eb19c346883c0fa32fe3bdd8") // with-generated-files
.package(url: "https://github.com/krzyzanowskim/tree-sitter-xcframework", from: "0.208.3")
],
targets: [
.target(
name: "NeonPlugin",
dependencies: [
.product(name: "STTextView", package: "STTextView"),
"Neon",
.product(name: "TreeSitterSwift", package: "tree-sitter-swift")
.product(name: "TreeSitter", package: "tree-sitter-xcframework")
]
)
]
Expand Down
11 changes: 5 additions & 6 deletions Sources/NeonPlugin/Coordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import Neon
import TreeSitterClient
import SwiftTreeSitter

// Swift
import TreeSitterSwift
// tree-sitter-xcframework
import TreeSitter
import TreeSitterResource

public class Coordinator {
private(set) var highlighter: Neon.Highlighter?
Expand All @@ -15,7 +16,7 @@ public class Coordinator {
private var prevViewportRange: NSTextRange?

init(textView: STTextView, theme: Theme) {
tsLanguage = Language(language: tree_sitter_swift())
tsLanguage = Language(language: TreeSitterLanguage.swift.parser)

tsClient = try! TreeSitterClient(language: tsLanguage) { codePointIndex in
guard let location = textView.textContentManager.location(at: codePointIndex),
Expand Down Expand Up @@ -65,9 +66,7 @@ public class Coordinator {

private func tokenProvider(textContentManager: NSTextContentManager) -> Neon.TokenProvider? {

let url = Bundle.main.resourceURL!.appendingPathComponent("TreeSitterSwift_TreeSitterSwift.bundle").appendingPathComponent("Contents/Resources/queries/highlights.scm")

guard let highlightsQuery = try? tsLanguage.query(contentsOf: url) else {
guard let highlightsQuery = try? tsLanguage.query(contentsOf: TreeSitterLanguage.swift.highlightQueryURL!) else {
return nil
}

Expand Down

0 comments on commit 9fc098c

Please sign in to comment.