plugins/git: normalize plugin defaults

This commit is contained in:
Matt Sturgeon 2024-06-11 16:52:32 +01:00
parent 25eed3c2f5
commit a208c7181c
No known key found for this signature in database
GPG key ID: 4F91844CED1A8299
8 changed files with 182 additions and 197 deletions

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 =

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

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)";
};
};

View file

@ -39,8 +39,7 @@ 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";
@ -55,8 +54,6 @@ with lib;
"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

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.
'';

View file

@ -225,7 +225,6 @@ with lib;
count_chars =
helpers.defaultNullOpts.mkAttrsOf types.str
''
{
"__unkeyed_1" = "1";
"__unkeyed_2" = "2";
@ -238,7 +237,6 @@ with lib;
"__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,7 +270,6 @@ with lib;
preview_config =
helpers.defaultNullOpts.mkAttrsOf types.anything
''
{
border = "single";
style = "minimal";
@ -280,7 +277,6 @@ with lib;
row = 0;
col = 1;
}
''
''
Option overrides for the Gitsigns preview window.
Table is passed directly to `nvim_open_win`.

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 = {

View file

@ -42,13 +42,11 @@ in
Disables signs for sections/items/hunks.
'';
git_services = helpers.defaultNullOpts.mkAttrsOf types.str ''
{
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'.";
} "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,7 +172,12 @@ in
mapAttrs
(
n: v:
helpers.defaultNullOpts.mkListOf types.str ''["${v.closed}" "${v.opened}"]'' ''
helpers.defaultNullOpts.mkListOf types.str
[
"${v.closed}"
"${v.opened}"
]
''
The icons to use for open and closed ${n}s.
''
)
@ -284,7 +287,6 @@ in
ignored_settings =
helpers.defaultNullOpts.mkListOf types.str
''
[
"NeogitPushPopup--force-with-lease"
"NeogitPushPopup--force"
@ -292,7 +294,6 @@ in
"NeogitCommitPopup--allow-empty"
"NeogitRevertPopup--no-edit"
]
''
''
Table of settings to never persist.
Uses format "Filetype--cli-value".
@ -303,26 +304,21 @@ in
mkMappingOption = helpers.defaultNullOpts.mkAttrsOf (with types; either str (enum [ false ]));
in
{
commit_editor = mkMappingOption ''
{
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.";
} "Mappings for the commit editor.";
commit_editor_I = mkMappingOption ''
{
commit_editor_I = mkMappingOption {
"<c-c><c-c>" = "Submit";
"<c-c><c-k>" = "Abort";
}
'' "Mappings for the commit editor (insert mode)";
} "Mappings for the commit editor (insert mode)";
rebase_editor = mkMappingOption ''
{
rebase_editor = mkMappingOption {
p = "Pick";
r = "Reword";
e = "Edit";
@ -339,18 +335,14 @@ in
"<c-c><c-k>" = "Abort";
"[c" = "OpenOrScrollUp";
"]c" = "OpenOrScrollDown";
}
'' "Mappings for the rebase editor.";
} "Mappings for the rebase editor.";
rebase_editor_I = mkMappingOption ''
{
rebase_editor_I = mkMappingOption {
"<c-c><c-c>" = "Submit";
"<c-c><c-k>" = "Abort";
}
'' "Mappings for the rebase editor (insert mode).";
} "Mappings for the rebase editor (insert mode).";
finder = mkMappingOption ''
{
finder = mkMappingOption {
"<cr>" = "Select";
"<c-c>" = "Close";
"<esc>" = "Close";
@ -367,11 +359,9 @@ in
"<ScrollWheelRight>" = "NOP";
"<LeftMouse>" = "MouseClick";
"<2-LeftMouse>" = "NOP";
}
'' "Mappings for the finder.";
} "Mappings for the finder.";
popup = mkMappingOption ''
{
popup = mkMappingOption {
"?" = "HelpPopup";
A = "CherryPickPopup";
d = "DiffPopup";
@ -391,11 +381,9 @@ in
p = "PullPopup";
r = "RebasePopup";
v = "RevertPopup";
}
'' "Mappings for popups.";
} "Mappings for popups.";
status = mkMappingOption ''
{
status = mkMappingOption {
q = "Close";
I = "InitRepo";
"1" = "Depth1";
@ -422,8 +410,7 @@ in
"}" = "GoToNextHunkHeader";
"[c" = "OpenOrScrollUp";
"]c" = "OpenOrScrollDown";
}
'' "Mappings for status.";
} "Mappings for status.";
};
notification_icon = helpers.defaultNullOpts.mkStr "󰊢" ''