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