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

Wrap auto load in vim.schedule #12

Merged
merged 1 commit into from
Jun 6, 2022
Merged

Wrap auto load in vim.schedule #12

merged 1 commit into from
Jun 6, 2022

Conversation

simonmclean
Copy link
Contributor

I'm experiencing a bug whereby if I enable autoloading, I don't get any syntax highlighting on startup (until I trigger it with :e for example). I had the same issue with persistence.nvim (I made an auto command to get the same functionality). For both plugins, wrapping the call to load() in vim.schedule solved the problem.

I don't really know enough about the inner workings of Neovim to explain this though.

I'm experiencing a bug whereby if I enable autoloading, I don't get any syntax highlighting on startup (until I trigger it with `:e` for example). I had the same issue with `persistence.nvim` (I made an auto command to get the same functionality). For both plugins, wrapping the call to `load` in `vim.schedule` solved the problem.

I don't really know enough about the inner workings of Neovim to explain this though.
@olimorris
Copy link
Owner

This may also help solve #11 as well!

@olimorris olimorris merged commit d9346bf into olimorris:main Jun 6, 2022
@olimorris
Copy link
Owner

Many thanks @simonmclean

@simonmclean simonmclean deleted the patch-1 branch June 6, 2022 17:41
@olimorris
Copy link
Owner

@simonmclean...I've noticed that vim.schedule is causing issues with tests and generally seems to be slow at loading the session file. I'm going to work on a solution which uses vim.schedule later today...likely as a config option.

@simonmclean
Copy link
Contributor Author

Ah, okay. I guess it isn't surprising that it's messed with the tests, as it makes a previously synchronous function asynchronous.

My impression though is that the autoload feature will always run into this bug if vim.schedule isn't used, because the buffer contents will be rendered before things like treesitter are ready

olimorris added a commit that referenced this pull request Jun 7, 2022
A big shoutout to @simonmclean for this pull request. Previously we autoloaded a session file as soon as Neovim opened. The problem with this is that key plugins like LSP and Treesitter may not have been initialised. This would lead to syntax highlighting issues or LSPs not attaching to buffers in the session. Pushing this to Neovim's event loop via vim.schedule allows us to sensibly load the session after these key plugins. Fixing the tests was a little cumbersome as we needed to use plenary's async library but once figured out, we have some lovely robust async tests
@olimorris
Copy link
Owner

I figured out how to write some async tests so this should be solved now and we should load and start sessions using vim.schedule automatically. Once again, thanks for the fix!

@simonmclean
Copy link
Contributor Author

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.

None yet

2 participants