1

Update generated neovim config

This commit is contained in:
2024-09-22 20:41:25 +02:00
parent 1743764e48
commit aa1271c42c
1247 changed files with 26512 additions and 15067 deletions

View File

@ -67,6 +67,7 @@ of the default settings:
delay = 1000,
ignore_whitespace = false,
virt_text_priority = 100,
use_focus = true,
},
current_line_blame_formatter = '<author>, <author_time:%R> - <summary>',
sign_priority = 6,
@ -821,6 +822,7 @@ current_line_blame_opts *gitsigns-config-current_line_blame_opts*
Default: >
`{
delay = 1000,
use_focus = true,
virt_text = true,
virt_text_pos = "eol",
virt_text_priority = 100
@ -844,6 +846,8 @@ current_line_blame_opts *gitsigns-config-current_line_blame_opts*
Ignore whitespace when running blame.
• virt_text_priority: integer
Priority of virtual text.
• use_focus: boolean
Enable only when buffer is in focus
• extra_opts: string[]
Extra options passed to `git-blame`.

View File

@ -67,6 +67,7 @@ of the default settings:
delay = 1000,
ignore_whitespace = false,
virt_text_priority = 100,
use_focus = true,
},
current_line_blame_formatter = '<author>, <author_time:%R> - <summary>',
sign_priority = 6,
@ -821,6 +822,7 @@ current_line_blame_opts *gitsigns-config-current_line_blame_opts*
Default: >
`{
delay = 1000,
use_focus = true,
virt_text = true,
virt_text_pos = "eol",
virt_text_priority = 100
@ -844,6 +846,8 @@ current_line_blame_opts *gitsigns-config-current_line_blame_opts*
Ignore whitespace when running blame.
• virt_text_priority: integer
Priority of virtual text.
• use_focus: boolean
Enable only when buffer is in focus
• extra_opts: string[]
Extra options passed to `git-blame`.

View File

@ -1,21 +1,21 @@
rock_manifest = {
doc = {
["gitsigns.txt"] = "ed2c2a9eac117833753afc9dd55adcf4"
["gitsigns.txt"] = "701ffdce0c14beaede62a3d0e551c7a8"
},
["gitsigns.nvim-scm-1.rockspec"] = "a9b165d604ce401cfeea760a9366418d",
lua = {
gitsigns = {
["actions.lua"] = "ac0661d45e50424f5f59924528b1c031",
["async.lua"] = "ab34c767e5b6c917335d19f2acc6fd36",
["actions.lua"] = "395d48d459147a4505ec15bd9c7f4f49",
["async.lua"] = "9c3d111da582ae7eef17c64ce2519a2a",
["attach.lua"] = "44664690d66389b4487d934ebcad98e6",
["blame.lua"] = "05feea95e221a2409a8d44334c47529f",
["cache.lua"] = "523c72aa06168f06b3ecd34fd04cbe9d",
["cache.lua"] = "b48aea0d367198dc603ab7775513fe87",
cli = {
["argparse.lua"] = "fb6c9ffda01b2090f3c252ecaf00f68a"
},
["cli.lua"] = "00273191aa1ca467c5edbd9531f8fd9d",
["config.lua"] = "8743742b5a5b0a0713f0352ff4e88db0",
["current_line_blame.lua"] = "48e477d836e39ab98e58c2b027dd9db8",
["config.lua"] = "d2e4c0fb951edf984cf534f7d0e90bfd",
["current_line_blame.lua"] = "660345d06ddf374bf8fdde0ee2200634",
["debounce.lua"] = "5a28036b5ac45c1f93f9883b855e564f",
debug = {
["log.lua"] = "f7e994b68e9cbcf91adfeb5bc379d7b1"
@ -27,14 +27,14 @@ rock_manifest = {
["diffthis.lua"] = "aaac58016e9982bb14e942f9e4e24c52",
git = {
["blame.lua"] = "e779f4344bcc41cdb92c1a1be5eb2815",
["cmd.lua"] = "449c03c67b7ae516babc41d6da0dc66e",
["repo.lua"] = "1efe3178f64b77e0fc22cad55d9586a0",
["cmd.lua"] = "87e37bb8fd03083a530970eb4d6943c8",
["repo.lua"] = "8db0a2c7d221ae5ba42db2b8ef24492d",
["version.lua"] = "068a582ed4565978eb1f6eb089a6fa6c"
},
["git.lua"] = "0d3e8859ff8cf7ebd3beb739b64a8c49",
["git.lua"] = "1b97799c57ef1392c67c2d9599da509b",
["highlight.lua"] = "f0bf039b629818fbfae8a6fad161f9a2",
["hunks.lua"] = "ee058ee8b056b055cd8404460ca6921f",
["manager.lua"] = "f6e7e2430f2f28a4dbcfd2479f2c8480",
["manager.lua"] = "394b58f67de90f8138453061eca03d4d",
["message.lua"] = "523ee4df9da4a7fa9b5ab2100eb27ac4",
["popup.lua"] = "2fcf3052f95d81cb5c0bb04ca4e06aae",
["repeat.lua"] = "798544de97c774bc8e10eecfd6479585",

View File

@ -275,6 +275,11 @@ M.stage_hunk = mk_repeatable(async.create(2, function(range, opts)
return
end
if bcache:locked() then
print('Error: busy')
return
end
if not util.path_exists(bcache.file) then
print('Error: Cannot stage lines. Please add the file to the working tree.')
return
@ -294,7 +299,6 @@ M.stage_hunk = mk_repeatable(async.create(2, function(range, opts)
end
bcache.git_obj:stage_hunks({ hunk }, invert)
table.insert(bcache.staged_diffs, hunk)
bcache:invalidate(true)
@ -397,6 +401,11 @@ M.undo_stage_hunk = async.create(function()
return
end
if bcache:locked() then
print('Error: busy')
return
end
local hunk = table.remove(bcache.staged_diffs)
if not hunk then
print('No hunks to undo')
@ -419,6 +428,11 @@ M.stage_buffer = async.create(function()
return
end
if bcache:locked() then
print('Error: busy')
return
end
-- Only process files with existing hunks
local hunks = bcache.hunks
if not hunks or #hunks == 0 then
@ -454,6 +468,11 @@ M.reset_buffer_index = async.create(function()
return
end
if bcache:locked() then
print('Error: busy')
return
end
-- `bcache.staged_diffs` won't contain staged changes outside of current
-- neovim session so signs added from this unstage won't be complete They will
-- however be fixed by gitdir watcher and properly updated We should implement
@ -463,7 +482,6 @@ M.reset_buffer_index = async.create(function()
bcache.staged_diffs = {}
bcache.git_obj:unstage_file()
bcache:invalidate(true)
update(bufnr)
end)
@ -551,6 +569,9 @@ local function get_nav_hunks(bufnr, target, greedy)
if target == 'all' then
hunks = hunks_main
vim.list_extend(hunks, hunks_head)
table.sort(hunks, function(h1, h2)
return h1.added.start < h2.added.start
end)
elseif target == 'staged' then
hunks = hunks_head
end

View File

@ -69,27 +69,37 @@ function Async_T:is_cancelled()
end
--- @param func function
--- @param protected boolean
--- @param callback? fun(...: any)
--- @param ... any
--- @return Gitsigns.Async_T
local function run(func, callback, ...)
local function run(func, protected, callback, ...)
local co = coroutine.create(func)
local handle = Async_T.new(co)
if protected then
assert(type(callback) == 'function')
end
local function step(...)
local ret = { coroutine.resume(co, ...) }
local stat = ret[1]
if not stat then
local err = ret[2] --[[@as string]]
error(
string.format('The coroutine failed with this message: %s\n%s', err, debug.traceback(co))
)
local co_err = ret[2] --- @type string
local err = debug.traceback(co, string.format('The async coroutine failed: %s', co_err))
if protected then
--- @cast callback -nil
callback(false, err)
else
error(err)
end
end
if coroutine.status(co) == 'dead' then
if callback then
callback(unpack(ret, 2, table.maxn(ret)))
-- Include status if protected
callback(unpack(ret, protected and 1 or 2, table.maxn(ret)))
end
return
end
@ -99,13 +109,21 @@ local function run(func, callback, ...)
assert(type(fn) == 'function', 'type error :: expected func')
local args = { select(4, unpack(ret)) }
--- @type any[]
local args = { unpack(ret, 4, table.maxn(ret)) }
args[nargs] = step
local r = fn(unpack(args, 1, nargs))
if is_Async_T(r) then
--- @cast r Gitsigns.Async_T
handle._current = r
if protected then
--- @cast callback -nil
xpcall(fn, function(err)
callback(false, string.format('The wrapped function failed: %s', err))
end, unpack(args, 1, nargs))
else
local r = fn(unpack(args, 1, nargs))
if is_Async_T(r) then
--- @cast r Gitsigns.Async_T
handle._current = r
end
end
end
@ -182,7 +200,7 @@ function M.create(argc_or_func, func)
return function(...)
local callback = argc and select(argc + 1, ...) or nil
assert(not callback or type(callback) == 'function')
return run(func, callback, unpack({ ... }, 1, argc))
return run(func, false, callback, unpack({ ... }, 1, argc))
end
end
@ -191,7 +209,16 @@ end
M.scheduler = M.wrap(1, vim.schedule)
function M.run(func, ...)
return run(func, nil, ...)
return run(func, false, nil, ...)
end
--- @param func fun()
--- @return boolean stat
--- @return string? err
function M.pcall(func)
return M.wait(1, function(cb)
run(func, true, cb)
end)
end
return M

View File

@ -20,6 +20,8 @@ local M = {
--- @field gitdir_watcher? uv.uv_fs_event_t
--- @field git_obj Gitsigns.GitObj
--- @field blame? table<integer,Gitsigns.BlameInfo?>
---
--- @field update_lock? true Update in progress
local CacheEntry = M.CacheEntry
function CacheEntry:get_rev_bufname(rev, nofile)
@ -30,6 +32,10 @@ function CacheEntry:get_rev_bufname(rev, nofile)
return string.format('gitsigns://%s//%s:%s', self.git_obj.repo.gitdir, rev, self.git_obj.relpath)
end
function CacheEntry:locked()
return self.git_obj.lock or self.update_lock or false
end
--- Invalidate any state dependent on the buffer content.
--- If 'all' is passed, then invalidate everything.
--- @param all? boolean

View File

@ -42,6 +42,7 @@
--- @field virt_text_pos? 'eol'|'overlay'|'right_align'
--- @field delay? integer
--- @field virt_text_priority? integer
--- @field use_focus? boolean
--- @class (exact) Gitsigns.BlameOpts
--- @field ignore_whitespace? boolean
@ -680,6 +681,7 @@ M.schema = {
virt_text_pos = 'eol',
virt_text_priority = 100,
delay = 1000,
use_focus = true,
},
description = [[
Options for the current line blame annotation.
@ -700,6 +702,8 @@ M.schema = {
Ignore whitespace when running blame.
• virt_text_priority: integer
Priority of virtual text.
• use_focus: boolean
Enable only when buffer is in focus
• extra_opts: string[]
Extra options passed to `git-blame`.
]],

View File

@ -225,13 +225,18 @@ function M.setup()
-- show current buffer line blame immediately
M.update(api.nvim_get_current_buf())
local events = { 'FocusGained', 'BufEnter', 'CursorMoved', 'CursorMovedI' }
local update_events = { 'BufEnter', 'CursorMoved', 'CursorMovedI' }
local reset_events = { 'InsertEnter', 'BufLeave' }
if vim.fn.exists('#WinResized') == 1 then
-- For nvim 0.9+
events[#events + 1] = 'WinResized'
update_events[#update_events + 1] = 'WinResized'
end
if opts.use_focus then
update_events[#update_events + 1] = 'FocusGained'
reset_events[#reset_events + 1] = 'FocusLost'
end
api.nvim_create_autocmd(events, {
api.nvim_create_autocmd(update_events, {
group = group,
callback = function(args)
reset(args.buf)
@ -239,7 +244,7 @@ function M.setup()
end,
})
api.nvim_create_autocmd({ 'InsertEnter', 'FocusLost', 'BufLeave' }, {
api.nvim_create_autocmd(reset_events, {
group = group,
callback = function(args)
reset(args.buf)

View File

@ -1,4 +1,5 @@
local log = require('gitsigns.debug.log')
local async = require('gitsigns.async')
local util = require('gitsigns.util')
local Repo = require('gitsigns.git.repo')
@ -31,6 +32,8 @@ end
--- @field orig_relpath? string Use for tracking moved files
--- @field repo Gitsigns.Repo
--- @field has_conflicts? boolean
---
--- @field lock? true
local Obj = {}
M.Obj = Obj
@ -61,12 +64,14 @@ function M.diff(file_cmp, file_buf, indent_heuristic, diff_algo)
})
end
--- @async
--- @param revision? string
function Obj:update_revision(revision)
self.revision = util.norm_base(revision)
self:update()
end
--- @async
--- @param update_relpath? boolean
--- @param silent? boolean
--- @return boolean
@ -98,6 +103,7 @@ function Obj:from_tree()
return self.revision and not vim.startswith(self.revision, ':')
end
--- @async
--- @param file? string
--- @param silent? boolean
--- @return Gitsigns.FileInfo
@ -110,6 +116,7 @@ function Obj:file_info(file, silent)
end
--- @private
--- @async
--- Get information about files in the index and the working tree
--- @param file? string
--- @param silent? boolean
@ -177,6 +184,7 @@ function Obj:file_info_index(file, silent)
end
--- @private
--- @async
--- Get information about files in a certain revision
--- @param file? string
--- @param silent? boolean
@ -213,6 +221,7 @@ function Obj:file_info_tree(file, silent)
}
end
--- @async
--- @param revision? string
--- @return string[] stdout, string? stderr
function Obj:get_show_text(revision)
@ -251,11 +260,15 @@ local function autocmd_changed(file)
end)
end
--- @async
function Obj:unstage_file()
self.lock = true
self.repo:command({ 'reset', self.file })
self.lock = nil
autocmd_changed(self.file)
end
--- @async
--- @param lines string[]
--- @param lnum? integer
--- @param revision? string
@ -265,28 +278,33 @@ function Obj:run_blame(lines, lnum, revision, opts)
return require('gitsigns.git.blame').run_blame(self, lines, lnum, revision, opts)
end
--- @param obj Gitsigns.GitObj
local function ensure_file_in_index(obj)
if obj.object_name and not obj.has_conflicts then
--- @async
--- @private
function Obj:ensure_file_in_index()
self.lock = true
if self.object_name and not self.has_conflicts then
return
end
if not obj.object_name then
if not self.object_name then
-- If there is no object_name then it is not yet in the index so add it
obj.repo:command({ 'add', '--intent-to-add', obj.file })
self.repo:command({ 'add', '--intent-to-add', self.file })
else
-- Update the index with the common ancestor (stage 1) which is what bcache
-- stores
local info = string.format('%s,%s,%s', obj.mode_bits, obj.object_name, obj.relpath)
obj.repo:command({ 'update-index', '--add', '--cacheinfo', info })
local info = string.format('%s,%s,%s', self.mode_bits, self.object_name, self.relpath)
self.repo:command({ 'update-index', '--add', '--cacheinfo', info })
end
obj:update()
self:update()
self.lock = nil
end
--- @async
--- Stage 'lines' as the entire contents of the file
--- @param lines string[]
function Obj:stage_lines(lines)
self.lock = true
local new_object = self.repo:command({
'hash-object',
'-w',
@ -301,13 +319,20 @@ function Obj:stage_lines(lines)
string.format('%s,%s,%s', self.mode_bits, new_object, self.relpath),
})
self.lock = nil
autocmd_changed(self.file)
end
local sleep = async.wrap(2, function(duration, cb)
vim.defer_fn(cb, duration)
end)
--- @async
--- @param hunks Gitsigns.Hunk.Hunk[]
--- @param invert? boolean
function Obj:stage_hunks(hunks, invert)
ensure_file_in_index(self)
self.lock = true
self:ensure_file_in_index()
local patch = require('gitsigns.hunks').create_patch(self.relpath, hunks, self.mode_bits, invert)
@ -318,19 +343,32 @@ function Obj:stage_hunks(hunks, invert)
end
end
self.repo:command({
'apply',
'--whitespace=nowarn',
'--cached',
'--unidiff-zero',
'-',
}, {
stdin = patch,
})
local stat, err = async.pcall(function()
self.repo:command({
'apply',
'--whitespace=nowarn',
'--cached',
'--unidiff-zero',
'-',
}, {
stdin = patch,
})
end)
if not stat then
self.lock = nil
error(err)
end
-- Staging operations cause IO of the git directory so wait some time
-- for the changes to settle.
sleep(100)
self.lock = nil
autocmd_changed(self.file)
end
--- @async
--- @return string?
function Obj:has_moved()
local out = self.repo:command({ 'diff', '--name-status', '-C', '--cached' })
@ -349,6 +387,7 @@ function Obj:has_moved()
end
end
--- @async
--- @param file string
--- @param revision string?
--- @param encoding string

View File

@ -12,7 +12,7 @@ local asystem = async.wrap(3, system)
--- @async
--- @param args string[]
--- @param spec? Gitsigns.Git.JobSpec
--- @return string[] stdout, string? stderr
--- @return string[] stdout, string? stderr, integer code
local function git_command(args, spec)
spec = spec or {}
@ -66,7 +66,7 @@ local function git_command(args, spec)
obj.stderr = nil
end
return stdout_lines, obj.stderr
return stdout_lines, obj.stderr, obj.code
end
return git_command

View File

@ -81,6 +81,7 @@ local function iconv_supported(encoding)
return true
end
--- @async
--- Get version of file in the index, return array lines
--- @param object string
--- @param encoding? string
@ -99,9 +100,9 @@ end
--- @async
function M:update_abbrev_head()
local info = M.get_info(self.toplevel)
local info, err = M.get_info(self.toplevel)
if not info then
log.eprintf('Could not get info for repo at %s', self.gitdir)
log.eprintf('Could not get info for repo at %s: %s', self.gitdir, err or '')
return
end
self.abbrev_head = info.abbrev_head
@ -211,7 +212,7 @@ end
--- @param cwd string
--- @param gitdir? string
--- @param toplevel? string
--- @return Gitsigns.RepoInfo?
--- @return Gitsigns.RepoInfo? info, string? err
function M.get_info(cwd, gitdir, toplevel)
-- Does git rev-parse have --absolute-git-dir, added in 2.13:
-- https://public-inbox.org/git/20170203024829.8071-16-szeder.dev@gmail.com/
@ -238,13 +239,13 @@ function M.get_info(cwd, gitdir, toplevel)
'HEAD',
})
local stdout = git_command(args, {
local stdout, stderr, code = git_command(args, {
ignore_error = true,
cwd = toplevel or cwd,
})
if not stdout[1] then
return
if code > 0 then
return nil, string.format('got stderr: %s', stderr or '')
end
local toplevel_r = normalize_path(stdout[1])

View File

@ -448,6 +448,8 @@ M.update = throttle_by_id(function(bufnr)
return
end
local bcache = assert(cache[bufnr])
bcache.update_lock = true
local old_hunks, old_hunks_staged = bcache.hunks, bcache.hunks_staged
bcache.hunks, bcache.hunks_staged = nil, nil
@ -505,6 +507,7 @@ M.update = throttle_by_id(function(bufnr)
summary.head = git_obj.repo.abbrev_head
Status:update(bufnr, summary)
end
bcache.update_lock = nil
end, true)
--- @param bufnr integer

View File

@ -1 +1 @@
/nix/store/rn8bzg423wwkayzbsbmhmvcgjmbzrq5z-lua-5.1.5
/nix/store/k55zni8plmbwkbv9l6ds65p981ndxk7x-lua-5.1.5

View File

@ -1,21 +1,21 @@
rock_manifest = {
doc = {
["gitsigns.txt"] = "ed2c2a9eac117833753afc9dd55adcf4"
["gitsigns.txt"] = "701ffdce0c14beaede62a3d0e551c7a8"
},
["gitsigns.nvim-scm-1.rockspec"] = "a9b165d604ce401cfeea760a9366418d",
lua = {
gitsigns = {
["actions.lua"] = "ac0661d45e50424f5f59924528b1c031",
["async.lua"] = "ab34c767e5b6c917335d19f2acc6fd36",
["actions.lua"] = "395d48d459147a4505ec15bd9c7f4f49",
["async.lua"] = "9c3d111da582ae7eef17c64ce2519a2a",
["attach.lua"] = "44664690d66389b4487d934ebcad98e6",
["blame.lua"] = "05feea95e221a2409a8d44334c47529f",
["cache.lua"] = "523c72aa06168f06b3ecd34fd04cbe9d",
["cache.lua"] = "b48aea0d367198dc603ab7775513fe87",
cli = {
["argparse.lua"] = "fb6c9ffda01b2090f3c252ecaf00f68a"
},
["cli.lua"] = "00273191aa1ca467c5edbd9531f8fd9d",
["config.lua"] = "8743742b5a5b0a0713f0352ff4e88db0",
["current_line_blame.lua"] = "48e477d836e39ab98e58c2b027dd9db8",
["config.lua"] = "d2e4c0fb951edf984cf534f7d0e90bfd",
["current_line_blame.lua"] = "660345d06ddf374bf8fdde0ee2200634",
["debounce.lua"] = "5a28036b5ac45c1f93f9883b855e564f",
debug = {
["log.lua"] = "f7e994b68e9cbcf91adfeb5bc379d7b1"
@ -27,14 +27,14 @@ rock_manifest = {
["diffthis.lua"] = "aaac58016e9982bb14e942f9e4e24c52",
git = {
["blame.lua"] = "e779f4344bcc41cdb92c1a1be5eb2815",
["cmd.lua"] = "449c03c67b7ae516babc41d6da0dc66e",
["repo.lua"] = "1efe3178f64b77e0fc22cad55d9586a0",
["cmd.lua"] = "87e37bb8fd03083a530970eb4d6943c8",
["repo.lua"] = "8db0a2c7d221ae5ba42db2b8ef24492d",
["version.lua"] = "068a582ed4565978eb1f6eb089a6fa6c"
},
["git.lua"] = "0d3e8859ff8cf7ebd3beb739b64a8c49",
["git.lua"] = "1b97799c57ef1392c67c2d9599da509b",
["highlight.lua"] = "f0bf039b629818fbfae8a6fad161f9a2",
["hunks.lua"] = "ee058ee8b056b055cd8404460ca6921f",
["manager.lua"] = "f6e7e2430f2f28a4dbcfd2479f2c8480",
["manager.lua"] = "394b58f67de90f8138453061eca03d4d",
["message.lua"] = "523ee4df9da4a7fa9b5ab2100eb27ac4",
["popup.lua"] = "2fcf3052f95d81cb5c0bb04ca4e06aae",
["repeat.lua"] = "798544de97c774bc8e10eecfd6479585",