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
Add support for builtin treesit using helix queries #93
Conversation
|
Hey @meain thanks for doing this, I can't wait for the built-in treesit support. I was trying this branch with: (use-package evil-textobj-tree-sitter
:after (evil treesit)
:straight (evil-textobj-tree-sitter
:host github
:repo "meain/evil-textobj-tree-sitter"
:branch "treesit")
:config
;; bind `function.outer`(entire function block) to `f` for use in things like `vaf`, `yaf`
(define-key evil-outer-text-objects-map "f" (evil-textobj-tree-sitter-get-textobj "function.outer"))
;; bind `function.inner`(function block without name and args) to `f` for use in things like `vif`, `yif`
(define-key evil-inner-text-objects-map "f" (evil-textobj-tree-sitter-get-textobj "function.inner"))
...Then, in a
|
|
@d1egoaz Thanks for trying it out. I had missed including PS: You might have to delete |
|
@meain Thanks, the new config fixes the issue. I'm now having a different issue, and I wonder what the issue is.
func (f *Feed) xxx() *Entry {
x := 1
for _, entry := range f.Entries {
if entry.Category.Term == "yyy" {
return &entry
}
}
return nil
}
|
You were on the right track with "... but it isn't in helix-editor/helix@master/runtime/queries/go/textobjects.scm...". The helix queries (which we use for treesit) are still in the early stages and does not provide loop or conditional textobjects.
Hmm, somehow I am not able to repro this. Where on this line is the cursor when you call the function? |
|
Thanks!!
Ohh sorry, I meant to say Which I think the answer is the same as your previous answer. Thanks! |
|
Also, i tried it on some elisp, and vaf, gave me this error, I notice combobulate has a more graceful error message here |
|
In (defcustom evil-textobj-tree-sitter-major-mode-language-alist nil can you add clojure please i.e. emacs-lisp-mode wouldn't hurt too. |
|
@jasonjckn I wonder if you have an additional minor/mode applied, might want to check with emacs -Q
|
I deleted everything in my config except doom itself, and i'm still able to reproduce :( EDIT:
|
That is my best guess too. Since I don't use doom I don't have much clue of what exactly might be going on unfortunately but I'll maybe dig in if I find some time. |
|
@jasonjckn I was cleaning up a few things and the problem you had might not have been a doom thing. The package was doing some extra stuff to handle non ascii or multibye buffers which is not needed for treesit and that was messing up the locations. Feel free to give the new changes a shot. |
|
|
|
The deps in Cask are just for development and CI and not really used anywhere else. I am keeping |
I just got a few more elisp experience now
|
@meain I thought package managers pulled in dependencies from Cask? |
|
@p00f IIUC they pull them from the file header (which I forgot to remove).
|
|
Ah |
|
When trying to get an inner/outer function/class/argument in rust, I'm getting the following error:
This appears to be due this section at the bottom of (; #[test]
(attribute_item
(attribute
(identifier) @_test_attribute))
; allow other attributes like #[should_panic] and comments
[
(attribute_item)
(line_comment)
]*
; the test function
(function_item
body: (_) @test.inner) @test.outer
(#eq? @_test_attribute "test"))Removing that section fixes the issue. |
Emacs treesit implementation doesn't support #eq? and #equal is the replacement for it.
|
@Stebalien thanks for bringing up the issue. I missed the fact that |





This branch, currently experimental, adds
evil-texobj-tree-sitterwith the builtin treesit using texobject queries from helix. Although neovim has more complete queries, the builtin treesit cannot parse most of them. This still gets you most of the way there, but will only miss a few QOL stuff like not including brackets when selecting inside a function etc. The idea is to keep this open and dogfood it for a while and merge it in eventually.You can use this branch with straight like above. For more information refer #76
TODOs
queries-dirUpdate recipe for evil-textobj-tree-sitter melpa/melpa#8669