4 ms·
I take it that many people like the idea with tree-sitter but don't really know how to use it. Tree-sitter does have documentation but it's not that useful. It
by z3t4 3y ago
I take it that many people like the idea with tree-sitter but don't really know how to use it. Tree-sitter does have documentation but it's not that useful.
It would be interesting to know how many sales you get from a niche book like this though.
- alwaysbeconsing 3y agoThere's not much end-user documentation the Tree-sitter project can really provide. It's a programming interface. The stuff that an Emacs, NeoVim, ... user is actually interacting with depends on the integration in the editor. So it's up to those docs to explain what features they expose based on Tree-sitter. For example, the multiple cursor thing at the end is enabled by having the concrete syntax tree from Tree-sitter's parse, but Tree-sitter has nothing whatsoever to do with the cursors: it just provides locations in the text based on particular queries (like "all `identifier` nodes named 'foo' that are sub-nodes of this other node"). Even the headliner feature, syntax highlighting, isn't provided directly by Tree-sitter. It's up to the client system to inspect the syntax tree and apply attributes to its rendered text -- however it does that rendering.
- nerdponx 3y agoThe query language and CLI tools are absolutely user-facing features on their own. But even if they aren't, developers still need to be able to learn from the docs. Currently that's very difficult to do. My experience is that you have to rely heavily on copying other people's examples in order to make progress.
- alwaysbeconsing 3y agoPoint taken about the developer documentation. But the query language is only user-facing if the tool you're using exposes it. And the CLI only if you need to build your own grammars; I expect that to be less and less common as time goes on.
- nerdponx 3y agoMaybe this is a "blind spot" of sorts to the developers of Tree Sitter, but I find that the CLI is directly useful for end users to perform queries on their code. Maybe it would be better if we had dedicated tools that were more oriented at end users rather than developers of TS grammars, but it seems silly not to use a perfectly good tool that already exists. Somewhat of an aside about building grammars, I have found that the grammars are relatively hard to make small modifications or extensions to. Whereas it's relatively easy with e.g. traditional Vim syntax highlighting. Making grammars easier to extend would be valuable for users of languages like SQL that have a zillion custom dialects.
- alwaysbeconsing 3y ago> I find that the CLI is directly useful for end users to perform queries on their code That's interesting; what do they use the results for? > I have found that the grammars are relatively hard to make small modifications or extensions to Definitely true. I think this may be an inherent problem of the system and the parser generation, though. I am not sure it's solvable by the grammar authors.
- nerdponx 3y agoI use it for code search. I can search for the definition of a given function, or all places that a particular function is called by name.
- pimeys 3y agoHelix editor has it built-in so it's a good place to start looking into tree-sitter. For me the important parts are: - Much better (and faster) syntax hilighting - Shrink and expand selection (select variable, all variables inside parentheses, the whole block, the whole function) - Select next or previous sibling node - Goto matching bracket from where I am right now - Jump between functions - Jump between type definitions - Jump between parameters - Jump between comments - Jump between tests I think Helix must be the easiest way to start experimenting with tree-sitter. You need no plugins, just install the editor and start experimenting: https://helix-editor.com/ https://helix-editor.com/
- catgoose 3y agopfft I can do that with 105 plugins in neovim
- ninepoints 3y agoIn what way is its documentation not useful? I did a project based on TreeSitter a year ago and the docs were perfectly clear and adequate, and I was up and running within half an hour or so
- z3t4 3y agoFor example the Query Syntax, I would like an example on how to find all function declarations and where in the code the function starts and end. As well as example data that such a query is supposed to return. And how to do it in the JavaScript/Web Tree-sitter binding =)