refactor!: download packages asynchronously#487
Open
diego-velez wants to merge 1 commit intonvim-java:mainfrom
Open
refactor!: download packages asynchronously#487diego-velez wants to merge 1 commit intonvim-java:mainfrom
diego-velez wants to merge 1 commit intonvim-java:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Downloading packages is synchronous and blocks the UI. Users cannot type or do anything in Neovim while packages are downloading. Furthermore, because the UI is blocked, users do not know that a package is being downloaded even though nvim-java is supposed to notify the user.
Solution
Download packages asynchronously.
Implementation
At the core, it seems to me that the issue was using the old
vim.fn.systemto execute programs. This PR swaps the oldvim.fn.systemfor the newervim.systemAPI, and makes all executions asynchronous.To make this work, I had to list out all the packages that needed to be installed, instead of installing each package one by one in setup. Then, I pass to the package manager the list of packages that need to be installed. The package manager asynchronously installs each package. When all packages are finished installing, the setup callback is called, and setup can finish.
The main breaking change is that users cannot call
vim.lsp.enable('jdtls')after they callrequire('java').setup()because it no longer blocks, so nvim-java might not be setup before the setup function completes. Because of this, we would need to enable jdtls ourselves after nvim-java is setup. Additionally, we could create a user autocommand, and have users setup their java tooling in that autocommand.Caution
This PR has not been tested in Windows.