lib/types: add extCommas...

that support str and list of str
This commit is contained in:
Dmitriy Pleshevskiy 2024-05-17 13:20:16 +03:00
parent 030b20da7d
commit 49b7045c56
Signed by: pleshevskiy
GPG key ID: 17041163DA10A9A2
4 changed files with 28 additions and 20 deletions

View file

@ -1,9 +1,16 @@
{ lib, nix2lua }:
let
extCommas = with lib.types;
coercedTo
(either (listOf str) commas)
(x: lib.concatStringsSep "," (lib.toList x))
commas;
modeEnum = lib.types.enum [ "" "n" "!" "i" "c" "v" "x" "s" "o" "t" "l" ];
mode = with lib.types; either modeEnum (uniq (listOf modeEnum));
# TODO: maybe add more options and add descriptions from
# :help vim.keymap.set
# :help nvim_set_keymap
@ -144,5 +151,6 @@ let
});
in
{
inherit extCommas;
inherit mode keymap;
}

View file

@ -25,8 +25,8 @@ let cfg = config.plugins.style.neoformat; in
autoformat = {
enable = mkEnableOption "Autoformat on save file";
pattern = {
type = commas;
pattern = mkOption {
type = types.extCommas;
default = "*";
};
};

View file

@ -2,7 +2,7 @@
with lib.nix2lua;
let
inherit (lib.mod) Space cmd ctrl leader localLeader;
inherit (lib.mod) Space cmd leader localLeader;
gs = config.plugin.gitsigns-nvim.varName;
hop = config.plugin.hop-nvim.varName;
in

View file

@ -271,7 +271,7 @@ let
};
path = {
type = commas;
type = extCommas;
vimDefault = ''
on Unix: ".,/usr/include,,"
other systems: ".,,"
@ -300,7 +300,7 @@ let
};
tags = {
type = commas;
type = extCommas;
vimDefault = [ "./tags;" "tags" ];
description = ''
Filenames for the tag command, separated by spaces or commas. To
@ -1493,7 +1493,7 @@ let
};
mousescroll = {
type = commas;
type = extCommas;
vimDefault = [ "ver:3" "hor:6" ];
description = ''
This option controls the number of lines / columns to scroll by when
@ -1504,7 +1504,7 @@ let
};
mouseshape = {
type = commas;
type = extCommas;
vimDefault = [ "i:beam" "r:beam" "s:updown" "sd:cross" "m:no" "ml:up-arrow" "v:rightup-arrow" ];
description = ''
This option tells Vim what the mouse pointer should look like in
@ -1809,7 +1809,7 @@ let
};
shada = {
type = commas;
type = extCommas;
vimDefault = ''
Win32: !,'100,<50,s10,h,rA:,rB:
others: !,'100,<50,s10,h)
@ -2145,7 +2145,7 @@ let
};
spellsuggest = {
type = commas;
type = extCommas;
vimDefault = [ "best" ];
description = ''
Methods used for spelling suggestions. Both for the |z=| command and
@ -2204,7 +2204,7 @@ let
};
suffixes = {
type = commas;
type = extCommas;
vimDefault = [ ".bak" "~" ".o" ".h" ".info" ".swp" ".obj" ];
description = ''
Files with these suffixes get a lower priority when multiple files
@ -2603,7 +2603,7 @@ let
};
wildignore = {
type = commas;
type = extCommas;
vimDefault = [ ];
description = ''
A list of file patterns. A file that matches with one of these
@ -2880,7 +2880,7 @@ let
};
breakindentopt = {
type = commas;
type = extCommas;
vimDefault = [ ];
description = ''
Settings for 'breakindent
@ -2888,7 +2888,7 @@ let
};
colorcolumn = {
type = commas;
type = extCommas;
vimDefault = [ ];
description = ''
'colorcolumn' is a comma-separated list of screen columns that are
@ -3382,7 +3382,7 @@ let
};
winhighlight = {
type = commas;
type = extCommas;
vimDefault = [ ];
description = ''
Window-local highlights. Comma-delimited list of highlight
@ -3537,7 +3537,7 @@ let
};
cinwords = {
type = commas;
type = extCommas;
vimDefault = [ "if" "else" "while" "do" "for" "switch" ];
description = ''
These keywords start an extra indent in the next line when
@ -3547,7 +3547,7 @@ let
};
cinscopedecls = {
type = commas;
type = extCommas;
vimDefault = [ "public" "protected" "private" ];
description = ''
Keywords that are interpreted as a C++ scope declaration by |cino-g|.
@ -3557,7 +3557,7 @@ let
};
comments = {
type = commas;
type = extCommas;
vimDefault = ''
[
"s1/*"
@ -3589,7 +3589,7 @@ let
};
complete = {
type = commas;
type = extCommas;
vimDefault = [ "." "w" "b" "u" "t" ];
description = ''
This option specifies how keyword completion |ins-completion| works
@ -3856,7 +3856,7 @@ let
};
matchpairs = {
type = commas;
type = extCommas;
vimDefault = [ "(:)" "{:}" "[:]" ];
description = ''
Characters that form pairs. The |%| command jumps from one to the other.
@ -4068,7 +4068,7 @@ let
};
suffixesadd = {
type = commas;
type = extCommas;
vimDefault = [ ];
description = ''
list of suffixes, which are used when searching for a