diff --git a/modules/neovim/init/basic.nix b/modules/neovim/init/basic.nix index f91ea9a1..532ebcea 100644 --- a/modules/neovim/init/basic.nix +++ b/modules/neovim/init/basic.nix @@ -5,6 +5,7 @@ }: let inherit (lib.options) mkOption mkEnableOption literalMD; inherit (lib.strings) optionalString; + inherit (lib.attrsets) optionalAttrs; inherit (lib.types) enum bool str int either; inherit (lib.generators) mkLuaInline; inherit (lib.nvim.dag) entryAfter; @@ -94,55 +95,55 @@ in { # Set options that were previously interpolated in 'luaConfigRC.basic' as vim.options (vim.o) # and 'vim.globals' (vim.g). Future options, if possible, should be added here instead of the # luaConfigRC section below. - options = pushDownDefault { - # Options that are always set, with a lower priority - encoding = "utf-8"; - hidden = true; - expandtab = true; + options = pushDownDefault (lib.mergeAttrsList [ + { + # Options that are always set, with a lower priority + encoding = "utf-8"; + hidden = true; + expandtab = true; - # Junkfile Behaviour - swapfile = !cfg.preventJunkFiles; - backup = !cfg.preventJunkFiles; - writebackup = !cfg.preventJunkFiles; - }; + # Junkfile Behaviour + swapfile = !cfg.preventJunkFiles; + backup = !cfg.preventJunkFiles; + writebackup = !cfg.preventJunkFiles; + } - # Options that are more difficult to set through 'vim.options'. Fear not, though - # as the Lua DAG is still as powerful as it could be. + (optionalAttrs cfg.undoFile.enable { + undofile = true; + undodir = cfg.undoFile.path; + }) + + (optionalAttrs (cfg.bell == "none") { + errorbells = false; + visualbell = false; + }) + + (optionalAttrs (cfg.bell == "on") { + visualbell = false; + }) + + (optionalAttrs (cfg.bell == "visual") { + visualbell = false; + }) + + (optionalAttrs (cfg.lineNumberMode == "relative") { + relativenumber = true; + }) + + (optionalAttrs (cfg.lineNumberMode == "number") { + number = true; + }) + + (optionalAttrs (cfg.lineNumberMode == "relNumber") { + number = true; + relativenumber = true; + }) + ]); + + # Options that are more difficult to set through 'vim.options'. Namely, appending values + # to pre-set Neovim options. Fear not, though as the Lua DAG is still as powerful as it + # could be. luaConfigRC.basic = entryAfter ["globalsScript"] '' - -- Settings that are set for everything - vim.opt.shortmess:append("c") - - ${optionalString cfg.undoFile.enable '' - vim.o.undofile = true - vim.o.undodir = ${toLuaObject cfg.undoFile.path} - ''} - - ${optionalString (cfg.bell == "none") '' - vim.o.errorbells = false - vim.o.visualbell = false - ''} - - ${optionalString (cfg.bell == "on") '' - vim.o.visualbell = false - ''} - - ${optionalString (cfg.bell == "visual") '' - vim.o.errorbells = false - ''} - - ${optionalString (cfg.lineNumberMode == "relative") '' - vim.o.relativenumber = true - ''} - - ${optionalString (cfg.lineNumberMode == "number") '' - vim.o.number = true - ''} - - ${optionalString (cfg.lineNumberMode == "relNumber") '' - vim.o.number = true - vim.o.relativenumber = true - ''} - ${optionalString cfg.useSystemClipboard '' vim.opt.clipboard:append("unnamedplus") ''} diff --git a/modules/wrapper/rc/options.nix b/modules/wrapper/rc/options.nix index 8fff005d..d82fc741 100644 --- a/modules/wrapper/rc/options.nix +++ b/modules/wrapper/rc/options.nix @@ -235,7 +235,8 @@ in { if isBool x then toVimBool x # convert to a yes/no str else x; - description = "Show the sign column" + description = "Show the sign column"; + }; tabstop = mkOption { type = int;