otavioschwanck / arrow.nvim

Bookmark your files, separated by project, and quickly navigate through them.
Other
341 stars 16 forks source link

fix: error when there's no `Cursor` highlight #46

Closed rasulomaroff closed 3 months ago

rasulomaroff commented 3 months ago

Hi there! First of all, really thank you for this plugin. I never knew I needed it until I tried haha!

Since I notice that arrow fails when there's no such a highlight as Cursor. It happens because of the deprecated nvim_get_hl_by_name method. If there's no such a highlight, it just throws an error.

But! When I started fixing the error, I found a data leak in BufLeave autocmd. You can clearly see it if you open and close arrow.nvim 10 times and then check your autocmds by :autocmd. You'll see 10 BufLeave autocmds. I fixed it in the first commit.

Returning back to the original issue - I don't really see the reason overcomplicating in that place, but maybe I'm missing anything? I just created a dummy highlight and shadowed the original cursor highlight. When leaving a buffer, I just deleted the highlight and the cursor setting for it.

P.S. just noticed that in the buffer_ui.lua there're the same errors. Created fixes for those as well!

otavioschwanck commented 3 months ago

Thanks!