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

FEATURE: Async Version of execute_command to Prevent IO Blocking #1677

Open
1 task done
Isrothy opened this issue Feb 1, 2025 · 0 comments
Open
1 task done

FEATURE: Async Version of execute_command to Prevent IO Blocking #1677

Isrothy opened this issue Feb 1, 2025 · 0 comments
Labels
enhancement New feature or request

Comments

@Isrothy
Copy link

Isrothy commented Feb 1, 2025

Did you check the docs?

  • I have read all the docs.

Is your feature request related to a problem? Please describe.

I would like to request an asynchronous version of the execute_command function. Currently, it runs synchronously, which can block Neovim’s IO when executing long-running commands. One instance of this issue is in lua/neo-tree/git/status.lua within the M.status function. In this function, the following command is executed:

local untracked_cmd = { "git", "-C", C, "ls-files", "--exclude-standard", "--others" }

For large repositories, the git ls-files command can take a significant amount of time, thereby blocking the UI and affecting overall performance.

Running commands asynchronously would help keep the Neovim UI responsive, even when dealing with large repositories or slow-running git commands. This issue is particularly evident in my setup where I use baredot to manage my dotfiles, with the git root set to the home directory. In such cases, operations that run across many files in the home directory can lead to noticeable delays and a degraded user experience.

Describe the solution you'd like.

A possible solution is to refactor execute_command (or create a new async variant) to use asynchronous job control (e.g., via vim.loop or another suitable async library) to run external commands without blocking the main event loop. This change would involve:

  • Refactoring the current synchronous implementation.
  • Ensuring that the async version properly collects and returns the output.
  • Optionally providing a callback or promise-based API to integrate smoothly with existing code.

Describe alternatives you've considered.

No response

Additional Context

I believe that this improvement would not only help in the specific context of Git operations but also enhance the overall performance of neo-tree.nvim when dealing with external commands. Given the rising importance of async programming in Neovim plugin development, this change would be a forward-compatible improvement.

@Isrothy Isrothy added the enhancement New feature or request label Feb 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant