meain / evil-textobj-tree-sitter

Tree-sitter powered textobjects for evil mode in Emacs
Apache License 2.0
191 stars 14 forks source link

No `parameter.outer` text object found #33

Closed EricCrosson closed 2 years ago

EricCrosson commented 2 years ago

Hi there,

this is an awesome project! Thanks so much for your work on this.

Using the following configuration

  (use-package evil-textobj-tree-sitter
    :ensure t
    :config
    (define-key evil-outer-text-objects-map "a" (evil-textobj-tree-sitter-get-textobj "parameter.outer"))
    (define-key evil-inner-text-objects-map "a" (evil-textobj-tree-sitter-get-textobj "parameter.inner")))

I expect commands like via and vaa to visually select inner and outer parameters, respectively.

The inner parameter works as expected, but the outer parameter provides me the error

No ’parameter.outer’ text object found

This text object is included in the nvim-treesitter-textobjects repository^1 so I figured it would be a part of this package too. Am I missing some reason it's not included, or have I bungled my configuration somehow?

meain commented 2 years ago

@EricCrosson Could you tell me which language you are using. Not all languages will have all the text objects available. The table below the list of items should tell you if you language supports that specific text object.

dvzubarev commented 2 years ago

parameter.outer won't work until custom predicate #make-range! is implemented. See https://github.com/emacs-tree-sitter/elisp-tree-sitter/issues/180

EricCrosson commented 2 years ago

@meain I was using TypeScript, which does appear to support parameter.outer. Good idea to double-check :slightly_smiling_face:

@dvzubarev that would explain it! Thank you for the pointer

meain commented 2 years ago

@dvzubarev thanks for letting me know. I was not aware of this issue.

meain commented 2 years ago

I think I will keep the issue open as this is technically still an issue. Plus this could be used to track any updates here or upstream towards this.

jeetelongname commented 2 years ago

Would it make sense to roll back / rewrite the queries to avoid make-range!? in one of the latest commits ruby text objects have pretty much become useless and it looks like the project is using it more and more which means we will lose out until its implemented on our side.

meain commented 2 years ago

I was really hoping to just piggyback off of the work that the nvim-treesitter team has done. I was initially thinking to maybe giving a shot at implementing it in elisp-tree-sitter, but I have not been able to dedicate much time to it.

I am not sure what the simplest way forward is. A simple revert to an old version would mean that we will be going back quite a lot. I have seen instances of #make-range! which are more than an year old. We will have to go through the queries and revert things selectively.

That said, maybe we could probably revert back to a version where it was still not completely useless. I see that you had reverted to an older commit. I could revert it back here as well if you think that is a good enough commit.

jeetelongname commented 2 years ago

The way forward is definitely to implement #make-range!. there is little point in duplicating the work, though I don't really have the time to learn enough rust to do it myself :sweat_smile:.

what I was thinking is less to revert the entire project but to use older versions of the queries, that way new languages can be supported / updated while also removing the breaking nature of #make-range!. though it may be that instead of "rolling back" the queries we would have to rewrite some to avoid #make-range!, This would happen in the cases where new text object queries were written with #make-range!, this is something I would probably be able to help with. The problem being is that we lose sync with nvim and your CI may not be usable in the interum.

as for rolling back your packages, thats not needed, I rolled it back because there are a sizable amount of ruby users (FD: including myself) and making the text objects useless for them is not fun. That being said doom pins packages for this reason, I would not worry about it especially since there were some text objects that have been updated / added since.

meain commented 2 years ago

It would be great if you could help out with fixing the queries. About the CI, I can switch to to manually pulling in queries in the future for the languages that use #make-range! until we have it implemented on the Emacs side.

jeetelongname commented 2 years ago

Sounds good!

meain commented 2 years ago

I have reverted the ruby textobjects alone to the one you have pinned in doom as the current one is completely unusable anyways. ref: https://github.com/meain/evil-textobj-tree-sitter/commit/607b71f38a1b2d7fa464814d968427435d31dd7c

jeetelongname commented 2 years ago

Hi sorry that I have not been able to PR changes, Ill bump the package in doom

meain commented 2 years ago

No worries. Btw, master should also have the goto functionality now.

jeetelongname commented 2 years ago

Ah awesome! ill have a play and add that to the module!

meain commented 2 years ago

I am working on something which should take care of this. There is some cleanup to be done, but as of now make-range branch fixes all that was broken due to make-range and is fully working.

Ref: #38

meain commented 2 years ago

This should now be fixed, not more make-range issues. :D

dvzubarev commented 2 years ago

Fantastic! Thank you very much for doing this.