243 points · by robenkleene · 3y ago · 67 comments
1 - the "search based" navigation is based on tree sitter https://docs.github.com/en/repositories/working-with-files/u...
2 - the list of parsers in the official docs: https://tree-sitter.github.io/tree-sitter/
I couldn't immediately find a way to opt out; I wouldn't mind the new file browser so much if I could drop into it on demand instead of having it forced down my throat.
I get what they’re trying to do, and in some ways it’s clearly beta growing pains, but in other ways it’s clear they’re fighting the browser environment in ways that don’t and probably shouldn’t work.
The new UI is more busy for no good reason. Sidebar makes sense in a local IDE, but over web every time you expand a subtree it takes ages anyway. And because it merely exists it is distracting and makes pages load slower...
So the answer may be that semantic does not yet have support for the language in question.
> During this time, the team migrated from a Semantic-based tagging service to one that operated entirely with (newly developed) Tree-sitter queries. Though Semantic performed well, using the Tree-sitter query language allowed faster iteration and avoided the operational overhead of a program-analysis framework.
I don't see an answer in there, though.
They use tagging (as described also here: https://tree-sitter.github.io/tree-sitter/code-navigation-sy...). From both docs I assume `tree-sitter tags` works out of box for any language that has a parser. (Since neither doc instructs to save a custom config for tag extraction query, I assume every language plugin provides tagging queries).
So, I wasn't trying to identify named things, like the tags command might seem to do, but more generic parts of the langauges like function, var, import/export statements, etc. I ultimately made my own walk functionality, but pulling out those atomic parts per language is still a very heavy task (basically need a mini lexer for each lang), even though TS seems to provide all the info to do the task.
[1] https://github.com/github/semantic/blob/793a876ae45d38a6bd17...
noun: sarcasm; plural noun: sarcasms
the use of irony to mock or convey contempt.
"his voice, hardened by sarcasm, could not hide his resentment"
Maybe on some setups the site name is not as easily visible as the title?
Some pictures/video or gif would have been really nice at the top of the article to get a quick idea of what I’ll be able to get by following the guide
I feel like a well written Tree-Sitter grammar should allow me to parse the files and follow the data from source to dashboard.
That said, the ability to query for things like "all SELECT statements where table 'xyz' is referenced in any table identifier" is very powerful.
We do use a fair bit of vendor-specific language, would be cool to make a good Oracle version and then commit back to the project.
It would be interesting to know how many sales you get from a niche book like this though.
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.
- 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:
But, it takes a lot of work to get there. I still don’t have everything working super well, debugging is way easier for me in VS Code. But, I’m still learning (after 25+ years as an Emacs user), and that brings me joy.
It’s like when I’m working on electronics. There’s a genuine joy I get from using my Hakko soldering station, Mitutoyo calipers, or my Engineer hand tools. Using something that is supremely well designed for a purpose brings me joy.
And org-mode. Seriously, org-mode.
Once Emacs 29 releases, your distro will package Emacs compiled with tree-sitter.
> you also need to have a language binding in a shared library in a known location
Emacs already ships with command that clones grammar repo, compiles, and installs the shared library to that known location - this was explained in the article. The only manual thing you need to do is to associate a language with a git repo in your configuration.
> And once you have that, you actually need someone to write a major mode that utilizes it at all.
Emacs developers have been also been working on covering major languages to provide tree-sitter based major modes. I count 23 major modes already being maintained as part of Emacs that will be shipped soon as part of 29.1, not to mention there are a lot more in Melpa (centralised community package repository).
In any case, whole thing with the tree-sitter is that it really makes writing major modes easy. It's all declarative now, including indentation rules that had traditionally been tricky to get right.
Even that setup step will be unnecessary in emacs 30, when all this stuff will be shipped by default.
The thing I love most about emacs is that it is joyously consistent. The same key combination to jump ahead by a word works everywhere, such as when you're opening files or navigating directories. This consistency means that I am often very efficient trying new packages that I have never used.
Maybe you've never seen someone use emacs in anger? If so, check out this video of Steve Yegge doing some stuff in Emacs: https://youtu.be/lkIicfzPBys?t=142