digitallyserviced / semanticolor

Provide Atom editor with semantic color highlighting.
https://atom.io/packages/semanticolor
MIT License
34 stars 3 forks source link

Add tree-sitter support for beta and nightly versions #44

Closed claytonrcarter closed 3 years ago

claytonrcarter commented 3 years ago

This PR fixes semanticolor's tree-sitter support in beta and nightly builds, which is currently broken because of how the Atom's version is being checked by semver.

The problematic code snippet is semver.satisfies(atom.getVersion(), '>=1.52.0'). This works fine for regular builds, where the version string is a bare semver string like 1.59.0, but beta and nightly builds return a version string ending in ...-beta0 and ...-nightly0, resp, and semver doesn't understand them. This results in beta and nightly users of sematicolor not having access to the tree-sitter support and always being forced to use the TM grammars.

My solution is to just use semver.coerce(atom.getVersion()) to chop off the trailing build type. Docs for coerce are at https://github.com/npm/node-semver#coercion

I've poked around at this locally and it's working just fine: semanticolor is working w/ tree-sitter grammars as expected.

Thanks!

sharedprophet commented 3 years ago

Thanks.