mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 08:35:43 +02:00
plugins/oil-git-status: improve signcolumn
warning
The warning should trigger when a valid value is configured that restricts the sign column to less than 2 columns.
This commit is contained in:
parent
2797fd8b64
commit
17e13d478d
2 changed files with 54 additions and 22 deletions
|
@ -58,29 +58,46 @@ lib.nixvim.plugins.mkNeovimPlugin {
|
||||||
${options.plugins.oil.enable} = true;
|
${options.plugins.oil.enable} = true;
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
{
|
(
|
||||||
when =
|
# The plugin requires the oil configuration allow at least 2 sign columns.
|
||||||
|
# They suggest `win_options.signcolumn = "yes:2"`, but valid options include
|
||||||
|
# any "yes" or "auto" with a max > 1: E.g. "auto:2", "auto:1-2", "yes:3", …
|
||||||
|
# See also `:h 'signcolumn'`
|
||||||
let
|
let
|
||||||
|
# Get `signcolumn` setting value
|
||||||
value = config.plugins.oil.settings.win_options.signcolumn or null;
|
value = config.plugins.oil.settings.win_options.signcolumn or null;
|
||||||
isKnownBadStr = lib.lists.elem value [
|
|
||||||
|
# These valid values do not allow the sign column to use more than one column,
|
||||||
|
# So they are incompatible with oil-git-status.
|
||||||
|
badValue = builtins.elem value [
|
||||||
|
"no"
|
||||||
|
"number"
|
||||||
|
"auto"
|
||||||
|
"auto:1"
|
||||||
"yes"
|
"yes"
|
||||||
"yes:"
|
|
||||||
"yes:0"
|
|
||||||
"yes:1"
|
"yes:1"
|
||||||
];
|
];
|
||||||
hasYes = lib.strings.hasInfix "yes" value;
|
|
||||||
in
|
|
||||||
!(lib.strings.isString value && hasYes && !isKnownBadStr);
|
|
||||||
|
|
||||||
|
currentValueNote =
|
||||||
|
lib.optionalString (value != null)
|
||||||
|
"\n`${options.plugins.oil.settings}.win_options.signcolumn` is currently set to ${
|
||||||
|
lib.generators.toPretty { } value
|
||||||
|
}.";
|
||||||
|
in
|
||||||
|
{
|
||||||
|
when = builtins.isString value -> badValue;
|
||||||
message = ''
|
message = ''
|
||||||
This plugin requires the following `plugins.oil` setting:
|
This plugin requires `plugins.oil` is configured to allow at least 2 sign columns.${currentValueNote}
|
||||||
|
E.g:
|
||||||
${options.plugins.oil.settings} = {
|
${options.plugins.oil.settings} = {
|
||||||
win_options = {
|
win_options = {
|
||||||
signcolumn = "yes:2";
|
signcolumn = "yes:2";
|
||||||
};
|
};
|
||||||
};`
|
};`
|
||||||
|
See :h 'signcolumn' for more options
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
)
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -31,4 +31,19 @@
|
||||||
plugins.oil-git-status.enable = true;
|
plugins.oil-git-status.enable = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bad-signcolumn_yes = {
|
||||||
|
test.buildNixvim = false;
|
||||||
|
test.warnings = expect: [
|
||||||
|
(expect "count" 1)
|
||||||
|
(expect "any" "Nixvim (plugins.oil-git-status): This plugin requires `plugins.oil` is configured to allow at least 2 sign columns.")
|
||||||
|
(expect "any" "`plugins.oil.settings.win_options.signcolumn` is currently set to \"yes\".")
|
||||||
|
];
|
||||||
|
|
||||||
|
plugins.oil = {
|
||||||
|
enable = true;
|
||||||
|
# Should trigger the warning
|
||||||
|
settings.win_options.signcolumn = "yes";
|
||||||
|
};
|
||||||
|
plugins.oil-git-status.enable = true;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue