nvim-orgmode / org-bullets.nvim

GNU Affero General Public License v3.0
138 stars 20 forks source link

Using decoration provider #6

Closed kristijanhusak closed 2 years ago

kristijanhusak commented 3 years ago

Hi,

today while debugging some things I checked source code here to see what's happening, and I noticed that you are setting these exmarks via autocmd, and managing them via internal state.

I think using nvim_set_decoration_provider + ephermal option should help you clean things up a bit and have less code to manage. I just pushed a fix for hide leading stars option on tree-sitter branch that is using this provider, and it seems it's working fine. I think same thing is used internally for treesitter highlights.

I'm pretty sure using the same chunk of code with addition to the virtual text instead of hl group should do the trick.

This is just a suggestion of course.

akinsho commented 3 years ago

@kristijanhusak thanks for mentioning, tbh I'd initially tried to use nvim_buf_attach and the associated callbacks to manage applying the extmarks rather than the cavalcade of autocommands which is much messier but for some reason none of the events were being triggered when I would undo an action. This only seemed to trigger in the autocommand method. I didn't actually try set_decoration_provider explicitly since it seemed similar to the buf_attach method and I guessed it would have the same issues but I'll give it a try when I get a chance. Would be nice to move back to a much tidier update mechanism.

kristijanhusak commented 3 years ago

If i remember correctly I also had some issues with nvim_buf_attach initially, but I'm not sure if it was related to an undo action. This seems to work fine.

akinsho commented 2 years ago

Refactored in 8ec3b6d