rasulomaroff / reactive.nvim

Reactivity. Right in your neovim.
Apache License 2.0
183 stars 1 forks source link

Indentation issues #11

Closed OXY2DEV closed 6 months ago

OXY2DEV commented 6 months ago

raeactive.nvim is causing issues with the indentation of .html file.

Without reactive.nvim Screenshot_2024-02-05-23-49-34-390_com termux-edit

With reactive.nvim Screenshot_2024-02-05-22-32-36-233_com termux-edit

[All plugins were disabled when I tested this]

Is there a particular reason why it only affects .html files?

Every other file type I had seems to work normally except for this one.

rasulomaroff commented 6 months ago

Hi there! I don't think this is reactive.nvim issue since the plugin itself doesn't do anything except applying highlights.

I tested on my machine and everything works fine. So, the problem can be in other plugins you have.

https://github.com/rasulomaroff/reactive.nvim/assets/80093436/b26ded36-77e7-4b29-b3a0-ae84a5bfabf9

rasulomaroff commented 6 months ago

@OXY2DEV I would suggest trying disabling a half of your plugins and then check if this problem exists. If so, disable another half of remained plugins etc. If the problem is gone, try doing the same in the previously disabled half and find a culprit.

OXY2DEV commented 6 months ago

Yep, some other plugin is causing issues with reactive. Let me see if I can find it.

OXY2DEV commented 6 months ago

@OXY2DEV I would suggest trying disabling a half of your plugins and then check if this problem exists. If so, disable another half of remained plugins etc. If the problem is gone, try doing the same in the previously disabled half and find a culprit.

Found it. It's statuscol.nvim. The odd part is this bug only appears when both plugins are enabled, but doesn't if any one of them is disabled.

Screenshot_2024-02-06-08-09-35-532_com termux-edit

luukvbaal commented 6 months ago

I was able to reproduce this issue with just :set statuscolumn=%l. No idea why but setting 'statuscolumn' in combination with this plugin seems to break treesitter indentation. :TSToggle indent restores the correct behavior at least.

rasulomaroff commented 6 months ago

@luukvbaal oh, didn't notice you actually answered here and replied to you in the mentioned issue. Anyway, thank you for you time spent on this!

It becomes even more weird when you realize that I don't do anything with the statuscolumn option. I attached the video at the beginning showing that everything works perfect without statuscolumn in my case. And when that option is combined with winhighlight it somehow breaks TS indents...

luukvbaal commented 6 months ago

Yeah it is weird. TBH it seems unlikely that this plugin is at fault, it just breaks the nvim-treesitter indent module in combination with 'statuscolumn'.

luukvbaal commented 6 months ago

Did some more investigating, commenting out this line "unbreaks" the indentation https://github.com/rasulomaroff/reactive.nvim/blob/c7089808d30ca5c1bfd42eb57d2c3fc43e815190/lua/reactive/highlight.lua#L14

Not too familiar with treesitter but perhaps this redraw somehow incorrectly validates the tree after inserting a newline. No idea how 'statuscolumn' fits into that hypothesis, I'll keep digging 🤷🏻

rasulomaroff commented 6 months ago

@luukvbaal there're only 2 places where I would check

  1. redraw command
  2. setting winhighlight option

I don't remember doing anything else that could somehow affect the neovim's behavior I believe you have already found the culprit of all of it - redraw in combination with statuscolumn (or without?)

luukvbaal commented 6 months ago

Yeah, I was able to reproduce without this plugin by just doing au ModeChanged * redraw!. Still working on reproducing from --clean.

No idea why but setting 'statuscolumn' in combination with this plugin seems to break treesitter indentation. :TSToggle indent restores the correct behavior at least.

This assumption was wrong btw. I incorrectly assumed treesitter indentation was enabled by default. TSToggle indent restores correct indentation in the repro because it is enabled. I suppose the issue is with statuscolumn, redraw and the html.vim indent plugin then... TBH my suggestion would be to just enable treesitter indenting.

OXY2DEV commented 6 months ago

Just wanted to add this temporary solution, in case someone stumbled in this same issue.

Setting { indent = { enable = true } } does fix the issue. However, it somehow disables nvim-cmp completions. So you also need to install cmp-treesitter and add it to the source table which fixes it.

Now everything works as intended Screenshot_2024-02-13-12-13-21-662_com termux-edit