Skip to content
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

treesitter directive offset, row offset not updating column #16135

Open
dvdsk opened this issue Oct 24, 2021 · 3 comments
Open

treesitter directive offset, row offset not updating column #16135

dvdsk opened this issue Oct 24, 2021 · 3 comments

Comments

@dvdsk
Copy link

dvdsk commented Oct 24, 2021

relevant piece of code:

["offset!"] = function(match, _, _, pred, metadata)

This takes the range of the captured node and applies an offset. However if you apply a row offset the column will generally need to be changed.

This code does not update the column. Probably because it is hard to decide what the column should be, what should it be when the row is increased with the offset?

This is not mentioned in the docs (version: 0.5), I think it might be helpful if it is. Can I open a PR updating the docs @steelsojka?

@dvdsk
Copy link
Author

dvdsk commented Oct 24, 2021

from this comment nvim-treesitter/playground#58 (comment) it seems that offset! is only at temporary measure. If so I it should be marked as such to prevent plugin authors such as my self from relying on it.

@theHamsta
Copy link
Member

Well, it is temporary in a way that we wanted to have a more generalized solution. But it should be made clear that it offset! is a very specialized solution that at the moment only works for injections. A more generalized offset! and a protocol to write other predicate other directives that modify ranges would be a more sustainable long-term solution.

offset! was merged under the premised that it will be generalized in follow-up PR. But it stayed the way it was because it is apparently working. It is however difficult to explain to users why they can't use offset! in other type of queries.

@neovim-discourse
Copy link

This issue has been mentioned on Neovim Discourse. There might be relevant details there:

https://neovim.discourse.group/t/treesitter-injections-for-julia/3370/3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants