plugins/git: normalize plugin defaults

This commit is contained in:
Matt Sturgeon
2024-06-21 08:48:00 +01:00
parent 25eed3c2f5
commit a208c7181c
8 changed files with 182 additions and 197 deletions
+7 -7
View File
@@ -73,7 +73,7 @@ let
current window.
'';
winOpts = mkAttributeSet "{}" ''
winOpts = mkAttributeSet { } ''
Table of window local options (see |vim.opt_local|).
These options are applied whenever the window is opened.
'';
@@ -96,11 +96,11 @@ in
See ':h diffview-config-enhanced_diff_hl'
'';
gitCmd = mkNullable (types.listOf types.str) ''[ "git" ]'' ''
gitCmd = mkListOf types.str [ "git" ] ''
The git executable followed by default args.
'';
hgCmd = mkNullable (types.listOf types.str) ''[ "hg" ]'' ''
hgCmd = mkListOf types.str [ "hg" ] ''
The hg executable followed by default args.
'';
@@ -323,7 +323,7 @@ in
List only the commits in the specified revision range.
'';
pathArgs = mkNullable (types.listOf types.str) "[]" ''
pathArgs = mkListOf types.str [ ] ''
Limit the target files to only the files matching the given
path arguments (git pathspec is supported).
'';
@@ -381,7 +381,7 @@ in
Limit the number of commits.
'';
l = mkNullable (types.listOf types.str) "[]" ''
l = mkListOf types.str [ ] ''
`{ ("<start>,<end>:<file>" | ":<funcname>:<file>")... }`
Trace the evolution of the line range given by <start>,<end>,
@@ -454,9 +454,9 @@ in
commonDesc = "Default args prepended to the arg-list for the listed commands";
in
{
diffviewOpen = mkNullable (types.listOf types.str) "[ ]" commonDesc;
diffviewOpen = mkListOf types.str [ ] commonDesc;
diffviewFileHistory = mkNullable (types.listOf types.str) "[ ]" commonDesc;
diffviewFileHistory = mkListOf types.str [ ] commonDesc;
};
hooks =
+1 -1
View File
@@ -24,7 +24,7 @@ helpers.neovim-plugin.mkNeovimPlugin config {
settingsOptions = {
default_mappings =
helpers.defaultNullOpts.mkNullable (with types; either bool (attrsOf str)) "true"
helpers.defaultNullOpts.mkNullable (with types; either bool (attrsOf str)) true
''
This plugin offers default buffer local mappings inside conflicted files.
This is primarily because applying these mappings only to relevant buffers is impossible
+6 -8
View File
@@ -24,23 +24,21 @@ in
highlightGroup = helpers.defaultNullOpts.mkStr "Comment" "The highlight group for virtual text.";
displayVirtualText =
helpers.defaultNullOpts.mkNullable (types.nullOr types.bool) (toString true)
"If the blame message should be displayed as virtual text. You may want to disable this if you display the blame message in statusline.";
displayVirtualText = helpers.defaultNullOpts.mkBool true "If the blame message should be displayed as virtual text. You may want to disable this if you display the blame message in statusline.";
ignoredFiletypes = helpers.defaultNullOpts.mkNullable (types.listOf types.str) (toString
[ ]
) "A list of filetypes for which gitblame information will not be displayed.";
ignoredFiletypes =
helpers.defaultNullOpts.mkListOf types.str [ ]
"A list of filetypes for which gitblame information will not be displayed.";
delay =
helpers.defaultNullOpts.mkUnsignedInt 0
"The delay in milliseconds after which the blame info will be displayed.";
virtualTextColumn =
helpers.defaultNullOpts.mkNullable types.ints.unsigned (toString null)
helpers.defaultNullOpts.mkNullable types.ints.unsigned null
"Have the blame message start at a given column instead of EOL. If the current line is longer than the specified column value the blame message will default to being displayed at EOL.";
extmarkOptions = helpers.defaultNullOpts.mkAttributeSet (toString null) "nvim_buf_set_extmark optional parameters. (Warning: overwriting id and virt_text will break the plugin behavior)";
extmarkOptions = helpers.defaultNullOpts.mkAttributeSet null "nvim_buf_set_extmark optional parameters. (Warning: overwriting id and virt_text will break the plugin behavior)";
};
};
+14 -17
View File
@@ -39,24 +39,21 @@ with lib;
mappings = helpers.defaultNullOpts.mkStr "<leader>gy" "Mapping to call url generation.";
callbacks =
helpers.defaultNullOpts.mkNullable (with types; attrsOf (either str helpers.nixvimTypes.rawLua))
helpers.defaultNullOpts.mkAttrsOf types.str
{
"github.com" = "get_github_type_url";
"gitlab.com" = "get_gitlab_type_url";
"try.gitea.io" = "get_gitea_type_url";
"codeberg.org" = "get_gitea_type_url";
"bitbucket.org" = "get_bitbucket_type_url";
"try.gogs.io" = "get_gogs_type_url";
"git.sr.ht" = "get_srht_type_url";
"git.launchpad.net" = "get_launchpad_type_url";
"repo.or.cz" = "get_repoorcz_type_url";
"git.kernel.org" = "get_cgit_type_url";
"git.savannah.gnu.org" = "get_cgit_type_url";
}
''
{
"github.com" = "get_github_type_url";
"gitlab.com" = "get_gitlab_type_url";
"try.gitea.io" = "get_gitea_type_url";
"codeberg.org" = "get_gitea_type_url";
"bitbucket.org" = "get_bitbucket_type_url";
"try.gogs.io" = "get_gogs_type_url";
"git.sr.ht" = "get_srht_type_url";
"git.launchpad.net" = "get_launchpad_type_url";
"repo.or.cz" = "get_repoorcz_type_url";
"git.kernel.org" = "get_cgit_type_url";
"git.savannah.gnu.org" = "get_cgit_type_url";
}
''
''
Each key can be
- the name of a built-in callback. Example: `"get_gitlab_type_url";` is setting
```lua
+1 -1
View File
@@ -84,7 +84,7 @@ with lib;
Note: Word diff is enabled by typing "r" in a popup window.
'';
floatingWinOps = helpers.defaultNullOpts.mkNullable (types.attrsOf types.anything) "{}" ''
floatingWinOps = helpers.defaultNullOpts.mkAttrsOf types.anything { } ''
Options passed to nvim_open_win() on opening a popup window. This is useful when you want to
override some window options.
'';
+19 -23
View File
@@ -225,20 +225,18 @@ with lib;
count_chars =
helpers.defaultNullOpts.mkAttrsOf types.str
''
{
"__unkeyed_1" = "1";
"__unkeyed_2" = "2";
"__unkeyed_3" = "3";
"__unkeyed_4" = "4";
"__unkeyed_5" = "5";
"__unkeyed_6" = "6";
"__unkeyed_7" = "7";
"__unkeyed_8" = "8";
"__unkeyed_9" = "9";
"+" = ">";
}
''
{
"__unkeyed_1" = "1";
"__unkeyed_2" = "2";
"__unkeyed_3" = "3";
"__unkeyed_4" = "4";
"__unkeyed_5" = "5";
"__unkeyed_6" = "6";
"__unkeyed_7" = "7";
"__unkeyed_8" = "8";
"__unkeyed_9" = "9";
"+" = ">";
}
''
The count characters used when `signs.*.show_count` is enabled.
The `+` entry is used as a fallback. With the default, any count outside of 1-9 uses the `>`
@@ -272,15 +270,13 @@ with lib;
preview_config =
helpers.defaultNullOpts.mkAttrsOf types.anything
''
{
border = "single";
style = "minimal";
relative = "cursor";
row = 0;
col = 1;
}
''
{
border = "single";
style = "minimal";
relative = "cursor";
row = 0;
col = 1;
}
''
Option overrides for the Gitsigns preview window.
Table is passed directly to `nvim_open_win`.
+13 -6
View File
@@ -15,17 +15,24 @@ helpers.vim-plugin.mkVimPlugin config {
maintainers = [ helpers.maintainers.AndresBermeoMarinelli ];
settingsOptions = {
floating_window_winblend = helpers.defaultNullOpts.mkNullable (types.ints.between 0 100) "0" ''
floating_window_winblend = helpers.defaultNullOpts.mkNullable (types.ints.between 0 100) 0 ''
Set the transparency of the floating window.
'';
floating_window_scaling_factor =
helpers.defaultNullOpts.mkNullable types.numbers.nonnegative "0.9"
helpers.defaultNullOpts.mkNullable types.numbers.nonnegative 0.9
"Set the scaling factor for floating window.";
floating_window_border_chars =
helpers.defaultNullOpts.mkListOf types.str ''["╭" "─" "╮" "│" "╯" "─" "╰" "│"]''
"Customize lazygit popup window border characters.";
floating_window_border_chars = helpers.defaultNullOpts.mkListOf types.str [
"╭"
"─"
"╮"
"│"
"╯"
"─"
"╰"
"│"
] "Customize lazygit popup window border characters.";
floating_window_use_plenary = helpers.defaultNullOpts.mkBool false ''
Whether to use plenary.nvim to manage floating window if available.
@@ -41,7 +48,7 @@ helpers.vim-plugin.mkVimPlugin config {
config_file_path = helpers.defaultNullOpts.mkNullable (
with types; either str (listOf str)
) "[]" "Custom config file path or list of custom config file paths.";
) [ ] "Custom config file path or list of custom config file paths.";
};
settingsExample = {
+121 -134
View File
@@ -42,13 +42,11 @@ in
Disables signs for sections/items/hunks.
'';
git_services = helpers.defaultNullOpts.mkAttrsOf types.str ''
{
"github.com" = "https://github.com/$\{owner}/$\{repository}/compare/$\{branch_name}?expand=1";
"bitbucket.org" = "https://bitbucket.org/$\{owner}/$\{repository}/pull-requests/new?source=$\{branch_name}&t=1";
"gitlab.com" = "https://gitlab.com/$\{owner}/$\{repository}/merge_requests/new?merge_request[source_branch]=$\{branch_name}";
}
'' "Used to generate URL's for branch popup action 'pull request'.";
git_services = helpers.defaultNullOpts.mkAttrsOf types.str {
"github.com" = "https://github.com/$\{owner}/$\{repository}/compare/$\{branch_name}?expand=1";
"bitbucket.org" = "https://bitbucket.org/$\{owner}/$\{repository}/pull-requests/new?source=$\{branch_name}&t=1";
"gitlab.com" = "https://gitlab.com/$\{owner}/$\{repository}/merge_requests/new?merge_request[source_branch]=$\{branch_name}";
} "Used to generate URL's for branch popup action 'pull request'.";
fetch_after_checkout = helpers.defaultNullOpts.mkBool false ''
Perform a fetch if the newly checked out branch has an upstream or pushRemote set.
@@ -174,9 +172,14 @@ in
mapAttrs
(
n: v:
helpers.defaultNullOpts.mkListOf types.str ''["${v.closed}" "${v.opened}"]'' ''
The icons to use for open and closed ${n}s.
''
helpers.defaultNullOpts.mkListOf types.str
[
"${v.closed}"
"${v.opened}"
]
''
The icons to use for open and closed ${n}s.
''
)
{
hunk = {
@@ -284,15 +287,13 @@ in
ignored_settings =
helpers.defaultNullOpts.mkListOf types.str
''
[
"NeogitPushPopup--force-with-lease"
"NeogitPushPopup--force"
"NeogitPullPopup--rebase"
"NeogitCommitPopup--allow-empty"
"NeogitRevertPopup--no-edit"
]
''
[
"NeogitPushPopup--force-with-lease"
"NeogitPushPopup--force"
"NeogitPullPopup--rebase"
"NeogitCommitPopup--allow-empty"
"NeogitRevertPopup--no-edit"
]
''
Table of settings to never persist.
Uses format "Filetype--cli-value".
@@ -303,127 +304,113 @@ in
mkMappingOption = helpers.defaultNullOpts.mkAttrsOf (with types; either str (enum [ false ]));
in
{
commit_editor = mkMappingOption ''
{
q = "Close";
"<c-c><c-c>" = "Submit";
"<c-c><c-k>" = "Abort";
"<m-p>" = "PrevMessage";
"<m-n>" = "NextMessage";
"<m-r>" = "ResetMessage";
}
'' "Mappings for the commit editor.";
commit_editor = mkMappingOption {
q = "Close";
"<c-c><c-c>" = "Submit";
"<c-c><c-k>" = "Abort";
"<m-p>" = "PrevMessage";
"<m-n>" = "NextMessage";
"<m-r>" = "ResetMessage";
} "Mappings for the commit editor.";
commit_editor_I = mkMappingOption ''
{
"<c-c><c-c>" = "Submit";
"<c-c><c-k>" = "Abort";
}
'' "Mappings for the commit editor (insert mode)";
commit_editor_I = mkMappingOption {
"<c-c><c-c>" = "Submit";
"<c-c><c-k>" = "Abort";
} "Mappings for the commit editor (insert mode)";
rebase_editor = mkMappingOption ''
{
p = "Pick";
r = "Reword";
e = "Edit";
s = "Squash";
f = "Fixup";
x = "Execute";
d = "Drop";
b = "Break";
q = "Close";
"<cr>" = "OpenCommit";
gk = "MoveUp";
gj = "MoveDown";
"<c-c><c-c>" = "Submit";
"<c-c><c-k>" = "Abort";
"[c" = "OpenOrScrollUp";
"]c" = "OpenOrScrollDown";
}
'' "Mappings for the rebase editor.";
rebase_editor = mkMappingOption {
p = "Pick";
r = "Reword";
e = "Edit";
s = "Squash";
f = "Fixup";
x = "Execute";
d = "Drop";
b = "Break";
q = "Close";
"<cr>" = "OpenCommit";
gk = "MoveUp";
gj = "MoveDown";
"<c-c><c-c>" = "Submit";
"<c-c><c-k>" = "Abort";
"[c" = "OpenOrScrollUp";
"]c" = "OpenOrScrollDown";
} "Mappings for the rebase editor.";
rebase_editor_I = mkMappingOption ''
{
"<c-c><c-c>" = "Submit";
"<c-c><c-k>" = "Abort";
}
'' "Mappings for the rebase editor (insert mode).";
rebase_editor_I = mkMappingOption {
"<c-c><c-c>" = "Submit";
"<c-c><c-k>" = "Abort";
} "Mappings for the rebase editor (insert mode).";
finder = mkMappingOption ''
{
"<cr>" = "Select";
"<c-c>" = "Close";
"<esc>" = "Close";
"<c-n>" = "Next";
"<c-p>" = "Previous";
"<down>" = "Next";
"<up>" = "Previous";
"<tab>" = "MultiselectToggleNext";
"<s-tab>" = "MultiselectTogglePrevious";
"<c-j>" = "NOP";
"<ScrollWheelDown>" = "ScrollWheelDown";
"<ScrollWheelUp>" = "ScrollWheelUp";
"<ScrollWheelLeft>" = "NOP";
"<ScrollWheelRight>" = "NOP";
"<LeftMouse>" = "MouseClick";
"<2-LeftMouse>" = "NOP";
}
'' "Mappings for the finder.";
finder = mkMappingOption {
"<cr>" = "Select";
"<c-c>" = "Close";
"<esc>" = "Close";
"<c-n>" = "Next";
"<c-p>" = "Previous";
"<down>" = "Next";
"<up>" = "Previous";
"<tab>" = "MultiselectToggleNext";
"<s-tab>" = "MultiselectTogglePrevious";
"<c-j>" = "NOP";
"<ScrollWheelDown>" = "ScrollWheelDown";
"<ScrollWheelUp>" = "ScrollWheelUp";
"<ScrollWheelLeft>" = "NOP";
"<ScrollWheelRight>" = "NOP";
"<LeftMouse>" = "MouseClick";
"<2-LeftMouse>" = "NOP";
} "Mappings for the finder.";
popup = mkMappingOption ''
{
"?" = "HelpPopup";
A = "CherryPickPopup";
d = "DiffPopup";
M = "RemotePopup";
P = "PushPopup";
X = "ResetPopup";
Z = "StashPopup";
i = "IgnorePopup";
t = "TagPopup";
b = "BranchPopup";
B = "BisectPopup";
w = "WorktreePopup";
c = "CommitPopup";
f = "FetchPopup";
l = "LogPopup";
m = "MergePopup";
p = "PullPopup";
r = "RebasePopup";
v = "RevertPopup";
}
'' "Mappings for popups.";
popup = mkMappingOption {
"?" = "HelpPopup";
A = "CherryPickPopup";
d = "DiffPopup";
M = "RemotePopup";
P = "PushPopup";
X = "ResetPopup";
Z = "StashPopup";
i = "IgnorePopup";
t = "TagPopup";
b = "BranchPopup";
B = "BisectPopup";
w = "WorktreePopup";
c = "CommitPopup";
f = "FetchPopup";
l = "LogPopup";
m = "MergePopup";
p = "PullPopup";
r = "RebasePopup";
v = "RevertPopup";
} "Mappings for popups.";
status = mkMappingOption ''
{
q = "Close";
I = "InitRepo";
"1" = "Depth1";
"2" = "Depth2";
"3" = "Depth3";
"4" = "Depth4";
"<tab>" = "Toggle";
x = "Discard";
s = "Stage";
S = "StageUnstaged";
"<c-s>" = "StageAll";
u = "Unstage";
K = "Untrack";
U = "UnstageStaged";
y = "ShowRefs";
"$" = "CommandHistory";
Y = "YankSelected";
"<c-r>" = "RefreshBuffer";
"<cr>" = "GoToFile";
"<c-v>" = "VSplitOpen";
"<c-x>" = "SplitOpen";
"<c-t>" = "TabOpen";
"{" = "GoToPreviousHunkHeader";
"}" = "GoToNextHunkHeader";
"[c" = "OpenOrScrollUp";
"]c" = "OpenOrScrollDown";
}
'' "Mappings for status.";
status = mkMappingOption {
q = "Close";
I = "InitRepo";
"1" = "Depth1";
"2" = "Depth2";
"3" = "Depth3";
"4" = "Depth4";
"<tab>" = "Toggle";
x = "Discard";
s = "Stage";
S = "StageUnstaged";
"<c-s>" = "StageAll";
u = "Unstage";
K = "Untrack";
U = "UnstageStaged";
y = "ShowRefs";
"$" = "CommandHistory";
Y = "YankSelected";
"<c-r>" = "RefreshBuffer";
"<cr>" = "GoToFile";
"<c-v>" = "VSplitOpen";
"<c-x>" = "SplitOpen";
"<c-t>" = "TabOpen";
"{" = "GoToPreviousHunkHeader";
"}" = "GoToNextHunkHeader";
"[c" = "OpenOrScrollUp";
"]c" = "OpenOrScrollDown";
} "Mappings for status.";
};
notification_icon = helpers.defaultNullOpts.mkStr "󰊢" ''