Skip to content

[audit] autoread = true without a checktime autocmd — files silently never reload #262

Description

@stanfish06

What

options.lua:70 sets:

vim.o.autoread = true

autoread tells Neovim to reload a file when it detects the file has changed on disk, but only at the moment Neovim itself checks for changes — which requires an explicit :checktime call. Without a trigger, autoread has no practical effect when switching back from another terminal, running git pull, or letting an external tool regenerate a file.

Where

lua/config/options.lua:70

Why it matters

The option creates a false expectation: the setting is present and looks like auto-reload is active, but files only reload if the user manually runs :checktime. This is a well-known autoread gotcha.

Recommended action

Add an autocmd to call :checktime at the moments when an external change is most likely to be relevant:

vim.api.nvim_create_autocmd({ "FocusGained", "BufEnter" }, {
    callback = function()
        if vim.fn.getcmdwintype() == "" then
            vim.cmd("checktime")
        end
    end,
})

The getcmdwintype() guard prevents :checktime from firing inside the command window (which can cause errors). FocusGained covers switching back from another app; BufEnter covers :e / buffer switch. Both are standard pairings for autoread in the Neovim ecosystem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions