chentoast / marks.nvim

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

Method 'refresh' breaks CursorHold #40

Open rodamaral opened 2 years ago

rodamaral commented 2 years ago

This plugin is making my CursorHold autocmds never execute.

For example:

autocmd CursorHold <buffer> lua print'CursorHold'

This seems to happen due to M.refresh being called before my updatetime expires and then reseting the hold timer. https://github.com/chentau/marks.nvim/blob/f43e349601b439b4b07bec1d996cfd70d48d09fb/lua/marks/init.lua#L68

chentoast commented 2 years ago

One option would be to set ‘refresh_interval’ to some very high value so it won’t interfere, and the set up your own custom mark redraw logic on CursorHold. I’m traveling now but will post a snippet when I can

mystilleef commented 2 years ago

I was wondering why my autosave suddenly stopped working.

windwp commented 2 years ago

Can we switch to event autocmd WinScrolled to call refresh. I don't think the marks sign need update too offten @chentau

chentoast commented 2 years ago

WinScrolled is not enough. For things like mark preview, and extracting marks to loc/quickfix lists, we need the mark state to be synchronized even if they are not visible on screen. In addition, WinScrolled is not fired when switching buffers, which may happen when moving to bookmarks or capital marks.

Here's the workaround that I promised but never got around to posting:

lua <<EOF
require'marks'.setup {
  refresh_interval = 0 -- or some really large value to disable mark tracking
}
EOF

au CursorHold * lua require'marks'.refresh()

Note that whatever autocmd you choose is up to you; you can use WinScrolled instead if you want, for example.

windwp commented 2 years ago

Ok i will do your solution to disable refresh. i notice your plugin force my status line redraw even i don't typing any key on normal mode.

rodamaral commented 2 years ago

This is related https://neovim.discourse.group/t/psa-dont-rely-on-cursorhold-yet/1813

chentoast commented 2 years ago

FYI there has been a potential fix pushed to latest Neovim master. Would be great if people test this on latest HEAD to see if the issue still persists.

chentoast commented 2 years ago

I'm thinking of switching over to cursorhold as default in the next couple of weeks, but I don't want to break anyone's configuration. Does anyone have a timer-based approach or usage of the plugin that would not work with a cursorhold based refresh approach?