Skip to content

Attempt to index field 'buffers' (a nil value) error. #4

@hsanson

Description

@hsanson

Thanks for the great plugin. I found out that if we don't call setup() function when configuring the plugin, then the buffers array in autosave is nil. This results in the following error whenever we try to invoke an action that access that variable:

E5108: Error executing lua: ...l/share/nvim/lazy/autosave.nvim/lua/autosave/actions.lua:61: attempt to index field 'buffers' (a nil value)       
stack traceback:                                                                                                                                       
        ...l/share/nvim/lazy/autosave.nvim/lua/autosave/actions.lua:61: in function 'buf_enable'

To replicate configure the plugin using Lazy.nvim with default values as below:

{
  'nullishamy/autosave.nvim',
  lazy = true
}

Open any document and try to enable autosave using the buf_enable() action:

:lua require('autosave.actions').buf_enable()

See the attempt to index field 'buffers' (a nil value)' appears. If we call setup({}) before calling the action then everything works as expected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions