Skip to content

feat(#1974): experimental.git.async #2094

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

Merged
merged 8 commits into from
Apr 3, 2023
Merged

feat(#1974): experimental.git.async #2094

merged 8 commits into from
Apr 3, 2023

Conversation

alex-courtis
Copy link
Member

@alex-courtis alex-courtis commented Mar 27, 2023

fixes #1974

File system and .git watchers execute asynchronously.

All other operations execute synchronously. It is impractical to (ever?) make them asynchronous due to their looping nature.

Completely separate codepaths was impractical, hence some refactoring to use callbacks was done. Async/await is coming to nvim API which will allow simplification to always use callbacks for synchronous operations.

@gegoune a sanity check would be gratefully appreciated before releasing this.

@@ -59,8 +59,9 @@ function M.create_watcher(node)
else
log.line("watcher", "node event executing refresh '%s'", node.absolute_path)
end
require("nvim-tree.explorer.reload").refresh_node(node)
require("nvim-tree.renderer").draw()
require("nvim-tree.explorer.reload").refresh_node(node, function()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the last action, hence safe to use a callback.

@@ -22,6 +22,21 @@ local WATCHED_FILES = {
"index", -- staging area
}

local function reload_git_status(project_root, path, project, git_status)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved from reload_project

@@ -103,21 +122,22 @@ local function reload_tree_at(project_root)
return
end

M.reload_project(project_root)
local git_status = M.get_project(project_root)
M.reload_project(project_root, nil, function()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Safe to call back as this is the last operation of the watcher.

@alex-courtis alex-courtis requested a review from gegoune March 28, 2023 02:36
@alex-courtis alex-courtis changed the title asynchronous git operations feat(#1974): experimental.git.async Mar 28, 2023
@alex-courtis
Copy link
Member Author

I'd like to create a sticky issue for experiments that we can link in the commit message.

Draft incoming...

git = {
async = false,
},
},
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like gitsigns has stopped (underscore prefixed) experiments.

Using the same pattern as the various lsp plugins.

@alex-courtis
Copy link
Member Author

Added issue: #2104

Dogfooded for a week; it can be reverted easily if any functionality breaks.

@alex-courtis alex-courtis merged commit 0ef3d46 into master Apr 3, 2023
@alex-courtis alex-courtis deleted the 1974-git-threads branch April 3, 2023 06:20
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.

Git Execution Blocks UI Thread
1 participant