-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.lua
More file actions
126 lines (110 loc) · 5.82 KB
/
config.lua
File metadata and controls
126 lines (110 loc) · 5.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
---@mod gitlad.config Configuration management
local M = {}
---@class GitladCommitEditorConfig
---@field split "above"|"replace" How to open the commit editor ("above" = split above status, "replace" = replace current buffer)
---@class GitladSectionConfig
---@field [1] string Section name (first array element)
---@field count? number For "recent" section - number of commits to show (default: 10)
---@field min_count? number For "worktrees" section - minimum worktrees to show section (default: 2)
---@alias GitladSection string|GitladSectionConfig
---@class GitladStatusConfig
---@field sections? GitladSection[] Section order and options. Omit sections to hide them. Options: "untracked", "unstaged", "staged", "conflicted", "stashes", "submodules", "worktrees", "unpushed", "unpulled", "recent". Use table form for options: { "recent", count = 5 }
--- Worktree directory strategy examples (from /code/project/main, branch feature/foo):
--- "sibling" → /code/project/main_feature-foo (prefixed with current worktree name)
--- "sibling-bare" → /code/project/feature-foo (just the branch name)
--- "prompt" → always prompts for path with no default
---@class GitladWorktreeConfig
---@field directory_strategy "sibling"|"sibling-bare"|"prompt" How to suggest default worktree paths
---@field worktrunk "auto"|"always"|"never" Whether to use worktrunk (wt) CLI. "auto" = use if installed, "always" = require it, "never" = disable
---@field copy_ignored_on_create "always"|"never" Whether to run wt step copy-ignored after creating a worktree (default: "never"; use popup switch for per-invocation control)
---@field copy_ignored_from "trunk"|"current" Source worktree for copy-ignored: "trunk" = default branch, "current" = current worktree
---@class GitladWatcherConfig
---@field enabled boolean Whether to enable file watching for git state changes (default: true)
---@field stale_indicator boolean Show stale indicator when external changes detected (default: true)
---@field auto_refresh boolean Automatically refresh when external changes detected (default: false)
---@field cooldown_ms number Cooldown period in ms after gitlad operations before events are processed (default: 1000)
---@field auto_refresh_debounce_ms number Debounce period in ms before triggering auto-refresh (default: 500)
---@field submodule_debounce_ms number Debounce period in ms for submodule file events (default: 5000). Longer than normal to avoid churn from build/IDE activity in submodules.
---@field watch_worktree boolean Whether to watch working tree files for changes (default: true)
---@class GitladOutputConfig
---@field hook_output "lazy"|"always"|"never" How to show hook output ("lazy" = only when output arrives, "always" = immediately, "never" = disabled)
---@class GitladForgeConfig
---@field show_pr_in_status boolean Show PR summary line in status buffer header (default: true)
---@field pr_info_ttl number Seconds before cached PR info is re-fetched on auto-refresh (default: 30). Manual refresh (gr) always bypasses this.
---@class GitladDiffConfig
---@field viewer "native" Diff viewer to use ("native" = built-in side-by-side)
---@class GitladGitConfig
---@field ignore_submodules false|"dirty"|"untracked"|"all" Pass --ignore-submodules to git status (default: false). "dirty" hides submodules with only working tree changes, "untracked" also hides untracked files, "all" hides all submodule changes. Makes git status dramatically faster in repos with many submodules.
---@class GitladConfig
---@field signs GitladSigns
---@field commit_editor GitladCommitEditorConfig
---@field status GitladStatusConfig
---@field worktree GitladWorktreeConfig
---@field watcher GitladWatcherConfig
---@field output GitladOutputConfig
---@field forge GitladForgeConfig
---@field diff GitladDiffConfig
---@field git GitladGitConfig
---@field show_tags_in_refs boolean Whether to show tags alongside branch names in refs (default: false)
local defaults = {
signs = {
staged = "●",
unstaged = "○",
untracked = "?",
conflict = "!",
},
commit_editor = {
split = "above", -- "above" or "replace"
},
status = {},
worktree = {
directory_strategy = "sibling", -- "sibling", "sibling-bare", or "prompt"
worktrunk = "auto", -- "auto" | "always" | "never"
copy_ignored_on_create = "never", -- "always" | "never"
copy_ignored_from = "trunk", -- "trunk" | "current"
},
watcher = {
enabled = true, -- Can disable for performance-sensitive users
stale_indicator = true, -- Show stale indicator when external changes detected
auto_refresh = false, -- Automatically refresh when external changes detected
cooldown_ms = 1000, -- Ignore events for 1s after gitlad operations
auto_refresh_debounce_ms = 500, -- Debounce for auto_refresh
submodule_debounce_ms = 5000, -- Longer debounce for submodule file events
watch_worktree = true, -- Watch working tree files for changes
},
output = {
hook_output = "lazy", -- "lazy", "always", or "never"
},
forge = {
show_pr_in_status = true, -- Show PR summary in status header
pr_info_ttl = 30, -- Seconds before auto-refresh re-fetches PR info (gr always bypasses)
},
diff = {
viewer = "native",
},
git = {
ignore_submodules = false, -- false | "dirty" | "untracked" | "all"
},
show_tags_in_refs = false,
}
---@type GitladConfig
local current_config = nil
--- Setup configuration with user options
---@param opts? GitladSetupOptions
function M.setup(opts)
current_config = vim.tbl_deep_extend("force", {}, defaults, opts or {})
end
--- Get current configuration
---@return GitladConfig
function M.get()
if not current_config then
-- Return defaults if setup hasn't been called
return vim.tbl_deep_extend("force", {}, defaults)
end
return current_config
end
--- Reset configuration to defaults (useful for testing)
function M.reset()
current_config = nil
end
return M