From 90341cf26d5f1193ebd586103e28a685e132fea6 Mon Sep 17 00:00:00 2001 From: Dmitriy Pleshevskiy Date: Wed, 15 May 2024 00:14:28 +0300 Subject: [PATCH] add more options --- modules/vim/options.nix | 320 +++++++++++++++++++++++++++++++++++----- 1 file changed, 279 insertions(+), 41 deletions(-) diff --git a/modules/vim/options.nix b/modules/vim/options.nix index f06c4e3..3f6a2df 100644 --- a/modules/vim/options.nix +++ b/modules/vim/options.nix @@ -1,8 +1,7 @@ { lib }: let - shared = with lib; with types; { - # global or window + sharedGlobalOrWindow = with lib; with types; { fillchars = mkOption { type = nullOr (listOf (enum [ "stl" @@ -32,8 +31,34 @@ let `:help fillchars` ''; }; + }; + + sharedGlobalOrBuffer = with lib; with types; { + autoread = mkOption { + type = nullOr bool; + default = null; + description = '' + When a file has been detected to have been changed outside of Vim and + it has not been changed inside of Vim, automatically read it again. + When the file has been deleted this is not done, so you have the text + from before it was deleted. When it appears again then it is read. + |timestamp| + + `:help autoread` + ''; + }; + + backupcopy = mkOption { + type = nullOr (listOf (enum [ "yes" "no" "auto" "breaksymlink" "breakhardlink" ])); + default = null; + description = '' + When writing a file and a backup is made, this option tells how it's + done. This is a comma-separated list of words. + + `:help backupcopy` + ''; + }; - # global or buffer formatprg = mkOption { type = nullOr string; default = null; @@ -47,7 +72,6 @@ let ''; }; - # global or buffer grepprg = mkOption { type = nullOr string; default = null; @@ -59,7 +83,6 @@ let ''; }; - # global or buffer include = mkOption { type = nullOr string; default = null; @@ -71,7 +94,6 @@ let ''; }; - # global or buffer keywordprg = mkOption { type = nullOr string; default = null; @@ -86,7 +108,6 @@ let ''; }; - # global or buffer lispwords = mkOption { type = nullOr (listOf string); default = null; @@ -98,11 +119,24 @@ let `:help lispwords` ''; }; + + makeencoding = mkOption { + type = nullOr string; + default = null; + defaultText = ""; + description = '' + Encoding used for reading the output of external commands. When empty, + encoding is not converted. + This is used for `:make`, `:lmake`, `:grep`, `:lgrep`, `:grepadd`, + `:lgrepadd`, `:cfile`, `:cgetfile`, `:caddfile`, `:lfile`, `:lgetfile`, + and `:laddfile`. + + `:help makeencoding` + ''; + }; }; - global = with lib; with types; { - inherit (shared) fillchars formatprg grepprg include keywordprg lispwords; - + global = with lib; with types; sharedGlobalOrWindow // sharedGlobalOrBuffer // { allowrevins = mkOption { type = nullOr bool; default = null; @@ -114,6 +148,7 @@ let `:help allowrevins` ''; }; + ambiwidth = mkOption { type = nullOr (enum [ "single" "double" ]); default = null; @@ -125,6 +160,7 @@ let `:help ambiwidth` ''; }; + autochdir = mkOption { type = nullOr bool; default = null; @@ -139,19 +175,17 @@ let `:help autochdir` ''; }; - # TODO: arabic, arabicshape - # TODO: autoindent - autoread = mkOption { + + arabicshape = mkOption { type = nullOr bool; default = null; + defaultText = literalExpression "false"; description = '' - When a file has been detected to have been changed outside of Vim and - it has not been changed inside of Vim, automatically read it again. - When the file has been deleted this is not done, so you have the text - from before it was deleted. When it appears again then it is read. - |timestamp| + When on and 'termbidi' is off, the required visual character + corrections that need to take place for displaying the Arabic language + take effect. - `:help autoread` + `:help arabicshape` ''; }; @@ -233,17 +267,6 @@ let ''; }; - backupcopy = mkOption { - type = nullOr (listOf (enum [ "yes" "no" "auto" "breaksymlink" "breakhardlink" ])); - default = null; - description = '' - When writing a file and a backup is made, this option tells how it's - done. This is a comma-separated list of words. - - `:help backupcopy` - ''; - }; - backupdir = mkOption { type = nullOr (listOf (either string path)); default = null; @@ -341,9 +364,6 @@ let ''; }; - # TODO: binary - # TODO: bomb - breakat = mkOption { type = nullOr string; default = null; @@ -354,7 +374,6 @@ let `:help breakat` ''; }; - # TODO: breakindent, breakindentopt browsedir = mkOption { type = nullOr (either path (enum [ "last" "buffer" "current" ])); @@ -370,8 +389,6 @@ let ''; }; - # TODO: bufhidden, buflisted, buftype - casemap = mkOption { type = nullOr (listOf (enum [ "internal" "keepascii" ])); default = null; @@ -399,6 +416,19 @@ let ''; }; + charconvert = mkOption { + type = nullOr string; + default = null; + defaultText = ""; + description = '' + An expression that is used for character encoding conversion. It is + evaluated when a file that is to be read or has been written has a + different encoding from what is desired. + + `:help charconvert` + ''; + }; + clipboard = mkOption { type = nullOr (listOf (enum [ "unnamed" "unnamedplus" ])); default = null; @@ -1289,8 +1319,54 @@ let }; }; - window = with lib; with types; { - inherit (shared) fillchars; + window = with lib; with types; sharedGlobalOrWindow // { + arabic = mkOption { + type = nullOr bool; + default = null; + defaultText = literalExpression "false"; + description = '' + This option can be set to start editing Arabic text. + + `:help arabic` + ''; + }; + + breakindent = mkOption { + type = nullOr bool; + default = null; + defaultText = literalExpression "false"; + description = '' + Every wrapped line will continue visually indented (same amount of + space as the beginning of that line), thus preserving horizontal blocks + of text. + + `:help breakindent` + ''; + }; + + breakindentopt = mkOption { + type = nullOr commas; + default = null; + defaultText = literalExpression "[]"; + description = '' + Settings for 'breakindent + + `:help breakindentopt` + ''; + }; + + colorcolumn = mkOption { + type = nullOr commas; + default = null; + defaultText = literalExpression "[]"; + description = '' + 'colorcolumn' is a comma-separated list of screen columns that are + highlighted with ColorColumn |hl-ColorColumn|. Useful to align + text. Will make screen redrawing slower. + + `:help colorcolumn` + ''; + }; foldcolumn = mkOption { type = nullOr string; @@ -1472,7 +1548,7 @@ let apply = x: assert ( (stringLength x >= min && stringLength x <= max) - || abort '' + || abort '' The number of characters ${x} does not correspond to the boundaries (min: ${toString min}; max: ${toString max}) '' @@ -1594,8 +1670,170 @@ let }; }; - buffer = with lib; with types; { - inherit (shared) formatprg grepprg include keywordprg lispwords; + buffer = with lib; with types; sharedGlobalOrBuffer // { + autoindent = mkOption { + type = nullOr bool; + default = null; + defaultText = literalExpression "true"; + description = '' + Copy indent from current line when starting a new line (typing + in Insert mode or when using the "o" or "O" command). If you do not + type anything on the new line except or CTRL-D and then type + , CTRL-O or , the indent is deleted again. + + `:help autoindent` + ''; + }; + + binary = mkOption { + type = nullOr bool; + default = null; + defaultText = literalExpression "false"; + description = '' + This option should be set before editing a binary file. You can also + use the |-b| Vim argument. + + `:help binary` + ''; + }; + + bomb = mkOption { + type = nullOr bool; + default = null; + defaultText = literalExpression "false"; + description = '' + When writing a file and the following conditions are met, a BOM (Byte + Order Mark) is prepended to the file: + - this option is on + - the 'binary' option is off + - 'fileencoding' is "utf-8", "ucs-2", "ucs-4" or one of the little/big + endian variants. + + `:help bomb` + ''; + }; + + bufhidden = mkOption { + type = nullOr (enum [ "" "hide" "unload" "delete" "wipe" ]); + default = null; + defaultText = ""; + description = '' + This option specifies what happens when a buffer is no longer + displayed in a window + + `:help bufhidden` + ''; + }; + + buflisted = mkOption { + type = nullOr bool; + default = null; + defaultText = literalExpression "true"; + description = '' + When this option is set, the buffer shows up in the buffer list. + + `:help buflisted` + ''; + }; + + buftype = mkOption { + type = nullOr (enum [ "" "acwrite" "help" "nofile" "nowrite" "quickfix" "terminal" "prompt" ]); + default = null; + defaultText = ""; + description = '' + This option is used together with 'bufhidden' and 'swapfile' to + specify special kinds of buffers. + + `:help buftype` + `:help special-buffers` + ''; + }; + + cindent = mkOption { + type = nullOr bool; + default = null; + defaultText = literalExpression "false"; + description = '' + Enables automatic C program indenting. + + `:help cindent` + ''; + }; + + cinkeys = mkOption { + type = nullOr string; + default = null; + defaultText = "0{,0},0),0],:,0#,!^F,o,O,e"; + description = '' + A list of keys that, when typed in Insert mode, cause reindenting of + the current line. + + `:help cinkeys` + ''; + }; + + cinoptions = mkOption { + type = nullOr string; + default = null; + defaultText = ""; + description = '' + The 'cinoptions' affect the way 'cindent' reindents lines in a C + program. + + `:help cinoptions` + `:help cinoptions-values` + ''; + }; + + cinwords = mkOption { + type = nullOr commas; + default = null; + defaultText = literalExpression ''["if" "else" "while" "do" "for" "switch"]''; + descrpition = '' + These keywords start an extra indent in the next line when + 'smartindent' or 'cindent' is set. For 'cindent' this is only done at + an appropriate place (inside {}). + + `:help cinwords` + ''; + }; + + cinscopedecls = mkOption { + type = nullOr commas; + default = null; + defaultText = literalExpression ''["public" "protected" "private"]''; + descrpition = '' + Keywords that are interpreted as a C++ scope declaration by |cino-g|. + Useful e.g. for working with the Qt framework that defines additional + scope declarations "signals", "public slots" and "private slots" + + `:help cinscopedecls` + ''; + }; + + comments = mkOption { + type = nullOr commas; + default = null; + defaultText = literalExpression '' + [ + "s1/*" + "mb:8" + "ex:*/" + "://" + "b:#" + ":%" + ":XCOMM" + "n:>" + "fb:-" + ] + ''; + description = '' + list of strings that can start a comment line. + + `:help comments` + `:help format-comments` + ''; + }; expandtab = mkOption { type = nullOr bool;