feat(blame_line): add option to show when not focused
This commit is contained in:
parent
899e993850
commit
2667904fb0
|
@ -90,6 +90,7 @@ require('gitsigns').setup {
|
|||
delay = 1000,
|
||||
ignore_whitespace = false,
|
||||
virt_text_priority = 100,
|
||||
use_focus = true,
|
||||
},
|
||||
current_line_blame_formatter = '<author>, <author_time:%R> - <summary>',
|
||||
sign_priority = 6,
|
||||
|
|
|
@ -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,
|
||||
|
@ -823,7 +824,8 @@ current_line_blame_opts *gitsigns-config-current_line_blame_opts*
|
|||
delay = 1000,
|
||||
virt_text = true,
|
||||
virt_text_pos = "eol",
|
||||
virt_text_priority = 100
|
||||
virt_text_priority = 100,
|
||||
use_focus = true,
|
||||
}`
|
||||
<
|
||||
Options for the current line blame annotation.
|
||||
|
@ -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`.
|
||||
|
||||
|
|
|
@ -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`.
|
||||
]],
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue