Skip to content

refactor!: download packages asynchronously#487

Open
diego-velez wants to merge 1 commit intonvim-java:mainfrom
diego-velez:refactor/async_network_io
Open

refactor!: download packages asynchronously#487
diego-velez wants to merge 1 commit intonvim-java:mainfrom
diego-velez:refactor/async_network_io

Conversation

@diego-velez
Copy link
Copy Markdown

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.system to execute programs. This PR swaps the old vim.fn.system for the newer vim.system API, 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 call require('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.

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.

1 participant