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 }: { lib, nix2lua }:
let 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" ]; modeEnum = lib.types.enum [ "" "n" "!" "i" "c" "v" "x" "s" "o" "t" "l" ];
mode = with lib.types; either modeEnum (uniq (listOf modeEnum)); mode = with lib.types; either modeEnum (uniq (listOf modeEnum));
# TODO: maybe add more options and add descriptions from # TODO: maybe add more options and add descriptions from
# :help vim.keymap.set # :help vim.keymap.set
# :help nvim_set_keymap # :help nvim_set_keymap
@ -144,5 +151,6 @@ let
}); });
in in
{ {
inherit extCommas;
inherit mode keymap; inherit mode keymap;
} }

View file

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

View file

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

View file

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