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

fix buffer autocommands bug? #13

Merged
merged 1 commit into from
Mar 4, 2024
Merged

fix buffer autocommands bug? #13

merged 1 commit into from
Mar 4, 2024

Conversation

m4cey
Copy link
Contributor

@m4cey m4cey commented Jan 8, 2024

fixes #12
apparently, removing vim.defer_fn from create_autocmds fixes this for me, but not sure if it's acceptable as I don't know the original purpose of using a defer here.

@m4cey m4cey closed this Jan 10, 2024
@pynappo
Copy link

pynappo commented Mar 3, 2024

I'm running into a similar buffer autocommands issue and this PR also fixes it. I do not call setup() from outside of my lazy.nvim plugin spec so I'm thinking this PR (and/or extra error checking with vim.api.nvim_buf_is_valid) is needed.

The error seems to happen whenever a new typst buffer is made and then deleted very quickly. For me this is caused by ultimate-autopair.nvim on <CR> in typst files for some reason. So by the time the deferred nvim_create_autocmd function is run the buffer is gone and registering the autocmd fails.

From reading the neovim docs, it seems like the wrapper is unnecessary anyways because nvim_create_autocmd is already deferred, so vim.defer_fn(func, 0) (which I believe is the same as vim.schedule(func)) just delays it further.

@m4cey m4cey reopened this Mar 3, 2024
@chomosuke
Copy link
Owner

Thank you for fixing this. I forgot the reason why it's wrapped in a vim.defer_fn though it might just be precautionary as sometimes certain functions can't run in certain context.

@chomosuke chomosuke merged commit 5867db9 into chomosuke:master Mar 4, 2024
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

Successfully merging this pull request may close these issues.

the first buffer autocommands not registered
3 participants