diff --git a/modules/autocmd.nix b/modules/autocmd.nix index 8b9cd76a..2d980c1c 100644 --- a/modules/autocmd.nix +++ b/modules/autocmd.nix @@ -4,11 +4,10 @@ config, ... }: -with lib; { options = { - autoGroups = mkOption { - type = types.attrsOf helpers.autocmd.autoGroupOption; + autoGroups = lib.mkOption { + type = lib.types.attrsOf helpers.autocmd.autoGroupOption; default = { }; description = "augroup definitions"; example = { @@ -18,8 +17,8 @@ with lib; }; }; - autoCmd = mkOption { - type = types.listOf helpers.autocmd.autoCmdOption; + autoCmd = lib.mkOption { + type = lib.types.listOf helpers.autocmd.autoCmdOption; default = [ ]; description = "autocmd definitions"; example = [ @@ -42,12 +41,12 @@ with lib; let inherit (config) autoGroups autoCmd; in - mkIf (autoGroups != { } || autoCmd != [ ]) { + lib.mkIf (autoGroups != { } || autoCmd != [ ]) { # Introduced early October 2023. # TODO remove in early December 2023. assertions = [ { - assertion = all (x: x.description == null) autoCmd; + assertion = lib.all (x: x.description == null) autoCmd; message = '' RENAMED OPTION: `autoCmd[].description` has been renamed `autoCmd[].desc`. Please update your configuration. @@ -56,7 +55,7 @@ with lib; ]; extraConfigLuaPost = - (optionalString (autoGroups != { }) '' + (lib.optionalString (autoGroups != { }) '' -- Set up autogroups {{ do local __nixvim_autogroups = ${helpers.toLuaObject autoGroups} @@ -67,7 +66,7 @@ with lib; end -- }} '') - + (optionalString (autoCmd != [ ]) '' + + (lib.optionalString (autoCmd != [ ]) '' -- Set up autocommands {{ do local __nixvim_autocommands = ${helpers.toLuaObject autoCmd} diff --git a/modules/clipboard.nix b/modules/clipboard.nix index f8cbce07..9b7324e4 100644 --- a/modules/clipboard.nix +++ b/modules/clipboard.nix @@ -4,30 +4,29 @@ pkgs, ... }: -with lib; let cfg = config.clipboard; in { options = { clipboard = { - register = mkOption { + register = lib.mkOption { description = '' Sets the register to use for the clipboard. Learn more in [`:h 'clipboard'`](https://neovim.io/doc/user/options.html#'clipboard'). ''; - type = with types; nullOr (either str (listOf str)); + type = with lib.types; nullOr (either str (listOf str)); default = null; example = "unnamedplus"; }; - providers = mkOption { - type = types.submodule { + providers = lib.mkOption { + type = lib.types.submodule { options = - mapAttrs + lib.mapAttrs (name: packageName: { - enable = mkEnableOption name; - package = mkPackageOption pkgs packageName { }; + enable = lib.mkEnableOption name; + package = lib.mkPackageOption pkgs packageName { }; }) { wl-copy = "wl-clipboard"; @@ -45,8 +44,10 @@ in }; config = { - opts.clipboard = mkIf (cfg.register != null) cfg.register; + opts.clipboard = lib.mkIf (cfg.register != null) cfg.register; - extraPackages = mapAttrsToList (n: v: v.package) (filterAttrs (n: v: v.enable) cfg.providers); + extraPackages = lib.mapAttrsToList (n: v: v.package) ( + lib.filterAttrs (n: v: v.enable) cfg.providers + ); }; } diff --git a/modules/colorscheme.nix b/modules/colorscheme.nix index 8a097aec..e42f3fc2 100644 --- a/modules/colorscheme.nix +++ b/modules/colorscheme.nix @@ -1,15 +1,14 @@ { config, lib, ... }: -with lib; { options = { - colorscheme = mkOption { - type = types.nullOr types.str; + colorscheme = lib.mkOption { + type = lib.types.nullOr lib.types.str; description = "The name of the colorscheme to use"; default = null; }; }; - config = mkIf (config.colorscheme != "" && config.colorscheme != null) { + config = lib.mkIf (config.colorscheme != "" && config.colorscheme != null) { extraConfigVim = '' colorscheme ${config.colorscheme} ''; diff --git a/modules/commands.nix b/modules/commands.nix index ebf730af..d1fda785 100644 --- a/modules/commands.nix +++ b/modules/commands.nix @@ -4,18 +4,17 @@ config, ... }: -with lib; let - commandAttributes = types.submodule { + commandAttributes = lib.types.submodule { options = { - command = mkOption { + command = lib.mkOption { type = with helpers.nixvimTypes; either str rawLua; description = "The command to run."; }; nargs = helpers.mkNullOrOption - (types.enum [ + (lib.types.enum [ 0 1 "*" @@ -25,13 +24,13 @@ let '' The number of arguments to expect, see :h command-nargs. ''; - complete = helpers.mkNullOrOption (with types; either str helpers.nixvimTypes.rawLua) '' + complete = helpers.mkNullOrOption (with lib.types; either str helpers.nixvimTypes.rawLua) '' Tab-completion behaviour, see :h command-complete. ''; range = helpers.mkNullOrOption ( - with types; + with lib.types; oneOf [ bool int @@ -41,10 +40,10 @@ let '' Whether the command accepts a range, see :h command-range. ''; - count = helpers.mkNullOrOption (with types; either bool int) '' + count = helpers.mkNullOrOption (with lib.types; either bool int) '' Whether the command accepts a count, see :h command-range. ''; - addr = helpers.mkNullOrOption types.str '' + addr = helpers.mkNullOrOption lib.types.str '' Whether special characters relate to other things, see :h command-addr. ''; bang = helpers.defaultNullOpts.mkBool false "Whether this command can take a bang (!)."; @@ -59,8 +58,8 @@ let }; in { - options.userCommands = mkOption { - type = types.attrsOf commandAttributes; + options.userCommands = lib.mkOption { + type = lib.types.attrsOf commandAttributes; default = { }; description = "A list of user commands to add to the configuration."; }; @@ -69,12 +68,12 @@ in let cleanupCommand = _: cmd: { inherit (cmd) command; - options = filterAttrs (name: _: name != "command") cmd; + options = lib.filterAttrs (name: _: name != "command") cmd; }; in - mkIf (config.userCommands != { }) { + lib.mkIf (config.userCommands != { }) { extraConfigLua = helpers.wrapDo '' - local cmds = ${helpers.toLuaObject (mapAttrs cleanupCommand config.userCommands)}; + local cmds = ${helpers.toLuaObject (lib.mapAttrs cleanupCommand config.userCommands)}; for name,cmd in pairs(cmds) do vim.api.nvim_create_user_command(name, cmd.command, cmd.options or {}) end diff --git a/modules/diagnostics.nix b/modules/diagnostics.nix index 189e525f..e850cb49 100644 --- a/modules/diagnostics.nix +++ b/modules/diagnostics.nix @@ -4,11 +4,10 @@ config, ... }: -with lib; { options = { - diagnostics = mkOption { - type = with types; attrsOf anything; + diagnostics = lib.mkOption { + type = with lib.types; attrsOf anything; default = { }; description = "The configuration diagnostic options, provided to `vim.diagnostic.config`."; example = { @@ -19,7 +18,7 @@ with lib; }; config = { - extraConfigLuaPre = mkIf (config.diagnostics != { }) '' + extraConfigLuaPre = lib.mkIf (config.diagnostics != { }) '' vim.diagnostic.config(${helpers.toLuaObject config.diagnostics}) ''; }; diff --git a/modules/editorconfig.nix b/modules/editorconfig.nix index 7d93278c..52d4f410 100644 --- a/modules/editorconfig.nix +++ b/modules/editorconfig.nix @@ -1,5 +1,4 @@ { lib, config, ... }: -with lib; { imports = [ (lib.mkRenamedOptionModule @@ -21,14 +20,14 @@ with lib; ]; options.editorconfig = { - enable = mkOption { - type = types.bool; + enable = lib.mkOption { + type = lib.types.bool; default = true; description = "editorconfig plugin for neovim"; }; - properties = mkOption { - type = types.attrsOf types.str; + properties = lib.mkOption { + type = lib.types.attrsOf lib.types.str; default = { }; description = '' The table key is a property name and the value is a callback function which accepts the @@ -55,7 +54,7 @@ with lib; cfg = config.editorconfig; in { - globals.editorconfig = mkIf (!cfg.enable) false; + globals.editorconfig = lib.mkIf (!cfg.enable) false; extraConfigLua = let @@ -64,7 +63,7 @@ with lib; ''; propertiesString = lib.concatLines (lib.mapAttrsToList mkProperty cfg.properties); in - mkIf (propertiesString != "" && cfg.enable) '' + lib.mkIf (propertiesString != "" && cfg.enable) '' do local __editorconfig = require('editorconfig') diff --git a/modules/filetype.nix b/modules/filetype.nix index f1653552..53da1205 100644 --- a/modules/filetype.nix +++ b/modules/filetype.nix @@ -4,8 +4,9 @@ config, ... }: -with lib; let + inherit (lib) types; + cfg = config.filetype; filetypeDefinition = helpers.mkNullOrOption ( @@ -19,7 +20,7 @@ let (listOf ( either str (submodule { options = { - priority = mkOption { + priority = lib.mkOption { type = ints.unsigned; description = '' Filename patterns can specify an optional priority to resolve cases when a file path diff --git a/modules/highlights.nix b/modules/highlights.nix index 1a0280ae..08077567 100644 --- a/modules/highlights.nix +++ b/modules/highlights.nix @@ -4,11 +4,10 @@ config, ... }: -with lib; { options = { - highlight = mkOption { - type = types.attrsOf helpers.nixvimTypes.highlight; + highlight = lib.mkOption { + type = lib.types.attrsOf helpers.nixvimTypes.highlight; default = { }; description = "Define new highlight groups"; example = { @@ -16,8 +15,8 @@ with lib; }; }; - highlightOverride = mkOption { - type = types.attrsOf helpers.nixvimTypes.highlight; + highlightOverride = lib.mkOption { + type = lib.types.attrsOf helpers.nixvimTypes.highlight; default = { }; description = "Define highlight groups to override existing highlight"; example = { @@ -25,8 +24,8 @@ with lib; }; }; - match = mkOption { - type = types.attrsOf types.str; + match = lib.mkOption { + type = lib.types.attrsOf lib.types.str; default = { }; description = "Define match groups"; example = { @@ -35,10 +34,10 @@ with lib; }; }; - config = mkMerge [ + config = lib.mkMerge [ { extraConfigLuaPre = - mkIf (config.highlight != { }) + lib.mkIf (config.highlight != { }) # lua '' -- Highlight groups {{ @@ -52,7 +51,7 @@ with lib; -- }} ''; extraConfigLuaPost = - mkIf (config.highlightOverride != { }) + lib.mkIf (config.highlightOverride != { }) # lua '' -- Highlight groups {{ @@ -68,7 +67,7 @@ with lib; } { extraConfigLuaPre = - mkIf (config.match != { }) + lib.mkIf (config.match != { }) # lua '' -- Match groups {{ diff --git a/modules/keymaps.nix b/modules/keymaps.nix index 5349d3c4..1fe874de 100644 --- a/modules/keymaps.nix +++ b/modules/keymaps.nix @@ -5,11 +5,10 @@ options, ... }: -with lib; { options = { - keymaps = mkOption { - type = types.listOf helpers.keymaps.deprecatedMapOptionSubmodule; + keymaps = lib.mkOption { + type = lib.types.listOf helpers.keymaps.deprecatedMapOptionSubmodule; default = [ ]; description = "Nixvim keymaps."; example = [ @@ -21,8 +20,8 @@ with lib; ]; }; - keymapsOnEvents = mkOption { - type = types.attrsOf (types.listOf helpers.keymaps.deprecatedMapOptionSubmodule); + keymapsOnEvents = lib.mkOption { + type = lib.types.attrsOf (lib.types.listOf helpers.keymaps.deprecatedMapOptionSubmodule); default = { }; example = { "InsertEnter" = [ @@ -67,7 +66,7 @@ with lib; in lib.pipe keymapOptions [ (map (opt: (opt.type.getSubOptions opt.loc).lua)) - (filter (opt: opt.isDefined)) + (lib.filter (opt: opt.isDefined)) (map (opt: '' ${"\n"} The `${lib.showOption opt.loc}' option is deprecated and will be removed in 24.11. @@ -79,7 +78,7 @@ with lib; '')) ]; - extraConfigLua = mkIf (config.keymaps != [ ]) '' + extraConfigLua = lib.mkIf (config.keymaps != [ ]) '' -- Set up keybinds {{{ do local __nixvim_binds = ${helpers.toLuaObject (map helpers.keymaps.removeDeprecatedMapAttrs config.keymaps)} @@ -90,11 +89,11 @@ with lib; -- }}} ''; - autoGroups = mapAttrs' ( - event: mappings: nameValuePair "nixvim_binds_${event}" { clear = true; } + autoGroups = lib.mapAttrs' ( + event: mappings: lib.nameValuePair "nixvim_binds_${event}" { clear = true; } ) config.keymapsOnEvents; - autoCmd = mapAttrsToList (event: mappings: { + autoCmd = lib.mapAttrsToList (event: mappings: { inherit event; group = "nixvim_binds_${event}"; callback = helpers.mkRaw '' diff --git a/modules/misc/nixvim-info.nix b/modules/misc/nixvim-info.nix index 92a8f83f..219f9202 100644 --- a/modules/misc/nixvim-info.nix +++ b/modules/misc/nixvim-info.nix @@ -1,5 +1,4 @@ { lib, ... }: -with lib; { # Attribute may contain the following fields: # - path: Path to the module, e.g. [ "plugins" "" ] @@ -7,8 +6,8 @@ with lib; # - url: Url for the plugin # # We need to use an attrs instead of a submodule to handle the merge. - options.meta.nixvimInfo = mkOption { - type = (types.nullOr types.attrs) // { + options.meta.nixvimInfo = lib.mkOption { + type = (lib.types.nullOr lib.types.attrs) // { # This will create an attrset of the form: # # { path.to.plugin.name = ; } @@ -26,7 +25,7 @@ with lib; ( acc: def: lib.recursiveUpdate acc ( - setAttrByPath def.value.path { + lib.setAttrByPath def.value.path { inherit (def) file; url = def.value.url or null; description = def.value.description or null; diff --git a/modules/opts.nix b/modules/opts.nix index e1472254..10c74a76 100644 --- a/modules/opts.nix +++ b/modules/opts.nix @@ -4,7 +4,6 @@ config, ... }: -with lib; let optionsAttrs = { opts = { @@ -37,18 +36,18 @@ let }; in { - options = mapAttrs ( + options = lib.mapAttrs ( _: { description, ... }: - mkOption { - type = with types; attrsOf anything; + lib.mkOption { + type = with lib.types; attrsOf anything; default = { }; inherit description; } ) optionsAttrs; # Added 2024-03-29 (do not remove) - imports = mapAttrsToList (old: new: mkRenamedOptionModule [ old ] [ new ]) { + imports = lib.mapAttrsToList (old: new: lib.mkRenamedOptionModule [ old ] [ new ]) { options = "opts"; globalOptions = "globalOpts"; localOptions = "localOpts"; @@ -58,7 +57,7 @@ in extraConfigLuaPre = let content = helpers.concatNonEmptyLines ( - mapAttrsToList ( + lib.mapAttrsToList ( optionName: { prettyName, @@ -70,7 +69,7 @@ in varName = "nixvim_${luaVariableName}"; optionDefinitions = config.${optionName}; in - optionalString (optionDefinitions != { }) '' + lib.optionalString (optionDefinitions != { }) '' -- Set up ${prettyName} {{{ do local ${varName} = ${helpers.toLuaObject optionDefinitions} @@ -84,6 +83,6 @@ in ) optionsAttrs ); in - mkIf (content != "") (mkOrder 600 content); # Move options to top of file below global table + lib.mkIf (content != "") (lib.mkOrder 600 content); # Move options to top of file below global table }; } diff --git a/modules/output.nix b/modules/output.nix index 112ee18e..d2d221a4 100644 --- a/modules/output.nix +++ b/modules/output.nix @@ -4,8 +4,9 @@ helpers, ... }: -with lib; let + inherit (lib) types mkOption; + pluginWithConfigType = types.submodule { options = { config = mkOption { @@ -14,7 +15,7 @@ let default = ""; }; - optional = mkEnableOption "optional" // { + optional = lib.mkEnableOption "optional" // { description = "Don't load by default (load with :packadd)"; }; @@ -43,7 +44,7 @@ in extraPython3Packages = mkOption { type = with types; functionTo (listOf package); default = p: [ ]; - defaultText = literalExpression "p: with p; [ ]"; + defaultText = lib.literalExpression "p: with p; [ ]"; description = "Python packages to add to the `PYTHONPATH` of neovim."; example = lib.literalExpression '' p: [ p.numpy ]