chentoast / marks.nvim

A better user experience for viewing and interacting with Vim marks.
MIT License
788 stars 40 forks source link

Add option to ignore certain buffers #34

Closed cseickel closed 2 years ago

cseickel commented 2 years ago

First off, this is a great plugin, thank you!

I have noticed a few issues fro the fact that it attaches itself to every buffer without any filters. The biggest issue is with https://github.com/dstein64/nvim-scrollview which uses floating windows to emulate a scrollbar. I've noticed that since I add marks.nvim, the buffers that scrollview creates are being marked as modified and causing me problems when I try to quit.

I also noticed marks being added to my terminals, which is not what I want.

I would think that a sane default is to make sure that the buffers is listed and not a floating window before running marks:refresh() on it. I think it also makes sense to add a configuration which is a list of filetypes that should be ignored. Things like quickfix, tree plugins, Startify, etc would be things people might add to that list.

chentoast commented 2 years ago

The current workaround is to use :MarksToggleSigns <bufnr> in conjunction with some autocommand, like TermEnter.

Regarding disabling on floating, the problem is that only windows can be floating; buffers cannot, meaning that a buffer can be both floating and not floating at the same time. So if you had a buffer with marks in it, and then opened up the same buffer in a floating window, you would lose all marks in both views of the buffer.

Excluded filetypes and disabling on unlisted buffers seems to me like the right way to go, since users can opt in to what they want to disable. Although, what would you expect if you open an empty buffer, place some marks, and then run set ft=<excluded filetype>? I suppose I would expect that the plugin would then proceed to ignore that buffer, although implementing that probably would require adding an autocommand onto OptionSet, which I kind of don't want to do.

cseickel commented 2 years ago

I didn't realize there was already the ability to toggle it off by bufnr, I will definitely use that now that I know!

I see what you mean with the floating issue, a buffer can easily be displayed in a non-floating, then a floating, then non, etc. Especially with previews and telescope type plugins. Scratch that.

Although, what would you expect if you open an empty buffer, place some marks, and then run set ft=?

I don't really see that happening. If I chose to ignore that type, why would I then be adding marks to it?

I suppose I would expect that the plugin would then proceed to ignore that buffer, although implementing that probably would require adding an autocommand onto OptionSet, which I kind of don't want to do.

It looks like there is actually a FileType event, which runs when the filetype is set. That seems like a good target as your buffer setup event, it will likely run once for each buffer, but if it does happen multiple times, it's probably only because other plugins or events are changing it automatically before the users has a chance to see it.