Skip to content

[audit] Nightly's native autoread fs-watcher will make the manual checktime polling shim redundant #318

Description

@stanfish06

What

Current Neovim nightly (unreleased, ahead of 0.12 stable) lists under "Notable changes since Nvim 0.12" → NEW FEATURES → EDITOR:

'autoread' uses file system watchers to detect external changes in real-time, instead of only on FocusGained or :checktime.

Where

lua/config/options.lua:71-78:

vim.o.autoread = true
-- autoread alone only reloads a changed-on-disk buffer on a handful of
-- vim-internal triggers (:e, some shell-outs); it does not poll, so external
-- changes (git checkout, another instance saving) are silently missed until
-- one of those triggers happens to fire. checktime forces the check.
vim.api.nvim_create_autocmd({ "FocusGained", "BufEnter", "CursorHold", "CursorHoldI" }, {
    command = "checktime",
})

Why it matters

This hand-rolled shim exists specifically to work around autoread not polling — but that's exactly what the new native fs-watcher feature fixes. This isn't an immediate break (the feature is nightly-only, not yet in 0.12.x stable, so today's shim is still needed), but once the config's target Neovim version picks up native fs-watching, the autocmd becomes redundant: it'll keep firing synchronous :checktime calls (including on every CursorHold/CursorHoldI) on top of a filesystem watcher that already does the same job in real time, for no benefit and a little unnecessary overhead.

Recommended action

Not urgent, but worth tracking so the shim doesn't quietly outlive its reason for existing. When the config's minimum supported Neovim version moves past whatever release ships the native watcher:

  • Gate the autocmd behind a version check (e.g. vim.fn.has("nvim-0.13") == 0 or whatever the actual cutoff release turns out to be), similar to the min = "0.13" pattern already used for config.image in init.lua, or
  • Remove the autocmd/comment entirely once the config no longer needs to support pre-watcher Neovim.

This needs a judgment call on timing (native feature isn't released yet) rather than a mechanical rename, hence filing as an issue rather than a PR.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions