Local tree-sitter grammar settings aren't recognized

I’m currently developing a language and have written a (not NPM published) tree-sitter parser for it. I have linked the language-name package and the package has the tree-sitter-name properly ‘installed’ in its node_modules. As far as I can see, this parser and language works fine – it highlights my test files nicely; it auto-detects the grammar based on a file’s extension, and the grammar selector button (in the status bar) also displays the proper name. Additionally, I have defined a settings/language-name.cson file and filled it out with a couple of reasonable defaults, such as increaseIndentPattern, and this works fine as well.

However, when I go to the Atom settings and open the package details, it does not display/expose grammar settings (it lists only the package details card and the readme), and similarly when I open the grammar selector to manually select a language (i.e. not auto-detect), it does not list my language.

I have little experience with hacking the Atom editor, and have no idea of where to start debugging this. I realize not having tree-sitter-name published to NPM is unusual, given the utter lack of documentation of this even being a possibility. However, I cannot fathom how that would impact anything, as all the non-user-facing features simply work.

Is there someone who might understand what is going on here?

The grammar selector won’t show them until this is finalised. I’m guessing the settings view issue has a similar cause, but I haven’t tested anything yet.

It’s just npm, so npm link will work as expected (and is probably why there’s no specific documentation for it). Of course, it will need to be published for end users to use it.

Interesting, thanks!

I think I was thrown off by packages such as language-javascript offering these options and even responding to them (say, changing tabLength) even though as far as I know it’s using the tree-sitter parser for the highlighting. I may experiment with adding a TextMate grammar and see whether that will fool Atom into displaying the settings.

Yeah, that’s probably easiest for the time being. I think the issue is that the settings view just doesn’t realise it’s a grammar; once the setting is written to the config.cson file, it should be applied like normal.

Confirmed; adding settings to the config.cson file does indeed apply the settings to the editor, and adding a (mostly) boilerplate TextMate grammar does indeed show the settings in the package details and the language in the grammar selector.

1 Like