-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Builtin treesitter #152
Builtin treesitter #152
Conversation
Hey @polaris64 , I'm just taking a look at this now. First of all, thank you so much, and perfect timing. This is definitely a huge head start and it looks like we're quite close! I think we're ready to start testing with this new branch. Btw, from a quick look, I see that you're abstracting the tree sitter library and supporting both tsc as well as the built-in library. Some users have complained that depending on Otherwise, if we manage to get to #26 as part of this release, then tree-sitter could be decoupled as a separate package and people could install As I'm on Emacs 29 now, I'm not sure it would be easy for me to test the tsc variant so I'm leaning towards dropping it regardless. I'm not too familiar with the tree-sitter ecosystem though, so wdyt? |
Siddhartha Kasivajhula ***@***.***> writes:
Hey @polaris64 , I'm just taking a look at this now. First of all,
thank you so much, and perfect timing. This is definitely a huge
head start
and it looks like we're quite close! I think we're ready to start
testing with this new branch. Btw, from a quick look, I see that
you're
abstracting the tree sitter library and supporting both tsc as well
as the built-in library. Some users have complained that depending
on tsc
/ elisp-tree-sitter is a non-starter for them, so I'm wondering if
we should just drop tsc and support only Emacs 29+.
That's exactly what I was doing in the latest commit.
When I first started this branch Emacs 29 had only just been released
so my idea was to allow Symex to work with older versions too using
the tsc library. That was a long time ago now and Emacs 30 is probably
going to be released quite soon so I decided that depending on the old
tsc library was also not worth it any more. So my latest commit
removes those dependencies.
Otherwise, if we manage to get to #26 as part of this release, then
tree-sitter could be decoupled as a separate package and people
could
install symex-ts, or not, at their discretion. That should allow the
rest of Symex to depend on an old version of Emacs (e.g. Emacs 27)
while
symex-ts specifically depends on Emacs 29.
As I'm on Emacs 29 now, I'm not sure it would be easy for me to test
the tsc variant so I'm leaning towards dropping it regardless. I'm
not
too familiar with the tree-sitter ecosystem though, so wdyt?
Yes I fully agree. The way it works now with my latest changes is that
if you use Symex on a version of Emacs prior to 29 then you'll get all
of Symex's functionality except for Tree Sitter. If you use it on 29+
(with Tree Sitter support enabled) then you'll get that too. I think
that's fine and, as you say, it's not worth supporting an old library
and adding extra dependencies.
Kind regards,
…--
Simon Pugnet
https://www.polaris64.net/
PGP key fingerprint: 3BF7 85DE 162C 00C8 FB4D A6FD BA13 59A8 2C0B
3EF9
|
11e6442
to
defe54b
Compare
Turns out I had unwittingly rebased/cherry-picked your commits in the reverse order! So your initial commit was added last and it included all of the interpolation between built-in and tree-sitter packages. I did the rebase over and it looks good now 🙂
Perfect. I'll continue testing 👍 |
OK, I did one full pass and tested every feature that's bound to a key! A quick summary is, the motions generally work well, including complex ones like traversals, leap branch, etc. But the other features (deletion etc.) don't always work. For the things that don't work, they fall into 3 broad classes:
Many features that make sense for Lisp languages just don't make sense for non-Lisp languages, like
Some features aren't quite undefined, but may have a different intuitive meaning in non-Lisp languages, and it would take some design effort to understand what the meaning should be. Examples:
For python, if we've selected a There are other features like For this class of issue, it would probably be quite useful to design the analogous behavior for Treesitter. But I'm also happy for us to work on this class of feature on the main branch after the release, unless there are any low-hanging fruit here.
This is the main class of issue to fix for the release. Some transformations (i.e., which mutate the buffer) don't work, and many of them give the same error message, about This may be related to the "changed ranges" or "parser notifier" issue you mentioned @polaris64. What's interesting though is that some transformations do work, so it will be interesting to see what's different about them. I'll share the detailed results in a separate comment. |
Here are the feature-by-feature testing results! I just went through the lithium mode definition (which has the mode keybindings) and tested each feature one by one. Legend:
There are also some features we should probably remove from Symex, like "go to messages buffer", leaving that to user .emacs.d config (and optionally mentioning them in the README). ("1" digit-argument) (i.e., count arguments) OK for motions
Whatever this issue is, it comes up a lot in the other features that mutate the buffer, and seems to be a core technical issue to resolve. ("h" symex-go-backward) OK ("gh" backward-char) OK They don't update the selection overlay after the motion, maybe? But they work fine. ("(" symex-create-round) OK (")" symex-wrap-round) ERROR:
("C-'" symex-cycle-quote) N/A ("f" symex-traverse-forward) OK ("F" symex-traverse-forward-skip) OK ("{" symex-leap-backward) OK ("C-k" symex-climb-branch) Requires design. Kinda works but doesn't update selection. Not very useful for non-Lisp, at the moment. ("y" symex-yank) OK ("p" symex-paste-after) ERROR:
("x" symex-delete) OK But note they don't work with counts, e.g. ("c" symex-change) OK Interestingly, although this just uses delete under the hood, this works with counts, too (i.e., ("D" symex-delete-remaining) ERROR:
("C" symex-change-remaining) OK ("C--" symex-clear) OK if we are actually on a parenthesized expression
("-" symex-splice) ERROR:
("S" symex-change-delimiter) OK, but it joins lines if the delimiter is followed by a newline (it should just change the delimiter) ("H" symex-shift-backward) ERROR:
("L" symex-shift-forward) No error, but doesn't work correctly. ("M-H" symex-shift-backward-most)
("K" symex-raise) No error, but doesn't work consistently. ("C-S-j" symex-emit-backward) Requires design. Currently not supported (noop). ("z" symex-swallow) These usually give an ERROR:
("e" symex-evaluate) N/A Currently raise an ERROR:
("t" symex-switch-to-scratch-buffer) Requires design. Currently ERROR:
("M" symex-switch-to-messages-buffer) OK ("r" symex-repl)
("R" symex-run)
("|" symex-split) N/A (or requires design) ("o" symex-open-line-after) OK, but (">" symex-insert-newline) OK, but messes up indentation (probably just an issue with ("J" symex-join-lines) OK ("M-J" symex-collapse) OK -- work in limited cases, but mess up commas. ("0" symex-goto-first) OK ("=" symex-tidy) Mostly OK? But can mess up commas by adding spaces around them. ("A" symex-append-after) Requires design. This is another place we could consider using Currently they kinda work in a Lisp style. ("w" symex-wrap) N/A (maybe requires design --- e.g., we could wrap with standard forms like
(";" symex-comment) OK ("C-;" symex-eval-print) N/A ("C-?" symex-describe) Requires design. Currently ERROR:
;; escapes OK |
I added the current test results to the PR description in an easy-to-read (I think) format. I'll keep it up to date as features get fixed. Any assistance / pointers appreciated --- especially could use help understanding the |
I think it would be good to merge this and continue things on the integration branch. Please let me know if this PR looks good to you @polaris64 |
* Define new functions or aliases for tree sitter functionality depending on the available support from Emacs. * Replace all occurrences of library function calls with calls to the new aliases/functions. TODO: change usage `tsc-changed-ranges', use `treesit-parser-add-notifier'.
Support for handling tree changes needs to be implemented differently for the internal tree sitter library.
The old package was used before Emacs had built-in support for Tree Sitter (starting in Emacs 29). Since then the elisp-tree-sitter package has not been updated and therefore it seems sensible for Symex only to support Tree Sitter modes when Emacs has built-in support available to it.
defe54b
to
eddf15e
Compare
Hi @countvajhula, Thanks for performing exhaustive tests on this, that's very valuable information to have and I know how long it takes to do the testing properly! Just some quick notes on the errors you're seeing: -
So for the first case, these are probably operations that should be using the I hope that makes sense! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This all looks good to me
@polaris64 Yes, that makes perfect sense and is exactly what I needed to know. I'll take a look today and see what progress we can make! |
Summary of Changes
Incorporate @polaris64 's updates to migrate to Emacs's built-in treesitter.
Current testing results
Legend:
Results:
Other todos
tsc-changed-ranges
, usetreesit-parser-add-notifier
?Public Domain Dedication
(Why: The freely released, copyright-free work in this repository represents an investment in a better way of doing things called attribution-based economics. Attribution-based economics is based on the simple idea that we gain more by giving more, not by holding on to things that, truly, we could only create because we, in our turn, received from others. As it turns out, an economic system based on attribution -- where those who give more are more empowered -- is significantly more efficient than capitalism while also being stable and fair (unlike capitalism, on both counts), giving it transformative power to elevate the human condition and address the problems that face us today along with a host of others that have been intractable since the beginning. You can help make this a reality by releasing your work in the same way -- freely into the public domain in the simple hope of providing value. Learn more about attribution-based economics at drym.org, tell your friends, do your part.)