feat(explorer): allow disabling untracked git status. Closes #983

This commit is contained in:
Folke Lemaitre 2025-02-07 10:26:19 +01:00
parent f037027cad
commit a3b083b844
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
3 changed files with 5 additions and 2 deletions

View file

@ -30,7 +30,7 @@ function M.is_dirty(cwd)
end
---@param cwd string
---@param opts? {on_update?: fun(), ttl?: number, force?: boolean, ignored?: boolean}
---@param opts? {on_update?: fun(), ttl?: number, force?: boolean, untracked?: boolean}
function M.update(cwd, opts)
opts = opts or {}
local ttl = opts.ttl or CACHE_TTL
@ -62,10 +62,10 @@ function M.update(cwd, opts)
args = {
"--no-pager",
"status",
"-unormal",
"--porcelain=v1",
"--ignored=matching",
"-z",
opts.untracked and "-unormal" or "-uno",
},
}, function()
stdout:close()

View file

@ -42,6 +42,7 @@ M.buffers = {
---@field tree? boolean show the file tree (default: true)
---@field git_status? boolean show git status (default: true)
---@field git_status_open? boolean show recursive git status for open directories
---@field git_untracked? boolean needed to show untracked git status
---@field diagnostics? boolean show diagnostics
---@field diagnostics_open? boolean show recursive diagnostics for open directories
---@field watch? boolean watch for file changes
@ -55,6 +56,7 @@ M.explorer = {
diagnostics_open = false,
git_status = true,
git_status_open = false,
git_untracked = true,
follow_file = true,
focus = "list",
auto_close = false,

View file

@ -211,6 +211,7 @@ function M.explorer(opts, ctx)
if opts.git_status then
require("snacks.explorer.git").update(ctx.filter.cwd, {
untracked = opts.git_untracked,
on_update = function()
if ctx.picker.closed then
return