Compare commits

...

2 commits

Author SHA1 Message Date
4f8b523579
lib/types: add extCommasEnum...
that convert enum or list of enum to commas
2024-05-17 13:25:36 +03:00
49b7045c56
lib/types: add extCommas...
that support str and list of str
2024-05-17 13:20:16 +03:00
4 changed files with 59 additions and 47 deletions

View file

@ -1,9 +1,20 @@
{ lib, nix2lua }:
let
extendCommasTypeWith = t:
with lib.types;
coercedTo
(either (listOf t) t)
(x: lib.concatStringsSep "," (lib.toList x))
commas;
extCommas = extendCommasTypeWith lib.types.str;
extCommasEnum = variants: extendCommasTypeWith (lib.types.enum variants);
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 +155,6 @@ let
});
in
{
inherit extCommas extCommasEnum;
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

@ -24,7 +24,7 @@ let
sharedGlobalOrWindow = with lib.types; {
fillchars = {
type = listOf (enum [
type = extCommasEnum [
"stl"
"stlnc"
"wbr"
@ -43,7 +43,7 @@ let
"msgsep"
"eob"
"lastline"
]);
];
vimDefault = [ ];
description = ''
Characters to fill the statuslines, vertical separators and special lines in the window.
@ -100,7 +100,7 @@ let
};
virtualedit = {
type = listOf (enum [ "block" "insert" "all" "onemore" "none" "NONE" ]);
type = extCommasEnum [ "block" "insert" "all" "onemore" "none" "NONE" ];
vimDefault = [ ];
description = ''
Virtual editing means that the cursor can be positioned where there is
@ -144,7 +144,7 @@ let
};
backupcopy = {
type = listOf (enum [ "yes" "no" "auto" "breaksymlink" "breakhardlink" ]);
type = extCommasEnum [ "yes" "no" "auto" "breaksymlink" "breakhardlink" ];
vimDefault = [ "auto" ];
description = ''
When writing a file and a backup is made, this option tells how it's
@ -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
@ -457,7 +457,7 @@ let
};
backspace = {
type = listOf (enum [ "indent" "eol" "start" "nostop" ]);
type = extCommasEnum [ "indent" "eol" "start" "nostop" ];
vimDefault = [ "indent" "eol" "start" ];
description = ''
Influences the working of <BS>, <Del>, CTRL-W and CTRL-U in Insert
@ -521,7 +521,7 @@ let
};
belloff = {
type = listOf (enum [
type = extCommasEnum [
"all"
"backspace"
"cursor"
@ -539,7 +539,7 @@ let
"shell"
"spell"
"willmode"
]);
];
vimDefault = [ "all" ];
description = ''
Specifies for which events the bell will not be rung. It is a comma-
@ -596,7 +596,7 @@ let
};
casemap = {
type = listOf (enum [ "internal" "keepascii" ]);
type = extCommasEnum [ "internal" "keepascii" ];
vimDefault = [ "internal" "keepascii" ];
description = ''
Specifies details about changing the case of letters. It may contain
@ -654,14 +654,14 @@ let
};
completeopt = {
type = listOf (enum [
type = extCommasEnum [
"menu"
"menuone"
"longest"
"preview"
"noinsert"
"noselect"
]);
];
vimDefault = [ "menu" "preview" ];
description = ''
A comma-separated list of options for Insert mode completion |ins-completion|.
@ -695,7 +695,7 @@ let
};
debug = {
type = listOf (enum [ "msg" "throw" "beep" ]);
type = extCommasEnum [ "msg" "throw" "beep" ];
vimDefault = [ ];
description = ''
These values can be used:
@ -756,7 +756,7 @@ let
};
display = {
type = listOf (enum [ "lastline" "truncate" "uhex" "msgsep" ]);
type = extCommasEnum [ "lastline" "truncate" "uhex" "msgsep" ];
vimDefault = [ "lastline" ];
description = ''
Change the way text is displayed.
@ -850,7 +850,7 @@ let
};
fileformats = {
type = listOf (enum [ "dos" "unix" "mac" ]);
type = extCommasEnum [ "dos" "unix" "mac" ];
vimDefault = ''
Windows default: ["dos" "unix"],
Unix default: ["unix" "dos"]
@ -896,7 +896,7 @@ let
};
foldopen = {
type = listOf (enum [
type = extCommasEnum [
"all"
"block"
"hor"
@ -908,7 +908,7 @@ let
"search"
"tag"
"undo"
]);
];
vimDefault = [
"block"
"hor"
@ -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
@ -1640,7 +1640,7 @@ let
};
redrawdebug = {
type = listOf (enum [ "compositor" "line" "flush" "nothrottle" "invalid" "nodelta" ]);
type = extCommasEnum [ "compositor" "line" "flush" "nothrottle" "invalid" "nodelta" ];
vimDefault = [ ];
description = ''
Flags to change the way redrawing works, for debugging purposes.
@ -1748,7 +1748,7 @@ let
};
scrollopt = {
type = listOf (enum [ "ver" "hor" "jump" ]);
type = extCommasEnum [ "ver" "hor" "jump" ];
vimDefault = [ "ver" "jump" ];
description = ''
This is a comma-separated list of words that specifies how
@ -1769,7 +1769,7 @@ let
};
sessionoptions = {
type = listOf (enum [
type = extCommasEnum [
"blank"
"buffers"
"curdir"
@ -1785,7 +1785,7 @@ let
"terminal"
"winpos"
"winsize"
]);
];
vimDefault = [
"blank"
"buffers"
@ -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
@ -2214,7 +2214,7 @@ let
};
switchbuf = {
type = listOf (enum [ "useopen" "usetab" "split" "vsplit" "newtab" "uselast" ]);
type = extCommasEnum [ "useopen" "usetab" "split" "vsplit" "newtab" "uselast" ];
vimDefault = [ "uselast" ];
description = ''
This option controls the behavior when switching between buffers.
@ -2311,7 +2311,7 @@ let
};
termpastefilter = {
type = listOf (enum [ "BS" "HT" "FF" "ESC" "DEL" "C0" "C1" ]);
type = extCommasEnum [ "BS" "HT" "FF" "ESC" "DEL" "C0" "C1" ];
vimDefault = [ "BS" "HT" "ESC" "DEL" ];
description = ''
list of options for specifying control characters
@ -2530,7 +2530,7 @@ let
};
viewoptions = {
type = listOf (enum [ "cursor" "curdir" "folds" "options" "localoptions" "slash" "unix" ]);
type = extCommasEnum [ "cursor" "curdir" "folds" "options" "localoptions" "slash" "unix" ];
vimDefault = [ "folds" "cursor" "curdir" ];
description = ''
Changes the effect of the |:mkview| command.
@ -2557,7 +2557,7 @@ let
};
whichwrap = {
type = listOf (enum [ "b" "s" "h" "l" "<" ">" "~" "[" "]" ]);
type = extCommasEnum [ "b" "s" "h" "l" "<" ">" "~" "[" "]" ];
vimDefault = [ "b" "s" ];
description = ''
Allow specified keys that move the cursor left/right to move to the
@ -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
@ -2672,7 +2672,7 @@ let
};
wildoptions = {
type = listOf (enum [ "fuzzy" "pum" "tagfile" ]);
type = extCommasEnum [ "fuzzy" "pum" "tagfile" ];
vimDefault = [ "pum" "tagfile" ];
description = ''
A list of words that change how |cmdline-completion| is done.
@ -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
@ -2953,7 +2953,7 @@ let
};
cursorlineopt = {
type = listOf (enum [ "line" "screenline" "number" "both" ]);
type = extCommasEnum [ "line" "screenline" "number" "both" ];
vimDefault = [ "number" "line" ];
description = ''
list of settings for how 'cursorline' is displayed.
@ -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.
@ -3889,7 +3889,7 @@ let
};
nrformats = {
type = listOf (enum [ "alpha" "octal" "hex" "bin" "unsigned" ]);
type = extCommasEnum [ "alpha" "octal" "hex" "bin" "unsigned" ];
vimDefault = [ "bin" "hex" ];
description = ''
This defines what bases Vim will consider for numbers when using the
@ -4052,7 +4052,7 @@ let
};
spelloptions = {
type = listOf (enum [ "camel" "noplainbuffer" ]);
type = extCommasEnum [ "camel" "noplainbuffer" ];
vimDefault = [ ];
description = ''
list of options for spell checking:
@ -4068,7 +4068,7 @@ let
};
suffixesadd = {
type = commas;
type = extCommas;
vimDefault = [ ];
description = ''
list of suffixes, which are used when searching for a