mirror of
https://github.com/nix-community/nixvim.git
synced 2025-07-20 10:45:51 +02:00
treewide: Reformat with nixfmt
This commit is contained in:
parent
c6281260dc
commit
62f32bfc71
459 changed files with 28139 additions and 26377 deletions
|
@ -4,11 +4,12 @@
|
|||
config,
|
||||
...
|
||||
}:
|
||||
with lib; {
|
||||
with lib;
|
||||
{
|
||||
options = {
|
||||
autoGroups = mkOption {
|
||||
type = types.attrsOf helpers.autocmd.autoGroupOption;
|
||||
default = {};
|
||||
default = { };
|
||||
description = "augroup definitions";
|
||||
example = ''
|
||||
autoGroups = {
|
||||
|
@ -21,7 +22,7 @@ with lib; {
|
|||
|
||||
autoCmd = mkOption {
|
||||
type = types.listOf helpers.autocmd.autoCmdOption;
|
||||
default = [];
|
||||
default = [ ];
|
||||
description = "autocmd definitions";
|
||||
example = ''
|
||||
autoCmd = [
|
||||
|
@ -35,18 +36,16 @@ with lib; {
|
|||
};
|
||||
};
|
||||
|
||||
config = let
|
||||
inherit (config) autoGroups autoCmd;
|
||||
in
|
||||
mkIf (autoGroups != {} || autoCmd != {}) {
|
||||
config =
|
||||
let
|
||||
inherit (config) autoGroups autoCmd;
|
||||
in
|
||||
mkIf (autoGroups != { } || autoCmd != { }) {
|
||||
# Introduced early October 2023.
|
||||
# TODO remove in early December 2023.
|
||||
assertions = [
|
||||
{
|
||||
assertion =
|
||||
all
|
||||
(x: x.description == null)
|
||||
autoCmd;
|
||||
assertion = all (x: x.description == null) autoCmd;
|
||||
message = ''
|
||||
RENAMED OPTION: `autoCmd[].description` has been renamed `autoCmd[].desc`.
|
||||
Please update your configuration.
|
||||
|
@ -55,7 +54,7 @@ with lib; {
|
|||
];
|
||||
|
||||
extraConfigLuaPost =
|
||||
(optionalString (autoGroups != {}) ''
|
||||
(optionalString (autoGroups != { }) ''
|
||||
-- Set up autogroups {{
|
||||
do
|
||||
local __nixvim_autogroups = ${helpers.toLuaObject autoGroups}
|
||||
|
@ -66,7 +65,7 @@ with lib; {
|
|||
end
|
||||
-- }}
|
||||
'')
|
||||
+ (optionalString (autoCmd != []) ''
|
||||
+ (optionalString (autoCmd != [ ]) ''
|
||||
-- Set up autocommands {{
|
||||
do
|
||||
local __nixvim_autocommands = ${helpers.toLuaObject autoCmd}
|
||||
|
|
|
@ -4,9 +4,11 @@
|
|||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
with lib;
|
||||
let
|
||||
cfg = config.clipboard;
|
||||
in {
|
||||
in
|
||||
{
|
||||
options = {
|
||||
clipboard = {
|
||||
register = mkOption {
|
||||
|
@ -14,9 +16,7 @@ in {
|
|||
Sets the register to use for the clipboard.
|
||||
Learn more at https://neovim.io/doc/user/options.html#'clipboard'.
|
||||
'';
|
||||
type = with types;
|
||||
nullOr
|
||||
(either str (listOf str));
|
||||
type = with types; nullOr (either str (listOf str));
|
||||
default = null;
|
||||
example = "unnamedplus";
|
||||
};
|
||||
|
@ -25,19 +25,17 @@ in {
|
|||
type = types.submodule {
|
||||
options =
|
||||
mapAttrs
|
||||
(
|
||||
name: packageName: {
|
||||
(name: packageName: {
|
||||
enable = mkEnableOption name;
|
||||
package = mkPackageOption pkgs packageName {};
|
||||
}
|
||||
)
|
||||
{
|
||||
wl-copy = "wl-clipboard";
|
||||
xclip = "xclip";
|
||||
xsel = "xsel";
|
||||
};
|
||||
package = mkPackageOption pkgs packageName { };
|
||||
})
|
||||
{
|
||||
wl-copy = "wl-clipboard";
|
||||
xclip = "xclip";
|
||||
xsel = "xsel";
|
||||
};
|
||||
};
|
||||
default = {};
|
||||
default = { };
|
||||
description = ''
|
||||
Package(s) to use as the clipboard provider.
|
||||
Learn more at `:h clipboard`.
|
||||
|
@ -49,9 +47,6 @@ in {
|
|||
config = {
|
||||
opts.clipboard = mkIf (cfg.register != null) cfg.register;
|
||||
|
||||
extraPackages =
|
||||
mapAttrsToList
|
||||
(n: v: v.package)
|
||||
(filterAttrs (n: v: v.enable) cfg.providers);
|
||||
extraPackages = mapAttrsToList (n: v: v.package) (filterAttrs (n: v: v.enable) cfg.providers);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
{ config, lib, ... }:
|
||||
with lib;
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
with lib; {
|
||||
options = {
|
||||
colorscheme = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
|
|
|
@ -4,7 +4,8 @@
|
|||
config,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
with lib;
|
||||
let
|
||||
commandAttributes = types.submodule {
|
||||
options = {
|
||||
command = mkOption {
|
||||
|
@ -12,15 +13,34 @@ with lib; let
|
|||
description = "The command to run.";
|
||||
};
|
||||
|
||||
nargs = helpers.mkNullOrOption (types.enum ["0" "1" "*" "?" "+"]) ''
|
||||
The number of arguments to expect, see :h command-nargs.
|
||||
'';
|
||||
nargs =
|
||||
helpers.mkNullOrOption
|
||||
(types.enum [
|
||||
"0"
|
||||
"1"
|
||||
"*"
|
||||
"?"
|
||||
"+"
|
||||
])
|
||||
''
|
||||
The number of arguments to expect, see :h command-nargs.
|
||||
'';
|
||||
complete = helpers.mkNullOrOption (with types; either str helpers.nixvimTypes.rawLua) ''
|
||||
Tab-completion behaviour, see :h command-complete.
|
||||
'';
|
||||
range = helpers.mkNullOrOption (with types; oneOf [bool int (enum ["%"])]) ''
|
||||
Whether the command accepts a range, see :h command-range.
|
||||
'';
|
||||
range =
|
||||
helpers.mkNullOrOption
|
||||
(
|
||||
with types;
|
||||
oneOf [
|
||||
bool
|
||||
int
|
||||
(enum [ "%" ])
|
||||
]
|
||||
)
|
||||
''
|
||||
Whether the command accepts a range, see :h command-range.
|
||||
'';
|
||||
count = helpers.mkNullOrOption (with types; either bool int) ''
|
||||
Whether the command accepts a count, see :h command-range.
|
||||
'';
|
||||
|
@ -37,20 +57,22 @@ with lib; let
|
|||
# TODO: command-preview, need to grab a function here.
|
||||
};
|
||||
};
|
||||
in {
|
||||
in
|
||||
{
|
||||
options.userCommands = mkOption {
|
||||
type = types.attrsOf commandAttributes;
|
||||
default = {};
|
||||
default = { };
|
||||
description = "A list of user commands to add to the configuration.";
|
||||
};
|
||||
|
||||
config = let
|
||||
cleanupCommand = _: cmd: {
|
||||
inherit (cmd) command;
|
||||
options = filterAttrs (name: _: name != "command") cmd;
|
||||
};
|
||||
in
|
||||
mkIf (config.userCommands != {}) {
|
||||
config =
|
||||
let
|
||||
cleanupCommand = _: cmd: {
|
||||
inherit (cmd) command;
|
||||
options = filterAttrs (name: _: name != "command") cmd;
|
||||
};
|
||||
in
|
||||
mkIf (config.userCommands != { }) {
|
||||
extraConfigLua = helpers.wrapDo ''
|
||||
local cmds = ${helpers.toLuaObject (mapAttrs cleanupCommand config.userCommands)};
|
||||
for name,cmd in pairs(cmds) do
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{lib, ...}: {
|
||||
{ lib, ... }:
|
||||
{
|
||||
options.enableMan = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = true;
|
||||
|
|
|
@ -1,12 +1,23 @@
|
|||
{ lib, config, ... }:
|
||||
with lib;
|
||||
{
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
with lib; {
|
||||
imports = [
|
||||
(lib.mkRenamedOptionModule ["plugins" "editorconfig" "enable"] ["editorconfig" "enable"])
|
||||
(lib.mkRemovedOptionModule ["plugins" "editorconfig" "package"] "editorconfig is now builtin, no plugin required")
|
||||
(lib.mkRenamedOptionModule
|
||||
[
|
||||
"plugins"
|
||||
"editorconfig"
|
||||
"enable"
|
||||
]
|
||||
[
|
||||
"editorconfig"
|
||||
"enable"
|
||||
]
|
||||
)
|
||||
(lib.mkRemovedOptionModule [
|
||||
"plugins"
|
||||
"editorconfig"
|
||||
"package"
|
||||
] "editorconfig is now builtin, no plugin required")
|
||||
];
|
||||
|
||||
options.editorconfig = {
|
||||
|
@ -18,7 +29,7 @@ with lib; {
|
|||
|
||||
properties = mkOption {
|
||||
type = types.attrsOf types.str;
|
||||
default = {};
|
||||
default = { };
|
||||
description = ''
|
||||
The table key is a property name and the value is a callback function which accepts the
|
||||
number of the buffer to be modified, the value of the property in the .editorconfig file,
|
||||
|
@ -39,23 +50,26 @@ with lib; {
|
|||
};
|
||||
};
|
||||
|
||||
config = let
|
||||
cfg = config.editorconfig;
|
||||
in {
|
||||
globals.editorconfig = mkIf (!cfg.enable) false;
|
||||
|
||||
extraConfigLua = let
|
||||
mkProperty = name: function: ''
|
||||
__editorconfig.properties.${name} = ${function}
|
||||
'';
|
||||
propertiesString = lib.concatLines (lib.mapAttrsToList mkProperty cfg.properties);
|
||||
config =
|
||||
let
|
||||
cfg = config.editorconfig;
|
||||
in
|
||||
mkIf (propertiesString != "" && cfg.enable) ''
|
||||
do
|
||||
local __editorconfig = require('editorconfig')
|
||||
{
|
||||
globals.editorconfig = mkIf (!cfg.enable) false;
|
||||
|
||||
${propertiesString}
|
||||
end
|
||||
'';
|
||||
};
|
||||
extraConfigLua =
|
||||
let
|
||||
mkProperty = name: function: ''
|
||||
__editorconfig.properties.${name} = ${function}
|
||||
'';
|
||||
propertiesString = lib.concatLines (lib.mapAttrsToList mkProperty cfg.properties);
|
||||
in
|
||||
mkIf (propertiesString != "" && cfg.enable) ''
|
||||
do
|
||||
local __editorconfig = require('editorconfig')
|
||||
|
||||
${propertiesString}
|
||||
end
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
|
@ -4,38 +4,40 @@
|
|||
config,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
filetypeDefinition =
|
||||
helpers.mkNullOrOption
|
||||
(with types;
|
||||
attrsOf (
|
||||
oneOf [
|
||||
# Raw filetype
|
||||
str
|
||||
# Function to set the filetype
|
||||
helpers.nixvimTypes.rawLua
|
||||
# ["filetype" {priority = xx;}]
|
||||
(listOf (either str (submodule {
|
||||
options = {
|
||||
priority = mkOption {
|
||||
type = int;
|
||||
};
|
||||
};
|
||||
})))
|
||||
]
|
||||
));
|
||||
in {
|
||||
with lib;
|
||||
let
|
||||
filetypeDefinition = helpers.mkNullOrOption (
|
||||
with types;
|
||||
attrsOf (oneOf [
|
||||
# Raw filetype
|
||||
str
|
||||
# Function to set the filetype
|
||||
helpers.nixvimTypes.rawLua
|
||||
# ["filetype" {priority = xx;}]
|
||||
(listOf (
|
||||
either str (submodule {
|
||||
options = {
|
||||
priority = mkOption { type = int; };
|
||||
};
|
||||
})
|
||||
))
|
||||
])
|
||||
);
|
||||
in
|
||||
{
|
||||
options.filetype =
|
||||
helpers.mkCompositeOption ''
|
||||
Define additional filetypes. The values can either be a literal filetype or a function
|
||||
taking the filepath and the buffer number.
|
||||
helpers.mkCompositeOption
|
||||
''
|
||||
Define additional filetypes. The values can either be a literal filetype or a function
|
||||
taking the filepath and the buffer number.
|
||||
|
||||
For more information check `:h vim.filetype.add()`
|
||||
'' {
|
||||
extension = filetypeDefinition "set filetypes matching the file extension";
|
||||
filename = filetypeDefinition "set filetypes matching the file name (or path)";
|
||||
pattern = filetypeDefinition "set filetypes matching the specified pattern";
|
||||
};
|
||||
For more information check `:h vim.filetype.add()`
|
||||
''
|
||||
{
|
||||
extension = filetypeDefinition "set filetypes matching the file extension";
|
||||
filename = filetypeDefinition "set filetypes matching the file name (or path)";
|
||||
pattern = filetypeDefinition "set filetypes matching the specified pattern";
|
||||
};
|
||||
|
||||
config.extraConfigLua = helpers.mkIfNonNull' config.filetype ''
|
||||
vim.filetype.add(${helpers.toLuaObject config.filetype})
|
||||
|
|
|
@ -4,11 +4,12 @@
|
|||
config,
|
||||
...
|
||||
}:
|
||||
with lib; {
|
||||
with lib;
|
||||
{
|
||||
options = {
|
||||
highlight = mkOption {
|
||||
type = types.attrsOf helpers.nixvimTypes.highlight;
|
||||
default = {};
|
||||
default = { };
|
||||
description = "Define new highlight groups";
|
||||
example = ''
|
||||
highlight = {
|
||||
|
@ -19,7 +20,7 @@ with lib; {
|
|||
|
||||
highlightOverride = mkOption {
|
||||
type = types.attrsOf helpers.nixvimTypes.highlight;
|
||||
default = {};
|
||||
default = { };
|
||||
description = "Define highlight groups to override existing highlight";
|
||||
example = ''
|
||||
highlight = {
|
||||
|
@ -30,7 +31,7 @@ with lib; {
|
|||
|
||||
match = mkOption {
|
||||
type = types.attrsOf types.str;
|
||||
default = {};
|
||||
default = { };
|
||||
description = "Define match groups";
|
||||
example = ''
|
||||
match = {
|
||||
|
@ -42,10 +43,8 @@ with lib; {
|
|||
|
||||
config = {
|
||||
extraConfigLuaPre =
|
||||
(optionalString (config.highlight != {})
|
||||
/*
|
||||
lua
|
||||
*/
|
||||
(optionalString (config.highlight != { })
|
||||
# lua
|
||||
''
|
||||
-- Highlight groups {{
|
||||
do
|
||||
|
@ -56,11 +55,10 @@ with lib; {
|
|||
end
|
||||
end
|
||||
-- }}
|
||||
'')
|
||||
+ (optionalString (config.match != {})
|
||||
/*
|
||||
lua
|
||||
*/
|
||||
''
|
||||
)
|
||||
+ (optionalString (config.match != { })
|
||||
# lua
|
||||
''
|
||||
-- Match groups {{
|
||||
do
|
||||
|
@ -71,23 +69,22 @@ with lib; {
|
|||
end
|
||||
end
|
||||
-- }}
|
||||
'');
|
||||
''
|
||||
);
|
||||
|
||||
extraConfigLuaPost =
|
||||
optionalString (config.highlightOverride != {})
|
||||
/*
|
||||
lua
|
||||
*/
|
||||
''
|
||||
-- Highlight groups {{
|
||||
do
|
||||
local highlights = ${helpers.toLuaObject config.highlightOverride}
|
||||
optionalString (config.highlightOverride != { })
|
||||
# lua
|
||||
''
|
||||
-- Highlight groups {{
|
||||
do
|
||||
local highlights = ${helpers.toLuaObject config.highlightOverride}
|
||||
|
||||
for k,v in pairs(highlights) do
|
||||
vim.api.nvim_set_hl(0, k, v)
|
||||
for k,v in pairs(highlights) do
|
||||
vim.api.nvim_set_hl(0, k, v)
|
||||
end
|
||||
end
|
||||
end
|
||||
-- }}
|
||||
'';
|
||||
-- }}
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
|
@ -4,13 +4,12 @@
|
|||
config,
|
||||
...
|
||||
}:
|
||||
with lib; {
|
||||
with lib;
|
||||
{
|
||||
options = {
|
||||
keymaps = mkOption {
|
||||
type =
|
||||
types.listOf
|
||||
helpers.keymaps.mapOptionSubmodule;
|
||||
default = [];
|
||||
type = types.listOf helpers.keymaps.mapOptionSubmodule;
|
||||
default = [ ];
|
||||
example = [
|
||||
{
|
||||
key = "<C-m>";
|
||||
|
@ -22,7 +21,7 @@ with lib; {
|
|||
|
||||
keymapsOnEvents = mkOption {
|
||||
type = types.attrsOf (types.listOf helpers.keymaps.mapOptionSubmodule);
|
||||
default = {};
|
||||
default = { };
|
||||
example = {
|
||||
"InsertEnter" = [
|
||||
{
|
||||
|
@ -44,24 +43,16 @@ with lib; {
|
|||
};
|
||||
};
|
||||
|
||||
config = let
|
||||
normalizeMapping = keyMapping: {
|
||||
inherit
|
||||
(keyMapping)
|
||||
mode
|
||||
key
|
||||
options
|
||||
;
|
||||
config =
|
||||
let
|
||||
normalizeMapping = keyMapping: {
|
||||
inherit (keyMapping) mode key options;
|
||||
|
||||
action =
|
||||
if keyMapping.lua
|
||||
then helpers.mkRaw keyMapping.action
|
||||
else keyMapping.action;
|
||||
};
|
||||
in {
|
||||
extraConfigLua =
|
||||
optionalString (config.keymaps != [])
|
||||
''
|
||||
action = if keyMapping.lua then helpers.mkRaw keyMapping.action else keyMapping.action;
|
||||
};
|
||||
in
|
||||
{
|
||||
extraConfigLua = optionalString (config.keymaps != [ ]) ''
|
||||
-- Set up keybinds {{{
|
||||
do
|
||||
local __nixvim_binds = ${helpers.toLuaObject (map normalizeMapping config.keymaps)}
|
||||
|
@ -72,27 +63,24 @@ with lib; {
|
|||
-- }}}
|
||||
'';
|
||||
|
||||
autoGroups = mapAttrs' (event: mappings: nameValuePair "nixvim_binds_${event}" {clear = true;}) config.keymapsOnEvents;
|
||||
autoGroups = mapAttrs' (
|
||||
event: mappings: nameValuePair "nixvim_binds_${event}" { clear = true; }
|
||||
) config.keymapsOnEvents;
|
||||
|
||||
autoCmd =
|
||||
mapAttrsToList
|
||||
(
|
||||
event: mappings: {
|
||||
inherit event;
|
||||
group = "nixvim_binds_${event}";
|
||||
callback = helpers.mkRaw ''
|
||||
function()
|
||||
do
|
||||
local __nixvim_binds = ${helpers.toLuaObject (map normalizeMapping mappings)}
|
||||
for i, map in ipairs(__nixvim_binds) do
|
||||
vim.keymap.set(map.mode, map.key, map.action, map.options)
|
||||
end
|
||||
autoCmd = mapAttrsToList (event: mappings: {
|
||||
inherit event;
|
||||
group = "nixvim_binds_${event}";
|
||||
callback = helpers.mkRaw ''
|
||||
function()
|
||||
do
|
||||
local __nixvim_binds = ${helpers.toLuaObject (map normalizeMapping mappings)}
|
||||
for i, map in ipairs(__nixvim_binds) do
|
||||
vim.keymap.set(map.mode, map.key, map.action, map.options)
|
||||
end
|
||||
end
|
||||
'';
|
||||
desc = "Load keymaps for ${event}";
|
||||
}
|
||||
)
|
||||
config.keymapsOnEvents;
|
||||
};
|
||||
end
|
||||
'';
|
||||
desc = "Load keymaps for ${event}";
|
||||
}) config.keymapsOnEvents;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
{ lib, config, ... }:
|
||||
with lib;
|
||||
let
|
||||
cfg = config.luaLoader;
|
||||
in {
|
||||
in
|
||||
{
|
||||
options.luaLoader = {
|
||||
enable = mkOption {
|
||||
type = types.bool;
|
||||
|
@ -27,9 +25,6 @@ in {
|
|||
};
|
||||
|
||||
config = {
|
||||
extraConfigLuaPre =
|
||||
if cfg.enable
|
||||
then "vim.loader.enable()"
|
||||
else "vim.loader.disable()";
|
||||
extraConfigLuaPre = if cfg.enable then "vim.loader.enable()" else "vim.loader.disable()";
|
||||
};
|
||||
}
|
||||
|
|
|
@ -4,7 +4,8 @@
|
|||
config,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
with lib;
|
||||
let
|
||||
optionsAttrs = {
|
||||
opts = {
|
||||
prettyName = "options";
|
||||
|
@ -34,59 +35,51 @@ with lib; let
|
|||
description = "Global variables (`vim.g.*`)";
|
||||
};
|
||||
};
|
||||
in {
|
||||
options =
|
||||
mapAttrs
|
||||
(
|
||||
_: {description, ...}:
|
||||
mkOption {
|
||||
type = with types; attrsOf anything;
|
||||
default = {};
|
||||
inherit description;
|
||||
}
|
||||
)
|
||||
optionsAttrs;
|
||||
in
|
||||
{
|
||||
options = mapAttrs (
|
||||
_:
|
||||
{ description, ... }:
|
||||
mkOption {
|
||||
type = with types; attrsOf anything;
|
||||
default = { };
|
||||
inherit description;
|
||||
}
|
||||
) optionsAttrs;
|
||||
|
||||
# Added 2024-03-29 (do not remove)
|
||||
imports =
|
||||
mapAttrsToList
|
||||
(old: new: mkRenamedOptionModule [old] [new])
|
||||
{
|
||||
options = "opts";
|
||||
globalOptions = "globalOpts";
|
||||
localOptions = "localOpts";
|
||||
};
|
||||
imports = mapAttrsToList (old: new: mkRenamedOptionModule [ old ] [ new ]) {
|
||||
options = "opts";
|
||||
globalOptions = "globalOpts";
|
||||
localOptions = "localOpts";
|
||||
};
|
||||
|
||||
config = {
|
||||
extraConfigLuaPre =
|
||||
concatLines
|
||||
(
|
||||
mapAttrsToList
|
||||
(
|
||||
optionName: {
|
||||
prettyName,
|
||||
luaVariableName,
|
||||
luaApi,
|
||||
...
|
||||
}: let
|
||||
varName = "nixvim_${luaVariableName}";
|
||||
optionDefinitions = config.${optionName};
|
||||
in
|
||||
optionalString
|
||||
(optionDefinitions != {})
|
||||
''
|
||||
-- Set up ${prettyName} {{{
|
||||
do
|
||||
local ${varName} = ${helpers.toLuaObject optionDefinitions}
|
||||
extraConfigLuaPre = concatLines (
|
||||
mapAttrsToList (
|
||||
optionName:
|
||||
{
|
||||
prettyName,
|
||||
luaVariableName,
|
||||
luaApi,
|
||||
...
|
||||
}:
|
||||
let
|
||||
varName = "nixvim_${luaVariableName}";
|
||||
optionDefinitions = config.${optionName};
|
||||
in
|
||||
optionalString (optionDefinitions != { }) ''
|
||||
-- Set up ${prettyName} {{{
|
||||
do
|
||||
local ${varName} = ${helpers.toLuaObject optionDefinitions}
|
||||
|
||||
for k,v in pairs(${varName}) do
|
||||
vim.${luaApi}[k] = v
|
||||
end
|
||||
end
|
||||
-- }}}
|
||||
''
|
||||
)
|
||||
optionsAttrs
|
||||
);
|
||||
for k,v in pairs(${varName}) do
|
||||
vim.${luaApi}[k] = v
|
||||
end
|
||||
end
|
||||
-- }}}
|
||||
''
|
||||
) optionsAttrs
|
||||
);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
{ lib, config, ... }:
|
||||
with lib;
|
||||
let
|
||||
pluginWithConfigType = types.submodule {
|
||||
options = {
|
||||
config = mkOption {
|
||||
|
@ -12,11 +9,9 @@ with lib; let
|
|||
default = "";
|
||||
};
|
||||
|
||||
optional =
|
||||
mkEnableOption "optional"
|
||||
// {
|
||||
description = "Don't load by default (load with :packadd)";
|
||||
};
|
||||
optional = mkEnableOption "optional" // {
|
||||
description = "Don't load by default (load with :packadd)";
|
||||
};
|
||||
|
||||
plugin = mkOption {
|
||||
type = types.package;
|
||||
|
@ -24,24 +19,25 @@ with lib; let
|
|||
};
|
||||
};
|
||||
};
|
||||
in {
|
||||
in
|
||||
{
|
||||
options = {
|
||||
extraPlugins = mkOption {
|
||||
type = with types; listOf (either package pluginWithConfigType);
|
||||
default = [];
|
||||
default = [ ];
|
||||
description = "List of vim plugins to install";
|
||||
};
|
||||
|
||||
extraPackages = mkOption {
|
||||
type = with types; listOf (nullOr package);
|
||||
default = [];
|
||||
default = [ ];
|
||||
description = "Extra packages to be made available to neovim";
|
||||
apply = builtins.filter (p: p != null);
|
||||
};
|
||||
|
||||
extraPython3Packages = mkOption {
|
||||
type = with types; functionTo (listOf package);
|
||||
default = p: [];
|
||||
default = p: [ ];
|
||||
defaultText = literalExpression "p: with p; [ ]";
|
||||
description = "Python packages to add to the `PYTHONPATH` of neovim.";
|
||||
example = lib.literalExpression ''
|
||||
|
@ -74,7 +70,10 @@ in {
|
|||
};
|
||||
|
||||
type = mkOption {
|
||||
type = types.enum ["vim" "lua"];
|
||||
type = types.enum [
|
||||
"vim"
|
||||
"lua"
|
||||
];
|
||||
default = "lua";
|
||||
description = "Whether the generated file is a vim or a lua file";
|
||||
};
|
||||
|
@ -94,40 +93,39 @@ in {
|
|||
extraLuaPackages = mkOption {
|
||||
type = types.functionTo (types.listOf types.package);
|
||||
description = "Extra lua packages to include with neovim";
|
||||
default = _: [];
|
||||
default = _: [ ];
|
||||
};
|
||||
|
||||
extraFiles = mkOption {
|
||||
type = types.attrsOf types.str;
|
||||
description = "Extra files to add to the runtime path";
|
||||
default = {};
|
||||
default = { };
|
||||
};
|
||||
};
|
||||
|
||||
config = let
|
||||
contentLua = ''
|
||||
${config.extraConfigLuaPre}
|
||||
vim.cmd([[
|
||||
${config.extraConfigVim}
|
||||
]])
|
||||
${config.extraConfigLua}
|
||||
${config.extraConfigLuaPost}
|
||||
'';
|
||||
|
||||
contentVim = ''
|
||||
lua << EOF
|
||||
config =
|
||||
let
|
||||
contentLua = ''
|
||||
${config.extraConfigLuaPre}
|
||||
EOF
|
||||
${config.extraConfigVim}
|
||||
lua << EOF
|
||||
vim.cmd([[
|
||||
${config.extraConfigVim}
|
||||
]])
|
||||
${config.extraConfigLua}
|
||||
${config.extraConfigLuaPost}
|
||||
EOF
|
||||
'';
|
||||
in {
|
||||
content =
|
||||
if config.type == "lua"
|
||||
then contentLua
|
||||
else contentVim;
|
||||
};
|
||||
'';
|
||||
|
||||
contentVim = ''
|
||||
lua << EOF
|
||||
${config.extraConfigLuaPre}
|
||||
EOF
|
||||
${config.extraConfigVim}
|
||||
lua << EOF
|
||||
${config.extraConfigLua}
|
||||
${config.extraConfigLuaPost}
|
||||
EOF
|
||||
'';
|
||||
in
|
||||
{
|
||||
content = if config.type == "lua" then contentLua else contentVim;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
{...}: {
|
||||
imports = [
|
||||
../plugins/default.nix
|
||||
];
|
||||
{ ... }:
|
||||
{
|
||||
imports = [ ../plugins/default.nix ];
|
||||
}
|
||||
|
|
|
@ -1,15 +1,16 @@
|
|||
{lib, ...}:
|
||||
with lib; {
|
||||
{ lib, ... }:
|
||||
with lib;
|
||||
{
|
||||
options = {
|
||||
warnings = mkOption {
|
||||
type = types.listOf types.str;
|
||||
visible = false;
|
||||
default = [];
|
||||
default = [ ];
|
||||
};
|
||||
assertions = mkOption {
|
||||
type = types.listOf types.attrs; # Not sure what the correct type is here
|
||||
visible = false;
|
||||
default = [];
|
||||
default = [ ];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue