Darazaki / indent-o-matic

Dumb automatic fast indentation detection for Neovim written in Lua
MIT License
176 stars 13 forks source link

Use tree-sitter #16

Closed lopi-py closed 1 year ago

lopi-py commented 1 year ago

it should accurate comments and strings when working with treesitter as it disables syntax so the current function to detect it wont work

Darazaki commented 1 year ago

Thanks for telling me! I'll take a look at this tomorrow :)

Since I'm currently very busy, fixing this might take a while. So if you have any example of code or a function in the documentation that could be used to check if a character's position is included in a comment/string please link it here. That'd be extremely helpful!

Labeling this issue as a bug since this plugin should work both with tree-sitter and without

lopi-py commented 1 year ago

I found one implementation that fits, also keep an eye at this functions: 1, 2. Also keep in mind that second function returns like root:named_descendant_for_range(...) so you can use it as

return result:type() == "comment" or result:type() == "string"`
Darazaki commented 1 year ago

Thanks a lot! These have really helped :D

I think I've finished fixing this issue inside the testing branch. I'll do some more testing and should merge the fix into master tomorrow :)