Refresh generated neovim config
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
*gitsigns.nvim*
|
||||
|
||||
Author: Lewis Russell <lewis6991@gmail.com>
|
||||
Version: v0.8.1
|
||||
Version: v0.9.0
|
||||
Homepage: <https://github.com/lewis6991/gitsigns.nvim>
|
||||
License: MIT license
|
||||
|
||||
@ -59,10 +59,7 @@ of the default settings:
|
||||
ignore_whitespace = false,
|
||||
virt_text_priority = 100,
|
||||
},
|
||||
current_line_blame_formatter = '<author>, <author_time:%Y-%m-%d> - <summary>',
|
||||
current_line_blame_formatter_opts = {
|
||||
relative_time = false,
|
||||
},
|
||||
current_line_blame_formatter = '<author>, <author_time:%R> - <summary>',
|
||||
sign_priority = 6,
|
||||
update_debounce = 100,
|
||||
status_formatter = nil, -- Use default
|
||||
@ -192,7 +189,7 @@ setqflist({target}, {opts}, {callback?}) *gitsigns.setqflist()*
|
||||
Open the quickfix/location list viewer.
|
||||
Defaults to `true`.
|
||||
|
||||
show({revision}) *gitsigns.show()*
|
||||
show({revision}, {callback}) *gitsigns.show()*
|
||||
Show revision {base} of the current file, if it is given, or
|
||||
with the currently set base (index by default).
|
||||
|
||||
@ -286,6 +283,17 @@ change_base({base}, {global}, {callback?}) *gitsigns.change_base()*
|
||||
{base} (string|nil): The object/revision to diff against.
|
||||
{global} (boolean|nil): Change the base of all buffers.
|
||||
|
||||
blame({callback?}) *gitsigns.blame()*
|
||||
Run git-blame on the current file and open the results
|
||||
in a scroll-bound vertical split.
|
||||
|
||||
<CR> is mapped to open a menu with the actions:
|
||||
- [Show commit] in a vertical split.
|
||||
- [Reblame at commit]
|
||||
|
||||
Attributes: ~
|
||||
{async}
|
||||
|
||||
blame_line({opts}, {callback?}) *gitsigns.blame_line()*
|
||||
Run git blame on the current line and show the results in a
|
||||
floating window. If already open, calling this will cause the
|
||||
@ -392,6 +400,8 @@ nav_hunk({direction}, {opts}, {callback?}) *gitsigns.nav_hunk()*
|
||||
• {greedy}: (boolean)
|
||||
Only navigate between non-contiguous hunks. Only useful if
|
||||
'diff_opts' contains `linematch`. Defaults to `true`.
|
||||
• {target}: (`'unstaged'|'staged'|'all'`)
|
||||
Which kinds of hunks to target. Defaults to `'unstaged'`.
|
||||
• {count}: (integer)
|
||||
Number of times to advance. Defaults to |v:count1|.
|
||||
|
||||
@ -554,6 +564,28 @@ signs *gitsigns-config-signs*
|
||||
|
||||
See |gitsigns-highlight-groups|.
|
||||
|
||||
signs_staged *gitsigns-config-signs_staged*
|
||||
Type: `table[extended]`
|
||||
Default: >
|
||||
{
|
||||
add = { text = '┃' },
|
||||
change = { text = '┃' },
|
||||
delete = { text = '▁' },
|
||||
topdelete = { text = '▔' },
|
||||
changedelete = { text = '~' },
|
||||
}
|
||||
<
|
||||
Configuration for signs of staged hunks.
|
||||
|
||||
See |gitsigns-config-signs|.
|
||||
|
||||
signs_staged_enable *gitsigns-config-signs_staged_enable*
|
||||
Type: `boolean`, Default: `true`
|
||||
|
||||
Show signs for staged hunks.
|
||||
|
||||
When enabled the signs defined in |git-config-signs_staged|` are used.
|
||||
|
||||
worktrees *gitsigns-config-worktrees*
|
||||
Type: `table`, Default: `nil`
|
||||
|
||||
@ -793,23 +825,8 @@ current_line_blame_opts *gitsigns-config-current_line_blame_opts*
|
||||
• extra_opts: string[]
|
||||
Extra options passed to `git-blame`.
|
||||
|
||||
current_line_blame_formatter_opts
|
||||
*gitsigns-config-current_line_blame_formatter_opts*
|
||||
DEPRECATED
|
||||
|
||||
Type: `table[extended]`
|
||||
Default: >
|
||||
`{
|
||||
relative_time = false
|
||||
}`
|
||||
<
|
||||
Options for the current line blame annotation formatter.
|
||||
|
||||
Fields: ~
|
||||
• relative_time: boolean
|
||||
|
||||
current_line_blame_formatter *gitsigns-config-current_line_blame_formatter*
|
||||
Type: `string|function`, Default: `" <author>, <author_time> - <summary> "`
|
||||
Type: `string|function`, Default: `" <author>, <author_time:%R> - <summary> "`
|
||||
|
||||
String or function used to format the virtual text of
|
||||
|gitsigns-config-current_line_blame|.
|
||||
@ -878,9 +895,6 @@ current_line_blame_formatter *gitsigns-config-current_line_blame_formatter*
|
||||
Note that the keys map onto the output of:
|
||||
`git blame --line-porcelain`
|
||||
|
||||
{opts} Passed directly from
|
||||
|gitsigns-config-current_line_blame_formatter_opts|.
|
||||
|
||||
Return: ~
|
||||
The result of this function is passed directly to the `opts.virt_text`
|
||||
field of |nvim_buf_set_extmark| and thus must be a list of
|
||||
@ -901,18 +915,6 @@ trouble *gitsigns-config-trouble*
|
||||
When using setqflist() or setloclist(), open Trouble instead of the
|
||||
quickfix/location list window.
|
||||
|
||||
yadm *gitsigns-config-yadm*
|
||||
DEPRECATED
|
||||
Please use |gitsigns-config-on_attach_pre| instead
|
||||
|
||||
Type: `table`
|
||||
Default: >
|
||||
`{
|
||||
enable = false
|
||||
}`
|
||||
<
|
||||
yadm configuration.
|
||||
|
||||
word_diff *gitsigns-config-word_diff*
|
||||
Type: `boolean`, Default: `false`
|
||||
|
||||
|
||||
@ -17,7 +17,6 @@ gitsigns-config-count_chars gitsigns.txt /*gitsigns-config-count_chars*
|
||||
gitsigns-config-current_line_blame gitsigns.txt /*gitsigns-config-current_line_blame*
|
||||
gitsigns-config-current_line_blame_formatter gitsigns.txt /*gitsigns-config-current_line_blame_formatter*
|
||||
gitsigns-config-current_line_blame_formatter_nc gitsigns.txt /*gitsigns-config-current_line_blame_formatter_nc*
|
||||
gitsigns-config-current_line_blame_formatter_opts gitsigns.txt /*gitsigns-config-current_line_blame_formatter_opts*
|
||||
gitsigns-config-current_line_blame_opts gitsigns.txt /*gitsigns-config-current_line_blame_opts*
|
||||
gitsigns-config-debug_mode gitsigns.txt /*gitsigns-config-debug_mode*
|
||||
gitsigns-config-diff_opts gitsigns.txt /*gitsigns-config-diff_opts*
|
||||
@ -30,13 +29,14 @@ gitsigns-config-show_deleted gitsigns.txt /*gitsigns-config-show_deleted*
|
||||
gitsigns-config-sign_priority gitsigns.txt /*gitsigns-config-sign_priority*
|
||||
gitsigns-config-signcolumn gitsigns.txt /*gitsigns-config-signcolumn*
|
||||
gitsigns-config-signs gitsigns.txt /*gitsigns-config-signs*
|
||||
gitsigns-config-signs_staged gitsigns.txt /*gitsigns-config-signs_staged*
|
||||
gitsigns-config-signs_staged_enable gitsigns.txt /*gitsigns-config-signs_staged_enable*
|
||||
gitsigns-config-status_formatter gitsigns.txt /*gitsigns-config-status_formatter*
|
||||
gitsigns-config-trouble gitsigns.txt /*gitsigns-config-trouble*
|
||||
gitsigns-config-update_debounce gitsigns.txt /*gitsigns-config-update_debounce*
|
||||
gitsigns-config-watch_gitdir gitsigns.txt /*gitsigns-config-watch_gitdir*
|
||||
gitsigns-config-word_diff gitsigns.txt /*gitsigns-config-word_diff*
|
||||
gitsigns-config-worktrees gitsigns.txt /*gitsigns-config-worktrees*
|
||||
gitsigns-config-yadm gitsigns.txt /*gitsigns-config-yadm*
|
||||
gitsigns-events gitsigns.txt /*gitsigns-events*
|
||||
gitsigns-functions gitsigns.txt /*gitsigns-functions*
|
||||
gitsigns-highlight-groups gitsigns.txt /*gitsigns-highlight-groups*
|
||||
@ -47,6 +47,7 @@ gitsigns-statusline gitsigns.txt /*gitsigns-statusline*
|
||||
gitsigns-textobject gitsigns.txt /*gitsigns-textobject*
|
||||
gitsigns-usage gitsigns.txt /*gitsigns-usage*
|
||||
gitsigns.attach() gitsigns.txt /*gitsigns.attach()*
|
||||
gitsigns.blame() gitsigns.txt /*gitsigns.blame()*
|
||||
gitsigns.blame_line() gitsigns.txt /*gitsigns.blame_line()*
|
||||
gitsigns.change_base() gitsigns.txt /*gitsigns.change_base()*
|
||||
gitsigns.detach() gitsigns.txt /*gitsigns.detach()*
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,37 +0,0 @@
|
||||
local _MODREV, _SPECREV = 'scm', '-1'
|
||||
|
||||
rockspec_format = "3.0"
|
||||
package = 'gitsigns.nvim'
|
||||
version = _MODREV .. _SPECREV
|
||||
|
||||
description = {
|
||||
summary = 'Git signs written in pure lua',
|
||||
detailed = [[
|
||||
Super fast git decorations implemented purely in Lua.
|
||||
]],
|
||||
homepage = 'http://github.com/lewis6991/gitsigns.nvim',
|
||||
license = 'MIT/X11',
|
||||
labels = { 'neovim' }
|
||||
}
|
||||
|
||||
dependencies = {
|
||||
'lua == 5.1',
|
||||
}
|
||||
|
||||
source = {
|
||||
url = 'http://github.com/lewis6991/gitsigns.nvim/archive/v' .. _MODREV .. '.zip',
|
||||
dir = 'gitsigns.nvim-' .. _MODREV,
|
||||
}
|
||||
|
||||
if _MODREV == 'scm' then
|
||||
source = {
|
||||
url = 'git://github.com/lewis6991/gitsigns.nvim',
|
||||
}
|
||||
end
|
||||
|
||||
build = {
|
||||
type = 'builtin',
|
||||
copy_directories = {
|
||||
'doc'
|
||||
}
|
||||
}
|
||||
@ -1,49 +0,0 @@
|
||||
rock_manifest = {
|
||||
doc = {
|
||||
["gitsigns.txt"] = "a329a90ab3b49a53ea44d986cbde6885"
|
||||
},
|
||||
["gitsigns.nvim-scm-1.rockspec"] = "a9b165d604ce401cfeea760a9366418d",
|
||||
lua = {
|
||||
gitsigns = {
|
||||
["actions.lua"] = "e1d7610fc1d5fc73cb891b286df0535e",
|
||||
["async.lua"] = "15f310cd469f5bfa46bb1e49e5a1d61c",
|
||||
["attach.lua"] = "097403415eba4dc5da07fdb948647841",
|
||||
["cache.lua"] = "909e8cdc787ca5e6d3ed62782dd5453b",
|
||||
cli = {
|
||||
["argparse.lua"] = "fb6c9ffda01b2090f3c252ecaf00f68a"
|
||||
},
|
||||
["cli.lua"] = "f00c3494d6be1b07c352c51132150586",
|
||||
["config.lua"] = "fa4a0f95747586aab60c9b848a72d9cf",
|
||||
["current_line_blame.lua"] = "bf5426f4569e207646c39f9d47a083af",
|
||||
["debounce.lua"] = "e0c1145a3dc341f46b36b43d814c1202",
|
||||
debug = {
|
||||
["log.lua"] = "897a3bf45d0996b9517fa8c0a2ba1dac"
|
||||
},
|
||||
["debug.lua"] = "ef5c8e3c1c9da306ed7b2eb33e657236",
|
||||
["diff.lua"] = "0c462ae71c77899e81da151dcfdf77eb",
|
||||
["diff_ext.lua"] = "04005195067132403fc336422e05c7d3",
|
||||
["diff_int.lua"] = "df447e56f11906998e81d5b94499e013",
|
||||
["diffthis.lua"] = "eb4ff5d430d2c4081f1fa9651d2768f7",
|
||||
git = {
|
||||
["version.lua"] = "068a582ed4565978eb1f6eb089a6fa6c"
|
||||
},
|
||||
["git.lua"] = "89ec79605c259e73ce8c19deb5b63194",
|
||||
["highlight.lua"] = "1d197d8f0f6f69a6455ac220a6890d80",
|
||||
["hunks.lua"] = "48fc2d8a9c89815e3c0521b1bb0788e9",
|
||||
["manager.lua"] = "af94331f013ed04d175e3c2b2d21c42b",
|
||||
["message.lua"] = "523ee4df9da4a7fa9b5ab2100eb27ac4",
|
||||
["popup.lua"] = "cbc11678e30094bff8ed54f0357e26f9",
|
||||
["repeat.lua"] = "798544de97c774bc8e10eecfd6479585",
|
||||
["signs.lua"] = "4c6533b4a406b049e68f49aee59417f6",
|
||||
["status.lua"] = "a229a7213a3fbecfcf2d98aaf587fcab",
|
||||
system = {
|
||||
["compat.lua"] = "05d2b6d08602fba46be9b540288091e7"
|
||||
},
|
||||
["system.lua"] = "d73fac4f6e734cc8ce9f13d6be027503",
|
||||
["test.lua"] = "082f7c7a556bf27352a378d047b8e79b",
|
||||
["util.lua"] = "e4c4d677e3ad296adee833318a5c5845",
|
||||
["watcher.lua"] = "ffcf36424ae17548bdc629cc2de3fcaa"
|
||||
},
|
||||
["gitsigns.lua"] = "48654d8ca2059edb2b3a0bdd09f871e1"
|
||||
}
|
||||
}
|
||||
@ -1,157 +0,0 @@
|
||||
commands = {}
|
||||
dependencies = {
|
||||
["gitsigns.nvim"] = {
|
||||
["scm-1"] = {
|
||||
{
|
||||
constraints = {
|
||||
{
|
||||
op = "==",
|
||||
version = {
|
||||
5, 1, string = "5.1"
|
||||
}
|
||||
}
|
||||
},
|
||||
name = "lua"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
modules = {
|
||||
gitsigns = {
|
||||
"gitsigns.nvim/scm-1"
|
||||
},
|
||||
["gitsigns.actions"] = {
|
||||
"gitsigns.nvim/scm-1"
|
||||
},
|
||||
["gitsigns.async"] = {
|
||||
"gitsigns.nvim/scm-1"
|
||||
},
|
||||
["gitsigns.attach"] = {
|
||||
"gitsigns.nvim/scm-1"
|
||||
},
|
||||
["gitsigns.cache"] = {
|
||||
"gitsigns.nvim/scm-1"
|
||||
},
|
||||
["gitsigns.cli"] = {
|
||||
"gitsigns.nvim/scm-1"
|
||||
},
|
||||
["gitsigns.cli.argparse"] = {
|
||||
"gitsigns.nvim/scm-1"
|
||||
},
|
||||
["gitsigns.config"] = {
|
||||
"gitsigns.nvim/scm-1"
|
||||
},
|
||||
["gitsigns.current_line_blame"] = {
|
||||
"gitsigns.nvim/scm-1"
|
||||
},
|
||||
["gitsigns.debounce"] = {
|
||||
"gitsigns.nvim/scm-1"
|
||||
},
|
||||
["gitsigns.debug"] = {
|
||||
"gitsigns.nvim/scm-1"
|
||||
},
|
||||
["gitsigns.debug.log"] = {
|
||||
"gitsigns.nvim/scm-1"
|
||||
},
|
||||
["gitsigns.diff"] = {
|
||||
"gitsigns.nvim/scm-1"
|
||||
},
|
||||
["gitsigns.diff_ext"] = {
|
||||
"gitsigns.nvim/scm-1"
|
||||
},
|
||||
["gitsigns.diff_int"] = {
|
||||
"gitsigns.nvim/scm-1"
|
||||
},
|
||||
["gitsigns.diffthis"] = {
|
||||
"gitsigns.nvim/scm-1"
|
||||
},
|
||||
["gitsigns.git"] = {
|
||||
"gitsigns.nvim/scm-1"
|
||||
},
|
||||
["gitsigns.git.version"] = {
|
||||
"gitsigns.nvim/scm-1"
|
||||
},
|
||||
["gitsigns.highlight"] = {
|
||||
"gitsigns.nvim/scm-1"
|
||||
},
|
||||
["gitsigns.hunks"] = {
|
||||
"gitsigns.nvim/scm-1"
|
||||
},
|
||||
["gitsigns.manager"] = {
|
||||
"gitsigns.nvim/scm-1"
|
||||
},
|
||||
["gitsigns.message"] = {
|
||||
"gitsigns.nvim/scm-1"
|
||||
},
|
||||
["gitsigns.popup"] = {
|
||||
"gitsigns.nvim/scm-1"
|
||||
},
|
||||
["gitsigns.repeat"] = {
|
||||
"gitsigns.nvim/scm-1"
|
||||
},
|
||||
["gitsigns.signs"] = {
|
||||
"gitsigns.nvim/scm-1"
|
||||
},
|
||||
["gitsigns.status"] = {
|
||||
"gitsigns.nvim/scm-1"
|
||||
},
|
||||
["gitsigns.system"] = {
|
||||
"gitsigns.nvim/scm-1"
|
||||
},
|
||||
["gitsigns.system.compat"] = {
|
||||
"gitsigns.nvim/scm-1"
|
||||
},
|
||||
["gitsigns.test"] = {
|
||||
"gitsigns.nvim/scm-1"
|
||||
},
|
||||
["gitsigns.util"] = {
|
||||
"gitsigns.nvim/scm-1"
|
||||
},
|
||||
["gitsigns.watcher"] = {
|
||||
"gitsigns.nvim/scm-1"
|
||||
}
|
||||
}
|
||||
repository = {
|
||||
["gitsigns.nvim"] = {
|
||||
["scm-1"] = {
|
||||
{
|
||||
arch = "installed",
|
||||
commands = {},
|
||||
dependencies = {},
|
||||
modules = {
|
||||
gitsigns = "gitsigns.lua",
|
||||
["gitsigns.actions"] = "gitsigns/actions.lua",
|
||||
["gitsigns.async"] = "gitsigns/async.lua",
|
||||
["gitsigns.attach"] = "gitsigns/attach.lua",
|
||||
["gitsigns.cache"] = "gitsigns/cache.lua",
|
||||
["gitsigns.cli"] = "gitsigns/cli.lua",
|
||||
["gitsigns.cli.argparse"] = "gitsigns/cli/argparse.lua",
|
||||
["gitsigns.config"] = "gitsigns/config.lua",
|
||||
["gitsigns.current_line_blame"] = "gitsigns/current_line_blame.lua",
|
||||
["gitsigns.debounce"] = "gitsigns/debounce.lua",
|
||||
["gitsigns.debug"] = "gitsigns/debug.lua",
|
||||
["gitsigns.debug.log"] = "gitsigns/debug/log.lua",
|
||||
["gitsigns.diff"] = "gitsigns/diff.lua",
|
||||
["gitsigns.diff_ext"] = "gitsigns/diff_ext.lua",
|
||||
["gitsigns.diff_int"] = "gitsigns/diff_int.lua",
|
||||
["gitsigns.diffthis"] = "gitsigns/diffthis.lua",
|
||||
["gitsigns.git"] = "gitsigns/git.lua",
|
||||
["gitsigns.git.version"] = "gitsigns/git/version.lua",
|
||||
["gitsigns.highlight"] = "gitsigns/highlight.lua",
|
||||
["gitsigns.hunks"] = "gitsigns/hunks.lua",
|
||||
["gitsigns.manager"] = "gitsigns/manager.lua",
|
||||
["gitsigns.message"] = "gitsigns/message.lua",
|
||||
["gitsigns.popup"] = "gitsigns/popup.lua",
|
||||
["gitsigns.repeat"] = "gitsigns/repeat.lua",
|
||||
["gitsigns.signs"] = "gitsigns/signs.lua",
|
||||
["gitsigns.status"] = "gitsigns/status.lua",
|
||||
["gitsigns.system"] = "gitsigns/system.lua",
|
||||
["gitsigns.system.compat"] = "gitsigns/system/compat.lua",
|
||||
["gitsigns.test"] = "gitsigns/test.lua",
|
||||
["gitsigns.util"] = "gitsigns/util.lua",
|
||||
["gitsigns.watcher"] = "gitsigns/watcher.lua"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -17,6 +17,10 @@ local cwd_watcher ---@type uv.uv_fs_event_t?
|
||||
local function get_gitdir_and_head()
|
||||
local cwd = assert(uv.cwd())
|
||||
|
||||
-- Run on the main loop to avoid:
|
||||
-- https://github.com/LazyVim/LazyVim/discussions/3407#discussioncomment-9622211
|
||||
async.scheduler()
|
||||
|
||||
-- Look in the cache first
|
||||
for _, bcache in pairs(require('gitsigns.cache').cache) do
|
||||
local repo = bcache.git_obj.repo
|
||||
@ -65,6 +69,11 @@ local update_cwd_head = async.create(function()
|
||||
|
||||
if cwd_watcher then
|
||||
cwd_watcher:stop()
|
||||
-- TODO(lewis6991): (#1027) Running `fs_event:stop()` -> `fs_event:start()`
|
||||
-- in the same loop event, on Windows, causes Nvim to hang on quit.
|
||||
if vim.fn.has('win32') then
|
||||
async.scheduler()
|
||||
end
|
||||
else
|
||||
cwd_watcher = assert(uv.new_fs_event())
|
||||
end
|
||||
@ -129,8 +138,10 @@ local function setup_attach()
|
||||
|
||||
local attach_autocmd_disabled = false
|
||||
|
||||
api.nvim_create_autocmd({ 'BufRead', 'BufNewFile', 'BufWritePost' }, {
|
||||
-- Need to attach in 'BufFilePost' since we always detach in 'BufFilePre'
|
||||
api.nvim_create_autocmd({ 'BufFilePost', 'BufRead', 'BufNewFile', 'BufWritePost' }, {
|
||||
group = 'gitsigns',
|
||||
desc = 'Gitsigns: attach',
|
||||
callback = function(args)
|
||||
local bufnr = args.buf --[[@as integer]]
|
||||
if attach_autocmd_disabled then
|
||||
@ -142,11 +153,21 @@ local function setup_attach()
|
||||
end,
|
||||
})
|
||||
|
||||
-- If the buffer name is about to change, then detach
|
||||
api.nvim_create_autocmd('BufFilePre', {
|
||||
group = 'gitsigns',
|
||||
desc = 'Gitsigns: detach when changing buffer names',
|
||||
callback = function(args)
|
||||
require('gitsigns.attach').detach(args.buf)
|
||||
end,
|
||||
})
|
||||
|
||||
--- vimpgrep creates and deletes lots of buffers so attaching to each one will
|
||||
--- waste lots of resource and even slow down vimgrep.
|
||||
--- waste lots of resource and slow down vimgrep.
|
||||
api.nvim_create_autocmd({ 'QuickFixCmdPre', 'QuickFixCmdPost' }, {
|
||||
group = 'gitsigns',
|
||||
pattern = '*vimgrep*',
|
||||
desc = 'Gitsigns: disable attach during vimgrep',
|
||||
callback = function(args)
|
||||
attach_autocmd_disabled = args.event == 'QuickFixCmdPre'
|
||||
end,
|
||||
|
||||
@ -215,10 +215,10 @@ local function get_hunks(bufnr, bcache, greedy, staged)
|
||||
end
|
||||
|
||||
if staged then
|
||||
return bcache.hunks_staged
|
||||
return vim.deepcopy(bcache.hunks_staged)
|
||||
end
|
||||
|
||||
return bcache.hunks
|
||||
return vim.deepcopy(bcache.hunks)
|
||||
end
|
||||
|
||||
--- @param bufnr integer
|
||||
@ -478,6 +478,7 @@ end)
|
||||
--- @field greedy boolean
|
||||
--- @field preview boolean
|
||||
--- @field count integer
|
||||
--- @field target 'unstaged'|'staged'|'all'
|
||||
|
||||
--- @param x string
|
||||
--- @param word string
|
||||
@ -513,6 +514,10 @@ local function process_nav_opts(opts)
|
||||
opts.count = vim.v.count1
|
||||
end
|
||||
|
||||
if opts.target == nil then
|
||||
opts.target = 'unstaged'
|
||||
end
|
||||
|
||||
return opts
|
||||
end
|
||||
|
||||
@ -532,6 +537,30 @@ local function has_preview_inline(bufnr)
|
||||
return #api.nvim_buf_get_extmarks(bufnr, ns_inline, 0, -1, { limit = 1 }) > 0
|
||||
end
|
||||
|
||||
--- @param bufnr integer
|
||||
--- @param target 'unstaged'|'staged'|'all'
|
||||
--- @param greedy boolean
|
||||
--- @return Gitsigns.Hunk.Hunk[]
|
||||
local function get_nav_hunks(bufnr, target, greedy)
|
||||
local bcache = assert(cache[bufnr])
|
||||
local hunks_main = get_hunks(bufnr, bcache, greedy, false) or {}
|
||||
|
||||
local hunks --- @type Gitsigns.Hunk.Hunk[]
|
||||
if target == 'unstaged' then
|
||||
hunks = hunks_main
|
||||
else
|
||||
local hunks_head = get_hunks(bufnr, bcache, greedy, true) or {}
|
||||
hunks_head = Hunks.filter_common(hunks_head, hunks_main) or {}
|
||||
if target == 'all' then
|
||||
hunks = hunks_main
|
||||
vim.list_extend(hunks, hunks_head)
|
||||
elseif target == 'staged' then
|
||||
hunks = hunks_head
|
||||
end
|
||||
end
|
||||
return hunks
|
||||
end
|
||||
|
||||
--- @async
|
||||
--- @param direction 'first'|'last'|'next'|'prev'
|
||||
--- @param opts? Gitsigns.NavOpts
|
||||
@ -543,9 +572,7 @@ local function nav_hunk(direction, opts)
|
||||
return
|
||||
end
|
||||
|
||||
local hunks = get_hunks(bufnr, bcache, opts.greedy, false) or {}
|
||||
local hunks_head = get_hunks(bufnr, bcache, opts.greedy, true) or {}
|
||||
vim.list_extend(hunks, Hunks.filter_common(hunks_head, hunks) or {})
|
||||
local hunks = get_nav_hunks(bufnr, opts.target, opts.greedy)
|
||||
|
||||
if not hunks or vim.tbl_isempty(hunks) then
|
||||
if opts.navigation_message then
|
||||
@ -629,6 +656,8 @@ end
|
||||
--- • {greedy}: (boolean)
|
||||
--- Only navigate between non-contiguous hunks. Only useful if
|
||||
--- 'diff_opts' contains `linematch`. Defaults to `true`.
|
||||
--- • {target}: (`'unstaged'|'staged'|'all'`)
|
||||
--- Which kinds of hunks to target. Defaults to `'unstaged'`.
|
||||
--- • {count}: (integer)
|
||||
--- Number of times to advance. Defaults to |v:count1|.
|
||||
M.nav_hunk = async.create(2, function(direction, opts)
|
||||
@ -1023,6 +1052,19 @@ C.blame_line = function(args, _)
|
||||
M.blame_line(args)
|
||||
end
|
||||
|
||||
--- Run git-blame on the current file and open the results
|
||||
--- in a scroll-bound vertical split.
|
||||
---
|
||||
--- <CR> is mapped to open a menu with the actions:
|
||||
--- - [Show commit] in a vertical split.
|
||||
--- - [Reblame at commit]
|
||||
---
|
||||
--- Attributes: ~
|
||||
--- {async}
|
||||
M.blame = async.create(0, function()
|
||||
return require('gitsigns.blame').blame()
|
||||
end)
|
||||
|
||||
--- @param bcache Gitsigns.CacheEntry
|
||||
--- @param base string?
|
||||
local function update_buf_base(bcache, base)
|
||||
@ -1191,14 +1233,14 @@ CP.diffthis = complete_heads
|
||||
---
|
||||
--- Attributes: ~
|
||||
--- {async}
|
||||
M.show = function(revision)
|
||||
M.show = function(revision, callback)
|
||||
local bufnr = api.nvim_get_current_buf()
|
||||
if not cache[bufnr] then
|
||||
print('Error: Buffer is not attached.')
|
||||
return
|
||||
end
|
||||
local diffthis = require('gitsigns.diffthis')
|
||||
diffthis.show(bufnr, revision)
|
||||
diffthis.show(bufnr, revision, callback)
|
||||
end
|
||||
|
||||
CP.show = complete_heads
|
||||
|
||||
@ -138,15 +138,16 @@ end
|
||||
|
||||
--- @param _bufnr integer
|
||||
--- @param file string
|
||||
--- @param revision string?
|
||||
--- @param encoding string
|
||||
--- @return Gitsigns.GitObj?
|
||||
local function try_worktrees(_bufnr, file, encoding)
|
||||
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, encoding, wt.gitdir, wt.toplevel)
|
||||
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
|
||||
@ -211,13 +212,12 @@ local function get_buf_context(bufnr)
|
||||
file = file,
|
||||
gitdir = gitdir,
|
||||
toplevel = toplevel,
|
||||
-- Commit buffers have there base set back one revision with '^'
|
||||
-- Stage buffers always compare against the common ancestor (':1')
|
||||
-- :0: index
|
||||
-- :1: common ancestor
|
||||
-- :2: target commit (HEAD)
|
||||
-- :3: commit which is being merged
|
||||
base = commit and (commit:match('^:[1-3]') and ':1' or commit .. '^') or nil,
|
||||
base = commit and (commit:match('^:[1-3]') and ':1' or commit) or nil,
|
||||
}
|
||||
end
|
||||
|
||||
@ -273,7 +273,7 @@ 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, encoding)
|
||||
git_obj = try_worktrees(cbuf, file, revision, encoding)
|
||||
async.scheduler()
|
||||
if not api.nvim_buf_is_valid(cbuf) then
|
||||
return
|
||||
|
||||
@ -67,15 +67,15 @@ end
|
||||
-- at a time.
|
||||
local BLAME_THRESHOLD_LEN = 1000000
|
||||
|
||||
--- @private
|
||||
--- @param lnum integer
|
||||
--- @async
|
||||
--- @param lnum? integer
|
||||
--- @param opts Gitsigns.BlameOpts
|
||||
--- @return table<integer,Gitsigns.BlameInfo?>?
|
||||
function CacheEntry:run_blame(lnum, opts)
|
||||
local bufnr = self.bufnr
|
||||
local blame_cache --- @type table<integer,Gitsigns.BlameInfo?>?
|
||||
repeat
|
||||
local buftext = util.buf_lines(bufnr)
|
||||
local buftext = util.buf_lines(bufnr, true)
|
||||
local tick = vim.b[bufnr].changedtick
|
||||
local lnum0 = #buftext > BLAME_THRESHOLD_LEN and lnum or nil
|
||||
-- TODO(lewis6991): Cancel blame on changedtick
|
||||
@ -97,7 +97,7 @@ local function get_blame_nc(file, lnum)
|
||||
return {
|
||||
orig_lnum = 0,
|
||||
final_lnum = lnum,
|
||||
commit = Git.not_commited(file),
|
||||
commit = Git.not_committed(file),
|
||||
filename = file,
|
||||
}
|
||||
end
|
||||
|
||||
@ -1,21 +1,10 @@
|
||||
--- @class (exact) Gitsigns.SchemaElem.Deprecated
|
||||
---
|
||||
--- Used for renaming fields.
|
||||
--- @field new_field? string
|
||||
---
|
||||
--- Documentation for deprecation. Will be added to the help file and used in
|
||||
--- the notification if `hard = true`.
|
||||
--- @field message? string
|
||||
---
|
||||
--- Emit a message via vim.notify
|
||||
--- @field hard? boolean
|
||||
|
||||
--- @class (exact) Gitsigns.SchemaElem
|
||||
--- @field type string|string[]
|
||||
--- @field type string|string[]|fun(x:any): boolean
|
||||
--- @field type_help? string
|
||||
--- @field refresh? fun(cb: fun()) Function to refresh the config value
|
||||
--- @field deep_extend? boolean
|
||||
--- @field default any
|
||||
--- @field deprecated? boolean|Gitsigns.SchemaElem.Deprecated
|
||||
--- @field deprecated? boolean
|
||||
--- @field default_help? string
|
||||
--- @field description string
|
||||
|
||||
@ -45,10 +34,7 @@
|
||||
--- | 'changedelete'
|
||||
--- | 'untracked'
|
||||
|
||||
--- @class (exact) Gitsigns.CurrentLineBlameFmtOpts
|
||||
--- @field relative_time boolean
|
||||
|
||||
--- @alias Gitsigns.CurrentLineBlameFmtFun fun(user: string, info: table<string,any>, opts: Gitsigns.CurrentLineBlameFmtOpts): {[1]:string,[2]:string}[]
|
||||
--- @alias Gitsigns.CurrentLineBlameFmtFun fun(user: string, info: table<string,any>): {[1]:string,[2]:string}[]
|
||||
|
||||
--- @class (exact) Gitsigns.CurrentLineBlameOpts : Gitsigns.BlameOpts
|
||||
--- @field virt_text? boolean
|
||||
@ -69,8 +55,8 @@
|
||||
--- @field diff_opts Gitsigns.DiffOpts
|
||||
--- @field base? string
|
||||
--- @field signs table<Gitsigns.SignType,Gitsigns.SignConfig>
|
||||
--- @field _signs_staged table<Gitsigns.SignType,Gitsigns.SignConfig>
|
||||
--- @field _signs_staged_enable boolean
|
||||
--- @field signs_staged table<Gitsigns.SignType,Gitsigns.SignConfig>
|
||||
--- @field signs_staged_enable boolean
|
||||
--- @field count_chars table<string|integer,string>
|
||||
--- @field signcolumn boolean
|
||||
--- @field numhl boolean
|
||||
@ -84,14 +70,12 @@
|
||||
--- @field update_debounce integer
|
||||
--- @field status_formatter fun(_: table<string,any>): string
|
||||
--- @field current_line_blame boolean
|
||||
--- @field current_line_blame_formatter_opts { relative_time: boolean }
|
||||
--- @field current_line_blame_formatter string|Gitsigns.CurrentLineBlameFmtFun
|
||||
--- @field current_line_blame_formatter_nc string|Gitsigns.CurrentLineBlameFmtFun
|
||||
--- @field current_line_blame_opts Gitsigns.CurrentLineBlameOpts
|
||||
--- @field preview_config table<string,any>
|
||||
--- @field auto_attach boolean
|
||||
--- @field attach_to_untracked boolean
|
||||
--- @field yadm { enable: boolean }
|
||||
--- @field worktrees {toplevel: string, gitdir: string}[]
|
||||
--- @field word_diff boolean
|
||||
--- @field trouble boolean
|
||||
@ -108,9 +92,7 @@ local M = {
|
||||
DiffOpts = {},
|
||||
SignConfig = {},
|
||||
watch_gitdir = {},
|
||||
current_line_blame_formatter_opts = {},
|
||||
current_line_blame_opts = {},
|
||||
yadm = {},
|
||||
Worktree = {},
|
||||
},
|
||||
}
|
||||
@ -182,10 +164,50 @@ M.config = setmetatable({}, {
|
||||
end,
|
||||
})
|
||||
|
||||
local function warn(s, ...)
|
||||
vim.notify_once(s:format(...), vim.log.levels.WARN, { title = 'gitsigns' })
|
||||
end
|
||||
|
||||
--- @param x Gitsigns.SignConfig
|
||||
--- @return boolean
|
||||
local function validate_signs(x)
|
||||
if type(x) ~= 'table' then
|
||||
return false
|
||||
end
|
||||
|
||||
local warnings --- @type table<string,true>?
|
||||
|
||||
--- @diagnostic disable-next-line:no-unknown
|
||||
for kind, s in pairs(M.schema.signs.default) do
|
||||
--- @diagnostic disable-next-line:no-unknown
|
||||
for ty, v in pairs(s) do
|
||||
if x[kind] and x[kind][ty] and vim.endswith(ty, 'hl') then
|
||||
warnings = warnings or {}
|
||||
local w = string.format(
|
||||
"'signs.%s.%s' is now deprecated, please define highlight '%s'",
|
||||
kind,
|
||||
ty,
|
||||
v
|
||||
)
|
||||
warnings[w] = true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if warnings then
|
||||
for w in vim.spairs(warnings) do
|
||||
warn(w)
|
||||
end
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
--- @type table<string,Gitsigns.SchemaElem>
|
||||
M.schema = {
|
||||
signs = {
|
||||
type = 'table',
|
||||
type_help = 'table',
|
||||
type = validate_signs,
|
||||
deep_extend = true,
|
||||
default = {
|
||||
add = { hl = 'GitSignsAdd', text = '┃', numhl = 'GitSignsAddNr', linehl = 'GitSignsAddLn' },
|
||||
@ -244,7 +266,7 @@ M.schema = {
|
||||
]],
|
||||
},
|
||||
|
||||
_signs_staged = {
|
||||
signs_staged = {
|
||||
type = 'table',
|
||||
deep_extend = true,
|
||||
default = {
|
||||
@ -293,9 +315,9 @@ M.schema = {
|
||||
]],
|
||||
},
|
||||
|
||||
_signs_staged_enable = {
|
||||
signs_staged_enable = {
|
||||
type = 'boolean',
|
||||
default = false,
|
||||
default = true,
|
||||
description = [[
|
||||
Show signs for staged hunks.
|
||||
|
||||
@ -649,24 +671,9 @@ M.schema = {
|
||||
]],
|
||||
},
|
||||
|
||||
current_line_blame_formatter_opts = {
|
||||
type = 'table',
|
||||
deep_extend = true,
|
||||
deprecated = true,
|
||||
default = {
|
||||
relative_time = false,
|
||||
},
|
||||
description = [[
|
||||
Options for the current line blame annotation formatter.
|
||||
|
||||
Fields: ~
|
||||
• relative_time: boolean
|
||||
]],
|
||||
},
|
||||
|
||||
current_line_blame_formatter = {
|
||||
type = { 'string', 'function' },
|
||||
default = ' <author>, <author_time> - <summary> ',
|
||||
default = ' <author>, <author_time:%R> - <summary> ',
|
||||
description = [[
|
||||
String or function used to format the virtual text of
|
||||
|gitsigns-config-current_line_blame|.
|
||||
@ -735,9 +742,6 @@ M.schema = {
|
||||
Note that the keys map onto the output of:
|
||||
`git blame --line-porcelain`
|
||||
|
||||
{opts} Passed directly from
|
||||
|gitsigns-config-current_line_blame_formatter_opts|.
|
||||
|
||||
Return: ~
|
||||
The result of this function is passed directly to the `opts.virt_text`
|
||||
field of |nvim_buf_set_extmark| and thus must be a list of
|
||||
@ -769,17 +773,6 @@ M.schema = {
|
||||
]],
|
||||
},
|
||||
|
||||
yadm = {
|
||||
type = 'table',
|
||||
deprecated = {
|
||||
message = 'Please use |gitsigns-config-on_attach_pre| instead',
|
||||
},
|
||||
default = { enable = false },
|
||||
description = [[
|
||||
yadm configuration.
|
||||
]],
|
||||
},
|
||||
|
||||
_git_version = {
|
||||
type = 'string',
|
||||
default = 'auto',
|
||||
@ -861,22 +854,18 @@ M.schema = {
|
||||
},
|
||||
}
|
||||
|
||||
local function warn(s, ...)
|
||||
vim.notify(s:format(...), vim.log.levels.WARN, { title = 'gitsigns' })
|
||||
end
|
||||
|
||||
--- @param config Gitsigns.Config
|
||||
local function validate_config(config)
|
||||
--- @diagnostic disable-next-line:no-unknown
|
||||
for k, v in pairs(config) do
|
||||
for k, v in
|
||||
pairs(config --[[@as table<string,any>]])
|
||||
do
|
||||
local kschema = M.schema[k]
|
||||
if kschema == nil then
|
||||
warn("gitsigns: Ignoring invalid configuration field '%s'", k)
|
||||
elseif kschema.type then
|
||||
if type(kschema.type) == 'string' then
|
||||
vim.validate({
|
||||
[k] = { v, kschema.type },
|
||||
})
|
||||
else
|
||||
local ty = kschema.type
|
||||
if type(ty) == 'string' or type(ty) == 'function' then
|
||||
vim.validate({ [k] = { v, ty } })
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -888,28 +877,15 @@ local function handle_deprecated(cfg)
|
||||
local dep = v.deprecated
|
||||
if dep and cfg[k] ~= nil then
|
||||
if type(dep) == 'table' then
|
||||
if dep.new_field then
|
||||
local opts_key, field = dep.new_field:match('(.*)%.(.*)')
|
||||
if opts_key and field then
|
||||
-- Field moved to an options table
|
||||
local opts = (cfg[opts_key] or {}) --[[@as table<any,any>]]
|
||||
opts[field] = cfg[k]
|
||||
cfg[opts_key] = opts
|
||||
else
|
||||
-- Field renamed
|
||||
cfg[dep.new_field] = cfg[k]
|
||||
end
|
||||
end
|
||||
|
||||
if dep.hard then
|
||||
if dep.message then
|
||||
warn(dep.message)
|
||||
elseif dep.new_field then
|
||||
warn('%s is now deprecated, please use %s', k, dep.new_field)
|
||||
else
|
||||
warn('%s is now deprecated; ignoring', k)
|
||||
end
|
||||
end
|
||||
else
|
||||
warn('%s is now deprecated; ignoring', k)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -28,7 +28,7 @@ local function expand_blame_format(fmt, name, info)
|
||||
if info.author == name then
|
||||
info.author = 'You'
|
||||
end
|
||||
return util.expand_format(fmt, info, config.current_line_blame_formatter_opts.relative_time)
|
||||
return util.expand_format(fmt, info)
|
||||
end
|
||||
|
||||
--- @param virt_text {[1]: string, [2]: string}[]
|
||||
@ -41,7 +41,6 @@ local function flatten_virt_text(virt_text)
|
||||
return table.concat(res)
|
||||
end
|
||||
|
||||
--- @param winid integer
|
||||
--- @return integer
|
||||
local function win_width()
|
||||
local winid = api.nvim_get_current_win()
|
||||
@ -61,7 +60,7 @@ end
|
||||
--- @param fmt string
|
||||
--- @return Gitsigns.CurrentLineBlameFmtFun
|
||||
local function default_formatter(fmt)
|
||||
return function(username, blame_info, _opts)
|
||||
return function(username, blame_info)
|
||||
return {
|
||||
{
|
||||
expand_blame_format(fmt, username, blame_info),
|
||||
@ -85,7 +84,7 @@ local function get_blame_virt_text(bufnr, blame_info)
|
||||
clb_formatter = default_formatter(clb_formatter)
|
||||
end
|
||||
|
||||
return clb_formatter(git_obj.repo.username, blame_info, config.current_line_blame_formatter_opts)
|
||||
return clb_formatter(git_obj.repo.username, blame_info)
|
||||
end
|
||||
|
||||
--- @param bufnr integer
|
||||
|
||||
@ -43,20 +43,7 @@ function M.dump_cache()
|
||||
vim.api.nvim_echo({ { text } }, false, {})
|
||||
end
|
||||
|
||||
--- @param noecho boolean
|
||||
--- @return string[]?
|
||||
function M.debug_messages(noecho)
|
||||
if noecho then
|
||||
return log.messages
|
||||
else
|
||||
for _, m in ipairs(log.messages) do
|
||||
vim.api.nvim_echo({ { m } }, false, {})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function M.clear_debug()
|
||||
log.messages = {}
|
||||
end
|
||||
M.debug_messages = log.show
|
||||
M.clear_debug = log.clear
|
||||
|
||||
return M
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
local start_time = vim.loop.hrtime()
|
||||
|
||||
local M = {
|
||||
debug_mode = false,
|
||||
verbose = false,
|
||||
messages = {}, --- @type string[]
|
||||
messages = {} --- @type [number, string, string, string][]
|
||||
}
|
||||
|
||||
--- @param name string
|
||||
@ -44,7 +46,6 @@ local function getvarvalue(name, lvl)
|
||||
end
|
||||
|
||||
-- not found; get global
|
||||
--- @diagnostic disable-next-line:deprecated
|
||||
return getfenv(func)[name]
|
||||
end
|
||||
|
||||
@ -52,71 +53,72 @@ end
|
||||
--- @return {name:string, bufnr: integer}
|
||||
local function get_context(lvl)
|
||||
lvl = lvl + 1
|
||||
local ret = {} --- @type {name:string, bufnr: integer}
|
||||
ret.name = getvarvalue('__FUNC__', lvl)
|
||||
if not ret.name then
|
||||
|
||||
local name = getvarvalue('__FUNC__', lvl)
|
||||
if not name then
|
||||
local name0 = debug.getinfo(lvl, 'n').name or ''
|
||||
ret.name = name0:gsub('(.*)%d+$', '%1')
|
||||
name = name0:gsub('(.*)%d+$', '%1')
|
||||
end
|
||||
ret.bufnr = getvarvalue('bufnr', lvl)
|
||||
|
||||
local bufnr = getvarvalue('bufnr', lvl)
|
||||
or getvarvalue('_bufnr', lvl)
|
||||
or getvarvalue('cbuf', lvl)
|
||||
or getvarvalue('buf', lvl)
|
||||
|
||||
return ret
|
||||
return {name=name, bufnr=bufnr}
|
||||
end
|
||||
|
||||
-- If called in a callback then make sure the callback defines a __FUNC__
|
||||
-- variable which can be used to identify the name of the function.
|
||||
--- @param kind string
|
||||
--- @param obj any
|
||||
--- @param lvl integer
|
||||
local function cprint(obj, lvl)
|
||||
local function cprint(kind, obj, lvl)
|
||||
lvl = lvl + 1
|
||||
--- @type string
|
||||
local msg = type(obj) == 'string' and obj or vim.inspect(obj)
|
||||
local ctx = get_context(lvl)
|
||||
local msg2 --- @type string
|
||||
local time = (vim.loop.hrtime() - start_time) / 1e6
|
||||
local ctx1 = ctx.name
|
||||
if ctx.bufnr then
|
||||
msg2 = string.format('%s(%s): %s', ctx.name, ctx.bufnr, msg)
|
||||
else
|
||||
msg2 = string.format('%s: %s', ctx.name, msg)
|
||||
ctx1 = string.format('%s(%s)', ctx1, ctx.bufnr)
|
||||
end
|
||||
table.insert(M.messages, msg2)
|
||||
table.insert(M.messages, {time, kind, ctx1, msg})
|
||||
end
|
||||
|
||||
function M.dprint(obj)
|
||||
if not M.debug_mode then
|
||||
return
|
||||
end
|
||||
cprint(obj, 2)
|
||||
cprint('debug', obj, 2)
|
||||
end
|
||||
|
||||
function M.dprintf(obj, ...)
|
||||
if not M.debug_mode then
|
||||
return
|
||||
end
|
||||
cprint(obj:format(...), 2)
|
||||
cprint('debug', obj:format(...), 2)
|
||||
end
|
||||
|
||||
function M.vprint(obj)
|
||||
if not (M.debug_mode and M.verbose) then
|
||||
return
|
||||
end
|
||||
cprint(obj, 2)
|
||||
cprint('info', obj, 2)
|
||||
end
|
||||
|
||||
function M.vprintf(obj, ...)
|
||||
if not (M.debug_mode and M.verbose) then
|
||||
return
|
||||
end
|
||||
cprint(obj:format(...), 2)
|
||||
cprint('info', obj:format(...), 2)
|
||||
end
|
||||
|
||||
local function eprint(msg, level)
|
||||
local info = debug.getinfo(level + 2, 'Sl')
|
||||
if info then
|
||||
msg = string.format('(ERROR) %s(%d): %s', info.short_src, info.currentline, msg)
|
||||
end
|
||||
M.messages[#M.messages + 1] = debug.traceback(msg)
|
||||
local ctx = info and string.format('%s<%d>', info.short_src, info.currentline) or '???'
|
||||
local time = (vim.loop.hrtime() - start_time) / 1e6
|
||||
table.insert(M.messages, { time, 'error', ctx, debug.traceback(msg) })
|
||||
if M.debug_mode then
|
||||
error(msg, 3)
|
||||
end
|
||||
@ -141,4 +143,49 @@ function M.assert(cond, msg)
|
||||
return not cond
|
||||
end
|
||||
|
||||
local sev_to_hl = {
|
||||
debug = 'Title',
|
||||
info = 'MoreMsg',
|
||||
warn = 'WarningMsg',
|
||||
error = 'ErrorMsg',
|
||||
}
|
||||
|
||||
function M.clear()
|
||||
M.messages = {}
|
||||
end
|
||||
|
||||
--- @param m [number, string, string, string]
|
||||
--- @return [string,string][]
|
||||
local function build_msg(m)
|
||||
local time, kind, ctx, msg = m[1], m[2], m[3], m[4]
|
||||
local hl = sev_to_hl[kind]
|
||||
return {
|
||||
{ string.format('%.2f ', time), 'Comment' },
|
||||
{ kind:upper():sub(1,1), hl },
|
||||
{ string.format(' %s:', ctx), 'Tag'},
|
||||
{ ' ' },
|
||||
{ msg }
|
||||
}
|
||||
end
|
||||
|
||||
function M.show()
|
||||
for _, m in ipairs(M.messages) do
|
||||
vim.api.nvim_echo(build_msg(m), false, {})
|
||||
end
|
||||
end
|
||||
|
||||
--- @return string[]?
|
||||
function M.get()
|
||||
local r = {} --- @type string[]
|
||||
for _, m in ipairs(M.messages) do
|
||||
local e = build_msg(m)
|
||||
local e1 = {} --- @type string[]
|
||||
for _, x in ipairs(e) do
|
||||
e1[#e1+1] = x[1]
|
||||
end
|
||||
r[#r+1] = table.concat(e1)
|
||||
end
|
||||
return r
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
@ -7,6 +7,7 @@ local manager = require('gitsigns.manager')
|
||||
local message = require('gitsigns.message')
|
||||
local Status = require('gitsigns.status')
|
||||
|
||||
local dprint = require('gitsigns.debug.log').dprint
|
||||
local throttle_by_id = require('gitsigns.debounce').throttle_by_id
|
||||
|
||||
local M = {}
|
||||
@ -176,11 +177,14 @@ end)
|
||||
--- @param bufnr integer
|
||||
--- @param base string
|
||||
M.show = async.create(2, function(bufnr, base)
|
||||
__FUNC__ = 'show'
|
||||
local bufname = create_show_buf(bufnr, base)
|
||||
if not bufname then
|
||||
dprint('No bufname for revision ' .. base)
|
||||
return
|
||||
end
|
||||
|
||||
dprint('bufname ' .. bufname)
|
||||
vim.cmd.edit(bufname)
|
||||
end)
|
||||
|
||||
|
||||
@ -327,35 +327,6 @@ function Repo:update_abbrev_head()
|
||||
self.abbrev_head = M.get_repo_info(self.toplevel).abbrev_head
|
||||
end
|
||||
|
||||
--- @private
|
||||
--- @param dir string
|
||||
--- @param gitdir? string
|
||||
--- @param toplevel? string
|
||||
function Repo:try_yadm(dir, gitdir, toplevel)
|
||||
if not config.yadm.enable or self.gitdir then
|
||||
return
|
||||
end
|
||||
|
||||
local home = os.getenv('HOME')
|
||||
|
||||
if not home or not vim.startswith(dir, home) then
|
||||
return
|
||||
end
|
||||
|
||||
if #git_command({ 'ls-files', dir }, { command = 'yadm' }) == 0 then
|
||||
return
|
||||
end
|
||||
|
||||
M.get_repo_info(dir, 'yadm', gitdir, toplevel)
|
||||
local yadm_info = M.get_repo_info(dir, 'yadm', gitdir, toplevel)
|
||||
for k, v in
|
||||
pairs(yadm_info --[[@as table<string,any>]])
|
||||
do
|
||||
---@diagnostic disable-next-line:no-unknown
|
||||
self[k] = v
|
||||
end
|
||||
end
|
||||
|
||||
--- @async
|
||||
--- @param dir string
|
||||
--- @param gitdir? string
|
||||
@ -373,8 +344,6 @@ function Repo.new(dir, gitdir, toplevel)
|
||||
self[k] = v
|
||||
end
|
||||
|
||||
self:try_yadm(dir, gitdir, toplevel)
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
@ -424,11 +393,15 @@ end
|
||||
--- @field object_name? string
|
||||
--- @field has_conflicts? true
|
||||
|
||||
function Obj:from_tree()
|
||||
return self.revision and not vim.startswith(self.revision, ':')
|
||||
end
|
||||
|
||||
--- @param file? string
|
||||
--- @param silent? boolean
|
||||
--- @return Gitsigns.FileInfo
|
||||
function Obj:file_info(file, silent)
|
||||
if self.revision and not vim.startswith(self.revision, ':') then
|
||||
if self:from_tree() then
|
||||
return self:file_info_tree(file, silent)
|
||||
else
|
||||
return self:file_info_index(file, silent)
|
||||
@ -436,12 +409,16 @@ function Obj:file_info(file, silent)
|
||||
end
|
||||
|
||||
--- @private
|
||||
--- Get information about files in the index and the working tree
|
||||
--- @param file? string
|
||||
--- @param silent? boolean
|
||||
--- @return Gitsigns.FileInfo
|
||||
function Obj:file_info_index(file, silent)
|
||||
local has_eol = check_version({ 2, 9 })
|
||||
|
||||
-- --others + --exclude-standard means ignored files won't return info, but
|
||||
-- untracked files will. Unlike file_info_tree which won't return untracked
|
||||
-- files.
|
||||
local cmd = {
|
||||
'-c',
|
||||
'core.quotepath=off',
|
||||
@ -499,6 +476,7 @@ function Obj:file_info_index(file, silent)
|
||||
end
|
||||
|
||||
--- @private
|
||||
--- Get information about files in a certain revision
|
||||
--- @param file? string
|
||||
--- @param silent? boolean
|
||||
--- @return Gitsigns.FileInfo
|
||||
@ -615,7 +593,7 @@ local NOT_COMMITTED = {
|
||||
|
||||
--- @param file string
|
||||
--- @return Gitsigns.CommitInfo
|
||||
function M.not_commited(file)
|
||||
function M.not_committed(file)
|
||||
local time = os.time()
|
||||
return {
|
||||
sha = string.rep('0', 40),
|
||||
@ -649,7 +627,7 @@ function Obj:run_blame(lines, lnum, opts)
|
||||
-- As we support attaching to untracked files we need to return something if
|
||||
-- the file isn't isn't tracked in git.
|
||||
-- If abbrev_head is empty, then assume the repo has no commits
|
||||
local commit = M.not_commited(self.file)
|
||||
local commit = M.not_committed(self.file)
|
||||
for i in ipairs(lines) do
|
||||
ret[i] = {
|
||||
orig_lnum = 0,
|
||||
|
||||
@ -283,7 +283,8 @@ local function cmul(x, factor)
|
||||
end
|
||||
|
||||
local function dprintf(fmt, ...)
|
||||
require('gitsigns.debug.log').dprintf(fmt, ...)
|
||||
dprintf = require('gitsigns.debug.log').dprintf
|
||||
dprintf(fmt, ...)
|
||||
end
|
||||
|
||||
--- @param hl string
|
||||
|
||||
@ -432,7 +432,6 @@ function M.filter_common(a, b)
|
||||
end
|
||||
|
||||
a, b = a or {}, b or {}
|
||||
local max_iter = math.max(#a, #b)
|
||||
|
||||
local a_i = 1
|
||||
local b_i = 1
|
||||
@ -440,7 +439,9 @@ function M.filter_common(a, b)
|
||||
--- @type Gitsigns.Hunk.Hunk[]
|
||||
local ret = {}
|
||||
|
||||
for _ = 1, max_iter do
|
||||
-- Need an offset of 1 in order to process when we hit the end of either
|
||||
-- a or b
|
||||
for _ = 1, math.max(#a, #b) + 1 do
|
||||
local a_h, b_h = a[a_i], b[b_i]
|
||||
|
||||
if not a_h then
|
||||
|
||||
@ -488,9 +488,10 @@ M.update = throttle_by_id(function(bufnr)
|
||||
return
|
||||
end
|
||||
|
||||
if config._signs_staged_enable and not file_mode and not git_obj.revision then
|
||||
if config.signs_staged_enable and not file_mode then
|
||||
if not bcache.compare_text_head or config._refresh_staged_on_update then
|
||||
bcache.compare_text_head = git_obj:get_show_text('HEAD')
|
||||
local staged_rev = git_obj:from_tree() and git_obj.revision .. '^' or 'HEAD'
|
||||
bcache.compare_text_head = git_obj:get_show_text(staged_rev)
|
||||
if not M.schedule(bufnr, true) then
|
||||
return
|
||||
end
|
||||
@ -581,8 +582,8 @@ function M.setup()
|
||||
})
|
||||
|
||||
signs_normal = Signs.new(config.signs)
|
||||
if config._signs_staged_enable then
|
||||
signs_staged = Signs.new(config._signs_staged, 'staged')
|
||||
if config.signs_staged_enable then
|
||||
signs_staged = Signs.new(config.signs_staged, 'staged')
|
||||
end
|
||||
|
||||
M.update_debounced = debounce_trailing(config.update_debounce, async.create(1, M.update))
|
||||
|
||||
@ -126,7 +126,7 @@ function M.new(cfg, name)
|
||||
|
||||
local self = setmetatable({}, { __index = M })
|
||||
self.config = cfg
|
||||
self.hls = name == 'staged' and config._signs_staged or config.signs
|
||||
self.hls = name == 'staged' and config.signs_staged or config.signs
|
||||
self.group = 'gitsigns_signs_' .. (name or '')
|
||||
self.ns = api.nvim_create_namespace(self.group)
|
||||
return self
|
||||
|
||||
@ -71,8 +71,9 @@ local function add_bom(x, encoding)
|
||||
end
|
||||
|
||||
--- @param bufnr integer
|
||||
--- @param noendofline? boolean
|
||||
--- @return string[]
|
||||
function M.buf_lines(bufnr)
|
||||
function M.buf_lines(bufnr, noendofline)
|
||||
-- nvim_buf_get_lines strips carriage returns if fileformat==dos
|
||||
local buftext = vim.api.nvim_buf_get_lines(bufnr, 0, -1, false)
|
||||
|
||||
@ -84,7 +85,7 @@ function M.buf_lines(bufnr)
|
||||
end
|
||||
end
|
||||
|
||||
if vim.bo[bufnr].endofline then
|
||||
if not noendofline and vim.bo[bufnr].endofline then
|
||||
-- Add CR to the last line
|
||||
if dos then
|
||||
buftext[#buftext] = buftext[#buftext] .. '\r'
|
||||
@ -116,6 +117,15 @@ function M.buf_rename(bufnr, name)
|
||||
delete_alt(bufnr)
|
||||
end
|
||||
|
||||
--- @param events string[]
|
||||
--- @param f fun()
|
||||
function M.noautocmd(events, f)
|
||||
local ei = vim.o.eventignore
|
||||
vim.o.eventignore = table.concat(events, ',')
|
||||
f()
|
||||
vim.o.eventignore = ei
|
||||
end
|
||||
|
||||
--- @param bufnr integer
|
||||
--- @param start_row integer
|
||||
--- @param end_row integer
|
||||
@ -254,9 +264,8 @@ end
|
||||
|
||||
---@param fmt string
|
||||
---@param info table<string,any>
|
||||
---@param reltime? boolean Use relative time as the default date format
|
||||
---@return string
|
||||
function M.expand_format(fmt, info, reltime)
|
||||
function M.expand_format(fmt, info)
|
||||
local ret = {} --- @type string[]
|
||||
|
||||
for _ = 1, 20 do -- loop protection
|
||||
@ -277,7 +286,7 @@ function M.expand_format(fmt, info, reltime)
|
||||
end
|
||||
if vim.endswith(key, '_time') then
|
||||
if time_fmt == '' then
|
||||
time_fmt = reltime and '%R' or '%Y-%m-%d'
|
||||
time_fmt = '%Y-%m-%d'
|
||||
end
|
||||
v = expand_date(time_fmt, v)
|
||||
end
|
||||
|
||||
@ -8,6 +8,7 @@ local util = require('gitsigns.util')
|
||||
|
||||
local cache = require('gitsigns.cache').cache
|
||||
local config = require('gitsigns.config').config
|
||||
local throttle_by_id = require('gitsigns.debounce').throttle_by_id
|
||||
local debounce_trailing = require('gitsigns.debounce').debounce_trailing
|
||||
local manager = require('gitsigns.manager')
|
||||
|
||||
@ -52,15 +53,21 @@ local function handle_moved(bufnr, old_relpath)
|
||||
local old_name = api.nvim_buf_get_name(bufnr)
|
||||
|
||||
if not bufexists then
|
||||
util.buf_rename(bufnr, bcache.file)
|
||||
-- Do not trigger BufFilePre/Post
|
||||
-- TODO(lewis6991): figure out how to avoid reattaching without
|
||||
-- disabling all autocommands.
|
||||
util.noautocmd({ 'BufFilePre', 'BufFilePost' }, function()
|
||||
util.buf_rename(bufnr, bcache.file)
|
||||
end)
|
||||
end
|
||||
|
||||
local msg = bufexists and 'Cannot rename' or 'Renamed'
|
||||
dprintf('%s buffer %d from %s to %s', msg, bufnr, old_name, bcache.file)
|
||||
end
|
||||
|
||||
--- @async
|
||||
--- @param bufnr integer
|
||||
local watcher_handler = async.create(1, function(bufnr)
|
||||
local function watcher_handler0(bufnr)
|
||||
local __FUNC__ = 'watcher_handler'
|
||||
|
||||
-- Avoid cache hit for detached buffer
|
||||
@ -99,9 +106,13 @@ local watcher_handler = async.create(1, function(bufnr)
|
||||
cache[bufnr]:invalidate(true)
|
||||
|
||||
require('gitsigns.manager').update(bufnr)
|
||||
end)
|
||||
end
|
||||
|
||||
local watcher_handler_debounced = debounce_trailing(200, watcher_handler, 1)
|
||||
--- Debounce and throttle the handler.
|
||||
--- We also throttle in case the debounce delay is not enough and to prevent
|
||||
--- too many handlers from being launched (and interleaved).
|
||||
local watcher_handler =
|
||||
debounce_trailing(200, async.create(1, throttle_by_id(watcher_handler0, true)), 1)
|
||||
|
||||
--- vim.inspect but on one line
|
||||
--- @param x any
|
||||
@ -142,7 +153,7 @@ function M.watch_gitdir(bufnr, gitdir)
|
||||
|
||||
dprint(info)
|
||||
|
||||
watcher_handler_debounced(bufnr)
|
||||
watcher_handler(bufnr)
|
||||
end)
|
||||
return w
|
||||
end
|
||||
|
||||
@ -1 +1 @@
|
||||
/nix/store/mqbhz05llkddfb5wni0m48kw22ixxps4-lua-5.1.5
|
||||
/nix/store/3czmrawji85vf8979kll2yx2f1kjkric-lua-5.1.5
|
||||
@ -1,49 +1,50 @@
|
||||
rock_manifest = {
|
||||
doc = {
|
||||
["gitsigns.txt"] = "a329a90ab3b49a53ea44d986cbde6885"
|
||||
["gitsigns.txt"] = "e537e0db7825ce01a1c568a124432989"
|
||||
},
|
||||
["gitsigns.nvim-scm-1.rockspec"] = "a9b165d604ce401cfeea760a9366418d",
|
||||
lua = {
|
||||
gitsigns = {
|
||||
["actions.lua"] = "e1d7610fc1d5fc73cb891b286df0535e",
|
||||
["actions.lua"] = "accecf1db114ace88739c40835cb5a77",
|
||||
["async.lua"] = "15f310cd469f5bfa46bb1e49e5a1d61c",
|
||||
["attach.lua"] = "097403415eba4dc5da07fdb948647841",
|
||||
["cache.lua"] = "909e8cdc787ca5e6d3ed62782dd5453b",
|
||||
["attach.lua"] = "6f81186d03fbde2ddc631c46fea09315",
|
||||
["blame.lua"] = "e8388c8b29982475bfccec28ea4f72be",
|
||||
["cache.lua"] = "a084b897b3af2f3603a018f4c00c20fa",
|
||||
cli = {
|
||||
["argparse.lua"] = "fb6c9ffda01b2090f3c252ecaf00f68a"
|
||||
},
|
||||
["cli.lua"] = "f00c3494d6be1b07c352c51132150586",
|
||||
["config.lua"] = "fa4a0f95747586aab60c9b848a72d9cf",
|
||||
["current_line_blame.lua"] = "bf5426f4569e207646c39f9d47a083af",
|
||||
["config.lua"] = "ef58f99d7782297a32e3867634906738",
|
||||
["current_line_blame.lua"] = "b1e920875977e12bb4f9f6be08a92db8",
|
||||
["debounce.lua"] = "e0c1145a3dc341f46b36b43d814c1202",
|
||||
debug = {
|
||||
["log.lua"] = "897a3bf45d0996b9517fa8c0a2ba1dac"
|
||||
["log.lua"] = "f7e994b68e9cbcf91adfeb5bc379d7b1"
|
||||
},
|
||||
["debug.lua"] = "ef5c8e3c1c9da306ed7b2eb33e657236",
|
||||
["debug.lua"] = "6a819b17a531b74ee11622145097afae",
|
||||
["diff.lua"] = "0c462ae71c77899e81da151dcfdf77eb",
|
||||
["diff_ext.lua"] = "04005195067132403fc336422e05c7d3",
|
||||
["diff_int.lua"] = "df447e56f11906998e81d5b94499e013",
|
||||
["diffthis.lua"] = "eb4ff5d430d2c4081f1fa9651d2768f7",
|
||||
["diffthis.lua"] = "b91c6a177c0a80c5e611b8c09f6eb46e",
|
||||
git = {
|
||||
["version.lua"] = "068a582ed4565978eb1f6eb089a6fa6c"
|
||||
},
|
||||
["git.lua"] = "89ec79605c259e73ce8c19deb5b63194",
|
||||
["highlight.lua"] = "1d197d8f0f6f69a6455ac220a6890d80",
|
||||
["hunks.lua"] = "48fc2d8a9c89815e3c0521b1bb0788e9",
|
||||
["manager.lua"] = "af94331f013ed04d175e3c2b2d21c42b",
|
||||
["git.lua"] = "8a216cac54214508e798c7f4b920dd36",
|
||||
["highlight.lua"] = "f1966ef758f9a0a86102a699ec7a1eca",
|
||||
["hunks.lua"] = "ee058ee8b056b055cd8404460ca6921f",
|
||||
["manager.lua"] = "527083250ad693ee4faa5e4dde47f275",
|
||||
["message.lua"] = "523ee4df9da4a7fa9b5ab2100eb27ac4",
|
||||
["popup.lua"] = "cbc11678e30094bff8ed54f0357e26f9",
|
||||
["repeat.lua"] = "798544de97c774bc8e10eecfd6479585",
|
||||
["signs.lua"] = "4c6533b4a406b049e68f49aee59417f6",
|
||||
["signs.lua"] = "9224bcde01ebd0c320bcd678822fc799",
|
||||
["status.lua"] = "a229a7213a3fbecfcf2d98aaf587fcab",
|
||||
system = {
|
||||
["compat.lua"] = "05d2b6d08602fba46be9b540288091e7"
|
||||
},
|
||||
["system.lua"] = "d73fac4f6e734cc8ce9f13d6be027503",
|
||||
["test.lua"] = "082f7c7a556bf27352a378d047b8e79b",
|
||||
["util.lua"] = "e4c4d677e3ad296adee833318a5c5845",
|
||||
["watcher.lua"] = "ffcf36424ae17548bdc629cc2de3fcaa"
|
||||
["util.lua"] = "b24bac967bc60ba1434bf5cd7cf3fc98",
|
||||
["watcher.lua"] = "034303cfa063c77bb6628f1a55d559c4"
|
||||
},
|
||||
["gitsigns.lua"] = "48654d8ca2059edb2b3a0bdd09f871e1"
|
||||
["gitsigns.lua"] = "784d1b15d5970f0177fd19d163ea9dfb"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user