tree-sitter-grammars / tree-sitter-markdown

Markdown grammar for tree-sitter
MIT License
375 stars 45 forks source link

Add Swift accessors for scm resources #87

Closed jsorge closed 1 year ago

jsorge commented 1 year ago

This PR updates the Swift bindings and moves the resources to their own targets that get bundled up in the library product. Before this, we had to do this to access the files:

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

Whereas now we can access them like this:

let markdownHighlights = TreeSitterMarkdownQueries.Query.highlightsFileURL
let markdownInlineHighlights = TreeSitterMarkdownQueries.Query.highlightsFileURL

This is a breaking change for anyone depending on the existing structure but I think it's a pretty big quality-of-life improvement (and has yet to make it in to an official release). Shout out to Simon Støvring who did things this way in his TreeSitterLanguages package.

MDeiml commented 1 year ago

Since there doesn't seem any other form of versioning for the swift bindings, I hope that anybody using them pinned them to a specific commit or release tag, so I guess breaking changes are ok. I don't know much about swift and how dependency management is usually done though, so please educate me if I'm wrong.