mirror of
https://github.com/lewis6991/gitsigns.nvim
synced 2025-01-30 20:11:42 +00:00
refactor: attach
Some checks are pending
CI / commit_lint (push) Waiting to run
CI / test (nightly) (push) Waiting to run
CI / test (v0.10.0) (push) Waiting to run
CI / test (v0.9.5) (push) Waiting to run
CI / stylua (push) Waiting to run
CI / luals (push) Waiting to run
CI / doc (push) Waiting to run
release-please / release-please (push) Waiting to run
release-please / luarocks-upload (push) Blocked by required conditions
release-please / update-doc (push) Blocked by required conditions
Some checks are pending
CI / commit_lint (push) Waiting to run
CI / test (nightly) (push) Waiting to run
CI / test (v0.10.0) (push) Waiting to run
CI / test (v0.9.5) (push) Waiting to run
CI / stylua (push) Waiting to run
CI / luals (push) Waiting to run
CI / doc (push) Waiting to run
release-please / release-please (push) Waiting to run
release-please / luarocks-upload (push) Blocked by required conditions
release-please / update-doc (push) Blocked by required conditions
This commit is contained in:
parent
2914235f0e
commit
2ff0c29f2a
@ -92,25 +92,6 @@ local function on_attach_pre(bufnr)
|
||||
return gitdir, toplevel
|
||||
end
|
||||
|
||||
--- @param _bufnr integer
|
||||
--- @param file string
|
||||
--- @param revision string?
|
||||
--- @param encoding string
|
||||
--- @return Gitsigns.GitObj?
|
||||
local function try_worktrees(_bufnr, file, revision, encoding)
|
||||
if not config.worktrees then
|
||||
return
|
||||
end
|
||||
|
||||
for _, wt in ipairs(config.worktrees) do
|
||||
local git_obj = git.Obj.new(file, revision, encoding, wt.gitdir, wt.toplevel)
|
||||
if git_obj and git_obj.object_name then
|
||||
dprintf('Using worktree %s', vim.inspect(wt))
|
||||
return git_obj
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local setup = util.once(function()
|
||||
manager.setup()
|
||||
|
||||
@ -237,10 +218,12 @@ local attach_throttled = throttle_by_id(function(cbuf, ctx, aucmd)
|
||||
local git_obj = git.Obj.new(file, revision, encoding, ctx.gitdir, ctx.toplevel)
|
||||
|
||||
if not git_obj and not passed_ctx then
|
||||
git_obj = try_worktrees(cbuf, file, revision, encoding)
|
||||
async.scheduler()
|
||||
if not api.nvim_buf_is_valid(cbuf) then
|
||||
return
|
||||
for _, wt in ipairs(config.worktrees or {}) do
|
||||
git_obj = git.Obj.new(file, revision, encoding, wt.gitdir, wt.toplevel)
|
||||
if git_obj and git_obj.object_name then
|
||||
dprintf('Using worktree %s', vim.inspect(wt))
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user