feat: configurable auto attach (#918)

* feat: configurable auto attach

* fixup! feat: configurable auto attach
This commit is contained in:
martinra 2024-01-05 08:42:32 -03:00 committed by GitHub
parent d195f0c35c
commit 3e6e91b09f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 1 deletions

View File

@ -73,6 +73,7 @@ require('gitsigns').setup {
watch_gitdir = {
follow_files = true
},
auto_attach = true,
attach_to_untracked = true,
current_line_blame = false, -- Toggle with `:Gitsigns toggle_current_line_blame`
current_line_blame_opts = {

View File

@ -49,6 +49,7 @@ of the default settings:
watch_gitdir = {
follow_files = true
},
auto_attach = true,
attach_to_untracked = true,
current_line_blame = false, -- Toggle with `:Gitsigns toggle_current_line_blame`
current_line_blame_opts = {
@ -713,6 +714,11 @@ preview_config *gitsigns-config-preview_config*
Option overrides for the Gitsigns preview window. Table is passed directly
to `nvim_open_win`.
auto_attach *gitsigns-config-auto_attach*
Type: `boolean`, Default: `true`
Automatically attach to files.
attach_to_untracked *gitsigns-config-attach_to_untracked*
Type: `boolean`, Default: `true`

View File

@ -183,7 +183,10 @@ M.setup = async.void(function(cfg)
require('gitsigns.git')._set_version(config._git_version)
end
setup_attach()
if config.auto_attach then
setup_attach()
end
setup_cwd_head()
M._setup_done = true

View File

@ -70,6 +70,7 @@
--- @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}[]
@ -562,6 +563,14 @@ M.schema = {
]],
},
auto_attach = {
type = 'boolean',
default = true,
description = [[
Automatically attach to files.
]],
},
attach_to_untracked = {
type = 'boolean',
default = true,