Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
hsanson opened this issue Sep 23, 2024 · 0 comments
Open

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

hsanson opened this issue Sep 23, 2024 · 0 comments

Comments

@hsanson
Copy link

hsanson commented Sep 23, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant