treewide: Reformat with nixfmt

This commit is contained in:
traxys 2024-05-05 19:39:35 +02:00
parent c6281260dc
commit 62f32bfc71
459 changed files with 28139 additions and 26377 deletions

View file

@ -1,14 +1,11 @@
( (import (
import
(
let let
lock = builtins.fromJSON (builtins.readFile ./flake.lock); lock = builtins.fromJSON (builtins.readFile ./flake.lock);
in in
fetchTarball { fetchTarball {
url = lock.nodes.flake-compat.locked.url or "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; url =
lock.nodes.flake-compat.locked.url
or "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash; sha256 = lock.nodes.flake-compat.locked.narHash;
} }
) ) { src = ./.; }).defaultNix
{src = ./.;}
)
.defaultNix

View file

@ -2,15 +2,16 @@
rawModules, rawModules,
helpers, helpers,
pkgs, pkgs,
}: let }:
let
pkgsDoc = pkgsDoc =
import (pkgs.applyPatches { import
(pkgs.applyPatches {
name = "nixpkgs-nixvim-doc"; name = "nixpkgs-nixvim-doc";
src = pkgs.path; src = pkgs.path;
patches = [ patches = [ ./either_recursive.patch ];
./either_recursive.patch })
]; {
}) {
inherit (pkgs) system; inherit (pkgs) system;
config.allowUnfree = true; config.allowUnfree = true;
}; };
@ -24,21 +25,21 @@
name = "<${repo}/${subpath}>"; name = "<${repo}/${subpath}>";
}; };
transformOptions = opt: transformOptions =
opt:
opt opt
// { // {
declarations = declarations = map (
map (
decl: decl:
if lib.hasPrefix nixvimPath (toString decl) if lib.hasPrefix nixvimPath (toString decl) then
then gitHubDeclaration "nix-community" "nixvim" "main" (
gitHubDeclaration "nix-community" "nixvim" "main" lib.removePrefix "/" (lib.removePrefix nixvimPath (toString decl))
(lib.removePrefix "/" (lib.removePrefix nixvimPath (toString decl)))
else if decl == "lib/modules.nix"
then gitHubDeclaration "NixOS" "nixpkgs" "master" decl
else decl
) )
opt.declarations; else if decl == "lib/modules.nix" then
gitHubDeclaration "NixOS" "nixpkgs" "master" decl
else
decl
) opt.declarations;
}; };
nixvmConfigType = lib.mkOptionType { nixvmConfigType = lib.mkOptionType {
@ -48,8 +49,7 @@
# Evaluation is irrelevant, only used for documentation. # Evaluation is irrelevant, only used for documentation.
}; };
topLevelModules = topLevelModules = [
[
../wrappers/modules/output.nix ../wrappers/modules/output.nix
# Fake module to avoid a duplicated documentation # Fake module to avoid a duplicated documentation
(lib.setDefaultModuleLocation "${nixvimPath}/wrappers/modules/files.nix" { (lib.setDefaultModuleLocation "${nixvimPath}/wrappers/modules/files.nix" {
@ -67,23 +67,15 @@
}; };
}; };
}) })
] ] ++ (rawModules pkgsDoc);
++ (rawModules pkgsDoc);
hmOptions = hmOptions = builtins.removeAttrs (lib.evalModules {
builtins.removeAttrs modules = [ (import ../wrappers/modules/hm.nix { inherit lib; }) ];
(lib.evalModules { }).options [ "_module" ];
modules = [
(import ../wrappers/modules/hm.nix {inherit lib;})
];
})
.options
["_module"];
in in
rec { rec {
options-json = options-json =
(pkgsDoc.nixosOptionsDoc (pkgsDoc.nixosOptionsDoc {
{
inherit inherit
(lib.evalModules { (lib.evalModules {
modules = topLevelModules; modules = topLevelModules;
@ -93,8 +85,7 @@ in
; ;
inherit transformOptions; inherit transformOptions;
warningsAreErrors = false; warningsAreErrors = false;
}) }).optionsJSON;
.optionsJSON;
man-docs = pkgsDoc.callPackage ./man { inherit options-json; }; man-docs = pkgsDoc.callPackage ./man { inherit options-json; };
} }
# Do not check if documentation builds fine on darwin as it fails: # Do not check if documentation builds fine on darwin as it fails:

View file

@ -4,7 +4,8 @@
installShellFiles, installShellFiles,
nixos-render-docs, nixos-render-docs,
pandoc, pandoc,
}: let }:
let
manualFilter = '' manualFilter = ''
local text = pandoc.text local text = pandoc.text
@ -23,13 +24,16 @@
end end
''; '';
manHeader = let manHeader =
let
mkMDSection = file: "<(pandoc --lua-filter <(echo \"$manualFilter\") -f gfm -t man ${file})"; mkMDSection = file: "<(pandoc --lua-filter <(echo \"$manualFilter\") -f gfm -t man ${file})";
in in
runCommand "nixvim-general-doc-manpage" { runCommand "nixvim-general-doc-manpage"
{
nativeBuildInputs = [ pandoc ]; nativeBuildInputs = [ pandoc ];
inherit manualFilter; inherit manualFilter;
} '' }
''
mkdir -p $out mkdir -p $out
cat \ cat \
${./nixvim-header-start.5} \ ${./nixvim-header-start.5} \
@ -38,11 +42,16 @@
${./nixvim-header-end.5} \ ${./nixvim-header-end.5} \
>$out/nixvim-header.5 >$out/nixvim-header.5
''; '';
# FIXME add platform specific docs to manpage
in in
runCommand "nixvim-configuration-reference-manpage" { # FIXME add platform specific docs to manpage
nativeBuildInputs = [installShellFiles nixos-render-docs]; runCommand "nixvim-configuration-reference-manpage"
} '' {
nativeBuildInputs = [
installShellFiles
nixos-render-docs
];
}
''
# Generate man-pages # Generate man-pages
mkdir -p $out/share/man/man5 mkdir -p $out/share/man/man5
nixos-render-docs -j $NIX_BUILD_CORES options manpage \ nixos-render-docs -j $NIX_BUILD_CORES options manpage \

View file

@ -7,22 +7,26 @@
transformOptions, transformOptions,
hmOptions, hmOptions,
}: }:
with lib; let with lib;
let
options = lib.evalModules { options = lib.evalModules {
inherit modules; inherit modules;
specialArgs = {inherit pkgs lib helpers;}; specialArgs = {
inherit pkgs lib helpers;
};
}; };
inherit (options.config.meta) nixvimInfo; inherit (options.config.meta) nixvimInfo;
mkMDDoc = options: mkMDDoc =
options:
(nixosOptionsDoc { (nixosOptionsDoc {
inherit options transformOptions; inherit options transformOptions;
warningsAreErrors = false; warningsAreErrors = false;
}) }).optionsCommonMark;
.optionsCommonMark;
removeUnwanted = attrs: removeUnwanted =
attrs:
builtins.removeAttrs attrs [ builtins.removeAttrs attrs [
"_module" "_module"
"_freeformOptions" "_freeformOptions"
@ -35,20 +39,19 @@ with lib; let
getSubOptions = opts: path: removeUnwanted (opts.type.getSubOptions path); getSubOptions = opts: path: removeUnwanted (opts.type.getSubOptions path);
isVisible = opts: isVisible =
if isOption opts opts:
then attrByPath ["visible"] true opts if isOption opts then
else if opts.isOption attrByPath [ "visible" ] true opts
then attrByPath ["index" "options" "visible"] true opts else if opts.isOption then
else let attrByPath [
filterFunc = "index"
filterAttrs "options"
( "visible"
_: v: ] true opts
if isAttrs v else
then isVisible v let
else true filterFunc = filterAttrs (_: v: if isAttrs v then isVisible v else true);
);
hasEmptyIndex = (filterFunc opts.index.options) == { }; hasEmptyIndex = (filterFunc opts.index.options) == { };
hasEmptyComponents = (filterFunc opts.components) == { }; hasEmptyComponents = (filterFunc opts.components) == { };
@ -58,13 +61,14 @@ with lib; let
wrapModule = path: opts: isOpt: rec { wrapModule = path: opts: isOpt: rec {
index = { index = {
options = options =
if isOpt if isOpt then
then opts opts
else filterAttrs (_: component: component.isOption && (isVisible component)) opts; else
filterAttrs (_: component: component.isOption && (isVisible component)) opts;
path = removeWhitespace (concatStringsSep "/" path); path = removeWhitespace (concatStringsSep "/" path);
moduleDoc = moduleDoc =
if builtins.length path >= 2 && lib.hasAttrByPath path nixvimInfo if builtins.length path >= 2 && lib.hasAttrByPath path nixvimInfo then
then let let
info = lib.getAttrFromPath path nixvimInfo; info = lib.getAttrFromPath path nixvimInfo;
maintainers = lib.unique (options.config.meta.maintainers.${info.file} or [ ]); maintainers = lib.unique (options.config.meta.maintainers.${info.file} or [ ]);
maintainersNames = builtins.map (m: m.name) maintainers; maintainersNames = builtins.map (m: m.name) maintainers;
@ -72,34 +76,40 @@ with lib; let
"# ${lib.last path}\n\n" "# ${lib.last path}\n\n"
+ (lib.optionalString (info.description != null) "${info.description}\n\n") + (lib.optionalString (info.description != null) "${info.description}\n\n")
+ (lib.optionalString (info.url != null) "**Url:** [${info.url}](${info.url})\n\n") + (lib.optionalString (info.url != null) "**Url:** [${info.url}](${info.url})\n\n")
+ (lib.optionalString (builtins.length maintainers > 0) + (lib.optionalString (
"**Maintainers:** ${lib.concatStringsSep ", " maintainersNames}\n\n") builtins.length maintainers > 0
else null; ) "**Maintainers:** ${lib.concatStringsSep ", " maintainersNames}\n\n")
else
null;
}; };
components = components =
if isOpt if isOpt then
then {} { }
else filterAttrs (_: component: !component.isOption && (isVisible component)) opts; else
filterAttrs (_: component: !component.isOption && (isVisible component)) opts;
hasComponents = components != { }; hasComponents = components != { };
isOption = isOpt; isOption = isOpt;
}; };
processModulesRec = modules: let processModulesRec =
recurse = path: mods: let modules:
g = name: opts: let
if !isOption opts recurse =
then wrapModule (path ++ [name]) (recurse (path ++ [name]) opts) false path: mods:
else let let
g =
name: opts:
if !isOption opts then
wrapModule (path ++ [ name ]) (recurse (path ++ [ name ]) opts) false
else
let
subOpts = getSubOptions opts (path ++ [ name ]); subOpts = getSubOptions opts (path ++ [ name ]);
in in
if subOpts != {} if subOpts != { } then
then wrapModule (path ++ [ name ]) (
wrapModule
(path ++ [name])
(
(recurse (path ++ [ name ]) subOpts) (recurse (path ++ [ name ]) subOpts)
// { // {
# This is necessary to include the submodule option's definition in the docs (description, type, etc.) # This is necessary to include the submodule option's definition in the docs (description, type, etc.)
@ -110,23 +120,19 @@ with lib; let
type.getSubOptions = _: _: { }; # Used to exclude suboptions from the submodule definition itself type.getSubOptions = _: _: { }; # Used to exclude suboptions from the submodule definition itself
}; };
} }
) ) false
false else
else wrapModule (path ++ [name]) opts true; wrapModule (path ++ [ name ]) opts true;
in in
mapAttrs g mods; mapAttrs g mods;
in in
foldlAttrs foldlAttrs (
( acc: name: opts:
acc: name: opts: let let
group = group = if !opts.hasComponents then "Neovim Options" else "none";
if !opts.hasComponents
then "Neovim Options"
else "none";
last = last =
acc.${group} acc.${group} or {
or {
index = { index = {
options = { }; options = { };
path = removeWhitespace "${group}"; path = removeWhitespace "${group}";
@ -142,19 +148,12 @@ with lib; let
acc acc
// { // {
${group} = recursiveUpdate last { ${group} = recursiveUpdate last {
index.options = optionalAttrs isOpt { index.options = optionalAttrs isOpt { ${name} = opts.index.options; };
${name} = opts.index.options;
};
components = optionalAttrs (!isOpt) { components = optionalAttrs (!isOpt) {
${name} = recursiveUpdate opts { ${name} = recursiveUpdate opts {
index.path = index.path = removeWhitespace (
removeWhitespace concatStringsSep "/" ((optional (group != "none") group) ++ [ opts.index.path ])
(
concatStringsSep "/"
(
(optional (group != "none") group) ++ [opts.index.path]
)
); );
hasComponents = true; hasComponents = true;
}; };
@ -163,21 +162,22 @@ with lib; let
hasComponents = last.components != { }; hasComponents = last.components != { };
}; };
} }
) ) { } (recurse [ ] modules);
{}
(recurse [] modules);
mapModulesToString = f: modules: let mapModulesToString =
recurse = mods: let f: modules:
g = name: opts: let
if (opts ? "isGroup") recurse =
then mods:
if name != "none" let
then (f name opts) + ("\n" + recurse opts.components) g =
else recurse opts.components name: opts:
else if opts.hasComponents if (opts ? "isGroup") then
then (f name opts) + ("\n" + recurse opts.components) if name != "none" then (f name opts) + ("\n" + recurse opts.components) else recurse opts.components
else f name opts; else if opts.hasComponents then
(f name opts) + ("\n" + recurse opts.components)
else
f name opts;
in in
concatStringsSep "\n" (mapAttrsToList g mods); concatStringsSep "\n" (mapAttrsToList g mods);
in in
@ -185,24 +185,16 @@ with lib; let
docs = rec { docs = rec {
modules = processModulesRec (removeUnwanted options.options); modules = processModulesRec (removeUnwanted options.options);
commands = commands = mapModulesToString (
mapModulesToString name: opts:
( let
name: opts: let isBranch = if (hasSuffix "index" opts.index.path) then true else opts.hasComponents;
isBranch = path = if isBranch then "${opts.index.path}/index.md" else "${opts.index.path}.md";
if (hasSuffix "index" opts.index.path)
then true
else opts.hasComponents;
path =
if isBranch
then "${opts.index.path}/index.md"
else "${opts.index.path}.md";
in in
(optionalString isBranch (optionalString isBranch "mkdir -p ${opts.index.path}\n")
"mkdir -p ${opts.index.path}\n")
+ ( + (
if opts.index.moduleDoc == null if opts.index.moduleDoc == null then
then "cp ${mkMDDoc opts.index.options} ${path}" "cp ${mkMDDoc opts.index.options} ${path}"
else else
# Including moduleDoc's text directly will result in bash interpreting special chars, # Including moduleDoc's text directly will result in bash interpreting special chars,
# write it to the nix store and `cat` the file instead. # write it to the nix store and `cat` the file instead.
@ -213,33 +205,29 @@ with lib; let
} > ${path} } > ${path}
'' ''
) )
) ) modules;
modules;
}; };
mdbook = { mdbook = {
nixvimOptions = nixvimOptions = mapModulesToString (
mapModulesToString name: opts:
( let
name: opts: let isBranch = if name == "index" then true else opts.hasComponents && opts.index.options != { };
isBranch =
if name == "index"
then true
else opts.hasComponents && opts.index.options != {};
path = path =
if isBranch if isBranch then
then "${opts.index.path}/index.md" "${opts.index.path}/index.md"
else if !opts.hasComponents else if !opts.hasComponents then
then "${opts.index.path}.md" "${opts.index.path}.md"
else ""; else
"";
indentLevel = with builtins; length (filter isString (split "/" opts.index.path)) - 1; indentLevel = with builtins; length (filter isString (split "/" opts.index.path)) - 1;
padding = concatStrings (builtins.genList (_: "\t") indentLevel); padding = concatStrings (builtins.genList (_: "\t") indentLevel);
in "${padding}- [${name}](${path})" in
) "${padding}- [${name}](${path})"
docs.modules; ) docs.modules;
}; };
prepareMD = '' prepareMD = ''
@ -268,7 +256,11 @@ in
phases = [ "buildPhase" ]; phases = [ "buildPhase" ];
buildInputs = [ pkgs.mdbook ]; buildInputs = [ pkgs.mdbook ];
inputs = sourceFilesBySuffices ./. [".md" ".toml" ".js"]; inputs = sourceFilesBySuffices ./. [
".md"
".toml"
".js"
];
buildPhase = '' buildPhase = ''
dest=$out/share/doc dest=$out/share/doc

View file

@ -1,4 +1,5 @@
{pkgs, ...}: { { pkgs, ... }:
{
programs.nixvim = { programs.nixvim = {
# This just enables NixVim. # This just enables NixVim.
# If all you have is this, then there will be little visible difference # If all you have is this, then there will be little visible difference
@ -60,8 +61,16 @@
# This is one of lightline's example configurations # This is one of lightline's example configurations
active = { active = {
left = [ left = [
["mode" "paste"] [
["readonly" "filename" "modified" "helloworld"] "mode"
"paste"
]
[
"readonly"
"filename"
"modified"
"helloworld"
]
]; ];
}; };

View file

@ -1,4 +1,5 @@
{inputs, ...}: { { inputs, ... }:
{
imports = [ imports = [
./dev ./dev
./helpers.nix ./helpers.nix
@ -12,11 +13,9 @@
./wrappers.nix ./wrappers.nix
]; ];
perSystem = { perSystem =
pkgs, { pkgs, system, ... }:
system, {
...
}: {
_module.args = { _module.args = {
pkgsUnfree = import inputs.nixpkgs { pkgsUnfree = import inputs.nixpkgs {
inherit system; inherit system;

View file

@ -1,7 +1,13 @@
{ inputs, ... }: { { inputs, ... }:
imports = [ inputs.pre-commit-hooks.flakeModule ./devshell.nix ]; {
imports = [
inputs.pre-commit-hooks.flakeModule
./devshell.nix
];
perSystem = { pkgs, ... }: { perSystem =
{ pkgs, ... }:
{
formatter = pkgs.nixfmt-rfc-style; formatter = pkgs.nixfmt-rfc-style;
pre-commit = { pre-commit = {
@ -12,8 +18,7 @@
}; };
statix = { statix = {
enable = true; enable = true;
excludes = excludes = [ "plugins/lsp/language-servers/rust-analyzer-config.nix" ];
[ "plugins/lsp/language-servers/rust-analyzer-config.nix" ];
}; };
typos.enable = true; typos.enable = true;
}; };

View file

@ -1,21 +1,24 @@
{inputs, ...}: { { inputs, ... }:
imports = [ {
inputs.devshell.flakeModule imports = [ inputs.devshell.flakeModule ];
];
perSystem = { perSystem =
{
pkgs, pkgs,
config, config,
system, system,
... ...
}: { }:
{
devshells.default = { devshells.default = {
devshell.startup.pre-commit.text = config.pre-commit.installationScript; devshell.startup.pre-commit.text = config.pre-commit.installationScript;
commands = let commands =
let
# Thanks to this, the user can choose to use `nix-output-monitor` (`nom`) instead of plain `nix` # Thanks to this, the user can choose to use `nix-output-monitor` (`nom`) instead of plain `nix`
nix = "$([ '$\{NIXVIM_NOM:-0}' = '1' ] && echo ${pkgs.lib.getExe pkgs.nom} || echo nix)"; nix = "$([ '$\{NIXVIM_NOM:-0}' = '1' ] && echo ${pkgs.lib.getExe pkgs.nom} || echo nix)";
in [ in
[
{ {
name = "checks"; name = "checks";
help = "Run all nixvim checks"; help = "Run all nixvim checks";

View file

@ -1,15 +1,15 @@
{getHelpers, ...}: { { getHelpers, ... }:
_module.args.getHelpers = pkgs: _nixvimTests: {
_module.args.getHelpers =
pkgs: _nixvimTests:
import ../lib/helpers.nix { import ../lib/helpers.nix {
inherit pkgs _nixvimTests; inherit pkgs _nixvimTests;
inherit (pkgs) lib; inherit (pkgs) lib;
}; };
perSystem = { perSystem =
pkgs, { pkgs, config, ... }:
config, {
...
}: {
_module.args.helpers = getHelpers pkgs false; _module.args.helpers = getHelpers pkgs false;
}; };
} }

View file

@ -1,13 +1,16 @@
{ {
perSystem = { perSystem =
{
pkgs, pkgs,
config, config,
makeNixvimWithModule, makeNixvimWithModule,
... ...
}: { }:
{
legacyPackages = rec { legacyPackages = rec {
inherit makeNixvimWithModule; inherit makeNixvimWithModule;
makeNixvim = configuration: makeNixvim =
configuration:
makeNixvimWithModule { makeNixvimWithModule {
module = { module = {
config = configuration; config = configuration;

View file

@ -3,14 +3,11 @@
lib, lib,
withSystem, withSystem,
... ...
}: { }:
{
flake.lib = lib.genAttrs config.systems ( flake.lib = lib.genAttrs config.systems (
lib.flip withSystem ( lib.flip withSystem (
{ { pkgs, config, ... }:
pkgs,
config,
...
}:
import ../lib { import ../lib {
inherit pkgs lib; inherit pkgs lib;
inherit (config.legacyPackages) makeNixvim makeNixvimWithModule; inherit (config.legacyPackages) makeNixvim makeNixvimWithModule;

View file

@ -1,6 +1,9 @@
{modules, ...}: { { modules, ... }:
{
_module.args = { _module.args = {
modules = pkgs: let modules =
pkgs:
let
nixpkgsMaintainersList = pkgs.path + "/nixos/modules/misc/meta.nix"; nixpkgsMaintainersList = pkgs.path + "/nixos/modules/misc/meta.nix";
nixvimExtraArgsModule = rec { nixvimExtraArgsModule = rec {
@ -13,12 +16,15 @@
}; };
}; };
}; };
in [ in
[
../modules ../modules
nixpkgsMaintainersList nixpkgsMaintainersList
nixvimExtraArgsModule nixvimExtraArgsModule
({lib, ...}: (
with lib; { { lib, ... }:
with lib;
{
# Attribute may contain the following fields: # Attribute may contain the following fields:
# - name: Name of the module # - name: Name of the module
# - kind: Either colorschemes or plugins # - kind: Either colorschemes or plugins
@ -29,9 +35,7 @@
# #
# 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 = mkOption {
type = type = (types.nullOr types.attrs) // {
(types.nullOr 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>; };
@ -43,14 +47,19 @@
# description = null or "<DESCRIPTION>"; # description = null or "<DESCRIPTION>";
# url = null or "<URL>"; # url = null or "<URL>";
# } # }
merge = _: defs: merge =
lib.foldl' (acc: def: _: defs:
lib.foldl'
(
acc: def:
lib.recursiveUpdate acc { lib.recursiveUpdate acc {
"${def.value.kind}"."${def.value.name}" = { "${def.value.kind}"."${def.value.name}" = {
inherit (def.value) url description; inherit (def.value) url description;
inherit (def) file; inherit (def) file;
}; };
}) { }
)
{
plugins = { }; plugins = { };
colorschemes = { }; colorschemes = { };
} }
@ -62,15 +71,14 @@
Nixvim related information on the module Nixvim related information on the module
''; '';
}; };
}) }
)
]; ];
}; };
perSystem = { perSystem =
pkgs, { pkgs, config, ... }:
config, {
...
}: {
_module.args = { _module.args = {
modules = modules pkgs; modules = modules pkgs;
rawModules = modules; rawModules = modules;

View file

@ -1,20 +1,17 @@
{inputs, ...}: { { inputs, ... }:
imports = [ {
inputs.flake-parts.flakeModules.easyOverlay imports = [ inputs.flake-parts.flakeModules.easyOverlay ];
]; perSystem =
perSystem = { {
config, config,
pkgs, pkgs,
final, final,
... ...
}: { }:
{
overlayAttrs = { overlayAttrs = {
nixvim = { nixvim = {
inherit inherit (config.legacyPackages) makeNixvim makeNixvimWithModule;
(config.legacyPackages)
makeNixvim
makeNixvimWithModule
;
}; };
}; };
}; };

View file

@ -1,14 +1,14 @@
{ {
perSystem = { perSystem =
{
pkgs, pkgs,
config, config,
rawModules, rawModules,
helpers, helpers,
... ...
}: { }:
packages = import ../docs { {
inherit rawModules pkgs helpers; packages = import ../docs { inherit rawModules pkgs helpers; };
};
# Test that all packages build fine when running `nix flake check`. # Test that all packages build fine when running `nix flake check`.
checks = config.packages; checks = config.packages;

View file

@ -1,8 +1,5 @@
{ self, inputs, ... }:
{ {
self,
inputs,
...
}: {
flake.templates = { flake.templates = {
default = { default = {
path = ../templates/simple; path = ../templates/simple;
@ -12,20 +9,25 @@
# The following adds the template flake's checks to the main (current) flake's checks. # The following adds the template flake's checks to the main (current) flake's checks.
# It ensures that the template's own checks are successful. # It ensures that the template's own checks are successful.
perSystem = { perSystem =
{
pkgs, pkgs,
system, system,
lib, lib,
... ...
}: { }:
checks = let {
checks =
let
# Approximates https://github.com/NixOS/nix/blob/7cd08ae379746749506f2e33c3baeb49b58299b8/src/libexpr/flake/call-flake.nix#L46 # Approximates https://github.com/NixOS/nix/blob/7cd08ae379746749506f2e33c3baeb49b58299b8/src/libexpr/flake/call-flake.nix#L46
# s/flake.outputs/args.outputs/ # s/flake.outputs/args.outputs/
callFlake = args @ { callFlake =
args@{
inputs, inputs,
outputs, outputs,
sourceInfo, sourceInfo,
}: let }:
let
outputs = args.outputs (inputs // { self = result; }); outputs = args.outputs (inputs // { self = result; });
result = result =
outputs outputs
@ -49,12 +51,6 @@
templateChecks = templateFlakeOutputs.checks.${system}; templateChecks = templateFlakeOutputs.checks.${system};
in in
lib.concatMapAttrs lib.concatMapAttrs (checkName: check: { "template-${checkName}" = check; }) templateChecks;
(
checkName: check: {
"template-${checkName}" = check;
}
)
templateChecks;
}; };
} }

View file

@ -1,5 +1,7 @@
{self, ...}: { { self, ... }:
perSystem = { {
perSystem =
{
pkgs, pkgs,
config, config,
system, system,
@ -7,12 +9,14 @@
makeNixvimWithModuleUnfree, makeNixvimWithModuleUnfree,
makeNixvimWithModule, makeNixvimWithModule,
... ...
}: { }:
{
checks = { checks = {
tests = import ../tests { tests = import ../tests {
inherit pkgs helpers makeNixvimWithModule; inherit pkgs helpers makeNixvimWithModule;
inherit (pkgs) lib; inherit (pkgs) lib;
makeNixvim = configuration: makeNixvim =
configuration:
makeNixvimWithModuleUnfree { makeNixvimWithModuleUnfree {
module = { module = {
config = configuration; config = configuration;
@ -25,9 +29,7 @@
inherit makeNixvimWithModule; inherit makeNixvimWithModule;
}; };
extend = import ../tests/extend.nix { extend = import ../tests/extend.nix { inherit pkgs makeNixvimWithModule; };
inherit pkgs makeNixvimWithModule;
};
enable-except-in-tests = import ../tests/enable-except-in-tests.nix { enable-except-in-tests = import ../tests/enable-except-in-tests.nix {
inherit pkgs makeNixvimWithModule; inherit pkgs makeNixvimWithModule;

View file

@ -4,30 +4,28 @@
getHelpers, getHelpers,
self, self,
... ...
}: let }:
let
wrapperArgs = { wrapperArgs = {
inherit modules; inherit modules;
inherit self; inherit self;
inherit getHelpers; inherit getHelpers;
}; };
in { in
perSystem = { {
perSystem =
{
system, system,
pkgs, pkgs,
pkgsUnfree, pkgsUnfree,
config, config,
... ...
}: { }:
{
_module.args = { _module.args = {
makeNixvimWithModule = makeNixvimWithModule = import ../wrappers/standalone.nix pkgs wrapperArgs;
import ../wrappers/standalone.nix
pkgs
wrapperArgs;
makeNixvimWithModuleUnfree = makeNixvimWithModuleUnfree = import ../wrappers/standalone.nix pkgsUnfree wrapperArgs;
import ../wrappers/standalone.nix
pkgsUnfree
wrapperArgs;
}; };
checks = checks =
@ -37,8 +35,7 @@ in {
inherit pkgs; inherit pkgs;
inherit (inputs) home-manager; inherit (inputs) home-manager;
nixvim = self; nixvim = self;
}) }).activationPackage;
.activationPackage;
} }
// pkgs.lib.optionalAttrs (!pkgs.stdenv.isDarwin) { // pkgs.lib.optionalAttrs (!pkgs.stdenv.isDarwin) {
nixos-module = nixos-module =
@ -46,11 +43,7 @@ in {
inherit system; inherit system;
inherit (inputs) nixpkgs; inherit (inputs) nixpkgs;
nixvim = self; nixvim = self;
}) }).config.system.build.toplevel;
.config
.system
.build
.toplevel;
} }
// pkgs.lib.optionalAttrs pkgs.stdenv.isDarwin { // pkgs.lib.optionalAttrs pkgs.stdenv.isDarwin {
darwin-module = darwin-module =
@ -58,8 +51,7 @@ in {
inherit system; inherit system;
inherit (inputs) nix-darwin; inherit (inputs) nix-darwin;
nixvim = self; nixvim = self;
}) }).system;
.system;
}; };
}; };

View file

@ -30,7 +30,8 @@
}; };
}; };
outputs = inputs: outputs =
inputs:
inputs.flake-parts.lib.mkFlake { inherit inputs; } { inputs.flake-parts.lib.mkFlake { inherit inputs; } {
systems = [ systems = [
"x86_64-linux" "x86_64-linux"

View file

@ -3,7 +3,8 @@
nixvimOptions, nixvimOptions,
nixvimTypes, nixvimTypes,
}: }:
with lib; rec { with lib;
rec {
autoGroupOption = types.submodule { autoGroupOption = types.submodule {
options = { options = {
clear = mkOption { clear = mkOption {
@ -75,7 +76,5 @@ with lib; rec {
nested = nixvimOptions.defaultNullOpts.mkBool false "Run nested autocommands."; nested = nixvimOptions.defaultNullOpts.mkBool false "Run nested autocommands.";
}; };
autoCmdOption = types.submodule { autoCmdOption = types.submodule { options = autoCmdOptions; };
options = autoCmdOptions;
};
} }

View file

@ -1,7 +1,5 @@
{ lib, pkgs }:
{ {
lib,
pkgs,
}: {
/* /*
Write a lua file to the nix store, formatted using stylua. Write a lua file to the nix store, formatted using stylua.
@ -16,7 +14,8 @@
- [name] The name of the derivation - [name] The name of the derivation
- [text] The content of the lua file - [text] The content of the lua file
*/ */
writeLua = name: text: writeLua =
name: text:
pkgs.runCommand name { inherit text; } '' pkgs.runCommand name { inherit text; } ''
echo -n "$text" > "$out" echo -n "$text" > "$out"

View file

@ -5,10 +5,9 @@
pkgs, pkgs,
_nixvimTests ? false, _nixvimTests ? false,
... ...
} @ args: { }@args:
{
# Add all exported modules here # Add all exported modules here
check = import ../tests/test-derivation.nix { check = import ../tests/test-derivation.nix { inherit makeNixvim makeNixvimWithModule pkgs; };
inherit makeNixvim makeNixvimWithModule pkgs;
};
helpers = import ./helpers.nix (args // { inherit _nixvimTests; }); helpers = import ./helpers.nix (args // { inherit _nixvimTests; });
} }

View file

@ -3,7 +3,8 @@
pkgs, pkgs,
_nixvimTests, _nixvimTests,
... ...
}: let }:
let
nixvimBuilders = import ./builders.nix { inherit lib pkgs; }; nixvimBuilders = import ./builders.nix { inherit lib pkgs; };
nixvimTypes = import ./types.nix { inherit lib nixvimOptions; }; nixvimTypes = import ./types.nix { inherit lib nixvimOptions; };
nixvimUtils = import ./utils.nix { inherit lib _nixvimTests; }; nixvimUtils = import ./utils.nix { inherit lib _nixvimTests; };
@ -14,7 +15,14 @@ in
maintainers = import ./maintainers.nix; maintainers = import ./maintainers.nix;
keymaps = import ./keymap-helpers.nix { inherit lib nixvimOptions nixvimTypes; }; keymaps = import ./keymap-helpers.nix { inherit lib nixvimOptions nixvimTypes; };
autocmd = import ./autocmd-helpers.nix { inherit lib nixvimOptions nixvimTypes; }; autocmd = import ./autocmd-helpers.nix { inherit lib nixvimOptions nixvimTypes; };
neovim-plugin = import ./neovim-plugin.nix {inherit lib nixvimOptions nixvimUtils toLuaObject;}; neovim-plugin = import ./neovim-plugin.nix {
inherit
lib
nixvimOptions
nixvimUtils
toLuaObject
;
};
vim-plugin = import ./vim-plugin.nix { inherit lib nixvimOptions nixvimUtils; }; vim-plugin = import ./vim-plugin.nix { inherit lib nixvimOptions nixvimUtils; };
inherit nixvimTypes; inherit nixvimTypes;
inherit toLuaObject; inherit toLuaObject;

View file

@ -3,40 +3,25 @@
nixvimOptions, nixvimOptions,
nixvimTypes, nixvimTypes,
}: }:
with lib; rec { with lib;
rec {
# These are the configuration options that change the behavior of each mapping. # These are the configuration options that change the behavior of each mapping.
mapConfigOptions = { mapConfigOptions = {
silent = silent = nixvimOptions.defaultNullOpts.mkBool false "Whether this mapping should be silent. Equivalent to adding <silent> to a map.";
nixvimOptions.defaultNullOpts.mkBool false
"Whether this mapping should be silent. Equivalent to adding <silent> to a map.";
nowait = nowait = nixvimOptions.defaultNullOpts.mkBool false "Whether to wait for extra input on ambiguous mappings. Equivalent to adding <nowait> to a map.";
nixvimOptions.defaultNullOpts.mkBool false
"Whether to wait for extra input on ambiguous mappings. Equivalent to adding <nowait> to a map.";
script = script = nixvimOptions.defaultNullOpts.mkBool false "Equivalent to adding <script> to a map.";
nixvimOptions.defaultNullOpts.mkBool false
"Equivalent to adding <script> to a map.";
expr = expr = nixvimOptions.defaultNullOpts.mkBool false "Means that the action is actually an expression. Equivalent to adding <expr> to a map.";
nixvimOptions.defaultNullOpts.mkBool false
"Means that the action is actually an expression. Equivalent to adding <expr> to a map.";
unique = unique = nixvimOptions.defaultNullOpts.mkBool false "Whether to fail if the map is already defined. Equivalent to adding <unique> to a map.";
nixvimOptions.defaultNullOpts.mkBool false
"Whether to fail if the map is already defined. Equivalent to adding <unique> to a map.";
noremap = noremap = nixvimOptions.defaultNullOpts.mkBool true "Whether to use the 'noremap' variant of the command, ignoring any custom mappings on the defined action. It is highly advised to keep this on, which is the default.";
nixvimOptions.defaultNullOpts.mkBool true
"Whether to use the 'noremap' variant of the command, ignoring any custom mappings on the defined action. It is highly advised to keep this on, which is the default.";
remap = remap = nixvimOptions.defaultNullOpts.mkBool false "Make the mapping recursive. Inverses \"noremap\"";
nixvimOptions.defaultNullOpts.mkBool false
"Make the mapping recursive. Inverses \"noremap\"";
desc = desc = nixvimOptions.mkNullOrOption types.str "A textual description of this keybind, to be shown in which-key, if you have it.";
nixvimOptions.mkNullOrOption types.str
"A textual description of this keybind, to be shown in which-key, if you have it.";
}; };
modes = { modes = {
@ -71,56 +56,50 @@ with lib; rec {
modeEnum = modeEnum =
types.enum types.enum
# ["" "n" "v" ...] # ["" "n" "v" ...]
( (map ({ short, ... }: short) (attrValues modes));
map
(
{short, ...}: short
)
(attrValues modes)
);
mapOptionSubmodule = mkMapOptionSubmodule { }; mapOptionSubmodule = mkMapOptionSubmodule { };
mkModeOption = default: mkModeOption =
default:
mkOption { mkOption {
type = with types; type = with types; either modeEnum (listOf modeEnum);
either
modeEnum
(listOf modeEnum);
description = '' description = ''
One or several modes. One or several modes.
Use the short-names (`"n"`, `"v"`, ...). Use the short-names (`"n"`, `"v"`, ...).
See `:h map-modes` to learn more. See `:h map-modes` to learn more.
''; '';
inherit default; inherit default;
example = ["n" "v"]; example = [
"n"
"v"
];
}; };
mkMapOptionSubmodule = defaults: (with types; mkMapOptionSubmodule =
defaults:
(
with types;
submodule { submodule {
options = { options = {
key = mkOption ({ key = mkOption (
{
type = str; type = str;
description = "The key to map."; description = "The key to map.";
example = "<C-m>"; example = "<C-m>";
} }
// ( // (optionalAttrs (defaults ? key) { default = defaults.key; })
optionalAttrs );
(defaults ? key)
{default = defaults.key;}
));
mode = mkModeOption defaults.mode or ""; mode = mkModeOption defaults.mode or "";
action = mkOption ({ action = mkOption (
{
type = nixvimTypes.maybeRaw str; type = nixvimTypes.maybeRaw str;
description = "The action to execute."; description = "The action to execute.";
} }
// ( // (optionalAttrs (defaults ? action) { default = defaults.action; })
optionalAttrs );
(defaults ? action)
{default = defaults.action;}
));
lua = mkOption { lua = mkOption {
type = bool; type = bool;
@ -133,17 +112,18 @@ with lib; rec {
options = mapConfigOptions; options = mapConfigOptions;
}; };
}); }
);
# Correctly merge two attrs (partially) representing a mapping. # Correctly merge two attrs (partially) representing a mapping.
mergeKeymap = defaults: keymap: let mergeKeymap =
defaults: keymap:
let
# First, merge the `options` attrs of both options. # First, merge the `options` attrs of both options.
mergedOpts = (defaults.options or { }) // (keymap.options or { }); mergedOpts = (defaults.options or { }) // (keymap.options or { });
in in
# Then, merge the root attrs together and add the previously merged `options` attrs. # Then, merge the root attrs together and add the previously merged `options` attrs.
(defaults // keymap) // { options = mergedOpts; }; (defaults // keymap) // { options = mergedOpts; };
mkKeymaps = defaults: mkKeymaps = defaults: map (mergeKeymap defaults);
map
(mergeKeymap defaults);
} }

View file

@ -18,9 +18,7 @@
github = "MattSturgeon"; github = "MattSturgeon";
githubId = 5046562; githubId = 5046562;
name = "Matt Sturgeon"; name = "Matt Sturgeon";
keys = [ keys = [ { fingerprint = "7082 22EA 1808 E39A 83AC 8B18 4F91 844C ED1A 8299"; } ];
{fingerprint = "7082 22EA 1808 E39A 83AC 8B18 4F91 844C ED1A 8299";}
];
}; };
DanielLaing = { DanielLaing = {
email = "daniel@daniellaing.com"; email = "daniel@daniellaing.com";
@ -28,9 +26,7 @@
github = "Bodleum"; github = "Bodleum";
githubId = 60107449; githubId = 60107449;
name = "Daniel Laing"; name = "Daniel Laing";
keys = [ keys = [ { fingerprint = "0821 8B96 DC73 85E5 BB7C A535 D264 3BD2 13BC 0FA8"; } ];
{fingerprint = "0821 8B96 DC73 85E5 BB7C A535 D264 3BD2 13BC 0FA8";}
];
}; };
JanKremer = { JanKremer = {
email = "mail@jankremer.eu"; email = "mail@jankremer.eu";
@ -38,9 +34,7 @@
github = "janurskremer"; github = "janurskremer";
githubId = 79042825; githubId = 79042825;
name = "Jan Kremer"; name = "Jan Kremer";
keys = [ keys = [ { fingerprint = "20AF 0A65 9F2B 93AD 9184 15D1 A7DA 689C B3B0 78EC"; } ];
{fingerprint = "20AF 0A65 9F2B 93AD 9184 15D1 A7DA 689C B3B0 78EC";}
];
}; };
Kareem-Medhat = { Kareem-Medhat = {
email = "kareemmedhatnabil@gmail.com"; email = "kareemmedhatnabil@gmail.com";

View file

@ -4,19 +4,20 @@
toLuaObject, toLuaObject,
nixvimUtils, nixvimUtils,
}: }:
with lib; rec { with lib;
mkSettingsOption = { rec {
mkSettingsOption =
{
pluginName ? null, pluginName ? null,
options ? { }, options ? { },
description ? description ?
if pluginName != null if pluginName != null then
then "Options provided to the `require('${pluginName}').setup` function." "Options provided to the `require('${pluginName}').setup` function."
else throw "mkSettingsOption: Please provide either a `pluginName` or `description`.", else
throw "mkSettingsOption: Please provide either a `pluginName` or `description`.",
example ? null, example ? null,
}: }:
nixvimOptions.mkSettingsOption { nixvimOptions.mkSettingsOption { inherit options description example; };
inherit options description example;
};
# TODO: DEPRECATED: use the `settings` option instead # TODO: DEPRECATED: use the `settings` option instead
extraOptionsOptions = { extraOptionsOptions = {
@ -30,7 +31,9 @@ with lib; rec {
}; };
}; };
mkNeovimPlugin = config: { mkNeovimPlugin =
config:
{
name, name,
maintainers, maintainers,
url ? defaultPackage.meta.homepage, url ? defaultPackage.meta.homepage,
@ -54,58 +57,42 @@ with lib; rec {
extraPlugins ? [ ], extraPlugins ? [ ],
extraPackages ? [ ], extraPackages ? [ ],
callSetup ? true, callSetup ? true,
}: let }:
namespace = let
if isColorscheme namespace = if isColorscheme then "colorschemes" else "plugins";
then "colorschemes" in
else "plugins"; {
in {
meta = { meta = {
inherit maintainers; inherit maintainers;
nixvimInfo = { nixvimInfo = {
inherit inherit description name url;
description
name
url
;
kind = namespace; kind = namespace;
}; };
}; };
imports = let imports =
basePluginPath = [namespace name]; let
basePluginPath = [
namespace
name
];
settingsPath = basePluginPath ++ [ "settings" ]; settingsPath = basePluginPath ++ [ "settings" ];
in in
imports imports
++ ( ++ (optional deprecateExtraOptions (
optional mkRenamedOptionModule (basePluginPath ++ [ "extraOptions" ]) settingsPath
deprecateExtraOptions ))
( ++ (map (
mkRenamedOptionModule option:
(basePluginPath ++ ["extraOptions"]) let
settingsPath optionPath = if isString option then [ option ] else option; # option is already a path (i.e. a list)
)
)
++ (
map
(
option: let
optionPath =
if isString option
then [option]
else option; # option is already a path (i.e. a list)
optionPathSnakeCase = map nixvimUtils.toSnakeCase optionPath; optionPathSnakeCase = map nixvimUtils.toSnakeCase optionPath;
in in
mkRenamedOptionModule mkRenamedOptionModule (basePluginPath ++ optionPath) (settingsPath ++ optionPathSnakeCase)
(basePluginPath ++ optionPath) ) optionsRenamedToSettings);
(settingsPath ++ optionPathSnakeCase)
)
optionsRenamedToSettings
);
options.${namespace}.${name} = options.${namespace}.${name} = {
{
enable = mkEnableOption originalName; enable = mkEnableOption originalName;
package = nixvimOptions.mkPackageOption originalName defaultPackage; package = nixvimOptions.mkPackageOption originalName defaultPackage;
@ -115,18 +102,14 @@ with lib; rec {
options = settingsOptions; options = settingsOptions;
example = settingsExample; example = settingsExample;
}; };
} } // extraOptions;
// extraOptions;
config = let config =
let
cfg = config.${namespace}.${name}; cfg = config.${namespace}.${name};
extraConfigNamespace = extraConfigNamespace = if isColorscheme then "extraConfigLuaPre" else "extraConfigLua";
if isColorscheme
then "extraConfigLuaPre"
else "extraConfigLua";
in in
mkIf cfg.enable ( mkIf cfg.enable (mkMerge [
mkMerge [
{ {
extraPlugins = [ cfg.package ] ++ extraPlugins; extraPlugins = [ cfg.package ] ++ extraPlugins;
inherit extraPackages; inherit extraPackages;
@ -135,11 +118,8 @@ with lib; rec {
require('${luaName}').setup(${toLuaObject cfg.settings}) require('${luaName}').setup(${toLuaObject cfg.settings})
''; '';
} }
(optionalAttrs (isColorscheme && (colorscheme != null)) { (optionalAttrs (isColorscheme && (colorscheme != null)) { inherit colorscheme; })
inherit colorscheme;
})
(extraConfig cfg) (extraConfig cfg)
] ]);
);
}; };
} }

View file

@ -4,21 +4,23 @@
nixvimUtils, nixvimUtils,
}: }:
with lib; with lib;
with nixvimUtils; rec { with nixvimUtils;
rec {
# Creates an option with a nullable type that defaults to null. # Creates an option with a nullable type that defaults to null.
mkNullOrOption = type: desc: mkNullOrOption =
type: desc:
lib.mkOption { lib.mkOption {
type = lib.types.nullOr type; type = lib.types.nullOr type;
default = null; default = null;
description = desc; description = desc;
}; };
mkCompositeOption = desc: options: mkCompositeOption = desc: options: mkNullOrOption (types.submodule { inherit options; }) desc;
mkNullOrOption (types.submodule {inherit options;}) desc;
mkNullOrStr = mkNullOrOption (with nixvimTypes; maybeRaw str); mkNullOrStr = mkNullOrOption (with nixvimTypes; maybeRaw str);
mkNullOrLua = desc: mkNullOrLua =
desc:
lib.mkOption { lib.mkOption {
type = lib.types.nullOr nixvimTypes.strLua; type = lib.types.nullOr nixvimTypes.strLua;
default = null; default = null;
@ -26,7 +28,8 @@ with nixvimUtils; rec {
apply = mkRaw; apply = mkRaw;
}; };
mkNullOrLuaFn = desc: mkNullOrLuaFn =
desc:
lib.mkOption { lib.mkOption {
type = lib.types.nullOr nixvimTypes.strLuaFn; type = lib.types.nullOr nixvimTypes.strLuaFn;
default = null; default = null;
@ -34,37 +37,35 @@ with nixvimUtils; rec {
apply = mkRaw; apply = mkRaw;
}; };
mkNullOrStrLuaOr = ty: desc: mkNullOrStrLuaOr =
ty: desc:
lib.mkOption { lib.mkOption {
type = lib.types.nullOr (types.either nixvimTypes.strLua ty); type = lib.types.nullOr (types.either nixvimTypes.strLua ty);
default = null; default = null;
description = desc; description = desc;
apply = v: apply = v: if builtins.isString v then mkRaw v else v;
if builtins.isString v
then mkRaw v
else v;
}; };
mkNullOrStrLuaFnOr = ty: desc: mkNullOrStrLuaFnOr =
ty: desc:
lib.mkOption { lib.mkOption {
type = lib.types.nullOr (types.either nixvimTypes.strLuaFn ty); type = lib.types.nullOr (types.either nixvimTypes.strLuaFn ty);
default = null; default = null;
description = desc; description = desc;
apply = v: apply = v: if builtins.isString v then mkRaw v else v;
if builtins.isString v
then mkRaw v
else v;
}; };
defaultNullOpts = rec { defaultNullOpts = rec {
mkNullable = type: default: desc: mkNullable =
type: default: desc:
mkNullOrOption type ( mkNullOrOption type (
let let
defaultDesc = "default: `${default}`"; defaultDesc = "default: `${default}`";
in in
if desc == "" if desc == "" then
then defaultDesc defaultDesc
else '' else
''
${desc} ${desc}
${defaultDesc} ${defaultDesc}
@ -73,33 +74,41 @@ with nixvimUtils; rec {
mkNullableWithRaw = type: mkNullable (maybeRaw type); mkNullableWithRaw = type: mkNullable (maybeRaw type);
mkStrLuaOr = type: default: desc: mkStrLuaOr =
mkNullOrStrLuaOr type (let type: default: desc:
mkNullOrStrLuaOr type (
let
defaultDesc = "default: `${default}`"; defaultDesc = "default: `${default}`";
in in
if desc == "" if desc == "" then
then defaultDesc defaultDesc
else '' else
''
${desc} ${desc}
${defaultDesc} ${defaultDesc}
''); ''
);
mkStrLuaFnOr = type: default: desc: mkStrLuaFnOr =
mkNullOrStrLuaFnOr type (let type: default: desc:
mkNullOrStrLuaFnOr type (
let
defaultDesc = "default: `${default}`"; defaultDesc = "default: `${default}`";
in in
if desc == "" if desc == "" then
then defaultDesc defaultDesc
else '' else
''
${desc} ${desc}
${defaultDesc} ${defaultDesc}
''); ''
);
mkLua = default: desc: mkLua =
mkNullOrLua default: desc:
( mkNullOrLua (
(optionalString (desc != "") '' (optionalString (desc != "") ''
${desc} ${desc}
@ -109,14 +118,16 @@ with nixvimUtils; rec {
'' ''
); );
mkLuaFn = default: desc: let mkLuaFn =
default: desc:
let
defaultDesc = "default: `${default}`"; defaultDesc = "default: `${default}`";
in in
mkNullOrLuaFn mkNullOrLuaFn (
( if desc == "" then
if desc == "" defaultDesc
then defaultDesc else
else '' ''
${desc} ${desc}
${defaultDesc} ${defaultDesc}
@ -129,120 +140,106 @@ with nixvimUtils; rec {
mkPositiveInt = default: mkNullable (with nixvimTypes; maybeRaw ints.positive) (toString default); mkPositiveInt = default: mkNullable (with nixvimTypes; maybeRaw ints.positive) (toString default);
# Unsigned: >=0 # Unsigned: >=0
mkUnsignedInt = default: mkNullable (with nixvimTypes; maybeRaw ints.unsigned) (toString default); mkUnsignedInt = default: mkNullable (with nixvimTypes; maybeRaw ints.unsigned) (toString default);
mkBool = default: mkBool =
mkNullable (with nixvimTypes; maybeRaw bool) ( default: mkNullable (with nixvimTypes; maybeRaw bool) (if default then "true" else "false");
if default
then "true"
else "false"
);
mkStr = default: mkNullable (with nixvimTypes; maybeRaw str) ''${builtins.toString default}''; mkStr = default: mkNullable (with nixvimTypes; maybeRaw str) ''${builtins.toString default}'';
mkAttributeSet = default: mkNullable nixvimTypes.attrs ''${default}''; mkAttributeSet = default: mkNullable nixvimTypes.attrs ''${default}'';
mkListOf = ty: default: mkNullable (with nixvimTypes; listOf (maybeRaw ty)) default; mkListOf = ty: default: mkNullable (with nixvimTypes; listOf (maybeRaw ty)) default;
mkAttrsOf = ty: default: mkNullable (with nixvimTypes; attrsOf (maybeRaw ty)) default; mkAttrsOf = ty: default: mkNullable (with nixvimTypes; attrsOf (maybeRaw ty)) default;
mkEnum = enumValues: default: mkNullable (with nixvimTypes; maybeRaw (enum enumValues)) ''"${default}"''; mkEnum =
enumValues: default: mkNullable (with nixvimTypes; maybeRaw (enum enumValues)) ''"${default}"'';
mkEnumFirstDefault = enumValues: mkEnum enumValues (head enumValues); mkEnumFirstDefault = enumValues: mkEnum enumValues (head enumValues);
mkBorder = default: name: desc: mkBorder =
mkNullable default: name: desc:
(with nixvimTypes; maybeRaw border) mkNullable (with nixvimTypes; maybeRaw border) default (
default let
(let
defaultDesc = '' defaultDesc = ''
Defines the border to use for ${name}. Defines the border to use for ${name}.
Accepts same border values as `nvim_open_win()`. See `:help nvim_open_win()` for more info. Accepts same border values as `nvim_open_win()`. See `:help nvim_open_win()` for more info.
''; '';
in in
if desc == "" if desc == "" then
then defaultDesc defaultDesc
else '' else
''
${desc} ${desc}
${defaultDesc} ${defaultDesc}
''); ''
mkSeverity = default: desc: );
mkSeverity =
default: desc:
mkOption { mkOption {
type = with types; type =
nullOr with types;
( nullOr (
either ints.unsigned either ints.unsigned (enum [
( "error"
enum "warn"
["error" "warn" "info" "hint"] "info"
) "hint"
])
); );
default = null; default = null;
apply = apply = mapNullable (
mapNullable value: if isInt value then value else mkRaw "vim.diagnostic.severity.${strings.toUpper value}"
(
value:
if isInt value
then value
else mkRaw "vim.diagnostic.severity.${strings.toUpper value}"
); );
description = let description =
let
defaultDesc = "default: `${toString default}`"; defaultDesc = "default: `${toString default}`";
in in
if desc == "" if desc == "" then
then defaultDesc defaultDesc
else '' else
''
${desc} ${desc}
${defaultDesc} ${defaultDesc}
''; '';
}; };
mkLogLevel = default: desc: mkLogLevel =
default: desc:
mkOption { mkOption {
type = with types; type = with types; nullOr (either ints.unsigned nixvimTypes.logLevel);
nullOr
(
either
ints.unsigned
nixvimTypes.logLevel
);
default = null; default = null;
apply = apply = mapNullable (
mapNullable value: if isInt value then value else mkRaw "vim.log.levels.${strings.toUpper value}"
(
value:
if isInt value
then value
else mkRaw "vim.log.levels.${strings.toUpper value}"
); );
description = let description =
let
defaultDesc = "default: `${toString default}`"; defaultDesc = "default: `${toString default}`";
in in
if desc == "" if desc == "" then
then defaultDesc defaultDesc
else '' else
''
${desc} ${desc}
${defaultDesc} ${defaultDesc}
''; '';
}; };
mkHighlight = default: name: desc: mkHighlight =
mkNullable default: name: desc:
nixvimTypes.highlight mkNullable nixvimTypes.highlight default (if desc == "" then "Highlight settings." else desc);
default
(
if desc == ""
then "Highlight settings."
else desc
);
}; };
mkPackageOption = name: default: mkPackageOption =
name: default:
mkOption { mkOption {
type = types.package; type = types.package;
inherit default; inherit default;
description = "Plugin to use for ${name}"; description = "Plugin to use for ${name}";
}; };
mkSettingsOption = { mkSettingsOption =
{
options ? { }, options ? { },
description, description,
example ? null, example ? null,
}: }:
mkOption { mkOption {
type = with types; type =
with types;
submodule { submodule {
freeformType = attrsOf anything; freeformType = attrsOf anything;
inherit options; inherit options;
@ -250,8 +247,8 @@ with nixvimUtils; rec {
default = { }; default = { };
inherit description; inherit description;
example = example =
if example == null if example == null then
then { {
foo_bar = 42; foo_bar = 42;
hostname = "localhost:8080"; hostname = "localhost:8080";
callback.__raw = '' callback.__raw = ''
@ -260,6 +257,7 @@ with nixvimUtils; rec {
end end
''; '';
} }
else example; else
example;
}; };
} }

View file

@ -1,46 +1,44 @@
{ lib }: { lib }:
with lib; rec { with lib;
rec {
# Black functional magic that converts a bunch of different Nix types to their # Black functional magic that converts a bunch of different Nix types to their
# lua equivalents! # lua equivalents!
toLuaObject = args: toLuaObject =
if builtins.isAttrs args args:
then if builtins.isAttrs args then
if hasAttr "__raw" args if hasAttr "__raw" args then
then args.__raw args.__raw
else if hasAttr "__empty" args else if hasAttr "__empty" args then
then "{ }" "{ }"
else else
"{" "{"
+ (concatStringsSep "," + (concatStringsSep "," (
(mapAttrsToList mapAttrsToList (
(n: v:
if (builtins.match "__unkeyed.*" n) != null
then toLuaObject v
else if n == "__emptyString"
then "[''] = " + (toLuaObject v)
else "[${toLuaObject n}] = " + (toLuaObject v))
(filterAttrs
(
n: v: n: v:
v != null && (toLuaObject v != "{}") if (builtins.match "__unkeyed.*" n) != null then
) toLuaObject v
args))) else if n == "__emptyString" then
"[''] = " + (toLuaObject v)
else
"[${toLuaObject n}] = " + (toLuaObject v)
) (filterAttrs (n: v: v != null && (toLuaObject v != "{}")) args)
))
+ "}" + "}"
else if builtins.isList args else if builtins.isList args then
then "{" + concatMapStringsSep "," toLuaObject args + "}" "{" + concatMapStringsSep "," toLuaObject args + "}"
else if builtins.isString args else if builtins.isString args then
then
# This should be enough! # This should be enough!
builtins.toJSON args builtins.toJSON args
else if builtins.isPath args else if builtins.isPath args then
then builtins.toJSON (toString args) builtins.toJSON (toString args)
else if builtins.isBool args else if builtins.isBool args then
then "${boolToString args}" "${boolToString args}"
else if builtins.isFloat args else if builtins.isFloat args then
then "${toString args}" "${toString args}"
else if builtins.isInt args else if builtins.isInt args then
then "${toString args}" "${toString args}"
else if (args == null) else if (args == null) then
then "nil" "nil"
else ""; else
"";
} }

View file

@ -1,12 +1,10 @@
{ { lib, nixvimOptions, ... }:
lib,
nixvimOptions,
...
}:
with lib; with lib;
with nixvimOptions; with nixvimOptions;
with lib.types; let with lib.types;
strLikeType = description: let
strLikeType =
description:
mkOptionType { mkOptionType {
name = "str"; name = "str";
inherit description; inherit description;
@ -26,19 +24,24 @@ in
check = isRawType; check = isRawType;
}; };
maybeRaw = type: maybeRaw = type: types.either type rawLua;
types.either
type
rawLua;
border = with types; border =
with types;
oneOf [ oneOf [
str str
(listOf str) (listOf str)
(listOf (listOf str)) (listOf (listOf str))
]; ];
logLevel = types.enum ["off" "error" "warn" "info" "debug" "trace"]; logLevel = types.enum [
"off"
"error"
"warn"
"info"
"debug"
"trace"
];
highlight = types.submodule { highlight = types.submodule {
# Adds flexibility for other keys # Adds flexibility for other keys

View file

@ -1,28 +1,27 @@
{ lib, _nixvimTests }:
with lib;
{ {
lib, listToUnkeyedAttrs =
_nixvimTests, list:
}: builtins.listToAttrs (lib.lists.imap0 (idx: lib.nameValuePair "__unkeyed-${toString idx}") list);
with lib; {
listToUnkeyedAttrs = list:
builtins.listToAttrs
(lib.lists.imap0 (idx: lib.nameValuePair "__unkeyed-${toString idx}") list);
enableExceptInTests = !_nixvimTests; enableExceptInTests = !_nixvimTests;
emptyTable = {"__empty" = null;}; emptyTable = {
"__empty" = null;
};
/* /*
Convert a string from camelCase to snake_case Convert a string from camelCase to snake_case
Type: string -> string Type: string -> string
*/ */
toSnakeCase = let toSnakeCase =
let
splitByWords = builtins.split "([A-Z])"; splitByWords = builtins.split "([A-Z])";
processWord = s: processWord = s: if isString s then s else "_" + toLower (elemAt s 0);
if isString s
then s
else "_" + toLower (elemAt s 0);
in in
string: let string:
let
words = splitByWords string; words = splitByWords string;
in in
concatStrings (map processWord words); concatStrings (map processWord words);
@ -31,15 +30,9 @@ with lib; {
mkIfNonNull = x: (mkIfNonNull' x x); mkIfNonNull = x: (mkIfNonNull' x x);
ifNonNull' = x: y: ifNonNull' = x: y: if (x == null) then null else y;
if (x == null)
then null
else y;
mkRaw = r: mkRaw = r: if (isString r && (r != "")) then { __raw = r; } else null;
if (isString r && (r != ""))
then {__raw = r;}
else null;
wrapDo = string: '' wrapDo = string: ''
do do

View file

@ -3,13 +3,13 @@
nixvimOptions, nixvimOptions,
nixvimUtils, nixvimUtils,
}: }:
with lib; { with lib;
mkVimPlugin = config: { {
mkVimPlugin =
config:
{
name, name,
url ? url ? if defaultPackage != null then defaultPackage.meta.homepage else null,
if defaultPackage != null
then defaultPackage.meta.homepage
else null,
maintainers, maintainers,
imports ? [ ], imports ? [ ],
description ? null, description ? null,
@ -30,11 +30,9 @@ with lib; {
extraConfig ? cfg: { }, extraConfig ? cfg: { },
extraPlugins ? [ ], extraPlugins ? [ ],
extraPackages ? [ ], extraPackages ? [ ],
}: let }:
namespace = let
if isColorscheme namespace = if isColorscheme then "colorschemes" else "plugins";
then "colorschemes"
else "plugins";
cfg = config.${namespace}.${name}; cfg = config.${namespace}.${name};
@ -42,17 +40,14 @@ with lib; {
# does this evaluate package? # does this evaluate package?
packageOption = packageOption =
if defaultPackage == null if defaultPackage == null then
then {} { }
else { else
package = nixvimOptions.mkPackageOption name defaultPackage; { package = nixvimOptions.mkPackageOption name defaultPackage; };
};
createSettingsOption = (isString globalPrefix) && (globalPrefix != ""); createSettingsOption = (isString globalPrefix) && (globalPrefix != "");
settingsOption = settingsOption = optionalAttrs createSettingsOption {
optionalAttrs createSettingsOption
{
settings = nixvimOptions.mkSettingsOption { settings = nixvimOptions.mkSettingsOption {
options = settingsOptions; options = settingsOptions;
example = settingsExample; example = settingsExample;
@ -68,73 +63,50 @@ with lib; {
''; '';
}; };
}; };
in { in
{
meta = { meta = {
inherit maintainers; inherit maintainers;
nixvimInfo = { nixvimInfo = {
inherit inherit description name url;
description
name
url
;
kind = namespace; kind = namespace;
}; };
}; };
options.${namespace}.${name} = options.${namespace}.${name} = {
{
enable = mkEnableOption originalName; enable = mkEnableOption originalName;
} } // settingsOption // packageOption // extraOptions;
// settingsOption
// packageOption
// extraOptions;
imports = let imports =
basePluginPath = [namespace name]; let
basePluginPath = [
namespace
name
];
settingsPath = basePluginPath ++ [ "settings" ]; settingsPath = basePluginPath ++ [ "settings" ];
in in
imports imports
++ ( ++ (optional (deprecateExtraConfig && createSettingsOption) (
optional mkRenamedOptionModule (basePluginPath ++ [ "extraConfig" ]) settingsPath
(deprecateExtraConfig && createSettingsOption) ))
( ++ (map (
mkRenamedOptionModule option:
(basePluginPath ++ ["extraConfig"]) let
settingsPath optionPath = if isString option then [ option ] else option; # option is already a path (i.e. a list)
)
)
++ (
map
(
option: let
optionPath =
if isString option
then [option]
else option; # option is already a path (i.e. a list)
optionPathSnakeCase = map nixvimUtils.toSnakeCase optionPath; optionPathSnakeCase = map nixvimUtils.toSnakeCase optionPath;
in in
mkRenamedOptionModule mkRenamedOptionModule (basePluginPath ++ optionPath) (settingsPath ++ optionPathSnakeCase)
(basePluginPath ++ optionPath) ) optionsRenamedToSettings);
(settingsPath ++ optionPathSnakeCase)
)
optionsRenamedToSettings
);
config = config = mkIf cfg.enable (mkMerge [
mkIf cfg.enable
(
mkMerge [
{ {
inherit extraPackages; inherit extraPackages;
globals = mapAttrs' (n: nameValuePair (globalPrefix + n)) globals; globals = mapAttrs' (n: nameValuePair (globalPrefix + n)) globals;
# does this evaluate package? it would not be desired to evaluate package if we use another package. # does this evaluate package? it would not be desired to evaluate package if we use another package.
extraPlugins = extraPlugins ++ optional (defaultPackage != null) cfg.package; extraPlugins = extraPlugins ++ optional (defaultPackage != null) cfg.package;
} }
(optionalAttrs (isColorscheme && (colorscheme != null)) { (optionalAttrs (isColorscheme && (colorscheme != null)) { inherit colorscheme; })
inherit colorscheme;
})
(extraConfig cfg) (extraConfig cfg)
] ]);
);
}; };
} }

View file

@ -4,7 +4,8 @@
config, config,
... ...
}: }:
with lib; { with lib;
{
options = { options = {
autoGroups = mkOption { autoGroups = mkOption {
type = types.attrsOf helpers.autocmd.autoGroupOption; type = types.attrsOf helpers.autocmd.autoGroupOption;
@ -35,7 +36,8 @@ with lib; {
}; };
}; };
config = let config =
let
inherit (config) autoGroups autoCmd; inherit (config) autoGroups autoCmd;
in in
mkIf (autoGroups != { } || autoCmd != { }) { mkIf (autoGroups != { } || autoCmd != { }) {
@ -43,10 +45,7 @@ with lib; {
# TODO remove in early December 2023. # TODO remove in early December 2023.
assertions = [ assertions = [
{ {
assertion = assertion = all (x: x.description == null) autoCmd;
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.

View file

@ -4,9 +4,11 @@
pkgs, pkgs,
... ...
}: }:
with lib; let with lib;
let
cfg = config.clipboard; cfg = config.clipboard;
in { in
{
options = { options = {
clipboard = { clipboard = {
register = mkOption { register = mkOption {
@ -14,9 +16,7 @@ in {
Sets the register to use for the clipboard. Sets the register to use for the clipboard.
Learn more at https://neovim.io/doc/user/options.html#'clipboard'. Learn more at https://neovim.io/doc/user/options.html#'clipboard'.
''; '';
type = with types; type = with types; nullOr (either str (listOf str));
nullOr
(either str (listOf str));
default = null; default = null;
example = "unnamedplus"; example = "unnamedplus";
}; };
@ -25,12 +25,10 @@ in {
type = types.submodule { type = types.submodule {
options = options =
mapAttrs mapAttrs
( (name: packageName: {
name: packageName: {
enable = mkEnableOption name; enable = mkEnableOption name;
package = mkPackageOption pkgs packageName { }; package = mkPackageOption pkgs packageName { };
} })
)
{ {
wl-copy = "wl-clipboard"; wl-copy = "wl-clipboard";
xclip = "xclip"; xclip = "xclip";
@ -49,9 +47,6 @@ in {
config = { config = {
opts.clipboard = mkIf (cfg.register != null) cfg.register; opts.clipboard = mkIf (cfg.register != null) cfg.register;
extraPackages = extraPackages = mapAttrsToList (n: v: v.package) (filterAttrs (n: v: v.enable) cfg.providers);
mapAttrsToList
(n: v: v.package)
(filterAttrs (n: v: v.enable) cfg.providers);
}; };
} }

View file

@ -1,9 +1,6 @@
{ config, lib, ... }:
with lib;
{ {
config,
lib,
...
}:
with lib; {
options = { options = {
colorscheme = mkOption { colorscheme = mkOption {
type = types.nullOr types.str; type = types.nullOr types.str;

View file

@ -4,7 +4,8 @@
config, config,
... ...
}: }:
with lib; let with lib;
let
commandAttributes = types.submodule { commandAttributes = types.submodule {
options = { options = {
command = mkOption { command = mkOption {
@ -12,13 +13,32 @@ with lib; let
description = "The command to run."; description = "The command to run.";
}; };
nargs = helpers.mkNullOrOption (types.enum ["0" "1" "*" "?" "+"]) '' nargs =
helpers.mkNullOrOption
(types.enum [
"0"
"1"
"*"
"?"
"+"
])
''
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 types; either str helpers.nixvimTypes.rawLua) ''
Tab-completion behaviour, see :h command-complete. Tab-completion behaviour, see :h command-complete.
''; '';
range = helpers.mkNullOrOption (with types; oneOf [bool int (enum ["%"])]) '' range =
helpers.mkNullOrOption
(
with types;
oneOf [
bool
int
(enum [ "%" ])
]
)
''
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 types; either bool int) ''
@ -37,14 +57,16 @@ with lib; let
# TODO: command-preview, need to grab a function here. # TODO: command-preview, need to grab a function here.
}; };
}; };
in { in
{
options.userCommands = mkOption { options.userCommands = mkOption {
type = types.attrsOf commandAttributes; type = 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.";
}; };
config = let config =
let
cleanupCommand = _: cmd: { cleanupCommand = _: cmd: {
inherit (cmd) command; inherit (cmd) command;
options = filterAttrs (name: _: name != "command") cmd; options = filterAttrs (name: _: name != "command") cmd;

View file

@ -1,4 +1,5 @@
{lib, ...}: { { lib, ... }:
{
options.enableMan = lib.mkOption { options.enableMan = lib.mkOption {
type = lib.types.bool; type = lib.types.bool;
default = true; default = true;

View file

@ -1,12 +1,23 @@
{ lib, config, ... }:
with lib;
{ {
lib,
config,
...
}:
with lib; {
imports = [ imports = [
(lib.mkRenamedOptionModule ["plugins" "editorconfig" "enable"] ["editorconfig" "enable"]) (lib.mkRenamedOptionModule
(lib.mkRemovedOptionModule ["plugins" "editorconfig" "package"] "editorconfig is now builtin, no plugin required") [
"plugins"
"editorconfig"
"enable"
]
[
"editorconfig"
"enable"
]
)
(lib.mkRemovedOptionModule [
"plugins"
"editorconfig"
"package"
] "editorconfig is now builtin, no plugin required")
]; ];
options.editorconfig = { options.editorconfig = {
@ -39,12 +50,15 @@ with lib; {
}; };
}; };
config = let config =
let
cfg = config.editorconfig; cfg = config.editorconfig;
in { in
{
globals.editorconfig = mkIf (!cfg.enable) false; globals.editorconfig = mkIf (!cfg.enable) false;
extraConfigLua = let extraConfigLua =
let
mkProperty = name: function: '' mkProperty = name: function: ''
__editorconfig.properties.${name} = ${function} __editorconfig.properties.${name} = ${function}
''; '';

View file

@ -4,34 +4,36 @@
config, config,
... ...
}: }:
with lib; let with lib;
filetypeDefinition = let
helpers.mkNullOrOption filetypeDefinition = helpers.mkNullOrOption (
(with types; with types;
attrsOf ( attrsOf (oneOf [
oneOf [
# Raw filetype # Raw filetype
str str
# Function to set the filetype # Function to set the filetype
helpers.nixvimTypes.rawLua helpers.nixvimTypes.rawLua
# ["filetype" {priority = xx;}] # ["filetype" {priority = xx;}]
(listOf (either str (submodule { (listOf (
either str (submodule {
options = { options = {
priority = mkOption { priority = mkOption { type = int; };
type = int;
}; };
}; })
}))) ))
] ])
)); );
in { in
{
options.filetype = options.filetype =
helpers.mkCompositeOption '' helpers.mkCompositeOption
''
Define additional filetypes. The values can either be a literal filetype or a function Define additional filetypes. The values can either be a literal filetype or a function
taking the filepath and the buffer number. taking the filepath and the buffer number.
For more information check `:h vim.filetype.add()` For more information check `:h vim.filetype.add()`
'' { ''
{
extension = filetypeDefinition "set filetypes matching the file extension"; extension = filetypeDefinition "set filetypes matching the file extension";
filename = filetypeDefinition "set filetypes matching the file name (or path)"; filename = filetypeDefinition "set filetypes matching the file name (or path)";
pattern = filetypeDefinition "set filetypes matching the specified pattern"; pattern = filetypeDefinition "set filetypes matching the specified pattern";

View file

@ -4,7 +4,8 @@
config, config,
... ...
}: }:
with lib; { with lib;
{
options = { options = {
highlight = mkOption { highlight = mkOption {
type = types.attrsOf helpers.nixvimTypes.highlight; type = types.attrsOf helpers.nixvimTypes.highlight;
@ -43,9 +44,7 @@ with lib; {
config = { config = {
extraConfigLuaPre = extraConfigLuaPre =
(optionalString (config.highlight != { }) (optionalString (config.highlight != { })
/* # lua
lua
*/
'' ''
-- Highlight groups {{ -- Highlight groups {{
do do
@ -56,11 +55,10 @@ with lib; {
end end
end end
-- }} -- }}
'') ''
)
+ (optionalString (config.match != { }) + (optionalString (config.match != { })
/* # lua
lua
*/
'' ''
-- Match groups {{ -- Match groups {{
do do
@ -71,13 +69,12 @@ with lib; {
end end
end end
-- }} -- }}
''); ''
);
extraConfigLuaPost = extraConfigLuaPost =
optionalString (config.highlightOverride != { }) optionalString (config.highlightOverride != { })
/* # lua
lua
*/
'' ''
-- Highlight groups {{ -- Highlight groups {{
do do

View file

@ -4,12 +4,11 @@
config, config,
... ...
}: }:
with lib; { with lib;
{
options = { options = {
keymaps = mkOption { keymaps = mkOption {
type = type = types.listOf helpers.keymaps.mapOptionSubmodule;
types.listOf
helpers.keymaps.mapOptionSubmodule;
default = [ ]; default = [ ];
example = [ example = [
{ {
@ -44,24 +43,16 @@ with lib; {
}; };
}; };
config = let config =
let
normalizeMapping = keyMapping: { normalizeMapping = keyMapping: {
inherit inherit (keyMapping) mode key options;
(keyMapping)
mode
key
options
;
action = action = if keyMapping.lua then helpers.mkRaw keyMapping.action else keyMapping.action;
if keyMapping.lua
then helpers.mkRaw keyMapping.action
else keyMapping.action;
}; };
in { in
extraConfigLua = {
optionalString (config.keymaps != []) extraConfigLua = optionalString (config.keymaps != [ ]) ''
''
-- Set up keybinds {{{ -- Set up keybinds {{{
do do
local __nixvim_binds = ${helpers.toLuaObject (map normalizeMapping config.keymaps)} local __nixvim_binds = ${helpers.toLuaObject (map normalizeMapping config.keymaps)}
@ -72,12 +63,11 @@ 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 = autoCmd = mapAttrsToList (event: mappings: {
mapAttrsToList
(
event: mappings: {
inherit event; inherit event;
group = "nixvim_binds_${event}"; group = "nixvim_binds_${event}";
callback = helpers.mkRaw '' callback = helpers.mkRaw ''
@ -91,8 +81,6 @@ with lib; {
end end
''; '';
desc = "Load keymaps for ${event}"; desc = "Load keymaps for ${event}";
} }) config.keymapsOnEvents;
)
config.keymapsOnEvents;
}; };
} }

View file

@ -1,11 +1,9 @@
{ { lib, config, ... }:
lib, with lib;
config, let
...
}:
with lib; let
cfg = config.luaLoader; cfg = config.luaLoader;
in { in
{
options.luaLoader = { options.luaLoader = {
enable = mkOption { enable = mkOption {
type = types.bool; type = types.bool;
@ -27,9 +25,6 @@ in {
}; };
config = { config = {
extraConfigLuaPre = extraConfigLuaPre = if cfg.enable then "vim.loader.enable()" else "vim.loader.disable()";
if cfg.enable
then "vim.loader.enable()"
else "vim.loader.disable()";
}; };
} }

View file

@ -4,7 +4,8 @@
config, config,
... ...
}: }:
with lib; let with lib;
let
optionsAttrs = { optionsAttrs = {
opts = { opts = {
prettyName = "options"; prettyName = "options";
@ -34,47 +35,40 @@ with lib; let
description = "Global variables (`vim.g.*`)"; description = "Global variables (`vim.g.*`)";
}; };
}; };
in { in
options = {
mapAttrs options = mapAttrs (
( _:
_: {description, ...}: { description, ... }:
mkOption { mkOption {
type = with types; attrsOf anything; type = with 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 = imports = mapAttrsToList (old: new: mkRenamedOptionModule [ old ] [ new ]) {
mapAttrsToList
(old: new: mkRenamedOptionModule [old] [new])
{
options = "opts"; options = "opts";
globalOptions = "globalOpts"; globalOptions = "globalOpts";
localOptions = "localOpts"; localOptions = "localOpts";
}; };
config = { config = {
extraConfigLuaPre = extraConfigLuaPre = concatLines (
concatLines mapAttrsToList (
( optionName:
mapAttrsToList {
(
optionName: {
prettyName, prettyName,
luaVariableName, luaVariableName,
luaApi, luaApi,
... ...
}: let }:
let
varName = "nixvim_${luaVariableName}"; varName = "nixvim_${luaVariableName}";
optionDefinitions = config.${optionName}; optionDefinitions = config.${optionName};
in in
optionalString optionalString (optionDefinitions != { }) ''
(optionDefinitions != {})
''
-- Set up ${prettyName} {{{ -- Set up ${prettyName} {{{
do do
local ${varName} = ${helpers.toLuaObject optionDefinitions} local ${varName} = ${helpers.toLuaObject optionDefinitions}
@ -85,8 +79,7 @@ in {
end end
-- }}} -- }}}
'' ''
) ) optionsAttrs
optionsAttrs
); );
}; };
} }

View file

@ -1,9 +1,6 @@
{ { lib, config, ... }:
lib, with lib;
config, let
...
}:
with lib; let
pluginWithConfigType = types.submodule { pluginWithConfigType = types.submodule {
options = { options = {
config = mkOption { config = mkOption {
@ -12,9 +9,7 @@ with lib; let
default = ""; default = "";
}; };
optional = optional = mkEnableOption "optional" // {
mkEnableOption "optional"
// {
description = "Don't load by default (load with :packadd)"; description = "Don't load by default (load with :packadd)";
}; };
@ -24,7 +19,8 @@ with lib; let
}; };
}; };
}; };
in { in
{
options = { options = {
extraPlugins = mkOption { extraPlugins = mkOption {
type = with types; listOf (either package pluginWithConfigType); type = with types; listOf (either package pluginWithConfigType);
@ -74,7 +70,10 @@ in {
}; };
type = mkOption { type = mkOption {
type = types.enum ["vim" "lua"]; type = types.enum [
"vim"
"lua"
];
default = "lua"; default = "lua";
description = "Whether the generated file is a vim or a lua file"; description = "Whether the generated file is a vim or a lua file";
}; };
@ -104,7 +103,8 @@ in {
}; };
}; };
config = let config =
let
contentLua = '' contentLua = ''
${config.extraConfigLuaPre} ${config.extraConfigLuaPre}
vim.cmd([[ vim.cmd([[
@ -124,10 +124,8 @@ in {
${config.extraConfigLuaPost} ${config.extraConfigLuaPost}
EOF EOF
''; '';
in { in
content = {
if config.type == "lua" content = if config.type == "lua" then contentLua else contentVim;
then contentLua
else contentVim;
}; };
} }

View file

@ -1,5 +1,4 @@
{...}: { { ... }:
imports = [ {
../plugins/default.nix imports = [ ../plugins/default.nix ];
];
} }

View file

@ -1,5 +1,6 @@
{ lib, ... }: { lib, ... }:
with lib; { with lib;
{
options = { options = {
warnings = mkOption { warnings = mkOption {
type = types.listOf types.str; type = types.listOf types.str;

View file

@ -5,7 +5,8 @@
pkgs, pkgs,
... ...
}: }:
with lib; let with lib;
let
cfg = config.plugins.barbar; cfg = config.plugins.barbar;
bufferOptions = { bufferOptions = {
@ -14,17 +15,20 @@ with lib; let
buffers in the tabline. buffers in the tabline.
''; '';
bufferNumber = bufferNumber = helpers.mkNullOrOption types.bool "Whether to show the `bufnr` for the associated buffer.";
helpers.mkNullOrOption types.bool
"Whether to show the `bufnr` for the associated buffer.";
button = button = helpers.mkNullOrOption (
helpers.mkNullOrOption (with types; either str (enum [false])) with types; either str (enum [ false ])
"the button which is clicked to close / save a buffer, or indicate that it is pinned."; ) "the button which is clicked to close / save a buffer, or indicate that it is pinned.";
diagnostics = diagnostics =
genAttrs genAttrs
["error" "warn" "info" "hint"] [
"error"
"warn"
"info"
"hint"
]
( (
name: name:
helpers.mkCompositeOption "${name} diagnostic icon." { helpers.mkCompositeOption "${name} diagnostic icon." {
@ -35,9 +39,7 @@ with lib; let
); );
filetype = { filetype = {
customColors = customColors = helpers.defaultNullOpts.mkBool false "Sets the icon's highlight group. If false, will use nvim-web-devicons colors";
helpers.defaultNullOpts.mkBool false
"Sets the icon's highlight group. If false, will use nvim-web-devicons colors";
enable = helpers.defaultNullOpts.mkBool true "Show the filetype icon."; enable = helpers.defaultNullOpts.mkBool true "Show the filetype icon.";
}; };
@ -48,12 +50,10 @@ with lib; let
}; };
}; };
stateOptions = stateOptions = {
{
modified = bufferOptions; modified = bufferOptions;
pinned = bufferOptions; pinned = bufferOptions;
} } // bufferOptions;
// bufferOptions;
keymapsActions = { keymapsActions = {
previous = "Previous"; previous = "Previous";
@ -78,23 +78,18 @@ with lib; let
orderByLanguage = "OrderByLanguage"; orderByLanguage = "OrderByLanguage";
orderByWindowNumber = "OrderByWindowNumber"; orderByWindowNumber = "OrderByWindowNumber";
}; };
in { in
options.plugins.barbar = {
helpers.neovim-plugin.extraOptionsOptions options.plugins.barbar = helpers.neovim-plugin.extraOptionsOptions // {
// {
enable = mkEnableOption "barbar.nvim"; enable = mkEnableOption "barbar.nvim";
package = helpers.mkPackageOption "barbar" pkgs.vimPlugins.barbar-nvim; package = helpers.mkPackageOption "barbar" pkgs.vimPlugins.barbar-nvim;
animation = helpers.defaultNullOpts.mkBool true "Enable/disable animations"; animation = helpers.defaultNullOpts.mkBool true "Enable/disable animations";
autoHide = autoHide = helpers.defaultNullOpts.mkBool false "Enable/disable auto-hiding the tab bar when there is a single buffer.";
helpers.defaultNullOpts.mkBool false
"Enable/disable auto-hiding the tab bar when there is a single buffer.";
tabpages = tabpages = helpers.defaultNullOpts.mkBool true "Enable/disable current/total tabpages indicator (top right corner).";
helpers.defaultNullOpts.mkBool true
"Enable/disable current/total tabpages indicator (top right corner).";
clickable = helpers.defaultNullOpts.mkBool true '' clickable = helpers.defaultNullOpts.mkBool true ''
Enable clickable tabs Enable clickable tabs
@ -111,31 +106,32 @@ in {
''; '';
focusOnClose = focusOnClose =
helpers.defaultNullOpts.mkEnumFirstDefault ["left" "right"] helpers.defaultNullOpts.mkEnumFirstDefault
[
"left"
"right"
]
'' ''
A buffer to this direction will be focused (if it exists) when closing the current buffer. A buffer to this direction will be focused (if it exists) when closing the current buffer.
''; '';
highlightAlternate = helpers.defaultNullOpts.mkBool false "Highlight alternate buffers"; highlightAlternate = helpers.defaultNullOpts.mkBool false "Highlight alternate buffers";
highlightInactiveFileIcons = highlightInactiveFileIcons = helpers.defaultNullOpts.mkBool false "Highlight file icons in inactive buffers";
helpers.defaultNullOpts.mkBool false
"Highlight file icons in inactive buffers";
highlightVisible = helpers.defaultNullOpts.mkBool true "Highlight visible buffers"; highlightVisible = helpers.defaultNullOpts.mkBool true "Highlight visible buffers";
icons = icons =
stateOptions stateOptions
// ( // (mapAttrs
mapAttrs (
(name: description: name: description:
mkOption { mkOption {
type = types.submodule { type = types.submodule { options = stateOptions; };
options = stateOptions;
};
default = { }; default = { };
inherit description; inherit description;
}) }
)
{ {
alternate = "The icons used for an alternate buffer."; alternate = "The icons used for an alternate buffer.";
current = "The icons for the current buffer."; current = "The icons for the current buffer.";
@ -170,9 +166,7 @@ in {
helpers.defaultNullOpts.mkInt 1 helpers.defaultNullOpts.mkInt 1
"Sets the minimum padding width with which to surround each tab"; "Sets the minimum padding width with which to surround each tab";
maximumLength = maximumLength = helpers.defaultNullOpts.mkInt 30 "Sets the maximum buffer name length.";
helpers.defaultNullOpts.mkInt 30
"Sets the maximum buffer name length.";
semanticLetters = helpers.defaultNullOpts.mkBool true '' semanticLetters = helpers.defaultNullOpts.mkBool true ''
If set, the letters for each buffer in buffer-pick mode will be assigned based on their If set, the letters for each buffer in buffer-pick mode will be assigned based on their
@ -181,33 +175,25 @@ in {
order of usability (see `letters` option) order of usability (see `letters` option)
''; '';
letters = letters = helpers.defaultNullOpts.mkStr "asdfjkl;ghnmxcvbziowerutyqpASDFJKLGHNMXCVBZIOWERUTYQP" ''
helpers.defaultNullOpts.mkStr
"asdfjkl;ghnmxcvbziowerutyqpASDFJKLGHNMXCVBZIOWERUTYQP"
''
New buffer letters are assigned in this order. New buffer letters are assigned in this order.
This order is optimal for the qwerty keyboard layout but might need adjustment for other layouts. This order is optimal for the qwerty keyboard layout but might need adjustment for other layouts.
''; '';
sidebarFiletypes = sidebarFiletypes = helpers.mkNullOrOption (
helpers.mkNullOrOption
(
with types; with types;
attrsOf ( attrsOf (
either either (enum [ true ]) (
(enum [true]) types.submodule {
(types.submodule {
options = { options = {
text = helpers.mkNullOrOption types.str "The text used for the offset"; text = helpers.mkNullOrOption types.str "The text used for the offset";
event = event = helpers.mkNullOrOption types.str "The event which the sidebar executes when leaving.";
helpers.mkNullOrOption types.str
"The event which the sidebar executes when leaving.";
}; };
}) }
) )
) )
"Set the filetypes which barbar will offset itself for"; ) "Set the filetypes which barbar will offset itself for";
noNameTitle = helpers.mkNullOrOption types.str '' noNameTitle = helpers.mkNullOrOption types.str ''
Sets the name of unnamed buffers. Sets the name of unnamed buffers.
@ -219,19 +205,14 @@ in {
{ {
silent = mkEnableOption "silent keymaps for barbar"; silent = mkEnableOption "silent keymaps for barbar";
} }
// ( // (mapAttrs (
mapAttrs optionName: funcName: helpers.mkNullOrOption types.str "Keymap for function Buffer${funcName}"
( ) keymapsActions);
optionName: funcName:
helpers.mkNullOrOption types.str "Keymap for function Buffer${funcName}"
)
keymapsActions
);
}; };
config = let config =
setupOptions = let
{ setupOptions = {
inherit (cfg) animation; inherit (cfg) animation;
auto_hide = cfg.autoHide; auto_hide = cfg.autoHide;
inherit (cfg) tabpages; inherit (cfg) tabpages;
@ -242,9 +223,10 @@ in {
highlight_alternate = cfg.highlightAlternate; highlight_alternate = cfg.highlightAlternate;
highlight_inactive_file_icons = cfg.highlightInactiveFileIcons; highlight_inactive_file_icons = cfg.highlightInactiveFileIcons;
highlight_visible = cfg.highlightVisible; highlight_visible = cfg.highlightVisible;
icons = let icons =
handleBufferOption = bufferOption: let
with bufferOption; { handleBufferOption =
bufferOption: with bufferOption; {
buffer_index = bufferIndex; buffer_index = bufferIndex;
buffer_number = bufferNumber; buffer_number = bufferNumber;
inherit button; inherit button;
@ -255,25 +237,19 @@ in {
*/ */
let let
setIcons = filterAttrs (n: v: v != null) cfg.icons.diagnostics; setIcons = filterAttrs (n: v: v != null) cfg.icons.diagnostics;
setIconsList = setIconsList = mapAttrsToList (name: value: {
mapAttrsToList
(name: value: {
key = "vim.diagnostic.severity.${strings.toUpper name}"; key = "vim.diagnostic.severity.${strings.toUpper name}";
value = helpers.ifNonNull' value (helpers.toLuaObject { value = helpers.ifNonNull' value (
helpers.toLuaObject {
enabled = value.enable; enabled = value.enable;
inherit (value) icon; inherit (value) icon;
}); }
}) );
setIcons; }) setIcons;
in in
helpers.mkRaw ( helpers.mkRaw (
"{" "{"
+ concatStringsSep "," + concatStringsSep "," (map (iconOption: "[${iconOption.key}] = ${iconOption.value}") setIconsList)
(
map
(iconOption: "[${iconOption.key}] = ${iconOption.value}")
setIconsList
)
+ "}" + "}"
); );
filetype = with filetype; { filetype = with filetype; {
@ -283,33 +259,22 @@ in {
inherit separator; inherit separator;
}; };
handleStateOption = stateOption: handleStateOption =
stateOption:
with stateOption; with stateOption;
{ {
modified = handleBufferOption modified; modified = handleBufferOption modified;
pinned = handleBufferOption pinned; pinned = handleBufferOption pinned;
} }
// ( // (handleBufferOption (getAttrs (attrNames stateOption) stateOption));
handleBufferOption
(
getAttrs (attrNames stateOption)
stateOption
)
);
in in
( (handleStateOption (getAttrs (attrNames stateOptions) cfg.icons))
handleStateOption // (genAttrs [
( "alternate"
getAttrs "current"
(attrNames stateOptions) "inactive"
cfg.icons "visible"
) ] (optionName: handleStateOption cfg.icons.${optionName}));
)
// (
genAttrs
["alternate" "current" "inactive" "visible"]
(optionName: handleStateOption cfg.icons.${optionName})
);
inherit (cfg) hide; inherit (cfg) hide;
insert_at_end = cfg.insertAtEnd; insert_at_end = cfg.insertAtEnd;
insert_at_start = cfg.insertAtStart; insert_at_start = cfg.insertAtStart;
@ -320,27 +285,21 @@ in {
inherit (cfg) letters; inherit (cfg) letters;
no_name_title = cfg.noNameTitle; no_name_title = cfg.noNameTitle;
sidebar_filetypes = cfg.sidebarFiletypes; sidebar_filetypes = cfg.sidebarFiletypes;
} } // cfg.extraOptions;
// cfg.extraOptions;
keymaps = keymaps = flatten (
flatten mapAttrsToList (
( optionName: funcName:
mapAttrsToList let
(
optionName: funcName: let
key = cfg.keymaps.${optionName}; key = cfg.keymaps.${optionName};
in in
optional optional (key != null) {
(key != null)
{
mode = "n"; mode = "n";
inherit key; inherit key;
action = "<Cmd>Buffer${funcName}<CR>"; action = "<Cmd>Buffer${funcName}<CR>";
options.silent = cfg.keymaps.silent; options.silent = cfg.keymaps.silent;
} }
) ) keymapsActions
keymapsActions
); );
in in
mkIf cfg.enable { mkIf cfg.enable {

View file

@ -5,13 +5,13 @@
pkgs, pkgs,
... ...
}: }:
with lib; let with lib;
let
cfg = config.plugins.barbecue; cfg = config.plugins.barbecue;
mkListStr = helpers.defaultNullOpts.mkNullable (types.listOf types.str); mkListStr = helpers.defaultNullOpts.mkNullable (types.listOf types.str);
in { in
options.plugins.barbecue = {
helpers.neovim-plugin.extraOptionsOptions options.plugins.barbecue = helpers.neovim-plugin.extraOptionsOptions // {
// {
enable = mkEnableOption "barbecue-nvim"; enable = mkEnableOption "barbecue-nvim";
package = helpers.mkPackageOption "barbecue-nvim" pkgs.vimPlugins.barbecue-nvim; package = helpers.mkPackageOption "barbecue-nvim" pkgs.vimPlugins.barbecue-nvim;
@ -120,13 +120,7 @@ in {
''; '';
}; };
kinds = kinds = mapAttrs (name: default: helpers.defaultNullOpts.mkStr default "icon for ${name}.") {
mapAttrs
(
name: default:
helpers.defaultNullOpts.mkStr default "icon for ${name}."
)
{
File = ""; File = "";
Module = ""; Module = "";
Namespace = ""; Namespace = "";
@ -156,19 +150,17 @@ in {
}; };
}; };
config = let config =
setupOptions = with cfg; let
setupOptions =
with cfg;
{ {
attach_navic = attachNavic; attach_navic = attachNavic;
create_autocmd = createAutocmd; create_autocmd = createAutocmd;
include_buftypes = includeBuftypes; include_buftypes = includeBuftypes;
exclude_filetypes = excludeFiletypes; exclude_filetypes = excludeFiletypes;
modifiers = { modifiers = {
inherit inherit (modifiers) dirname basename;
(modifiers)
dirname
basename
;
}; };
show_dirname = showDirname; show_dirname = showDirname;
show_basename = showBasename; show_basename = showBasename;
@ -180,12 +172,7 @@ in {
inherit theme; inherit theme;
context_follow_icon_color = contextFollowIconColor; context_follow_icon_color = contextFollowIconColor;
symbols = { symbols = {
inherit inherit (symbols) modified ellipsis separator;
(symbols)
modified
ellipsis
separator
;
}; };
inherit kinds; inherit kinds;
} }

View file

@ -5,7 +5,8 @@
pkgs, pkgs,
... ...
}: }:
with lib; let with lib;
let
cfg = config.plugins.bufferline; cfg = config.plugins.bufferline;
highlightOptions = { highlightOptions = {
@ -88,28 +89,31 @@ with lib; let
trunc_marker = "trunkMarker"; trunc_marker = "trunkMarker";
}; };
in { in
{
options = { options = {
plugins.bufferline = plugins.bufferline = helpers.neovim-plugin.extraOptionsOptions // {
helpers.neovim-plugin.extraOptionsOptions
// {
enable = mkEnableOption "bufferline"; enable = mkEnableOption "bufferline";
package = helpers.mkPackageOption "bufferline" pkgs.vimPlugins.bufferline-nvim; package = helpers.mkPackageOption "bufferline" pkgs.vimPlugins.bufferline-nvim;
mode = helpers.defaultNullOpts.mkEnumFirstDefault ["buffers" "tabs"] "mode"; mode = helpers.defaultNullOpts.mkEnumFirstDefault [
"buffers"
"tabs"
] "mode";
themable = themable = helpers.defaultNullOpts.mkBool true "Whether or not bufferline highlights can be overridden externally";
helpers.defaultNullOpts.mkBool true
"Whether or not bufferline highlights can be overridden externally";
numbers = numbers =
helpers.defaultNullOpts.mkNullable helpers.defaultNullOpts.mkNullable
( (
with types; with types;
either either (enum [
(enum ["none" "ordinal" "buffer_id" "both"]) "none"
helpers.nixvimTypes.rawLua "ordinal"
"buffer_id"
"both"
]) helpers.nixvimTypes.rawLua
) )
"none" "none"
'' ''
@ -123,45 +127,41 @@ in {
bufferCloseIcon = helpers.defaultNullOpts.mkStr "" "The close icon for each buffer."; bufferCloseIcon = helpers.defaultNullOpts.mkStr "" "The close icon for each buffer.";
modifiedIcon = modifiedIcon = helpers.defaultNullOpts.mkStr "" "The icon indicating a buffer was modified.";
helpers.defaultNullOpts.mkStr ""
"The icon indicating a buffer was modified.";
closeIcon = helpers.defaultNullOpts.mkStr "" "The close icon."; closeIcon = helpers.defaultNullOpts.mkStr "" "The close icon.";
closeCommand = closeCommand = helpers.defaultNullOpts.mkStr "bdelete! %d" "Command or function run when closing a buffer.";
helpers.defaultNullOpts.mkStr "bdelete! %d"
"Command or function run when closing a buffer.";
leftMouseCommand = leftMouseCommand = helpers.defaultNullOpts.mkStr "buffer %d" "Command or function run when clicking on a buffer.";
helpers.defaultNullOpts.mkStr "buffer %d"
"Command or function run when clicking on a buffer.";
rightMouseCommand = rightMouseCommand = helpers.defaultNullOpts.mkStr "bdelete! %d" "Command or function run when right clicking on a buffer.";
helpers.defaultNullOpts.mkStr "bdelete! %d"
"Command or function run when right clicking on a buffer.";
middleMouseCommand = middleMouseCommand = helpers.defaultNullOpts.mkStr "null" "Command or function run when middle clicking on a buffer.";
helpers.defaultNullOpts.mkStr "null"
"Command or function run when middle clicking on a buffer.";
indicator = { indicator = {
icon = helpers.defaultNullOpts.mkStr "" "icon"; icon = helpers.defaultNullOpts.mkStr "" "icon";
style = helpers.defaultNullOpts.mkEnumFirstDefault ["icon" "underline"] "style"; style = helpers.defaultNullOpts.mkEnumFirstDefault [
"icon"
"underline"
] "style";
}; };
leftTruncMarker = helpers.defaultNullOpts.mkStr "" "left trunc marker"; leftTruncMarker = helpers.defaultNullOpts.mkStr "" "left trunc marker";
rightTruncMarker = helpers.defaultNullOpts.mkStr "" "right trunc marker"; rightTruncMarker = helpers.defaultNullOpts.mkStr "" "right trunc marker";
separatorStyle = separatorStyle = helpers.defaultNullOpts.mkEnum [
helpers.defaultNullOpts.mkEnum ["slant" "padded_slant" "slope" "padded_slope" "thick" "thin"] "thin" "slant"
"Separator style"; "padded_slant"
"slope"
"padded_slope"
"thick"
"thin"
] "thin" "Separator style";
nameFormatter = nameFormatter = helpers.defaultNullOpts.mkLuaFn "null" ''
helpers.defaultNullOpts.mkLuaFn "null"
''
A lua function that can be used to modify the buffer's label. A lua function that can be used to modify the buffer's label.
The argument 'buf' containing a name, path and bufnr is supplied. The argument 'buf' containing a name, path and bufnr is supplied.
''; '';
@ -178,9 +178,7 @@ in {
showBufferCloseIcons = helpers.defaultNullOpts.mkBool true "Show buffer close icons"; showBufferCloseIcons = helpers.defaultNullOpts.mkBool true "Show buffer close icons";
getElementIcon = getElementIcon = helpers.defaultNullOpts.mkLuaFn "null" ''
helpers.defaultNullOpts.mkLuaFn "null"
''
Lua function returning an element icon. Lua function returning an element icon.
``` ```
@ -190,53 +188,39 @@ in {
showCloseIcon = helpers.defaultNullOpts.mkBool true "Whether to show the close icon."; showCloseIcon = helpers.defaultNullOpts.mkBool true "Whether to show the close icon.";
showTabIndicators = showTabIndicators = helpers.defaultNullOpts.mkBool true "Whether to show the tab indicators.";
helpers.defaultNullOpts.mkBool true
"Whether to show the tab indicators.";
showDuplicatePrefix = showDuplicatePrefix = helpers.defaultNullOpts.mkBool true "Whether to show the prefix of duplicated files.";
helpers.defaultNullOpts.mkBool true
"Whether to show the prefix of duplicated files.";
enforceRegularTabs = enforceRegularTabs = helpers.defaultNullOpts.mkBool false "Whether to enforce regular tabs.";
helpers.defaultNullOpts.mkBool false
"Whether to enforce regular tabs.";
alwaysShowBufferline = alwaysShowBufferline = helpers.defaultNullOpts.mkBool true "Whether to always show the bufferline.";
helpers.defaultNullOpts.mkBool true
"Whether to always show the bufferline.";
persistBufferSort = persistBufferSort = helpers.defaultNullOpts.mkBool true "Whether to make the buffer sort persistent.";
helpers.defaultNullOpts.mkBool true
"Whether to make the buffer sort persistent.";
maxPrefixLength = helpers.defaultNullOpts.mkInt 15 "Maximum prefix length"; maxPrefixLength = helpers.defaultNullOpts.mkInt 15 "Maximum prefix length";
sortBy = helpers.defaultNullOpts.mkStr "id" "sort by"; sortBy = helpers.defaultNullOpts.mkStr "id" "sort by";
diagnostics = diagnostics = helpers.defaultNullOpts.mkNullable (
helpers.defaultNullOpts.mkNullable with types;
(with types; either bool (enum ["nvim_lsp" "coc"])) "false" "diagnostics"; either bool (enum [
"nvim_lsp"
"coc"
])
) "false" "diagnostics";
diagnosticsIndicator = diagnosticsIndicator = helpers.defaultNullOpts.mkLuaFn "null" "Either `null` or a function that returns the diagnostics indicator.";
helpers.defaultNullOpts.mkLuaFn "null"
"Either `null` or a function that returns the diagnostics indicator.";
diagnosticsUpdateInInsert = diagnosticsUpdateInInsert = helpers.defaultNullOpts.mkBool true "Whether diagnostics should update in insert mode";
helpers.defaultNullOpts.mkBool true
"Whether diagnostics should update in insert mode";
offsets = helpers.defaultNullOpts.mkNullable (types.listOf types.attrs) "null" "offsets"; offsets = helpers.defaultNullOpts.mkNullable (types.listOf types.attrs) "null" "offsets";
groups = { groups = {
items = items = helpers.defaultNullOpts.mkNullable (types.listOf types.attrs) "[]" "List of groups.";
helpers.defaultNullOpts.mkNullable (types.listOf types.attrs) "[]"
"List of groups.";
options = { options = {
toggleHiddenOnEnter = toggleHiddenOnEnter = helpers.defaultNullOpts.mkBool true "Re-open hidden groups on bufenter.";
helpers.defaultNullOpts.mkBool true
"Re-open hidden groups on bufenter.";
}; };
}; };
@ -252,18 +236,13 @@ in {
logging = helpers.defaultNullOpts.mkBool false "Whether to enable logging"; logging = helpers.defaultNullOpts.mkBool false "Whether to enable logging";
}; };
customFilter = customFilter = helpers.defaultNullOpts.mkLuaFn "null" ''
helpers.defaultNullOpts.mkLuaFn "null"
''
``` ```
fun(buf: number, bufnums: number[]): boolean fun(buf: number, bufnums: number[]): boolean
``` ```
''; '';
highlights = highlights = genAttrs (attrValues highlightOptions) (
genAttrs
(attrValues highlightOptions)
(
name: name:
helpers.mkNullOrOption helpers.nixvimTypes.highlight '' helpers.mkNullOrOption helpers.nixvimTypes.highlight ''
Highlight group definition for ${name}. Highlight group definition for ${name}.
@ -272,15 +251,11 @@ in {
}; };
}; };
config = let config =
let
setupOptions = with cfg; { setupOptions = with cfg; {
options = options = {
{ inherit mode themable numbers;
inherit
mode
themable
numbers
;
buffer_close_icon = bufferCloseIcon; buffer_close_icon = bufferCloseIcon;
modified_icon = modifiedIcon; modified_icon = modifiedIcon;
close_icon = closeIcon; close_icon = closeIcon;
@ -319,27 +294,17 @@ in {
}; };
}; };
hover = { hover = {
inherit inherit (hover) enabled reveal delay;
(hover)
enabled
reveal
delay
;
}; };
debug = { debug = {
inherit (debug) logging; inherit (debug) logging;
}; };
custom_filter = customFilter; custom_filter = customFilter;
} } // cfg.extraOptions;
// cfg.extraOptions;
highlights = highlights = mapAttrs (
mapAttrs pluginOptionName: nixvimOptionName: cfg.highlights.${nixvimOptionName}
( ) highlightOptions;
pluginOptionName: nixvimOptionName:
cfg.highlights.${nixvimOptionName}
)
highlightOptions;
}; };
in in
mkIf cfg.enable { mkIf cfg.enable {

View file

@ -5,23 +5,17 @@
pkgs, pkgs,
... ...
}: }:
with lib; let with lib;
let
cfg = config.plugins.navic; cfg = config.plugins.navic;
in { in
options.plugins.navic = {
helpers.neovim-plugin.extraOptionsOptions options.plugins.navic = helpers.neovim-plugin.extraOptionsOptions // {
// {
enable = mkEnableOption "nvim-navic"; enable = mkEnableOption "nvim-navic";
package = helpers.mkPackageOption "nvim-navic" pkgs.vimPlugins.nvim-navic; package = helpers.mkPackageOption "nvim-navic" pkgs.vimPlugins.nvim-navic;
icons = icons = mapAttrs (name: default: helpers.defaultNullOpts.mkStr default "icon for ${name}.") {
mapAttrs
(
name: default:
helpers.defaultNullOpts.mkStr default "icon for ${name}."
)
{
File = "󰈙 "; File = "󰈙 ";
Module = " "; Module = " ";
Namespace = "󰌗 "; Namespace = "󰌗 ";
@ -91,8 +85,10 @@ in {
''; '';
}; };
config = let config =
setupOptions = with cfg; let
setupOptions =
with cfg;
{ {
inherit inherit
icons icons

View file

@ -28,11 +28,7 @@ with lib;
Set to `true` to use `mirage` variant instead of `dark` for dark background. Set to `true` to use `mirage` variant instead of `dark` for dark background.
''; '';
overrides = overrides = helpers.defaultNullOpts.mkStrLuaOr (with helpers.nixvimTypes; attrsOf highlight) "{}" ''
helpers.defaultNullOpts.mkStrLuaOr
(with helpers.nixvimTypes; attrsOf highlight)
"{}"
''
A dictionary of group names, each associated with a dictionary of parameters A dictionary of group names, each associated with a dictionary of parameters
(`bg`, `fg`, `sp` and `style`) and colors in hex. (`bg`, `fg`, `sp` and `style`) and colors in hex.

View file

@ -20,47 +20,60 @@ with lib;
colorscheme = null; colorscheme = null;
# TODO introduced 2024-03-12: remove 2024-05-12 # TODO introduced 2024-03-12: remove 2024-05-12
imports = let imports =
basePluginPath = ["colorschemes" "base16"]; let
in [ basePluginPath = [
( "colorschemes"
mkRenamedOptionModule "base16"
(basePluginPath ++ ["customColorScheme"]) ];
(basePluginPath ++ ["colorscheme"]) in
) [
( (mkRenamedOptionModule (basePluginPath ++ [ "customColorScheme" ]) (
mkRenamedOptionModule basePluginPath ++ [ "colorscheme" ]
(basePluginPath ++ ["useTruecolor"]) ))
["options" "termguicolors"] (mkRenamedOptionModule (basePluginPath ++ [ "useTruecolor" ]) [
) "options"
"termguicolors"
])
]; ];
extraOptions = { extraOptions = {
colorscheme = let colorscheme =
let
customColorschemeType = types.submodule { customColorschemeType = types.submodule {
options = options = listToAttrs (
listToAttrs
(
map map
( (colorId: rec {
colorId: rec {
name = "base0" + colorId; name = "base0" + colorId;
value = mkOption { value = mkOption {
type = types.str; type = types.str;
description = "The value for color `${name}`."; description = "The value for color `${name}`.";
example = "#16161D"; example = "#16161D";
}; };
} })
) [
["0" "1" "2" "3" "4" "5" "6" "7" "8" "9" "A" "B" "C" "D" "E" "F"] "0"
"1"
"2"
"3"
"4"
"5"
"6"
"7"
"8"
"9"
"A"
"B"
"C"
"D"
"E"
"F"
]
); );
}; };
in in
mkOption { mkOption {
type = with types; type = with types; either (enum (import ./theme-list.nix)) customColorschemeType;
either
(enum (import ./theme-list.nix))
customColorschemeType;
description = '' description = ''
The base16 colorscheme to use. The base16 colorscheme to use.
It can either be the name of a builtin colorscheme or an attrs specifying each color explicitly. It can either be the name of a builtin colorscheme or an attrs specifying each color explicitly.
@ -97,7 +110,8 @@ with lib;
}; };
}; };
extraConfig = cfg: extraConfig =
cfg:
mkMerge [ mkMerge [
{ {
plugins.airline.settings.theme = mkIf cfg.setUpBar "base16"; plugins.airline.settings.theme = mkIf cfg.setUpBar "base16";
@ -106,9 +120,7 @@ with lib;
opts.termguicolors = mkDefault true; opts.termguicolors = mkDefault true;
} }
(mkIf (isString cfg.colorscheme) { (mkIf (isString cfg.colorscheme) { colorscheme = "base16-${cfg.colorscheme}"; })
colorscheme = "base16-${cfg.colorscheme}";
})
(mkIf (isAttrs cfg.colorscheme) { (mkIf (isAttrs cfg.colorscheme) {
extraConfigLuaPre = '' extraConfigLuaPre = ''
require('base16-colorscheme').setup(${helpers.toLuaObject cfg.colorscheme}) require('base16-colorscheme').setup(${helpers.toLuaObject cfg.colorscheme})

View file

@ -16,34 +16,95 @@ with lib;
# TODO introduced 2024-03-27: remove 2024-05-27 # TODO introduced 2024-03-27: remove 2024-05-27
optionsRenamedToSettings = [ optionsRenamedToSettings = [
"flavour" "flavour"
["background" "light"] [
["background" "dark"] "background"
"light"
]
[
"background"
"dark"
]
"transparentBackground" "transparentBackground"
["dimInactive" "enabled"] [
["dimInactive" "shade"] "dimInactive"
["dimInactive" "percentage"] "enabled"
["styles" "comments"] ]
["styles" "conditionals"] [
["styles" "loops"] "dimInactive"
["styles" "functions"] "shade"
["styles" "keywords"] ]
["styles" "strings"] [
["styles" "variables"] "dimInactive"
["styles" "numbers"] "percentage"
["styles" "booleans"] ]
["styles" "properties"] [
["styles" "types"] "styles"
["styles" "operators"] "comments"
]
[
"styles"
"conditionals"
]
[
"styles"
"loops"
]
[
"styles"
"functions"
]
[
"styles"
"keywords"
]
[
"styles"
"strings"
]
[
"styles"
"variables"
]
[
"styles"
"numbers"
]
[
"styles"
"booleans"
]
[
"styles"
"properties"
]
[
"styles"
"types"
]
[
"styles"
"operators"
]
"colorOverrides" "colorOverrides"
"customHighlights" "customHighlights"
"integrations" "integrations"
]; ];
imports = imports =
mapAttrsToList ( mapAttrsToList
(
old: new: old: new:
mkRenamedOptionModule mkRenamedOptionModule
["colorschemes" "catppuccin" old] [
["colorschemes" "catppuccin" "settings" new] "colorschemes"
"catppuccin"
old
]
[
"colorschemes"
"catppuccin"
"settings"
new
]
) )
{ {
showBufferEnd = "show_end_of_buffer"; showBufferEnd = "show_end_of_buffer";
@ -53,29 +114,31 @@ with lib;
disableUnderline = "no_underline"; disableUnderline = "no_underline";
}; };
settingsOptions = let settingsOptions =
let
flavours = [ flavours = [
"latte" "latte"
"mocha" "mocha"
"frappe" "frappe"
"macchiato" "macchiato"
]; ];
in { in
compile_path = {
helpers.defaultNullOpts.mkStr compile_path = helpers.defaultNullOpts.mkStr ''{__raw = "vim.fn.stdpath 'cache' .. '/catppuccin'";}'' "Set the compile cache directory.";
''{__raw = "vim.fn.stdpath 'cache' .. '/catppuccin'";}''
"Set the compile cache directory.";
flavour = helpers.mkNullOrOption (types.enum (flavours ++ [ "auto" ])) '' flavour = helpers.mkNullOrOption (types.enum (flavours ++ [ "auto" ])) ''
Theme flavour. Theme flavour.
''; '';
background = let background =
mkBackgroundStyle = name: let
mkBackgroundStyle =
name:
helpers.defaultNullOpts.mkEnumFirstDefault flavours '' helpers.defaultNullOpts.mkEnumFirstDefault flavours ''
Background for `${name}` background. Background for `${name}` background.
''; '';
in { in
{
light = mkBackgroundStyle "light"; light = mkBackgroundStyle "light";
dark = mkBackgroundStyle "dark"; dark = mkBackgroundStyle "dark";
@ -169,17 +232,13 @@ with lib;
''; '';
}; };
color_overrides = color_overrides = genAttrs (flavours ++ [ "all" ]) (
genAttrs
(flavours ++ ["all"])
(
flavour: flavour:
helpers.defaultNullOpts.mkAttrsOf types.str helpers.defaultNullOpts.mkAttrsOf types.str "{}" (
"{}" if flavour == "all" then
( "Override colors for all the flavours."
if flavour == "all" else
then "Override colors for all the flavours." "Override colors for the ${flavour} flavour."
else "Override colors for the ${flavour} flavour."
) )
); );
@ -236,7 +295,10 @@ with lib;
term_colors = true; term_colors = true;
color_overrides.mocha.base = "#1e1e2f"; color_overrides.mocha.base = "#1e1e2f";
styles = { styles = {
booleans = ["bold" "italic"]; booleans = [
"bold"
"italic"
];
conditionals = [ "bold" ]; conditionals = [ "bold" ];
}; };
integrations = { integrations = {
@ -252,7 +314,5 @@ with lib;
}; };
}; };
extraConfig = cfg: { extraConfig = cfg: { opts.termguicolors = mkDefault true; };
opts.termguicolors = mkDefault true;
};
} }

View file

@ -5,9 +5,11 @@
pkgs, pkgs,
... ...
}: }:
with lib; let with lib;
let
cfg = config.colorschemes.dracula; cfg = config.colorschemes.dracula;
in { in
{
options = { options = {
colorschemes.dracula = { colorschemes.dracula = {
enable = mkEnableOption "dracula"; enable = mkEnableOption "dracula";

View file

@ -19,9 +19,11 @@ helpers.neovim-plugin.mkNeovimPlugin config {
map map
( (
optionName: optionName:
lib.mkRemovedOptionModule lib.mkRemovedOptionModule [
["colorschemes" "gruvbox" optionName] "colorschemes"
"Please use `colorschemes.gruvbox.settings.${helpers.toSnakeCase optionName}` instead." "gruvbox"
optionName
] "Please use `colorschemes.gruvbox.settings.${helpers.toSnakeCase optionName}` instead."
) )
[ [
"italics" "italics"

View file

@ -22,16 +22,19 @@ with lib;
# TODO introduced 2024-03-15: remove 2024-05-15 # TODO introduced 2024-03-15: remove 2024-05-15
deprecateExtraOptions = true; deprecateExtraOptions = true;
imports = let imports =
basePluginPath = ["colorschemes" "kanagawa"]; let
basePluginPath = [
"colorschemes"
"kanagawa"
];
in in
( (map
map
( (
optionPath: optionPath:
mkRenamedOptionModule mkRenamedOptionModule (basePluginPath ++ optionPath) (
(basePluginPath ++ optionPath) basePluginPath ++ [ "settings" ] ++ optionPath
(basePluginPath ++ ["settings"] ++ optionPath) )
) )
[ [
[ "compile" ] [ "compile" ]
@ -44,26 +47,34 @@ with lib;
[ "transparent" ] [ "transparent" ]
[ "dimInactive" ] [ "dimInactive" ]
[ "terminalColors" ] [ "terminalColors" ]
["colors" "palette"] [
["colors" "theme"] "colors"
"palette"
]
[
"colors"
"theme"
]
[ "theme" ] [ "theme" ]
["background" "dark"] [
["background" "light"] "background"
"dark"
]
[
"background"
"light"
]
] ]
) )
++ [ ++ [
( (mkRemovedOptionModule (basePluginPath ++ [ "overrides" ]) ''
mkRemovedOptionModule
(basePluginPath ++ ["overrides"])
''
Use `colorschemes.kanagawa.settings.overrides` but you now have to add the full function definition: Use `colorschemes.kanagawa.settings.overrides` but you now have to add the full function definition:
``` ```
function(colors) function(colors)
... ...
end end
``` ```
'' '')
)
]; ];
settingsOptions = { settingsOptions = {

View file

@ -14,7 +14,5 @@ with lib;
maintainers = [ maintainers.GaetanLepage ]; maintainers = [ maintainers.GaetanLepage ];
extraConfig = cfg: { extraConfig = cfg: { opts.termguicolors = mkDefault true; };
opts.termguicolors = mkDefault true;
};
} }

View file

@ -24,7 +24,5 @@ helpers.vim-plugin.mkVimPlugin config {
allow_italics = true; allow_italics = true;
}; };
extraConfig = cfg: { extraConfig = cfg: { opts.termguicolors = lib.mkDefault true; };
opts.termguicolors = lib.mkDefault true;
};
} }

View file

@ -13,7 +13,5 @@ helpers.vim-plugin.mkVimPlugin config {
maintainers = [ lib.maintainers.GaetanLepage ]; maintainers = [ lib.maintainers.GaetanLepage ];
extraConfig = cfg: { extraConfig = cfg: { opts.termguicolors = lib.mkDefault true; };
opts.termguicolors = lib.mkDefault true;
};
} }

View file

@ -51,25 +51,22 @@ with lib;
mapAttrs mapAttrs
( (
name: colorNames: name: colorNames:
helpers.defaultNullOpts.mkAttrsOf ( helpers.defaultNullOpts.mkAttrsOf
types.submodule { (types.submodule {
options = options = genAttrs colorNames (
genAttrs
colorNames
(
colorName: colorName:
mkOption { mkOption {
type = types.str; type = types.str;
description = "Definition of color '${colorName}'"; description = "Definition of color '${colorName}'";
} }
); );
} })
)
"{}" "{}"
'' ''
Custom palettes for ${name} colors. Custom palettes for ${name} colors.
'' ''
) { )
{
main = [ main = [
"color0" "color0"
"color1" "color1"
@ -113,23 +110,23 @@ with lib;
Whether to enable caching. Whether to enable caching.
''; '';
cache_dir = cache_dir = helpers.defaultNullOpts.mkStr ''{__raw = "vim.fn.stdpath('cache') .. '/palette'";}'' "Cache directory.";
helpers.defaultNullOpts.mkStr
''{__raw = "vim.fn.stdpath('cache') .. '/palette'";}''
"Cache directory.";
}; };
settingsExample = { }; settingsExample = { };
extraConfig = cfg: { extraConfig = cfg: {
assertions = assertions =
mapAttrsToList ( mapAttrsToList
name: defaultPaletteNames: let (
name: defaultPaletteNames:
let
customPalettesNames = attrNames cfg.settings.custom_palettes.${name}; customPalettesNames = attrNames cfg.settings.custom_palettes.${name};
allowedPaletteNames = customPalettesNames ++ defaultPaletteNames; allowedPaletteNames = customPalettesNames ++ defaultPaletteNames;
palette = cfg.settings.palettes.${name}; palette = cfg.settings.palettes.${name};
in { in
{
assertion = isString palette -> elem palette allowedPaletteNames; assertion = isString palette -> elem palette allowedPaletteNames;
message = '' message = ''
Nixvim (colorschemes.palette): `settings.palettes.${name}` (${palette}") is not part of the allowed ${name} palette names (${concatStringsSep " " allowedPaletteNames}). Nixvim (colorschemes.palette): `settings.palettes.${name}` (${palette}") is not part of the allowed ${name} palette names (${concatStringsSep " " allowedPaletteNames}).
@ -137,9 +134,20 @@ with lib;
} }
) )
{ {
main = ["dark" "light"]; main = [
accent = ["pastel" "dark" "bright"]; "dark"
state = ["pastel" "dark" "bright"]; "light"
];
accent = [
"pastel"
"dark"
"bright"
];
state = [
"pastel"
"dark"
"bright"
];
}; };
}; };
} }

View file

@ -18,48 +18,69 @@ with lib;
"groups" "groups"
"highlightGroups" "highlightGroups"
]; ];
imports = let imports =
basePluginPath = ["colorschemes" "rose-pine"]; let
in [ basePluginPath = [
( "colorschemes"
mkRenamedOptionModule "rose-pine"
(basePluginPath ++ ["style"]) ];
(basePluginPath ++ ["settings" "dark_variant"]) in
) [
( (mkRenamedOptionModule (basePluginPath ++ [ "style" ]) (
mkRenamedOptionModule basePluginPath
(basePluginPath ++ ["dimInactive"]) ++ [
(basePluginPath ++ ["settings" "dim_inactive_windows"]) "settings"
) "dark_variant"
( ]
mkRemovedOptionModule ))
(basePluginPath ++ ["disableItalics"]) (mkRenamedOptionModule (basePluginPath ++ [ "dimInactive" ]) (
"Use `colorschemes.rose-pine.settings.enable.italics` instead." basePluginPath
) ++ [
( "settings"
mkRemovedOptionModule "dim_inactive_windows"
(basePluginPath ++ ["boldVerticalSplit"]) ]
"Use `colorschemes.rose-pine.settings.highlight_groups` instead." ))
) (mkRemovedOptionModule (
( basePluginPath ++ [ "disableItalics" ]
mkRemovedOptionModule ) "Use `colorschemes.rose-pine.settings.enable.italics` instead.")
(basePluginPath ++ ["transparentFloat"]) (mkRemovedOptionModule (
"Use `colorschemes.rose-pine.settings.highlight_groups.NormalFloat` instead." basePluginPath ++ [ "boldVerticalSplit" ]
) ) "Use `colorschemes.rose-pine.settings.highlight_groups` instead.")
( (mkRemovedOptionModule (
mkRenamedOptionModule basePluginPath ++ [ "transparentFloat" ]
(basePluginPath ++ ["transparentBackground"]) ) "Use `colorschemes.rose-pine.settings.highlight_groups.NormalFloat` instead.")
(basePluginPath ++ ["settings" "enable" "transparency"]) (mkRenamedOptionModule (basePluginPath ++ [ "transparentBackground" ]) (
) basePluginPath
++ [
"settings"
"enable"
"transparency"
]
))
]; ];
settingsOptions = { settingsOptions = {
variant = helpers.mkNullOrOption (types.enum ["auto" "main" "moon" "dawn"]) '' variant =
helpers.mkNullOrOption
(types.enum [
"auto"
"main"
"moon"
"dawn"
])
''
Set the desired variant: "auto" will follow the vim background, defaulting to `dark_variant` Set the desired variant: "auto" will follow the vim background, defaulting to `dark_variant`
or "main" for dark and "dawn" for light. or "main" for dark and "dawn" for light.
''; '';
dark_variant = helpers.defaultNullOpts.mkEnumFirstDefault ["main" "moon" "dawn"] '' dark_variant =
helpers.defaultNullOpts.mkEnumFirstDefault
[
"main"
"moon"
"dawn"
]
''
Set the desired dark variant when `settings.variant` is set to "auto". Set the desired dark variant when `settings.variant` is set to "auto".
''; '';
@ -135,7 +156,5 @@ with lib;
before_highlight = "function(group, highlight, palette) end"; before_highlight = "function(group, highlight, palette) end";
}; };
extraConfig = cfg: { extraConfig = cfg: { opts.termguicolors = mkDefault true; };
opts.termguicolors = mkDefault true;
};
} }

View file

@ -19,12 +19,30 @@ with lib;
"style" "style"
"transparent" "transparent"
"terminalColors" "terminalColors"
["styles" "comments"] [
["styles" "keywords"] "styles"
["styles" "functions"] "comments"
["styles" "variables"] ]
["styles" "sidebars"] [
["styles" "floats"] "styles"
"keywords"
]
[
"styles"
"functions"
]
[
"styles"
"variables"
]
[
"styles"
"sidebars"
]
[
"styles"
"floats"
]
"sidebars" "sidebars"
"dayBrightness" "dayBrightness"
"hideInactiveStatusline" "hideInactiveStatusline"
@ -35,7 +53,14 @@ with lib;
]; ];
settingsOptions = { settingsOptions = {
style = helpers.defaultNullOpts.mkEnumFirstDefault ["storm" "night" "day"] '' style =
helpers.defaultNullOpts.mkEnumFirstDefault
[
"storm"
"night"
"day"
]
''
The theme comes in three styles, `storm`, a darker variant `night` and `day`. The theme comes in three styles, `storm`, a darker variant `night` and `day`.
''; '';
@ -51,11 +76,17 @@ with lib;
Configure the colors used when opening a :terminal in Neovim Configure the colors used when opening a :terminal in Neovim
''; '';
styles = let styles =
mkBackgroundStyle = name: let
helpers.defaultNullOpts.mkEnumFirstDefault ["dark" "transparent" "normal"] mkBackgroundStyle =
"Background style for ${name}"; name:
in { helpers.defaultNullOpts.mkEnumFirstDefault [
"dark"
"transparent"
"normal"
] "Background style for ${name}";
in
{
comments = helpers.defaultNullOpts.mkHighlight "{italic = true;}" "" '' comments = helpers.defaultNullOpts.mkHighlight "{italic = true;}" "" ''
Define comments highlight properties. Define comments highlight properties.
''; '';
@ -126,7 +157,12 @@ with lib;
sidebars = "dark"; sidebars = "dark";
floats = "dark"; floats = "dark";
}; };
sidebars = ["qf" "vista_kind" "terminal" "packer"]; sidebars = [
"qf"
"vista_kind"
"terminal"
"packer"
];
day_brightness = 0.3; day_brightness = 0.3;
hide_inactive_statusline = false; hide_inactive_statusline = false;
dim_inactive = false; dim_inactive = false;
@ -135,7 +171,5 @@ with lib;
on_highlights = "function(highlights, colors) end"; on_highlights = "function(highlights, colors) end";
}; };
extraConfig = cfg: { extraConfig = cfg: { opts.termguicolors = mkDefault true; };
opts.termguicolors = mkDefault true;
};
} }

View file

@ -21,17 +21,13 @@ with lib;
italic_comments = helpers.defaultNullOpts.mkBool false "Whether to enable italic comments"; italic_comments = helpers.defaultNullOpts.mkBool false "Whether to enable italic comments";
underline_links = helpers.defaultNullOpts.mkBool false "Whether to underline links"; underline_links = helpers.defaultNullOpts.mkBool false "Whether to underline links";
disable_nvimtree_bg = helpers.defaultNullOpts.mkBool true "Whether to disable nvim-tree background"; disable_nvimtree_bg = helpers.defaultNullOpts.mkBool true "Whether to disable nvim-tree background";
color_overrides = color_overrides = helpers.defaultNullOpts.mkAttrsOf types.str "{}" ''
helpers.defaultNullOpts.mkAttrsOf types.str
"{}"
''
A dictionary of color overrides. A dictionary of color overrides.
See https://github.com/Mofiqul/vscode.nvim/blob/main/lua/vscode/colors.lua for color names. See https://github.com/Mofiqul/vscode.nvim/blob/main/lua/vscode/colors.lua for color names.
''; '';
group_overrides = with helpers; group_overrides =
defaultNullOpts.mkAttrsOf nixvimTypes.highlight with helpers;
"{}" defaultNullOpts.mkAttrsOf nixvimTypes.highlight "{}" ''
''
A dictionary of group names, each associated with a dictionary of parameters A dictionary of group names, each associated with a dictionary of parameters
(`bg`, `fg`, `sp` and `style`) and colors in hex. (`bg`, `fg`, `sp` and `style`) and colors in hex.
''; '';

View file

@ -6,8 +6,10 @@
... ...
}: }:
with helpers.vim-plugin; with helpers.vim-plugin;
with lib; rec { with lib;
mkCmpSourcePlugin = { rec {
mkCmpSourcePlugin =
{
name, name,
extraPlugins ? [ ], extraPlugins ? [ ],
useDefaultPackage ? true, useDefaultPackage ? true,
@ -20,62 +22,40 @@ with lib; rec {
maintainers = [ maintainers.GaetanLepage ]; maintainers = [ maintainers.GaetanLepage ];
}; };
extractSourcesFromOptionValue = sources: extractSourcesFromOptionValue = sources: if isList sources then sources else [ ];
if isList sources
then sources
else [];
autoInstallSourcePluginsModule = cfg: let autoInstallSourcePluginsModule =
cfg:
let
# cfg.setup.sources # cfg.setup.sources
setupSources = extractSourcesFromOptionValue cfg.settings.sources; setupSources = extractSourcesFromOptionValue cfg.settings.sources;
# cfg.filetype.<name>.sources # cfg.filetype.<name>.sources
filetypeSources = filetypeSources = mapAttrsToList (
mapAttrsToList _: filetypeConfig: extractSourcesFromOptionValue filetypeConfig.sources
(_: filetypeConfig: ) cfg.filetype;
extractSourcesFromOptionValue filetypeConfig.sources)
cfg.filetype;
# cfg.cmdline.<name>.sources # cfg.cmdline.<name>.sources
cmdlineSources = cmdlineSources = mapAttrsToList (
mapAttrsToList _: cmdlineConfig: extractSourcesFromOptionValue cmdlineConfig.sources
(_: cmdlineConfig: ) cfg.cmdline;
extractSourcesFromOptionValue cmdlineConfig.sources)
cfg.cmdline;
# [{name = "foo";} {name = "bar"; x = 42;} ...] # [{name = "foo";} {name = "bar"; x = 42;} ...]
allSources = flatten (setupSources ++ filetypeSources ++ cmdlineSources); allSources = flatten (setupSources ++ filetypeSources ++ cmdlineSources);
# Take only the names from the sources provided by the user # Take only the names from the sources provided by the user
# ["foo" "bar"] # ["foo" "bar"]
foundSources = foundSources = lists.unique (map (source: source.name) allSources);
lists.unique
(
map
(source: source.name)
allSources
);
# If the user has enabled the `foo` and `bar` sources, this attrs will look like: # If the user has enabled the `foo` and `bar` sources, this attrs will look like:
# { # {
# cmp-foo.enable = true; # cmp-foo.enable = true;
# cmp-bar.enable = true; # cmp-bar.enable = true;
# } # }
attrsEnabled = attrsEnabled = mapAttrs' (sourceName: pluginName: {
mapAttrs'
(
sourceName: pluginName: {
name = pluginName; name = pluginName;
value.enable = value.enable = mkIf (elem sourceName foundSources) true;
mkIf }) (import ./sources.nix);
(elem sourceName foundSources)
true;
}
)
(import ./sources.nix);
lspCapabilities = lspCapabilities = mkIf (elem "nvim_lsp" foundSources) {
mkIf
(elem "nvim_lsp" foundSources)
{
lsp.capabilities = '' lsp.capabilities = ''
capabilities = vim.tbl_deep_extend("force", capabilities, require('cmp_nvim_lsp').default_capabilities()) capabilities = vim.tbl_deep_extend("force", capabilities, require('cmp_nvim_lsp').default_capabilities())
''; '';

View file

@ -4,7 +4,8 @@
pkgs, pkgs,
config, config,
... ...
} @ args: let }@args:
let
cmpOptions = import ./options { inherit lib helpers; }; cmpOptions = import ./options { inherit lib helpers; };
in in
with lib; with lib;
@ -39,7 +40,9 @@ in
callSetup = false; callSetup = false;
extraConfig = cfg: { extraConfig = cfg: {
warnings = optional (cfg.autoEnableSources && (helpers.nixvimTypes.isRawType cfg.settings.sources)) '' warnings =
optional (cfg.autoEnableSources && (helpers.nixvimTypes.isRawType cfg.settings.sources))
''
Nixvim (plugins.cmp): You have enabled `autoEnableSources` that tells Nixvim to automatically Nixvim (plugins.cmp): You have enabled `autoEnableSources` that tells Nixvim to automatically
enable the source plugins with respect to the list of sources provided in `settings.sources`. enable the source plugins with respect to the list of sources provided in `settings.sources`.
However, the latter is proveded as a raw lua string which is not parseable by Nixvim. However, the latter is proveded as a raw lua string which is not parseable by Nixvim.
@ -55,26 +58,16 @@ in
cmp.setup(${helpers.toLuaObject cfg.settings}) cmp.setup(${helpers.toLuaObject cfg.settings})
'' ''
+ ( + (concatStringsSep "\n" (
concatStringsSep "\n" mapAttrsToList (
(
mapAttrsToList
(
filetype: settings: "cmp.setup.filetype('${filetype}', ${helpers.toLuaObject settings})\n" filetype: settings: "cmp.setup.filetype('${filetype}', ${helpers.toLuaObject settings})\n"
) ) cfg.filetype
cfg.filetype ))
) + (concatStringsSep "\n" (
) mapAttrsToList (
+ (
concatStringsSep "\n"
(
mapAttrsToList
(
cmdtype: settings: "cmp.setup.cmdline('${cmdtype}', ${helpers.toLuaObject settings})\n" cmdtype: settings: "cmp.setup.cmdline('${cmdtype}', ${helpers.toLuaObject settings})\n"
) ) cfg.cmdline
cfg.cmdline ));
)
);
# If autoEnableSources is set to true, figure out which are provided by the user # If autoEnableSources is set to true, figure out which are provided by the user
# and enable the corresponding plugins. # and enable the corresponding plugins.

View file

@ -1,140 +1,335 @@
{ lib, ... }: { lib, ... }:
with lib; let with lib;
oldPluginBasePath = ["plugins" "nvim-cmp"]; let
newPluginBasePath = ["plugins" "cmp"]; oldPluginBasePath = [
"plugins"
"nvim-cmp"
];
newPluginBasePath = [
"plugins"
"cmp"
];
settingsPath = newPluginBasePath ++ [ "settings" ]; settingsPath = newPluginBasePath ++ [ "settings" ];
renamedOptions = [ renamedOptions = [
{old = ["performance" "debounce"];}
{old = ["performance" "throttle"];}
{ {
old = ["performance" "fetchingTimeout"]; old = [
new = ["performance" "fetching_timeout"]; "performance"
"debounce"
];
} }
{ {
old = ["performance" "asyncBudget"]; old = [
new = ["performance" "async_budget"]; "performance"
"throttle"
];
} }
{ {
old = ["performance" "maxViewEntries"]; old = [
new = ["performance" "max_view_entries"]; "performance"
"fetchingTimeout"
];
new = [
"performance"
"fetching_timeout"
];
}
{
old = [
"performance"
"asyncBudget"
];
new = [
"performance"
"async_budget"
];
}
{
old = [
"performance"
"maxViewEntries"
];
new = [
"performance"
"max_view_entries"
];
} }
{ old = [ "mapping" ]; } { old = [ "mapping" ]; }
{ {
old = ["completion" "keywordLength"]; old = [
new = ["completion" "keyword_length"]; "completion"
"keywordLength"
];
new = [
"completion"
"keyword_length"
];
} }
{ {
old = ["completion" "keywordPattern"]; old = [
new = ["completion" "keyword_pattern"]; "completion"
} "keywordPattern"
{old = ["completion" "autocomplete"];} ];
{old = ["completion" "completeopt"];} new = [
{ "completion"
old = ["confirmation" "getCommitCharacters"]; "keyword_pattern"
new = ["confirmation" "get_commit_characters"]; ];
} }
{ {
old = ["formatting" "expandableIndicator"]; old = [
new = ["formatting" "expandable_indicator"]; "completion"
} "autocomplete"
{old = ["formatting" "fields"];} ];
{old = ["formatting" "format"];}
{
old = ["matching" "disallowFuzzyMatching"];
new = ["matching" "disallow_fuzzy_matching"];
} }
{ {
old = ["matching" "disallowFullfuzzyMatching"]; old = [
new = ["matching" "disallow_fullfuzzy_matching"]; "completion"
"completeopt"
];
} }
{ {
old = ["matching" "disallowPartialFuzzyMatching"]; old = [
new = ["matching" "disallow_partial_fuzzy_matching"]; "confirmation"
"getCommitCharacters"
];
new = [
"confirmation"
"get_commit_characters"
];
} }
{ {
old = ["matching" "disallowPartialMatching"]; old = [
new = ["matching" "disallow_partial_matching"]; "formatting"
"expandableIndicator"
];
new = [
"formatting"
"expandable_indicator"
];
} }
{ {
old = ["matching" "disallowPrefixUnmatching"]; old = [
new = ["matching" "disallow_prefix_unmatching"]; "formatting"
"fields"
];
} }
{ {
old = ["sorting" "priorityWeight"]; old = [
new = ["sorting" "priority_weight"]; "formatting"
} "format"
{old = ["view" "entries"];} ];
{
old = ["view" "docs" "autoOpen"];
new = ["view" "docs" "auto_open"];
}
{old = ["window" "completion" "border"];}
{old = ["window" "completion" "winhighlight"];}
{old = ["window" "completion" "zindex"];}
{old = ["window" "completion" "scrolloff"];}
{
old = ["window" "completion" "colOffset"];
new = ["window" "completion" "col_offset"];
} }
{ {
old = ["window" "completion" "sidePadding"]; old = [
new = ["window" "completion" "side_padding"]; "matching"
} "disallowFuzzyMatching"
{old = ["window" "completion" "scrollbar"];} ];
{old = ["window" "documentation" "border"];} new = [
{old = ["window" "documentation" "winhighlight"];} "matching"
{old = ["window" "documentation" "zindex"];} "disallow_fuzzy_matching"
{ ];
old = ["window" "documentation" "maxWidth"];
new = ["window" "documentation" "max_width"];
} }
{ {
old = ["window" "documentation" "maxHeight"]; old = [
new = ["window" "documentation" "max_height"]; "matching"
"disallowFullfuzzyMatching"
];
new = [
"matching"
"disallow_fullfuzzy_matching"
];
}
{
old = [
"matching"
"disallowPartialFuzzyMatching"
];
new = [
"matching"
"disallow_partial_fuzzy_matching"
];
}
{
old = [
"matching"
"disallowPartialMatching"
];
new = [
"matching"
"disallow_partial_matching"
];
}
{
old = [
"matching"
"disallowPrefixUnmatching"
];
new = [
"matching"
"disallow_prefix_unmatching"
];
}
{
old = [
"sorting"
"priorityWeight"
];
new = [
"sorting"
"priority_weight"
];
}
{
old = [
"view"
"entries"
];
}
{
old = [
"view"
"docs"
"autoOpen"
];
new = [
"view"
"docs"
"auto_open"
];
}
{
old = [
"window"
"completion"
"border"
];
}
{
old = [
"window"
"completion"
"winhighlight"
];
}
{
old = [
"window"
"completion"
"zindex"
];
}
{
old = [
"window"
"completion"
"scrolloff"
];
}
{
old = [
"window"
"completion"
"colOffset"
];
new = [
"window"
"completion"
"col_offset"
];
}
{
old = [
"window"
"completion"
"sidePadding"
];
new = [
"window"
"completion"
"side_padding"
];
}
{
old = [
"window"
"completion"
"scrollbar"
];
}
{
old = [
"window"
"documentation"
"border"
];
}
{
old = [
"window"
"documentation"
"winhighlight"
];
}
{
old = [
"window"
"documentation"
"zindex"
];
}
{
old = [
"window"
"documentation"
"maxWidth"
];
new = [
"window"
"documentation"
"max_width"
];
}
{
old = [
"window"
"documentation"
"maxHeight"
];
new = [
"window"
"documentation"
"max_height"
];
} }
{ old = [ "experimental" ]; } { old = [ "experimental" ]; }
]; ];
renameWarnings = renameWarnings = map (
map
(
rename: rename:
mkRenamedOptionModule mkRenamedOptionModule (oldPluginBasePath ++ rename.old) (settingsPath ++ (rename.new or rename.old))
(oldPluginBasePath ++ rename.old) ) renamedOptions;
(settingsPath ++ (rename.new or rename.old)) in
) {
renamedOptions; imports = renameWarnings ++ [
in { (mkRenamedOptionModule (oldPluginBasePath ++ [ "enable" ]) (newPluginBasePath ++ [ "enable" ]))
imports = (mkRenamedOptionModule (oldPluginBasePath ++ [ "autoEnableSources" ]) (
renameWarnings newPluginBasePath ++ [ "autoEnableSources" ]
++ [ ))
( (mkRemovedOptionModule (oldPluginBasePath ++ [ "preselect" ]) ''
mkRenamedOptionModule
(oldPluginBasePath ++ ["enable"])
(newPluginBasePath ++ ["enable"])
)
(
mkRenamedOptionModule
(oldPluginBasePath ++ ["autoEnableSources"])
(newPluginBasePath ++ ["autoEnableSources"])
)
(
mkRemovedOptionModule
(oldPluginBasePath ++ ["preselect"])
''
Use `plugins.cmp.settings.preselect` option. But watch out, you now have to explicitly write `cmp.PreselectMode.<mode>`. Use `plugins.cmp.settings.preselect` option. But watch out, you now have to explicitly write `cmp.PreselectMode.<mode>`.
See the option documentation for more details. See the option documentation for more details.
'' '')
) (mkRemovedOptionModule (oldPluginBasePath ++ [ "mappingPresets" ])
(
mkRemovedOptionModule
(oldPluginBasePath ++ ["mappingPresets"])
"If you want to have a complex mapping logic, express it in raw lua within the `plugins.cmp.settings.mapping` option." "If you want to have a complex mapping logic, express it in raw lua within the `plugins.cmp.settings.mapping` option."
) )
(mkRemovedOptionModule
( (
mkRemovedOptionModule oldPluginBasePath
(oldPluginBasePath ++ ["snippet" "expand"]) ++ [
"snippet"
"expand"
]
)
'' ''
Use `plugins.cmp.settings.snippet.expand` option. But watch out, you can no longer put only the name of the snippet engine. Use `plugins.cmp.settings.snippet.expand` option. But watch out, you can no longer put only the name of the snippet engine.
If you use `luasnip` for instance, set: If you use `luasnip` for instance, set:
@ -143,22 +338,23 @@ in {
``` ```
'' ''
) )
(mkRemovedOptionModule
( (
mkRemovedOptionModule oldPluginBasePath
(oldPluginBasePath ++ ["sorting" "comparators"]) ++ [
"sorting"
"comparators"
]
)
'' ''
Use `plugins.cmp.settings.sorting.comparators` option. But watch out, you can no longer put only the name of the comparators. Use `plugins.cmp.settings.sorting.comparators` option. But watch out, you can no longer put only the name of the comparators.
See the option documentation for more details. See the option documentation for more details.
'' ''
) )
( (mkRemovedOptionModule (oldPluginBasePath ++ [ "sources" ]) ''
mkRemovedOptionModule
(oldPluginBasePath ++ ["sources"])
''
Use `plugins.cmp.settings.sources` option. But watch out, you can no longer provide a list of lists of sources. Use `plugins.cmp.settings.sources` option. But watch out, you can no longer provide a list of lists of sources.
For this type of use, directly write lua. For this type of use, directly write lua.
See the option documentation for more details. See the option documentation for more details.
'' '')
)
]; ];
} }

View file

@ -1,8 +1,6 @@
{ { lib, helpers }:
lib, with lib;
helpers, rec {
}:
with lib; rec {
settingsOptions = import ./settings-options.nix { inherit lib helpers; }; settingsOptions = import ./settings-options.nix { inherit lib helpers; };
settingsExample = { settingsExample = {
@ -29,13 +27,12 @@ with lib; rec {
''; '';
}; };
attrsOfOptions = with types; attrsOfOptions =
attrsOf ( with types;
submodule { attrsOf (submodule {
freeformType = attrsOf anything; freeformType = attrsOf anything;
options = settingsOptions; options = settingsOptions;
} });
);
filetype = mkOption { filetype = mkOption {
type = attrsOfOptions; type = attrsOfOptions;
@ -43,9 +40,7 @@ with lib; rec {
description = "Options for `cmp.filetype()`."; description = "Options for `cmp.filetype()`.";
example = { example = {
python = { python = {
sources = [ sources = [ { name = "nvim_lsp"; } ];
{name = "nvim_lsp";}
];
}; };
}; };
}; };
@ -57,9 +52,7 @@ with lib; rec {
example = { example = {
"/" = { "/" = {
mapping.__raw = "cmp.mapping.preset.cmdline()"; mapping.__raw = "cmp.mapping.preset.cmdline()";
sources = [ sources = [ { name = "buffer"; } ];
{name = "buffer";}
];
}; };
":" = { ":" = {
mapping.__raw = "cmp.mapping.preset.cmdline()"; mapping.__raw = "cmp.mapping.preset.cmdline()";
@ -68,7 +61,10 @@ with lib; rec {
{ {
name = "cmdline"; name = "cmdline";
option = { option = {
ignore_cmds = ["Man" "!"]; ignore_cmds = [
"Man"
"!"
];
}; };
} }
]; ];

View file

@ -1,8 +1,6 @@
{ lib, helpers }:
with lib;
{ {
lib,
helpers,
}:
with lib; {
performance = { performance = {
debounce = helpers.defaultNullOpts.mkUnsignedInt 60 '' debounce = helpers.defaultNullOpts.mkUnsignedInt 60 ''
Sets debounce time. Sets debounce time.
@ -40,15 +38,15 @@ with lib; {
mapping = mkOption { mapping = mkOption {
default = { }; default = { };
type = with helpers.nixvimTypes; type = with helpers.nixvimTypes; maybeRaw (attrsOf strLua);
maybeRaw apply =
(attrsOf strLua); v:
apply = v:
# Handle the raw case first # Handle the raw case first
if helpers.nixvimTypes.isRawType v if helpers.nixvimTypes.isRawType v then
then v v
# When v is an attrs **but not {__raw = ...}** # When v is an attrs **but not {__raw = ...}**
else mapAttrs (_: helpers.mkRaw) v; else
mapAttrs (_: helpers.mkRaw) v;
example = { example = {
"<C-d>" = "cmp.mapping.scroll_docs(-4)"; "<C-d>" = "cmp.mapping.scroll_docs(-4)";
"<C-f>" = "cmp.mapping.scroll_docs(4)"; "<C-f>" = "cmp.mapping.scroll_docs(4)";
@ -110,19 +108,11 @@ with lib; {
The number of characters needed to trigger auto-completion. The number of characters needed to trigger auto-completion.
''; '';
keyword_pattern = keyword_pattern = helpers.defaultNullOpts.mkLua ''[[\%(-\?\d\+\%(\.\d\+\)\?\|\h\w*\%(-\w*\)*\)]]'' "The default keyword pattern.";
helpers.defaultNullOpts.mkLua
''[[\%(-\?\d\+\%(\.\d\+\)\?\|\h\w*\%(-\w*\)*\)]]''
"The default keyword pattern.";
autocomplete = autocomplete =
helpers.defaultNullOpts.mkNullable helpers.defaultNullOpts.mkNullable
( (with helpers.nixvimTypes; either (enum [ false ]) (listOf strLua))
with helpers.nixvimTypes;
either
(enum [false])
(listOf strLua)
)
''["require('cmp.types').cmp.TriggerEvent.TextChanged"]'' ''["require('cmp.types').cmp.TriggerEvent.TextChanged"]''
'' ''
The event to trigger autocompletion. The event to trigger autocompletion.
@ -210,12 +200,7 @@ with lib; {
comparators = mkOption { comparators = mkOption {
type = with helpers.nixvimTypes; nullOr (listOf strLuaFn); type = with helpers.nixvimTypes; nullOr (listOf strLuaFn);
apply = v: apply = v: helpers.ifNonNull' v (map helpers.mkRaw v);
helpers.ifNonNull' v (
map
helpers.mkRaw
v
);
default = null; default = null;
description = '' description = ''
The function to customize the sorting behavior. The function to customize the sorting behavior.
@ -244,13 +229,7 @@ with lib; {
view = { view = {
entries = entries =
helpers.defaultNullOpts.mkNullable helpers.defaultNullOpts.mkNullable (with types; either str (attrsOf anything))
(
with types;
either
str
(attrsOf anything)
)
'' ''
{ {
name = "custom"; name = "custom";
@ -268,11 +247,11 @@ with lib; {
}; };
}; };
window = let window =
mkWinhighlightOption = default: let
helpers.defaultNullOpts.mkStr mkWinhighlightOption =
default default:
'' helpers.defaultNullOpts.mkStr default ''
Specify the window's winhighlight option. Specify the window's winhighlight option.
See `|nvim_open_win|`. See `|nvim_open_win|`.
''; '';
@ -281,17 +260,14 @@ with lib; {
The window's zindex. The window's zindex.
See `|nvim_open_win|`. See `|nvim_open_win|`.
''; '';
in { in
{
completion = { completion = {
border = border =
helpers.defaultNullOpts.mkBorder helpers.defaultNullOpts.mkBorder ''[ "" "" "" "" "" "" "" "" ]'' "nvim-cmp completion popup menu"
''[ "" "" "" "" "" "" "" "" ]''
"nvim-cmp completion popup menu"
""; "";
winhighlight = winhighlight = mkWinhighlightOption "Normal:Pmenu,FloatBorder:Pmenu,CursorLine:PmenuSel,Search:None";
mkWinhighlightOption
"Normal:Pmenu,FloatBorder:Pmenu,CursorLine:PmenuSel,Search:None";
inherit zindex; inherit zindex;
@ -315,8 +291,7 @@ with lib; {
documentation = { documentation = {
border = border =
helpers.defaultNullOpts.mkBorder helpers.defaultNullOpts.mkBorder ''[ "" "" "" " " "" "" "" " " ]''
''[ "" "" "" " " "" "" "" " " ]''
"nvim-cmp documentation popup menu" "nvim-cmp documentation popup menu"
""; "";
@ -324,17 +299,13 @@ with lib; {
inherit zindex; inherit zindex;
max_width = max_width = helpers.mkNullOrStrLuaOr types.ints.unsigned ''
helpers.mkNullOrStrLuaOr types.ints.unsigned
''
The documentation window's max width. The documentation window's max width.
Default: "math.floor((40 * 2) * (vim.o.columns / (40 * 2 * 16 / 9)))" Default: "math.floor((40 * 2) * (vim.o.columns / (40 * 2 * 16 / 9)))"
''; '';
max_height = max_height = helpers.mkNullOrStrLuaOr types.ints.unsigned ''
helpers.mkNullOrStrLuaOr types.ints.unsigned
''
The documentation window's max height. The documentation window's max height.
Default: "math.floor(40 * (40 / vim.o.lines))" Default: "math.floor(40 * (40 / vim.o.lines))"

View file

@ -1,8 +1,6 @@
{ { lib, helpers }:
lib, with lib;
helpers, let
}:
with lib; let
sourceType = types.submodule { sourceType = types.submodule {
freeformType = with types; attrsOf anything; freeformType = with types; attrsOf anything;
options = { options = {
@ -83,8 +81,7 @@ with lib; let
in in
mkOption { mkOption {
default = [ ]; default = [ ];
type = with helpers.nixvimTypes; type = with helpers.nixvimTypes; maybeRaw (listOf sourceType);
maybeRaw (listOf sourceType);
description = '' description = ''
The sources to use. The sources to use.
Can either be a list of `sourceConfigs` which will be made directly to a Lua object. Can either be a list of `sourceConfigs` which will be made directly to a Lua object.

View file

@ -4,9 +4,11 @@
pkgs, pkgs,
... ...
}: }:
with lib; let with lib;
let
cfg = config.plugins.cmp-fish; cfg = config.plugins.cmp-fish;
in { in
{
meta.maintainers = [ maintainers.GaetanLepage ]; meta.maintainers = [ maintainers.GaetanLepage ];
options.plugins.cmp-fish = { options.plugins.cmp-fish = {
@ -21,7 +23,5 @@ in {
}; };
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable { extraPackages = [ cfg.fishPackage ]; };
extraPackages = [cfg.fishPackage];
};
} }

View file

@ -4,9 +4,11 @@
config, config,
... ...
}: }:
with lib; let with lib;
let
cfg = config.plugins.cmp-git; cfg = config.plugins.cmp-git;
in { in
{
options.plugins.cmp-git.settings = helpers.neovim-plugin.mkSettingsOption { options.plugins.cmp-git.settings = helpers.neovim-plugin.mkSettingsOption {
pluginName = "cmp_git"; pluginName = "cmp_git";
options = { options = {
@ -47,8 +49,7 @@ in {
issues = { issues = {
fields = fields =
helpers.defaultNullOpts.mkListOf types.str helpers.defaultNullOpts.mkListOf types.str ''["title" "number" "body" "updatedAt" "state"]''
''["title" "number" "body" "updatedAt" "state"]''
"The fields used for issues."; "The fields used for issues.";
filter = helpers.defaultNullOpts.mkStr "all" '' filter = helpers.defaultNullOpts.mkStr "all" ''
@ -92,8 +93,7 @@ in {
pull_requests = { pull_requests = {
fields = fields =
helpers.defaultNullOpts.mkListOf types.str helpers.defaultNullOpts.mkListOf types.str ''["title" "number" "body" "updatedAt" "state"]''
''["title" "number" "body" "updatedAt" "state"]''
"The fields used for pull requests."; "The fields used for pull requests.";
limit = helpers.defaultNullOpts.mkUnsignedInt 100 '' limit = helpers.defaultNullOpts.mkUnsignedInt 100 ''
@ -275,7 +275,11 @@ in {
}; };
example = { example = {
remotes = ["upstream" "origin" "foo"]; remotes = [
"upstream"
"origin"
"foo"
];
github.issues = { github.issues = {
filter = "all"; filter = "all";
limit = 250; limit = 250;

View file

@ -4,14 +4,14 @@
config, config,
... ...
}: }:
with lib; let with lib;
let
cfg = config.plugins.cmp-tabby; cfg = config.plugins.cmp-tabby;
in { in
{
meta.maintainers = [ maintainers.GaetanLepage ]; meta.maintainers = [ maintainers.GaetanLepage ];
options.plugins.cmp-tabby = options.plugins.cmp-tabby = helpers.neovim-plugin.extraOptionsOptions // {
helpers.neovim-plugin.extraOptionsOptions
// {
host = helpers.defaultNullOpts.mkStr "http://localhost:5000" '' host = helpers.defaultNullOpts.mkStr "http://localhost:5000" ''
The address of the tabby host server. The address of the tabby host server.
''; '';
@ -28,8 +28,10 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
extraConfigLua = let extraConfigLua =
setupOptions = with cfg; let
setupOptions =
with cfg;
{ {
inherit host; inherit host;
max_lines = maxLines; max_lines = maxLines;
@ -37,7 +39,8 @@ in {
inherit stop; inherit stop;
} }
// cfg.extraOptions; // cfg.extraOptions;
in '' in
''
require('cmp_tabby.config'):setup(${helpers.toLuaObject setupOptions}) require('cmp_tabby.config'):setup(${helpers.toLuaObject setupOptions})
''; '';
}; };

View file

@ -4,9 +4,11 @@
config, config,
... ...
}: }:
with lib; let with lib;
let
cfg = config.plugins.cmp-tabnine; cfg = config.plugins.cmp-tabnine;
in { in
{
options.plugins.cmp-tabnine = helpers.neovim-plugin.extraOptionsOptions; options.plugins.cmp-tabnine = helpers.neovim-plugin.extraOptionsOptions;
config = mkIf cfg.enable { config = mkIf cfg.enable {

View file

@ -5,25 +5,19 @@
pkgs, pkgs,
... ...
}: }:
with lib; let with lib;
let
cfg = config.plugins.codeium-nvim; cfg = config.plugins.codeium-nvim;
in { in
{
meta.maintainers = [ maintainers.GaetanLepage ]; meta.maintainers = [ maintainers.GaetanLepage ];
options.plugins.codeium-nvim = options.plugins.codeium-nvim = helpers.neovim-plugin.extraOptionsOptions // {
helpers.neovim-plugin.extraOptionsOptions
// {
package = helpers.mkPackageOption "codeium.nvim" pkgs.vimPlugins.codeium-nvim; package = helpers.mkPackageOption "codeium.nvim" pkgs.vimPlugins.codeium-nvim;
configPath = configPath = helpers.defaultNullOpts.mkStr ''{__raw = "vim.fn.stdpath('cache') .. '/codeium/config.json'";}'' "The path to the config file, used to store the API key.";
helpers.defaultNullOpts.mkStr
''{__raw = "vim.fn.stdpath('cache') .. '/codeium/config.json'";}''
"The path to the config file, used to store the API key.";
binPath = binPath = helpers.defaultNullOpts.mkStr ''{__raw = "vim.fn.stdpath('cache') .. '/codeium/bin'";}'' "The path to the directory where the Codeium server will be downloaded to.";
helpers.defaultNullOpts.mkStr
''{__raw = "vim.fn.stdpath('cache') .. '/codeium/bin'";}''
"The path to the directory where the Codeium server will be downloaded to.";
api = { api = {
host = helpers.defaultNullOpts.mkStr "server.codeium.com" '' host = helpers.defaultNullOpts.mkStr "server.codeium.com" ''
@ -58,17 +52,16 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
extraConfigLua = let extraConfigLua =
setupOptions = with cfg; let
setupOptions =
with cfg;
{ {
config_path = configPath; config_path = configPath;
bin_path = binPath; bin_path = binPath;
api = with api; { api = with api; {
inherit host; inherit host;
port = port = if isInt port then toString port else port;
if isInt port
then toString port
else port;
}; };
tools = with tools; { tools = with tools; {
inherit inherit
@ -82,7 +75,8 @@ in {
inherit wrapper; inherit wrapper;
} }
// cfg.extraOptions; // cfg.extraOptions;
in '' in
''
require('codeium').setup(${helpers.toLuaObject setupOptions}) require('codeium').setup(${helpers.toLuaObject setupOptions})
''; '';
}; };

View file

@ -4,17 +4,15 @@
config, config,
... ...
}: }:
with lib; let with lib;
let
copilot-lua-cfg = config.plugins.copilot-lua; copilot-lua-cfg = config.plugins.copilot-lua;
cfg = config.plugins.copilot-cmp; cfg = config.plugins.copilot-cmp;
in { in
options.plugins.copilot-cmp = {
helpers.neovim-plugin.extraOptionsOptions options.plugins.copilot-cmp = helpers.neovim-plugin.extraOptionsOptions // {
// {
event = event =
helpers.defaultNullOpts.mkNullable helpers.defaultNullOpts.mkNullable (with types; listOf str) ''["InsertEnter" "LspAttach"]''
(with types; listOf str)
''["InsertEnter" "LspAttach"]''
'' ''
Configures when the source is registered. Configures when the source is registered.
Unless you have a unique problem for your particular configuration you probably don't want Unless you have a unique problem for your particular configuration you probably don't want
@ -35,31 +33,28 @@ in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
warnings = warnings =
optional optional ((!isBool copilot-lua-cfg.suggestion.enabled) || copilot-lua-cfg.suggestion.enabled) ''
((!isBool copilot-lua-cfg.suggestion.enabled) || copilot-lua-cfg.suggestion.enabled)
''
It is recommended to disable copilot's `suggestion` module, as it can interfere with It is recommended to disable copilot's `suggestion` module, as it can interfere with
completions properly appearing in copilot-cmp. completions properly appearing in copilot-cmp.
'' ''
++ optional ++ optional ((!isBool copilot-lua-cfg.panel.enabled) || copilot-lua-cfg.panel.enabled) ''
(
(!isBool copilot-lua-cfg.panel.enabled) || copilot-lua-cfg.panel.enabled
)
''
It is recommended to disable copilot's `panel` module, as it can interfere with completions It is recommended to disable copilot's `panel` module, as it can interfere with completions
properly appearing in copilot-cmp. properly appearing in copilot-cmp.
''; '';
plugins.copilot-lua.enable = true; plugins.copilot-lua.enable = true;
extraConfigLua = let extraConfigLua =
setupOptions = with cfg; let
setupOptions =
with cfg;
{ {
inherit event; inherit event;
fix_pairs = fixPairs; fix_pairs = fixPairs;
} }
// cfg.extraOptions; // cfg.extraOptions;
in '' in
''
require('copilot_cmp').setup(${helpers.toLuaObject setupOptions}) require('copilot_cmp').setup(${helpers.toLuaObject setupOptions})
''; '';
}; };

View file

@ -4,9 +4,11 @@
config, config,
... ...
}: }:
with lib; let with lib;
let
cfg = config.plugins.crates-nvim; cfg = config.plugins.crates-nvim;
in { in
{
options.plugins.crates-nvim = helpers.neovim-plugin.extraOptionsOptions; options.plugins.crates-nvim = helpers.neovim-plugin.extraOptionsOptions;
config = mkIf cfg.enable { config = mkIf cfg.enable {

View file

@ -5,20 +5,22 @@
pkgs, pkgs,
... ...
}: }:
with lib; let with lib;
cmpLib = import ../cmp-helpers.nix {inherit lib config helpers pkgs;}; let
cmpLib = import ../cmp-helpers.nix {
inherit
lib
config
helpers
pkgs
;
};
cmpSourcesPluginNames = attrValues (import ../sources.nix); cmpSourcesPluginNames = attrValues (import ../sources.nix);
pluginModules = pluginModules = map (name: cmpLib.mkCmpSourcePlugin { inherit name; }) cmpSourcesPluginNames;
map in
( {
name:
cmpLib.mkCmpSourcePlugin {inherit name;}
)
cmpSourcesPluginNames;
in {
# For extra cmp plugins # For extra cmp plugins
imports = imports = [
[
./codeium-nvim.nix ./codeium-nvim.nix
./copilot-cmp.nix ./copilot-cmp.nix
./cmp-fish.nix ./cmp-fish.nix
@ -26,6 +28,5 @@ in {
./cmp-tabby.nix ./cmp-tabby.nix
./cmp-tabnine.nix ./cmp-tabnine.nix
./crates-nvim.nix ./crates-nvim.nix
] ] ++ pluginModules;
++ pluginModules;
} }

View file

@ -5,7 +5,8 @@
pkgs, pkgs,
... ...
}: }:
with lib; let with lib;
let
keymapsDefinitions = { keymapsDefinitions = {
clear = { clear = {
default = "<C-]>"; default = "<C-]>";
@ -106,36 +107,32 @@ in
}; };
extraOptions = { extraOptions = {
keymaps = keymaps = mapAttrs (
mapAttrs
(
optionName: v: optionName: v:
helpers.defaultNullOpts.mkStr v.default '' helpers.defaultNullOpts.mkStr v.default ''
${v.description} ${v.description}
Command: `${v.command}` Command: `${v.command}`
'' ''
) ) keymapsDefinitions;
keymapsDefinitions;
}; };
extraConfig = cfg: { extraConfig = cfg: {
plugins.codeium-vim.settings.enabled = true; plugins.codeium-vim.settings.enabled = true;
keymaps = let keymaps =
processKeymap = optionName: v: let
optional processKeymap =
(v != null) optionName: v:
{ optional (v != null) {
key = v; key = v;
action = let action =
let
inherit (keymapsDefinitions.${optionName}) command; inherit (keymapsDefinitions.${optionName}) command;
in in
helpers.mkRaw "function() ${command} end"; helpers.mkRaw "function() ${command} end";
}; };
keymapsList = flatten ( keymapsList = flatten (mapAttrsToList processKeymap cfg.keymaps);
mapAttrsToList processKeymap cfg.keymaps
);
defaults = { defaults = {
mode = "i"; mode = "i";
@ -145,8 +142,6 @@ in
}; };
}; };
in in
helpers.keymaps.mkKeymaps helpers.keymaps.mkKeymaps defaults keymapsList;
defaults
keymapsList;
}; };
} }

View file

@ -5,11 +5,14 @@
pkgs, pkgs,
... ...
}: }:
with lib; let with lib;
let
cfg = config.plugins.copilot-lua; cfg = config.plugins.copilot-lua;
in { in
{
options = { options = {
plugins.copilot-lua = let plugins.copilot-lua =
let
keymapOption = helpers.defaultNullOpts.mkNullable (with types; either (enum [ false ]) str); keymapOption = helpers.defaultNullOpts.mkNullable (with types; either (enum [ false ]) str);
in in
helpers.neovim-plugin.extraOptionsOptions helpers.neovim-plugin.extraOptionsOptions
@ -36,7 +39,16 @@ in {
}; };
layout = { layout = {
position = helpers.defaultNullOpts.mkEnum ["bottom" "top" "left" "right"] "bottom" '' position =
helpers.defaultNullOpts.mkEnum
[
"bottom"
"top"
"left"
"right"
]
"bottom"
''
The panel position. The panel position.
''; '';
@ -69,8 +81,7 @@ in {
}; };
filetypes = filetypes =
helpers.defaultNullOpts.mkNullable helpers.defaultNullOpts.mkNullable (with types; attrsOf (either bool helpers.nixvimTypes.rawLua))
(with types; attrsOf (either bool helpers.nixvimTypes.rawLua))
'' ''
{ {
yaml = false; yaml = false;
@ -166,8 +177,10 @@ in {
extraPlugins = [ cfg.package ]; extraPlugins = [ cfg.package ];
extraConfigLua = let extraConfigLua =
setupOptions = with cfg; let
setupOptions =
with cfg;
{ {
panel = with panel; { panel = with panel; {
inherit enabled; inherit enabled;
@ -197,7 +210,8 @@ in {
server_opts_overrides = serverOptsOverrides; server_opts_overrides = serverOptsOverrides;
} }
// cfg.extraOptions; // cfg.extraOptions;
in '' in
''
require('copilot').setup(${helpers.toLuaObject setupOptions}) require('copilot').setup(${helpers.toLuaObject setupOptions})
''; '';
}; };

View file

@ -5,16 +5,19 @@
pkgs, pkgs,
... ...
}: }:
with lib; let with lib;
let
cfg = config.plugins.coq-thirdparty; cfg = config.plugins.coq-thirdparty;
in { in
{
options.plugins.coq-thirdparty = { options.plugins.coq-thirdparty = {
enable = mkEnableOption "coq-thirdparty"; enable = mkEnableOption "coq-thirdparty";
package = helpers.mkPackageOption "coq-thirdparty" pkgs.vimPlugins.coq-thirdparty; package = helpers.mkPackageOption "coq-thirdparty" pkgs.vimPlugins.coq-thirdparty;
sources = mkOption { sources = mkOption {
type = types.listOf (types.submodule { type = types.listOf (
types.submodule {
freeformType = types.attrs; freeformType = types.attrs;
options = { options = {
@ -33,7 +36,8 @@ in {
default = null; default = null;
}; };
}; };
}); }
);
description = '' description = ''
List of sources. List of sources.
Each source is a free-form type, so additional settings like `accept_key` may be specified even if they are not declared by nixvim. Each source is a free-form type, so additional settings like `accept_key` may be specified even if they are not declared by nixvim.

View file

@ -11,7 +11,10 @@ with lib;
originalName = "coq_nvim"; originalName = "coq_nvim";
defaultPackage = pkgs.vimPlugins.coq_nvim; defaultPackage = pkgs.vimPlugins.coq_nvim;
maintainers = [maintainers.traxys helpers.maintainers.Kareem-Medhat]; maintainers = [
maintainers.traxys
helpers.maintainers.Kareem-Medhat
];
extraOptions = { extraOptions = {
installArtifacts = mkEnableOption "and install coq-artifacts"; installArtifacts = mkEnableOption "and install coq-artifacts";
@ -27,29 +30,37 @@ with lib;
"xdg" "xdg"
"autoStart" "autoStart"
]; ];
imports = let imports =
basePath = ["plugins" "coq-nvim"]; let
basePath = [
"plugins"
"coq-nvim"
];
settingsPath = basePath ++ [ "settings" ]; settingsPath = basePath ++ [ "settings" ];
in [ in
( [
mkRenamedOptionModule (mkRenamedOptionModule (basePath ++ [ "recommendedKeymaps" ]) (
(basePath ++ ["recommendedKeymaps"]) settingsPath
(settingsPath ++ ["keymap" "recommended"]) ++ [
) "keymap"
"recommended"
]
))
( (mkRenamedOptionModule (basePath ++ [ "alwaysComplete" ]) (
mkRenamedOptionModule settingsPath
(basePath ++ ["alwaysComplete"]) ++ [
(settingsPath ++ ["completion" "always"]) "completion"
) "always"
]
))
]; ];
callSetup = false; callSetup = false;
settingsOptions = { settingsOptions = {
auto_start = auto_start = helpers.mkNullOrOption (
helpers.mkNullOrOption with helpers.nixvimTypes; maybeRaw (either bool (enum [ "shut-up" ]))
(with helpers.nixvimTypes; maybeRaw (either bool (enum ["shut-up"]))) ) "Auto-start or shut up";
"Auto-start or shut up";
xdg = mkOption { xdg = mkOption {
type = types.bool; type = types.bool;
@ -63,9 +74,7 @@ with lib;
}; };
extraConfig = cfg: { extraConfig = cfg: {
extraPlugins = mkIf cfg.installArtifacts [ extraPlugins = mkIf cfg.installArtifacts [ cfg.artifactsPackage ];
cfg.artifactsPackage
];
globals = { globals = {
coq_settings = cfg.settings; coq_settings = cfg.settings;

View file

@ -5,23 +5,27 @@
pkgs, pkgs,
... ...
}: }:
with lib; let with lib;
let
cfg = config.plugins.lspkind; cfg = config.plugins.lspkind;
in { in
options.plugins.lspkind = {
helpers.neovim-plugin.extraOptionsOptions options.plugins.lspkind = helpers.neovim-plugin.extraOptionsOptions // {
// {
enable = mkEnableOption "lspkind.nvim"; enable = mkEnableOption "lspkind.nvim";
package = helpers.mkPackageOption "lspkind" pkgs.vimPlugins.lspkind-nvim; package = helpers.mkPackageOption "lspkind" pkgs.vimPlugins.lspkind-nvim;
mode = mode = helpers.defaultNullOpts.mkEnum [
helpers.defaultNullOpts.mkEnum "text"
["text" "text_symbol" "symbol_text" "symbol"] "text_symbol"
"symbol_text" "symbol_text"
"Defines how annotations are shown"; "symbol"
] "symbol_text" "Defines how annotations are shown";
preset = helpers.defaultNullOpts.mkEnum ["default" "codicons"] "codicons" "Default symbol map"; preset = helpers.defaultNullOpts.mkEnum [
"default"
"codicons"
] "codicons" "Default symbol map";
symbolMap = helpers.mkNullOrOption (types.attrsOf types.str) "Override preset symbols"; symbolMap = helpers.mkNullOrOption (types.attrsOf types.str) "Override preset symbols";
@ -32,23 +36,18 @@ in {
description = "Integrate with nvim-cmp"; description = "Integrate with nvim-cmp";
}; };
maxWidth = maxWidth = helpers.mkNullOrOption types.int "Maximum number of characters to show in the popup";
helpers.mkNullOrOption types.int
"Maximum number of characters to show in the popup";
ellipsisChar = ellipsisChar = helpers.mkNullOrOption types.str "Character to show when the popup exceeds maxwidth";
helpers.mkNullOrOption types.str
"Character to show when the popup exceeds maxwidth";
menu = helpers.mkNullOrOption (types.attrsOf types.str) "Show source names in the popup"; menu = helpers.mkNullOrOption (types.attrsOf types.str) "Show source names in the popup";
after = after = helpers.mkNullOrOption types.str "Function to run after calculating the formatting. function(entry, vim_item, kind)";
helpers.mkNullOrOption types.str
"Function to run after calculating the formatting. function(entry, vim_item, kind)";
}; };
}; };
config = let config =
let
doCmp = cfg.cmp.enable && config.plugins.cmp.enable; doCmp = cfg.cmp.enable && config.plugins.cmp.enable;
options = options =
{ {
@ -56,13 +55,14 @@ in {
symbol_map = cfg.symbolMap; symbol_map = cfg.symbolMap;
} }
// ( // (
if doCmp if doCmp then
then { {
maxwidth = cfg.cmp.maxWidth; maxwidth = cfg.cmp.maxWidth;
ellipsis_char = cfg.cmp.ellipsisChar; ellipsis_char = cfg.cmp.ellipsisChar;
inherit (cfg.cmp) menu; inherit (cfg.cmp) menu;
} }
else {} else
{ }
) )
// cfg.extraOptions; // cfg.extraOptions;
in in
@ -74,15 +74,16 @@ in {
''; '';
plugins.cmp.settings.formatting.format = plugins.cmp.settings.formatting.format =
if cfg.cmp.after != null if cfg.cmp.after != null then
then '' ''
function(entry, vim_item) function(entry, vim_item)
local kind = require('lspkind').cmp_format(${helpers.toLuaObject options})(entry, vim_item) local kind = require('lspkind').cmp_format(${helpers.toLuaObject options})(entry, vim_item)
return (${cfg.cmp.after})(entry, vim_after, kind) return (${cfg.cmp.after})(entry, vim_after, kind)
end end
'' ''
else '' else
''
require('lspkind').cmp_format(${helpers.toLuaObject options}) require('lspkind').cmp_format(${helpers.toLuaObject options})
''; '';
}; };

View file

@ -5,10 +5,12 @@
pkgs, pkgs,
... ...
}: }:
with lib; let with lib;
let
cfg = config.plugins.dap.extensions.dap-go; cfg = config.plugins.dap.extensions.dap-go;
dapHelpers = import ./dapHelpers.nix { inherit lib helpers; }; dapHelpers = import ./dapHelpers.nix { inherit lib helpers; };
in { in
{
options.plugins.dap.extensions.dap-go = { options.plugins.dap.extensions.dap-go = {
enable = mkEnableOption "dap-go"; enable = mkEnableOption "dap-go";
@ -22,7 +24,9 @@ in {
delve = { delve = {
path = helpers.defaultNullOpts.mkStr "dlv" "The path to the executable dlv which will be used for debugging."; path = helpers.defaultNullOpts.mkStr "dlv" "The path to the executable dlv which will be used for debugging.";
initializeTimeoutSec = helpers.defaultNullOpts.mkInt 20 "Time to wait for delve to initialize the debug session."; initializeTimeoutSec =
helpers.defaultNullOpts.mkInt 20
"Time to wait for delve to initialize the debug session.";
port = helpers.defaultNullOpts.mkStr "$\{port}" '' port = helpers.defaultNullOpts.mkStr "$\{port}" ''
A string that defines the port to start delve debugger. A string that defines the port to start delve debugger.
@ -36,7 +40,8 @@ in {
}; };
}; };
config = let config =
let
options = with cfg; { options = with cfg; {
dap_configurations = dapConfigurations; dap_configurations = dapConfigurations;

View file

@ -5,10 +5,12 @@
pkgs, pkgs,
... ...
}: }:
with lib; let with lib;
let
cfg = config.plugins.dap.extensions.dap-python; cfg = config.plugins.dap.extensions.dap-python;
dapHelpers = import ./dapHelpers.nix { inherit lib helpers; }; dapHelpers = import ./dapHelpers.nix { inherit lib helpers; };
in { in
{
options.plugins.dap.extensions.dap-python = { options.plugins.dap.extensions.dap-python = {
enable = mkEnableOption "dap-python"; enable = mkEnableOption "dap-python";
@ -20,7 +22,11 @@ in {
type = types.str; type = types.str;
}; };
console = helpers.defaultNullOpts.mkEnumFirstDefault ["integratedTerminal" "internalConsole" "externalTerminal"] "Debugpy console."; console = helpers.defaultNullOpts.mkEnumFirstDefault [
"integratedTerminal"
"internalConsole"
"externalTerminal"
] "Debugpy console.";
customConfigurations = helpers.mkNullOrOption (types.listOf dapHelpers.configurationOption) "Custom python configurations for dap."; customConfigurations = helpers.mkNullOrOption (types.listOf dapHelpers.configurationOption) "Custom python configurations for dap.";
@ -46,7 +52,8 @@ in {
''; '';
}; };
config = let config =
let
options = with cfg; { options = with cfg; {
inherit console; inherit console;
include_configs = includeConfigs; include_configs = includeConfigs;
@ -58,18 +65,14 @@ in {
plugins.dap = { plugins.dap = {
enable = true; enable = true;
extensionConfigLua = with helpers; extensionConfigLua =
with helpers;
'' ''
require("dap-python").setup("${cfg.adapterPythonPath}", ${toLuaObject options}) require("dap-python").setup("${cfg.adapterPythonPath}", ${toLuaObject options})
'' ''
+ (optionalString (cfg.testRunners != null) '' + (optionalString (cfg.testRunners != null) ''
table.insert(require("dap-python").test_runners, table.insert(require("dap-python").test_runners,
${ ${toLuaObject (builtins.mapAttrs (_: mkRaw) cfg.testRunners)})
toLuaObject
(
builtins.mapAttrs (_: mkRaw) cfg.testRunners
)
})
'') '')
+ (optionalString (cfg.customConfigurations != null) '' + (optionalString (cfg.customConfigurations != null) ''
table.insert(require("dap").configurations.python, ${toLuaObject cfg.customConfigurations}) table.insert(require("dap").configurations.python, ${toLuaObject cfg.customConfigurations})

View file

@ -5,20 +5,19 @@
pkgs, pkgs,
... ...
}: }:
with lib; let with lib;
let
cfg = config.plugins.dap.extensions.dap-ui; cfg = config.plugins.dap.extensions.dap-ui;
mkSizeOption = mkSizeOption = helpers.mkNullOrOption (with types; either int (numbers.between 0.0 1.0));
helpers.mkNullOrOption
(
with types;
either int (numbers.between 0.0 1.0)
);
mkKeymapOptions = name: mkKeymapOptions =
name:
mapAttrs ( mapAttrs (
key: default: key: default:
helpers.defaultNullOpts.mkNullable (with types; either str (listOf str)) "${default}" "Map `${key}` for ${name}" helpers.defaultNullOpts.mkNullable (with types; either str (listOf str)) "${
default
}" "Map `${key}` for ${name}"
); );
elementOption = types.submodule { elementOption = types.submodule {
@ -46,14 +45,18 @@ with lib; let
position = mkOption { position = mkOption {
default = "left"; default = "left";
description = "Which side of editor to open layout on."; description = "Which side of editor to open layout on.";
type = types.enum ["left" "right" "top" "bottom"]; type = types.enum [
"left"
"right"
"top"
"bottom"
];
}; };
}; };
}; };
in { in
options.plugins.dap.extensions.dap-ui = {
helpers.neovim-plugin.extraOptionsOptions options.plugins.dap.extensions.dap-ui = helpers.neovim-plugin.extraOptionsOptions // {
// {
enable = mkEnableOption "dap-ui"; enable = mkEnableOption "dap-ui";
package = helpers.mkPackageOption "dap-ui" pkgs.vimPlugins.nvim-dap-ui; package = helpers.mkPackageOption "dap-ui" pkgs.vimPlugins.nvim-dap-ui;
@ -61,9 +64,14 @@ in {
controls = { controls = {
enabled = helpers.defaultNullOpts.mkBool true "Enable controls"; enabled = helpers.defaultNullOpts.mkBool true "Enable controls";
element = element = helpers.defaultNullOpts.mkEnumFirstDefault [
helpers.defaultNullOpts.mkEnumFirstDefault ["repl" "scopes" "stacks" "watches" "breakpoints" "console"] "repl"
"Element to show the controls on."; "scopes"
"stacks"
"watches"
"breakpoints"
"console"
] "Element to show the controls on.";
icons = { icons = {
disconnect = helpers.defaultNullOpts.mkStr "" ""; disconnect = helpers.defaultNullOpts.mkStr "" "";
@ -78,8 +86,7 @@ in {
}; };
}; };
elementMappings = helpers.mkNullOrOption ( elementMappings = helpers.mkNullOrOption (types.attrsOf (
types.attrsOf (
types.submodule { types.submodule {
options = mkKeymapOptions "element mapping overrides" { options = mkKeymapOptions "element mapping overrides" {
edit = "e"; edit = "e";
@ -90,8 +97,7 @@ in {
toggle = "t"; toggle = "t";
}; };
} }
) )) "Per-element overrides of global mappings.";
) "Per-element overrides of global mappings.";
expandLines = helpers.defaultNullOpts.mkBool true "Expand current line to hover window if larger than window size."; expandLines = helpers.defaultNullOpts.mkBool true "Expand current line to hover window if larger than window size.";
@ -102,13 +108,9 @@ in {
border = helpers.defaultNullOpts.mkBorder "single" "dap-ui floating window" ""; border = helpers.defaultNullOpts.mkBorder "single" "dap-ui floating window" "";
mappings = mappings = helpers.mkNullOrOption (types.submodule {
helpers.mkNullOrOption (types.submodule { options = mkKeymapOptions "dap-ui floating" { close = ''["<ESC>" "q"]''; };
options = mkKeymapOptions "dap-ui floating" { }) "Keys to trigger actions in elements.";
close = ''["<ESC>" "q"]'';
};
})
"Keys to trigger actions in elements.";
}; };
forceBuffers = helpers.defaultNullOpts.mkBool true "Prevents other buffers being loaded into dap-ui windows."; forceBuffers = helpers.defaultNullOpts.mkBool true "Prevents other buffers being loaded into dap-ui windows.";
@ -119,9 +121,7 @@ in {
expanded = helpers.defaultNullOpts.mkStr "" ""; expanded = helpers.defaultNullOpts.mkStr "" "";
}; };
layouts = layouts = helpers.defaultNullOpts.mkNullable (types.listOf layoutOption) ''
helpers.defaultNullOpts.mkNullable (types.listOf layoutOption)
''
```nix ```nix
[ [
{ {
@ -162,11 +162,9 @@ in {
} }
]; ];
``` ```
'' '' "List of layouts for dap-ui.";
"List of layouts for dap-ui.";
mappings = mappings = helpers.mkNullOrOption (types.submodule {
helpers.mkNullOrOption (types.submodule {
options = mkKeymapOptions "dap-ui" { options = mkKeymapOptions "dap-ui" {
edit = "e"; edit = "e";
expand = ''["<CR>" "<2-LeftMouse>"]''; expand = ''["<CR>" "<2-LeftMouse>"]'';
@ -175,15 +173,16 @@ in {
repl = "r"; repl = "r";
toggle = "t"; toggle = "t";
}; };
}) }) "Keys to trigger actions in elements.";
"Keys to trigger actions in elements.";
render = { render = {
indent = helpers.defaultNullOpts.mkInt 1 "Default indentation size."; indent = helpers.defaultNullOpts.mkInt 1 "Default indentation size.";
maxTypeLength = helpers.mkNullOrOption types.int "Maximum number of characters to allow a type name to fill before trimming."; maxTypeLength = helpers.mkNullOrOption types.int "Maximum number of characters to allow a type name to fill before trimming.";
maxValueLines = helpers.defaultNullOpts.mkInt 100 "Maximum number of lines to allow a value to fill before trimming."; maxValueLines =
helpers.defaultNullOpts.mkInt 100
"Maximum number of lines to allow a value to fill before trimming.";
}; };
selectWindow = helpers.defaultNullOpts.mkLuaFn "null" '' selectWindow = helpers.defaultNullOpts.mkLuaFn "null" ''
@ -191,10 +190,17 @@ in {
''; '';
}; };
config = let config =
options = with cfg; let
options =
with cfg;
{ {
inherit controls icons layouts mappings; inherit
controls
icons
layouts
mappings
;
element_mappings = elementMappings; element_mappings = elementMappings;

View file

@ -5,9 +5,11 @@
pkgs, pkgs,
... ...
}: }:
with lib; let with lib;
let
cfg = config.plugins.dap.extensions.dap-virtual-text; cfg = config.plugins.dap.extensions.dap-virtual-text;
in { in
{
options.plugins.dap.extensions.dap-virtual-text = { options.plugins.dap.extensions.dap-virtual-text = {
enable = mkEnableOption "dap-virtual-text"; enable = mkEnableOption "dap-virtual-text";
@ -61,7 +63,8 @@ in {
''; '';
}; };
config = let config =
let
options = with cfg; { options = with cfg; {
inherit commented; inherit commented;

View file

@ -1,12 +1,10 @@
{ { lib, helpers }:
lib, with lib;
helpers, rec {
}: mkAdapterType =
with lib; rec { attrs:
mkAdapterType = attrs:
types.submodule { types.submodule {
options = options = {
{
id = helpers.mkNullOrOption types.str '' id = helpers.mkNullOrOption types.str ''
Identifier of the adapter. This is used for the Identifier of the adapter. This is used for the
`adapterId` property of the initialize request. `adapterId` property of the initialize request.
@ -33,8 +31,7 @@ with lib; rec {
The filetype to use for content retrieved via a source request. The filetype to use for content retrieved via a source request.
''; '';
}; };
} } // attrs;
// attrs;
}; };
executableAdapterOption = mkAdapterType { executableAdapterOption = mkAdapterType {
@ -76,7 +73,8 @@ with lib; rec {
''; '';
}; };
mkAdapterOption = name: type: mkAdapterOption =
name: type:
helpers.mkNullOrOption (with types; attrsOf (either str type)) '' helpers.mkNullOrOption (with types; attrsOf (either str type)) ''
Debug adapters of `${name}` type. Debug adapters of `${name}` type.
The adapters can also be set to a function which takes three arguments: The adapters can also be set to a function which takes three arguments:
@ -100,7 +98,10 @@ with lib; rec {
}; };
request = mkOption { request = mkOption {
type = types.enum ["attach" "launch"]; type = types.enum [
"attach"
"launch"
];
description = '' description = ''
Indicates whether the debug adapter should launch a debuggee or attach to one that is already running. Indicates whether the debug adapter should launch a debuggee or attach to one that is already running.
''; '';
@ -120,11 +121,13 @@ with lib; rec {
numhl = helpers.mkNullOrOption types.str "`numhl` for sign."; numhl = helpers.mkNullOrOption types.str "`numhl` for sign.";
}; };
processAdapters = type: adapters: processAdapters =
type: adapters:
with builtins; with builtins;
mapAttrs (_: adapter: mapAttrs (
if isString adapter _: adapter:
then helpers.mkRaw adapter if isString adapter then
helpers.mkRaw adapter
else else
filterAttrs (n: _: n != "enrichConfig") ( filterAttrs (n: _: n != "enrichConfig") (
adapter adapter
@ -132,6 +135,6 @@ with lib; rec {
inherit type; inherit type;
enrich_config = adapter.enrichConfig; enrich_config = adapter.enrichConfig;
} }
)) )
adapters; ) adapters;
} }

View file

@ -5,11 +5,13 @@
pkgs, pkgs,
... ...
}: }:
with lib; let with lib;
let
cfg = config.plugins.dap; cfg = config.plugins.dap;
dapHelpers = import ./dapHelpers.nix { inherit lib helpers; }; dapHelpers = import ./dapHelpers.nix { inherit lib helpers; };
in in
with dapHelpers; { with dapHelpers;
{
imports = [ imports = [
./dap-go.nix ./dap-go.nix
./dap-python.nix ./dap-python.nix
@ -17,9 +19,7 @@ in
./dap-virtual-text.nix ./dap-virtual-text.nix
]; ];
options.plugins.dap = options.plugins.dap = helpers.neovim-plugin.extraOptionsOptions // {
helpers.neovim-plugin.extraOptionsOptions
// {
enable = mkEnableOption "dap"; enable = mkEnableOption "dap";
package = helpers.mkPackageOption "dap" pkgs.vimPlugins.nvim-dap; package = helpers.mkPackageOption "dap" pkgs.vimPlugins.nvim-dap;
@ -29,7 +29,9 @@ in
servers = mkAdapterOption "server" serverAdapterOption; servers = mkAdapterOption "server" serverAdapterOption;
}; };
configurations = helpers.mkNullOrOption (with types; attrsOf (listOf dapHelpers.configurationOption)) '' configurations =
helpers.mkNullOrOption (with types; attrsOf (listOf dapHelpers.configurationOption))
''
Debuggee configurations, see `:h dap-configuration` for more info. Debuggee configurations, see `:h dap-configuration` for more info.
''; '';
@ -55,20 +57,18 @@ in
}; };
}; };
config = let config =
options = with cfg; let
options =
with cfg;
{ {
inherit configurations; inherit configurations;
adapters = adapters =
( (lib.optionalAttrs (adapters.executables != null) (
lib.optionalAttrs (adapters.executables != null) processAdapters "executable" adapters.executables
(processAdapters "executable" adapters.executables) ))
) // (lib.optionalAttrs (adapters.servers != null) (processAdapters "server" adapters.servers));
// (
lib.optionalAttrs (adapters.servers != null)
(processAdapters "server" adapters.servers)
);
signs = with signs; { signs = with signs; {
DapBreakpoint = dapBreakpoint; DapBreakpoint = dapBreakpoint;

View file

@ -5,13 +5,13 @@
pkgs, pkgs,
... ...
}: }:
with lib; let with lib;
let
cfg = config.plugins.chadtree; cfg = config.plugins.chadtree;
mkListStr = helpers.defaultNullOpts.mkNullable (types.listOf types.str); mkListStr = helpers.defaultNullOpts.mkNullable (types.listOf types.str);
in { in
options.plugins.chadtree = {
helpers.neovim-plugin.extraOptionsOptions options.plugins.chadtree = helpers.neovim-plugin.extraOptionsOptions // {
// {
enable = mkEnableOption "chadtree"; enable = mkEnableOption "chadtree";
package = helpers.mkPackageOption "chadtree" pkgs.vimPlugins.chadtree; package = helpers.mkPackageOption "chadtree" pkgs.vimPlugins.chadtree;
@ -74,7 +74,14 @@ in {
}; };
view = { view = {
openDirection = helpers.defaultNullOpts.mkEnum ["left" "right"] "left" '' openDirection =
helpers.defaultNullOpts.mkEnum
[
"left"
"right"
]
"left"
''
Which way does CHADTree open? Which way does CHADTree open?
''; '';
@ -90,7 +97,8 @@ in {
''; '';
windowOptions = windowOptions =
helpers.defaultNullOpts.mkAttributeSet '' helpers.defaultNullOpts.mkAttributeSet
''
{ {
cursorline = true; cursorline = true;
number = false; number = false;
@ -125,12 +133,22 @@ in {
''; '';
}; };
iconGlyphSet = helpers.defaultNullOpts.mkEnum ["devicons" "emoji" "ascii" "ascii_hollow"] "devicons" '' iconGlyphSet =
helpers.defaultNullOpts.mkEnum
[
"devicons"
"emoji"
"ascii"
"ascii_hollow"
]
"devicons"
''
Icon glyph set to use. Icon glyph set to use.
''; '';
textColourSet = textColourSet =
helpers.defaultNullOpts.mkEnum [ helpers.defaultNullOpts.mkEnum
[
"env" "env"
"solarized_dark_256" "solarized_dark_256"
"solarized_dark" "solarized_dark"
@ -140,7 +158,9 @@ in {
"trapdoor" "trapdoor"
"nerdtree_syntax_light" "nerdtree_syntax_light"
"nerdtree_syntax_dark" "nerdtree_syntax_dark"
] "env" '' ]
"env"
''
On `unix`, the command `ls` can produce coloured results based on the `LS_COLORS` environmental variable. On `unix`, the command `ls` can produce coloured results based on the `LS_COLORS` environmental variable.
CHADTree can pretend it's `ls` by setting `chadtree.theme.textColourSet` to `env`. CHADTree can pretend it's `ls` by setting `chadtree.theme.textColourSet` to `env`.
@ -148,7 +168,14 @@ in {
If you are not happy with that, you can choose one of the many others. If you are not happy with that, you can choose one of the many others.
''; '';
iconColourSet = helpers.defaultNullOpts.mkEnum ["github" "none"] "github" '' iconColourSet =
helpers.defaultNullOpts.mkEnum
[
"github"
"none"
]
"github"
''
Right now you all the file icons are coloured according to Github colours. Right now you all the file icons are coloured according to Github colours.
You may also disable colouring if you wish. You may also disable colouring if you wish.
@ -333,7 +360,8 @@ in {
}; };
}; };
config = let config =
let
setupOptions = with cfg; { setupOptions = with cfg; {
xdg = true; xdg = true;
options = with options; { options = with options; {
@ -371,7 +399,8 @@ in {
text_colour_set = textColourSet; text_colour_set = textColourSet;
icon_colour_set = iconColourSet; icon_colour_set = iconColourSet;
}; };
keymap = with keymap; keymap =
with keymap;
with windowManagement; with windowManagement;
with rerooting; with rerooting;
with openFileFolder; with openFileFolder;
@ -380,7 +409,8 @@ in {
with bookmarks; with bookmarks;
with selecting; with selecting;
with fileOperations; with fileOperations;
with toggles; { with toggles;
{
inherit quit; inherit quit;
inherit bigger; inherit bigger;
inherit smaller; inherit smaller;
@ -423,7 +453,9 @@ in {
mkIf cfg.enable { mkIf cfg.enable {
extraPlugins = extraPlugins =
[ cfg.package ] [ cfg.package ]
++ (optional (cfg.theme == null || cfg.theme.iconGlyphSet == "devicons") pkgs.vimPlugins.nvim-web-devicons); ++ (optional (
cfg.theme == null || cfg.theme.iconGlyphSet == "devicons"
) pkgs.vimPlugins.nvim-web-devicons);
extraConfigLua = '' extraConfigLua = ''
vim.api.nvim_set_var("chadtree_settings", ${helpers.toLuaObject setupOptions}) vim.api.nvim_set_var("chadtree_settings", ${helpers.toLuaObject setupOptions})

View file

@ -5,36 +5,40 @@
pkgs, pkgs,
... ...
}: }:
with lib; let with lib;
let
cfg = config.plugins.neo-tree; cfg = config.plugins.neo-tree;
basePluginPath = ["plugins" "neo-tree"]; basePluginPath = [
in { "plugins"
imports = [ "neo-tree"
(
mkRemovedOptionModule
(basePluginPath ++ ["sourceSelector" "tabLabels"])
"Use `plugins.neo-tree.sourceSelector.sources` to achieve the same functionality."
)
(
mkRemovedOptionModule
(basePluginPath ++ ["closeFloatsOnEscapeKey"])
"This option has been removed from upstream."
)
]; ];
options.plugins.neo-tree = let in
{
imports = [
(mkRemovedOptionModule (
basePluginPath
++ [
"sourceSelector"
"tabLabels"
]
) "Use `plugins.neo-tree.sourceSelector.sources` to achieve the same functionality.")
(mkRemovedOptionModule (
basePluginPath ++ [ "closeFloatsOnEscapeKey" ]
) "This option has been removed from upstream.")
];
options.plugins.neo-tree =
let
listOfRendererComponents = with types; listOf (either str attrs); listOfRendererComponents = with types; listOf (either str attrs);
mkRendererComponentListOption = helpers.defaultNullOpts.mkNullable listOfRendererComponents; mkRendererComponentListOption = helpers.defaultNullOpts.mkNullable listOfRendererComponents;
mkMappingsOption = defaults: mkMappingsOption =
helpers.defaultNullOpts.mkNullable defaults:
(with types; attrsOf (either str attrs)) helpers.defaultNullOpts.mkNullable (
defaults with types; attrsOf (either str attrs)
"Mapping options"; ) defaults "Mapping options";
mkWindowMappingsOption = defaults: { mkWindowMappingsOption = defaults: { mappings = mkMappingsOption defaults; };
mappings = mkMappingsOption defaults;
};
mkFollowCurrentFileOption = default: { mkFollowCurrentFileOption = default: {
enabled = helpers.defaultNullOpts.mkBool default '' enabled = helpers.defaultNullOpts.mkBool default ''
@ -67,17 +71,11 @@ in {
Extra sources to be added to the sources. This is an internal nixvim option. Extra sources to be added to the sources. This is an internal nixvim option.
''; '';
addBlankLineAtTop = addBlankLineAtTop = helpers.defaultNullOpts.mkBool false "Add a blank line at the top of the tree.";
helpers.defaultNullOpts.mkBool false
"Add a blank line at the top of the tree.";
autoCleanAfterSessionRestore = autoCleanAfterSessionRestore = helpers.defaultNullOpts.mkBool false "Automatically clean up broken neo-tree buffers saved in sessions";
helpers.defaultNullOpts.mkBool false
"Automatically clean up broken neo-tree buffers saved in sessions";
closeIfLastWindow = closeIfLastWindow = helpers.defaultNullOpts.mkBool false "Close Neo-tree if it is the last window left in the tab";
helpers.defaultNullOpts.mkBool false
"Close Neo-tree if it is the last window left in the tab";
defaultSource = helpers.defaultNullOpts.mkStr "filesystem" ""; defaultSource = helpers.defaultNullOpts.mkStr "filesystem" "";
@ -85,13 +83,9 @@ in {
enableGitStatus = helpers.defaultNullOpts.mkBool true ""; enableGitStatus = helpers.defaultNullOpts.mkBool true "";
enableModifiedMarkers = enableModifiedMarkers = helpers.defaultNullOpts.mkBool true "Show markers for files with unsaved changes.";
helpers.defaultNullOpts.mkBool true
"Show markers for files with unsaved changes.";
enableRefreshOnWrite = enableRefreshOnWrite = helpers.defaultNullOpts.mkBool true "Refresh the tree when a file is written. Only used if `use_libuv_file_watcher` is false.";
helpers.defaultNullOpts.mkBool true
"Refresh the tree when a file is written. Only used if `use_libuv_file_watcher` is false.";
gitStatusAsync = helpers.defaultNullOpts.mkBool true ""; gitStatusAsync = helpers.defaultNullOpts.mkBool true "";
@ -104,9 +98,7 @@ in {
helpers.defaultNullOpts.mkInt 10 helpers.defaultNullOpts.mkInt 10
"delay in ms between batches. Spreads out the workload to let other processes run."; "delay in ms between batches. Spreads out the workload to let other processes run.";
maxLines = maxLines = helpers.defaultNullOpts.mkInt 10000 ''
helpers.defaultNullOpts.mkInt 10000
''
How many lines of git status results to process. Anything after this will be dropped. How many lines of git status results to process. Anything after this will be dropped.
Anything before this will be used. Anything before this will be used.
The last items to be processed are the untracked files. The last items to be processed are the untracked files.
@ -115,74 +107,65 @@ in {
hideRootNode = helpers.defaultNullOpts.mkBool false "Hide the root node."; hideRootNode = helpers.defaultNullOpts.mkBool false "Hide the root node.";
retainHiddenRootIndent = retainHiddenRootIndent = helpers.defaultNullOpts.mkBool false ''
helpers.defaultNullOpts.mkBool false
''
If the root node is hidden, keep the indentation anyhow. If the root node is hidden, keep the indentation anyhow.
This is needed if you use expanders because they render in the indent. This is needed if you use expanders because they render in the indent.
''; '';
logLevel = logLevel = helpers.defaultNullOpts.mkEnum [
helpers.defaultNullOpts.mkEnum "trace"
["trace" "debug" "info" "warn" "error" "fatal"] "info" ""; "debug"
"info"
"warn"
"error"
"fatal"
] "info" "";
logToFile = logToFile =
helpers.defaultNullOpts.mkNullable (types.either types.bool types.str) helpers.defaultNullOpts.mkNullable (types.either types.bool types.str) "false"
"false"
"use :NeoTreeLogs to show the file"; "use :NeoTreeLogs to show the file";
openFilesInLastWindow = openFilesInLastWindow = helpers.defaultNullOpts.mkBool true "If `false`, open files in top left window";
helpers.defaultNullOpts.mkBool true
"If `false`, open files in top left window";
popupBorderStyle = popupBorderStyle = helpers.defaultNullOpts.mkEnum [
helpers.defaultNullOpts.mkEnum "NC"
["NC" "double" "none" "rounded" "shadow" "single" "solid"] "NC" ""; "double"
"none"
"rounded"
"shadow"
"single"
"solid"
] "NC" "";
resizeTimerInterval = resizeTimerInterval = helpers.defaultNullOpts.mkInt 500 ''
helpers.defaultNullOpts.mkInt 500
''
In ms, needed for containers to redraw right aligned and faded content. In ms, needed for containers to redraw right aligned and faded content.
Set to -1 to disable the resize timer entirely. Set to -1 to disable the resize timer entirely.
NOTE: this will speed up to 50 ms for 1 second following a resize NOTE: this will speed up to 50 ms for 1 second following a resize
''; '';
sortCaseInsensitive = sortCaseInsensitive = helpers.defaultNullOpts.mkBool false "Used when sorting files and directories in the tree";
helpers.defaultNullOpts.mkBool false
"Used when sorting files and directories in the tree";
sortFunction = sortFunction = helpers.defaultNullOpts.mkLuaFn "nil" "Uses a custom function for sorting files and directories in the tree";
helpers.defaultNullOpts.mkLuaFn "nil"
"Uses a custom function for sorting files and directories in the tree";
usePopupsForInput = usePopupsForInput = helpers.defaultNullOpts.mkBool true "If false, inputs will use vim.ui.input() instead of custom floats.";
helpers.defaultNullOpts.mkBool true
"If false, inputs will use vim.ui.input() instead of custom floats.";
useDefaultMappings = helpers.defaultNullOpts.mkBool true ""; useDefaultMappings = helpers.defaultNullOpts.mkBool true "";
# sourceSelector provides clickable tabs to switch between sources." # sourceSelector provides clickable tabs to switch between sources."
sourceSelector = { sourceSelector = {
winbar = winbar = helpers.defaultNullOpts.mkBool false "toggle to show selector on winbar";
helpers.defaultNullOpts.mkBool false
"toggle to show selector on winbar";
statusline = statusline = helpers.defaultNullOpts.mkBool false "toggle to show selector on statusline";
helpers.defaultNullOpts.mkBool false
"toggle to show selector on statusline";
showScrolledOffParentNode = helpers.defaultNullOpts.mkBool false '' showScrolledOffParentNode = helpers.defaultNullOpts.mkBool false ''
If `true`, tabs are replaced with the parent path of the top visible node when If `true`, tabs are replaced with the parent path of the top visible node when
scrolled down. scrolled down.
''; '';
sources = sources = helpers.mkNullOrOption (
helpers.mkNullOrOption
(
with types; with types;
listOf listOf (submodule {
(submodule {
options = { options = {
source = mkOption { source = mkOption {
type = str; type = str;
@ -192,11 +175,15 @@ in {
displayName = helpers.mkNullOrOption str "How that source to appear in the bar."; displayName = helpers.mkNullOrOption str "How that source to appear in the bar.";
}; };
}) })
) ) "Configure the characters shown on each tab.";
"Configure the characters shown on each tab.";
contentLayout = contentLayout =
helpers.defaultNullOpts.mkEnumFirstDefault ["start" "end" "focus"] helpers.defaultNullOpts.mkEnumFirstDefault
[
"start"
"end"
"focus"
]
'' ''
Defines how the labels are placed inside a tab. Defines how the labels are placed inside a tab.
This only takes effect when the tab width is greater than the length of label i.e. This only takes effect when the tab width is greater than the length of label i.e.
@ -210,7 +197,13 @@ in {
tabsLayout = tabsLayout =
helpers.defaultNullOpts.mkEnum helpers.defaultNullOpts.mkEnum
["start" "end" "center" "equal" "focus"] [
"start"
"end"
"center"
"equal"
"focus"
]
"equal" "equal"
'' ''
Defines how the tabs are aligned inside the window when there is more than enough Defines how the tabs are aligned inside the window when there is more than enough
@ -225,9 +218,7 @@ in {
"active" : expand the focused tab to fit the window width / focused tab \/ ~ \/ ~ \ "active" : expand the focused tab to fit the window width / focused tab \/ ~ \/ ~ \
''; '';
truncationCharacter = truncationCharacter = helpers.defaultNullOpts.mkStr "" "Character to use when truncating the tab label";
helpers.defaultNullOpts.mkStr ""
"Character to use when truncating the tab label";
tabsMinWidth = tabsMinWidth =
helpers.defaultNullOpts.mkNullable types.int "null" helpers.defaultNullOpts.mkNullable types.int "null"
@ -237,11 +228,7 @@ in {
helpers.defaultNullOpts.mkNullable types.int "null" helpers.defaultNullOpts.mkNullable types.int "null"
"This will truncate text even if `textTruncToFit = false`"; "This will truncate text even if `textTruncToFit = false`";
padding = padding = helpers.defaultNullOpts.mkNullable (with types; either int (attrsOf int)) "0" ''
helpers.defaultNullOpts.mkNullable
(with types; either int (attrsOf int))
"0"
''
Defines the global padding of the source selector. Defines the global padding of the source selector.
It can be an integer or an attrs with keys `left` and `right`. It can be an integer or an attrs with keys `left` and `right`.
Setting `padding = 2` is exactly the same as `{ left = 2; right = 2; }`. Setting `padding = 2` is exactly the same as `{ left = 2; right = 2; }`.
@ -249,9 +236,7 @@ in {
Example: `{ left = 2; right = 0; }` Example: `{ left = 2; right = 0; }`
''; '';
separator = separator = helpers.defaultNullOpts.mkNullable (
helpers.defaultNullOpts.mkNullable
(
with types; with types;
either str (submodule { either str (submodule {
options = { options = {
@ -260,9 +245,7 @@ in {
override = helpers.defaultNullOpts.mkStr null ""; override = helpers.defaultNullOpts.mkStr null "";
}; };
}) })
) ) "Can be a string or a table" ''{ left = ""; right= ""; }'';
"Can be a string or a table"
''{ left = ""; right= ""; }'';
separatorActive = separatorActive =
helpers.defaultNullOpts.mkNullable helpers.defaultNullOpts.mkNullable
@ -282,9 +265,7 @@ in {
'' ''
"null"; "null";
showSeparatorOnEdge = showSeparatorOnEdge = helpers.defaultNullOpts.mkBool false ''
helpers.defaultNullOpts.mkBool false
''
Takes a boolean value where `false` (default) hides the separators on the far Takes a boolean value where `false` (default) hides the separators on the far
left / right. left / right.
Especially useful when left and right separator are the same. Especially useful when left and right separator are the same.
@ -303,10 +284,7 @@ in {
highlightSeparatorActive = helpers.defaultNullOpts.mkStr "NeoTreeTabSeparatorActive" ""; highlightSeparatorActive = helpers.defaultNullOpts.mkStr "NeoTreeTabSeparatorActive" "";
}; };
eventHandlers = eventHandlers = helpers.mkNullOrOption (with types; attrsOf str) ''
helpers.mkNullOrOption
(with types; attrsOf str)
''
Configuration of event handlers. Configuration of event handlers.
Attrs: Attrs:
- keys are the events (e.g. `before_render`, `file_opened`) - keys are the events (e.g. `before_render`, `file_opened`)
@ -421,13 +399,7 @@ in {
}; };
gitStatus = { gitStatus = {
symbols = symbols = mapAttrs (optionName: default: helpers.defaultNullOpts.mkStr default optionName) {
mapAttrs
(
optionName: default:
helpers.defaultNullOpts.mkStr default optionName
)
{
added = ""; added = "";
deleted = ""; deleted = "";
modified = ""; modified = "";
@ -444,9 +416,7 @@ in {
}; };
renderers = { renderers = {
directory = directory = mkRendererComponentListOption ''
mkRendererComponentListOption
''
[ [
"indent" "indent"
"icon" "icon"
@ -478,12 +448,9 @@ in {
]; ];
} }
] ]
'' '' "directory renderers";
"directory renderers";
file = file = mkRendererComponentListOption ''
mkRendererComponentListOption
''
[ [
"indent" "indent"
"icon" "icon"
@ -520,12 +487,9 @@ in {
]; ];
} }
] ]
'' '' "file renderers";
"file renderers";
message = message = mkRendererComponentListOption ''
mkRendererComponentListOption
''
[ [
{ {
name = "indent"; name = "indent";
@ -536,38 +500,35 @@ in {
highlight = "NeoTreeMessage"; highlight = "NeoTreeMessage";
} }
] ]
'' '' "message renderers";
"message renderers";
terminal = terminal = mkRendererComponentListOption ''
mkRendererComponentListOption
''
[ [
"indent" "indent"
"icon" "icon"
"name" "name"
"bufnr" "bufnr"
] ]
'' '' "message renderers";
"message renderers";
}; };
nestingRules = nestingRules = helpers.defaultNullOpts.mkNullable (types.attrsOf types.str) "{}" "nesting rules";
helpers.defaultNullOpts.mkNullable (types.attrsOf types.str) "{}"
"nesting rules";
window = { window = {
position = position = helpers.defaultNullOpts.mkEnum [
helpers.defaultNullOpts.mkEnum "left"
["left" "right" "top" "bottom" "float" "current"] "left" "position"; "right"
"top"
"bottom"
"float"
"current"
] "left" "position";
width = helpers.defaultNullOpts.mkInt 40 "Applies to left and right positions"; width = helpers.defaultNullOpts.mkInt 40 "Applies to left and right positions";
height = helpers.defaultNullOpts.mkInt 15 "Applies to top and bottom positions"; height = helpers.defaultNullOpts.mkInt 15 "Applies to top and bottom positions";
autoExpandWidth = autoExpandWidth = helpers.defaultNullOpts.mkBool false ''
helpers.defaultNullOpts.mkBool false
''
Expand the window when file exceeds the window width. does not work with Expand the window when file exceeds the window width. does not work with
position = "float" position = "float"
''; '';
@ -591,7 +552,13 @@ in {
(as opposed to within the directory under cursor). (as opposed to within the directory under cursor).
''; '';
insertAs = helpers.defaultNullOpts.mkEnumFirstDefault ["child" "sibling"] '' insertAs =
helpers.defaultNullOpts.mkEnumFirstDefault
[
"child"
"sibling"
]
''
Affects how nodes get inserted into the tree during creation/pasting/moving of files if Affects how nodes get inserted into the tree during creation/pasting/moving of files if
the node under the cursor is a directory: the node under the cursor is a directory:
@ -605,9 +572,7 @@ in {
nowait = helpers.defaultNullOpts.mkBool true "nowait"; nowait = helpers.defaultNullOpts.mkBool true "nowait";
}; };
mappings = mappings = mkMappingsOption ''
mkMappingsOption
''
```nix ```nix
{ {
"<space>" = { "<space>" = {
@ -678,21 +643,32 @@ in {
} }
``` ```
''; '';
asyncDirectoryScan = helpers.defaultNullOpts.mkEnumFirstDefault ["auto" "always" "never"] '' asyncDirectoryScan =
helpers.defaultNullOpts.mkEnumFirstDefault
[
"auto"
"always"
"never"
]
''
- "auto" means refreshes are async, but it's synchronous when called from the Neotree - "auto" means refreshes are async, but it's synchronous when called from the Neotree
commands. commands.
- "always" means directory scans are always async. - "always" means directory scans are always async.
- "never" means directory scans are never async. - "never" means directory scans are never async.
''; '';
scanMode = helpers.defaultNullOpts.mkEnumFirstDefault ["shallow" "deep"] '' scanMode =
helpers.defaultNullOpts.mkEnumFirstDefault
[
"shallow"
"deep"
]
''
- "shallow": Don't scan into directories to detect possible empty directory a priori. - "shallow": Don't scan into directories to detect possible empty directory a priori.
- "deep": Scan into directories to detect empty or grouped empty directories a priori. - "deep": Scan into directories to detect empty or grouped empty directories a priori.
''; '';
bindToCwd = bindToCwd = helpers.defaultNullOpts.mkBool true "true creates a 2-way binding between vim's cwd and neo-tree's root.";
helpers.defaultNullOpts.mkBool true
"true creates a 2-way binding between vim's cwd and neo-tree's root.";
cwdTarget = { cwdTarget = {
sidebar = helpers.defaultNullOpts.mkStr "tab" "sidebar is when position = left or right"; sidebar = helpers.defaultNullOpts.mkStr "tab" "sidebar is when position = left or right";
@ -700,29 +676,20 @@ in {
}; };
filteredItems = { filteredItems = {
visible = visible = helpers.defaultNullOpts.mkBool false "when true, they will just be displayed differently than normal items";
helpers.defaultNullOpts.mkBool false
"when true, they will just be displayed differently than normal items";
forceVisibleInEmptyFolder = forceVisibleInEmptyFolder = helpers.defaultNullOpts.mkBool false "when true, hidden files will be shown if the root folder is otherwise empty";
helpers.defaultNullOpts.mkBool false
"when true, hidden files will be shown if the root folder is otherwise empty";
showHiddenCount = showHiddenCount = helpers.defaultNullOpts.mkBool true "when true, the number of hidden items in each folder will be shown as the last entry";
helpers.defaultNullOpts.mkBool true
"when true, the number of hidden items in each folder will be shown as the last entry";
hideDotfiles = helpers.defaultNullOpts.mkBool true "hide dotfiles"; hideDotfiles = helpers.defaultNullOpts.mkBool true "hide dotfiles";
hideGitignored = helpers.defaultNullOpts.mkBool true "hide gitignored files"; hideGitignored = helpers.defaultNullOpts.mkBool true "hide gitignored files";
hideHidden = hideHidden = helpers.defaultNullOpts.mkBool true "only works on Windows for hidden files/directories";
helpers.defaultNullOpts.mkBool true
"only works on Windows for hidden files/directories";
hideByName = hideByName =
helpers.defaultNullOpts.mkNullable (types.listOf types.str) helpers.defaultNullOpts.mkNullable (types.listOf types.str) ''[".DS_Store" "thumbs.db"]''
''[".DS_Store" "thumbs.db"]''
"hide by name"; "hide by name";
hideByPattern = helpers.defaultNullOpts.mkNullable (types.listOf types.str) "[]" '' hideByPattern = helpers.defaultNullOpts.mkNullable (types.listOf types.str) "[]" ''
@ -764,25 +731,20 @@ in {
`./sources/filesystem/init.lua `./sources/filesystem/init.lua
''; '';
findCommand = findCommand = helpers.defaultNullOpts.mkStr "fd" "This is determined automatically, you probably don't need to set it";
helpers.defaultNullOpts.mkStr "fd"
"This is determined automatically, you probably don't need to set it";
findArgs = findArgs =
helpers.mkNullOrStrLuaFnOr helpers.mkNullOrStrLuaFnOr
(types.submodule { (types.submodule {
options = { options = {
fd = fd = helpers.defaultNullOpts.mkNullable (types.listOf types.str) ''
helpers.defaultNullOpts.mkNullable (types.listOf types.str)
''
[ [
"--exclude" "--exclude"
".git" ".git"
"--exclude" "--exclude"
"node_modules" "node_modules"
] ]
'' '' "You can specify extra args to pass to the find command.";
"You can specify extra args to pass to the find command.";
}; };
}) })
'' ''
@ -828,19 +790,19 @@ in {
``` ```
''; '';
groupEmptyDirs = groupEmptyDirs = helpers.defaultNullOpts.mkBool false "when true, empty folders will be grouped together";
helpers.defaultNullOpts.mkBool false
"when true, empty folders will be grouped together";
searchLimit = searchLimit = helpers.defaultNullOpts.mkInt 50 "max number of search results when using filters";
helpers.defaultNullOpts.mkInt 50
"max number of search results when using filters";
followCurrentFile = mkFollowCurrentFileOption false; followCurrentFile = mkFollowCurrentFileOption false;
hijackNetrwBehavior = hijackNetrwBehavior =
helpers.defaultNullOpts.mkEnumFirstDefault helpers.defaultNullOpts.mkEnumFirstDefault
["open_default" "open_current" "disabled"] [
"open_default"
"open_current"
"disabled"
]
'' ''
- "open_default": netrw disabled, opening a directory opens neo-tree in whatever - "open_default": netrw disabled, opening a directory opens neo-tree in whatever
position is specified in window.position position is specified in window.position
@ -860,9 +822,7 @@ in {
followCurrentFile = mkFollowCurrentFileOption true; followCurrentFile = mkFollowCurrentFileOption true;
groupEmptyDirs = groupEmptyDirs = helpers.defaultNullOpts.mkBool true "When true, empty directories will be grouped together.";
helpers.defaultNullOpts.mkBool true
"When true, empty directories will be grouped together.";
window = mkWindowMappingsOption '' window = mkWindowMappingsOption ''
{ {
@ -889,9 +849,7 @@ in {
example = { example = {
renderers = { renderers = {
custom = custom = mkRendererComponentListOption ''
mkRendererComponentListOption
''
[ [
"indent" "indent"
{ {
@ -901,8 +859,7 @@ in {
"custom" "custom"
"name" "name"
] ]
'' '' "custom renderers";
"custom renderers";
}; };
window = mkWindowMappingsOption '' window = mkWindowMappingsOption ''
@ -915,9 +872,7 @@ in {
}; };
documentSymbols = { documentSymbols = {
followCursor = followCursor = helpers.defaultNullOpts.mkBool false "If set to `true`, will automatically focus on the symbol under the cursor.";
helpers.defaultNullOpts.mkBool false
"If set to `true`, will automatically focus on the symbol under the cursor.";
kinds = kinds =
helpers.mkNullOrOption helpers.mkNullOrOption
@ -962,63 +917,55 @@ in {
}; };
}; };
config = let config =
let
inherit (helpers) ifNonNull' mkRaw; inherit (helpers) ifNonNull' mkRaw;
processRendererComponent = component: processRendererComponent =
if isString component component:
then [component] if isString component then
[ component ]
else else
(mapAttrs' ( (mapAttrs' (name: value: {
name: value: { name = if name == "name" then "__unkeyed" else name;
name = value = if isList value then processRendererComponentList value else value;
if name == "name" }) component);
then "__unkeyed"
else name;
value =
if isList value
then processRendererComponentList value
else value;
}
)
component);
processRendererComponentList = componentList: processRendererComponentList =
ifNonNull' componentList componentList: ifNonNull' componentList (map processRendererComponent componentList);
(map processRendererComponent componentList);
processMapping = key: action: processMapping =
if isString action key: action:
then action if isString action then
action
else else
mapAttrs' (k: v: { mapAttrs' (k: v: {
name = name = if k == "command" then "__unkeyed" else k;
if k == "command"
then "__unkeyed"
else k;
value = v; value = v;
}) }) action;
action;
processMappings = mappings: processMappings = mappings: ifNonNull' mappings (mapAttrs processMapping mappings);
ifNonNull' mappings
(mapAttrs processMapping mappings);
processWindowMappings = window: { processWindowMappings = window: { mappings = processMappings window.mappings; };
mappings = processMappings window.mappings;
};
setupOptions = with cfg; setupOptions =
with cfg;
{ {
# Concatenate sources and extraSources, setting sources to it's default value if it is null # Concatenate sources and extraSources, setting sources to it's default value if it is null
# and extraSources is not null # and extraSources is not null
sources = sources =
if (extraSources != null) if (extraSources != null) then
then if (sources == null) then
if (sources == null) [
then ["filesystem" "git_status" "buffers"] ++ extraSources "filesystem"
else sources ++ extraSources "git_status"
else sources; "buffers"
]
++ extraSources
else
sources ++ extraSources
else
sources;
add_blank_line_at_top = addBlankLineAtTop; add_blank_line_at_top = addBlankLineAtTop;
auto_clean_after_session_restore = autoCleanAfterSessionRestore; auto_clean_after_session_restore = autoCleanAfterSessionRestore;
close_if_last_window = closeIfLastWindow; close_if_last_window = closeIfLastWindow;
@ -1047,17 +994,11 @@ in {
source_selector = with sourceSelector; { source_selector = with sourceSelector; {
inherit winbar statusline; inherit winbar statusline;
show_scrolled_off_parent_node = showScrolledOffParentNode; show_scrolled_off_parent_node = showScrolledOffParentNode;
sources = sources = ifNonNull' sources (
ifNonNull' sources map (source: {
(
map
(
source: {
inherit (source) source; inherit (source) source;
display_name = source.displayName; display_name = source.displayName;
} }) sources
)
sources
); );
content_layout = contentLayout; content_layout = contentLayout;
tabs_layout = tabsLayout; tabs_layout = tabsLayout;
@ -1073,15 +1014,11 @@ in {
highlight_separator = highlightSeparator; highlight_separator = highlightSeparator;
highlight_separator_active = highlightSeparatorActive; highlight_separator_active = highlightSeparatorActive;
}; };
event_handlers = event_handlers = ifNonNull' eventHandlers (
ifNonNull' eventHandlers mapAttrsToList (event: handler: {
(
mapAttrsToList
(event: handler: {
inherit event; inherit event;
handler = helpers.mkRaw handler; handler = helpers.mkRaw handler;
}) }) eventHandlers
eventHandlers
); );
default_component_configs = with defaultComponentConfigs; { default_component_configs = with defaultComponentConfigs; {
container = with container; { container = with container; {
@ -1107,10 +1044,7 @@ in {
folder_open = folderOpen; folder_open = folderOpen;
folder_empty = folderEmpty; folder_empty = folderEmpty;
folder_empty_open = folderEmptyOpen; folder_empty_open = folderEmptyOpen;
inherit inherit default highlight;
default
highlight
;
}; };
inherit modified; inherit modified;
name = with name; { name = with name; {
@ -1120,9 +1054,7 @@ in {
}; };
git_status = gitStatus; git_status = gitStatus;
}; };
renderers = ifNonNull' cfg.renderers ( renderers = ifNonNull' cfg.renderers (mapAttrs (name: processRendererComponentList) cfg.renderers);
mapAttrs (name: processRendererComponentList) cfg.renderers
);
nesting_rules = cfg.nestingRules; nesting_rules = cfg.nestingRules;
window = with window; { window = with window; {
inherit position width height; inherit position width height;
@ -1179,14 +1111,7 @@ in {
follow_cursor = followCursor; follow_cursor = followCursor;
inherit kinds; inherit kinds;
custom_kinds.__raw = custom_kinds.__raw =
"{" "{" + (concatStringsSep "," (mapAttrsToList (id: name: ''[${id}] = "${name}"'') customKinds)) + "}";
+ (concatStringsSep ","
(
mapAttrsToList
(id: name: ''[${id}] = "${name}"'')
customKinds
))
+ "}";
window = processWindowMappings window; window = processWindowMappings window;
}; };
} }

View file

@ -5,7 +5,8 @@
config, config,
... ...
}: }:
with lib; let with lib;
let
cfg = config.plugins.nvim-tree; cfg = config.plugins.nvim-tree;
inherit (helpers) ifNonNull'; inherit (helpers) ifNonNull';
@ -29,16 +30,17 @@ with lib; let
You shouldn't define `"width"` and `"height"` values here. You shouldn't define `"width"` and `"height"` values here.
They will be overridden to fit the file_popup content. They will be overridden to fit the file_popup content.
''; '';
in { in
{
imports = [ imports = [
( (mkRemovedOptionModule [
mkRemovedOptionModule ["plugins" "nvim-tree" "view" "hideRootFolder"] "plugins"
"Set `plugins.nvim-tree.renderer.rootFolderLabel` to `false` to hide the root folder." "nvim-tree"
) "view"
"hideRootFolder"
] "Set `plugins.nvim-tree.renderer.rootFolderLabel` to `false` to hide the root folder.")
]; ];
options.plugins.nvim-tree = options.plugins.nvim-tree = helpers.neovim-plugin.extraOptionsOptions // {
helpers.neovim-plugin.extraOptionsOptions
// {
enable = mkEnableOption "nvim-tree"; enable = mkEnableOption "nvim-tree";
package = helpers.mkPackageOption "nvim-tree" pkgs.vimPlugins.nvim-tree-lua; package = helpers.mkPackageOption "nvim-tree" pkgs.vimPlugins.nvim-tree-lua;
@ -96,11 +98,12 @@ in {
sortBy = sortBy =
helpers.defaultNullOpts.mkNullable helpers.defaultNullOpts.mkNullable
( (types.either (types.enum [
types.either "name"
(types.enum ["name" "case_sensitive" "modification_time" "extension"]) "case_sensitive"
helpers.nixvimTypes.rawLua "modification_time"
) "extension"
]) helpers.nixvimTypes.rawLua)
"name" "name"
'' ''
Changes how files within the same directory are sorted. Changes how files within the same directory are sorted.
@ -361,14 +364,17 @@ in {
width = width =
helpers.defaultNullOpts.mkNullable helpers.defaultNullOpts.mkNullable
(with types; (
with types;
oneOf [ oneOf [
str str
int int
(submodule { (submodule {
options = let options =
let
strOrInt = either str int; strOrInt = either str int;
in { in
{
# TODO check type # TODO check type
min = helpers.defaultNullOpts.mkNullable strOrInt "30" "Minimum dynamic width."; min = helpers.defaultNullOpts.mkNullable strOrInt "30" "Minimum dynamic width.";
@ -377,20 +383,25 @@ in {
''; '';
padding = padding =
helpers.defaultNullOpts.mkNullable helpers.defaultNullOpts.mkNullable (either ints.unsigned helpers.nixvimTypes.rawLua) "1"
(either ints.unsigned helpers.nixvimTypes.rawLua)
"1"
"Extra padding to the right."; "Extra padding to the right.";
}; };
}) })
]) ]
)
"30" "30"
'' ''
Width of the window: can be a `%` string, a number representing columns or a table. Width of the window: can be a `%` string, a number representing columns or a table.
A table indicates that the view should be dynamically sized based on the longest line. A table indicates that the view should be dynamically sized based on the longest line.
''; '';
side = helpers.defaultNullOpts.mkEnumFirstDefault ["left" "right"] '' side =
helpers.defaultNullOpts.mkEnumFirstDefault
[
"left"
"right"
]
''
Side of the tree, can be `"left"`, `"right"`. Side of the tree, can be `"left"`, `"right"`.
''; '';
@ -409,7 +420,15 @@ in {
will be the line number instead of `0`. will be the line number instead of `0`.
''; '';
signcolumn = helpers.defaultNullOpts.mkEnum ["yes" "auto" "no"] "yes" '' signcolumn =
helpers.defaultNullOpts.mkEnum
[
"yes"
"auto"
"no"
]
"yes"
''
Show diagnostic sign column. Value can be `"yes"`, `"auto"`, `"no"`. Show diagnostic sign column. Value can be `"yes"`, `"auto"`, `"no"`.
''; '';
@ -447,7 +466,12 @@ in {
highlightOpenedFiles = highlightOpenedFiles =
helpers.defaultNullOpts.mkEnumFirstDefault helpers.defaultNullOpts.mkEnumFirstDefault
["none" "icon" "name" "all"] [
"none"
"icon"
"name"
"all"
]
'' ''
Highlight icons and/or names for opened files using the `NvimTreeOpenedFile` highlight Highlight icons and/or names for opened files using the `NvimTreeOpenedFile` highlight
group. group.
@ -455,7 +479,12 @@ in {
highlightModified = highlightModified =
helpers.defaultNullOpts.mkEnumFirstDefault helpers.defaultNullOpts.mkEnumFirstDefault
["none" "icon" "name" "all"] [
"none"
"icon"
"name"
"all"
]
'' ''
Highlight icons and/or names for modified files using the `NvimTreeModified` highlight Highlight icons and/or names for modified files using the `NvimTreeModified` highlight
group. group.
@ -466,7 +495,14 @@ in {
rootFolderLabel = rootFolderLabel =
helpers.defaultNullOpts.mkNullable helpers.defaultNullOpts.mkNullable
# Type # Type
(with types; oneOf [str bool helpers.nixvimTypes.rawLua]) (
with types;
oneOf [
str
bool
helpers.nixvimTypes.rawLua
]
)
# Default # Default
":~:s?$?/..?" ":~:s?$?/..?"
# Description # Description
@ -519,7 +555,11 @@ in {
gitPlacement = gitPlacement =
helpers.defaultNullOpts.mkEnum helpers.defaultNullOpts.mkEnum
["after" "before" "signcolumn"] [
"after"
"before"
"signcolumn"
]
"before" "before"
'' ''
Place where the git icons will be rendered. Place where the git icons will be rendered.
@ -531,7 +571,11 @@ in {
modifiedPlacement = modifiedPlacement =
helpers.defaultNullOpts.mkEnum helpers.defaultNullOpts.mkEnum
["after" "before" "signcolumn"] [
"after"
"before"
"signcolumn"
]
"after" "after"
'' ''
Place where the modified icon will be rendered. Place where the modified icon will be rendered.
@ -639,8 +683,7 @@ in {
}; };
specialFiles = specialFiles =
helpers.defaultNullOpts.mkNullable helpers.defaultNullOpts.mkNullable (types.listOf types.str)
(types.listOf types.str)
"[ \"Cargo.toml\" \"Makefile\" \"README.md\" \"readme.md\" ]" "[ \"Cargo.toml\" \"Makefile\" \"README.md\" \"readme.md\" ]"
"A list of filenames that gets highlighted with `NvimTreeSpecialFile`."; "A list of filenames that gets highlighted with `NvimTreeSpecialFile`.";
@ -739,9 +782,7 @@ in {
''; '';
picker = picker =
helpers.defaultNullOpts.mkNullable helpers.defaultNullOpts.mkNullable (types.either types.str helpers.nixvimTypes.rawLua) "default"
(types.either types.str helpers.nixvimTypes.rawLua)
"default"
'' ''
Change the default window picker, can be a string `"default"` or a function. Change the default window picker, can be a string `"default"` or a function.
The function should return the window id that will open the node, or `nil` if an The function should return the window id that will open the node, or `nil` if an
@ -867,8 +908,10 @@ in {
}; };
}; };
config = let config =
options = with cfg; let
options =
with cfg;
{ {
disable_netrw = disableNetrw; disable_netrw = disableNetrw;
hijack_netrw = hijackNetrw; hijack_netrw = hijackNetrw;
@ -898,10 +941,7 @@ in {
show_on_open_dirs = showOnOpenDirs; show_on_open_dirs = showOnOpenDirs;
inherit icons; inherit icons;
severity = with severity; { severity = with severity; {
inherit inherit min max;
min
max
;
}; };
}; };
git = with git; { git = with git; {
@ -959,15 +999,30 @@ in {
inherit padding; inherit padding;
symlink_arrow = symlinkArrow; symlink_arrow = symlinkArrow;
show = with show; { show = with show; {
inherit file folder git modified; inherit
file
folder
git
modified
;
folder_arrow = folderArrow; folder_arrow = folderArrow;
}; };
glyphs = with glyphs; { glyphs = with glyphs; {
inherit default symlink modified git; inherit
default
symlink
modified
git
;
folder = with folder; { folder = with folder; {
arrow_closed = arrowClosed; arrow_closed = arrowClosed;
arrow_open = arrowOpen; arrow_open = arrowOpen;
inherit default open empty symlink; inherit
default
open
empty
symlink
;
empty_open = emptyOpen; empty_open = emptyOpen;
symlink_open = symlinkOpen; symlink_open = symlinkOpen;
}; };
@ -1016,7 +1071,14 @@ in {
log = with log; { log = with log; {
inherit enable truncate; inherit enable truncate;
types = with log.types; { types = with log.types; {
inherit all profile dev diagnostics git watcher; inherit
all
profile
dev
diagnostics
git
watcher
;
inherit (log.types) config; inherit (log.types) config;
copy_paste = copyPaste; copy_paste = copyPaste;
}; };

View file

@ -5,11 +5,19 @@
pkgs, pkgs,
... ...
}: }:
with lib; let with lib;
let
cfg = config.plugins.diffview; cfg = config.plugins.diffview;
mkWinConfig = type: width: height: position: mkWinConfig =
with helpers.defaultNullOpts; { type: width: height: position: with helpers.defaultNullOpts; {
type = mkEnum ["split" "float"] type '' type =
mkEnum
[
"split"
"float"
]
type
''
Determines whether the window should be a float or a normal Determines whether the window should be a float or a normal
split. split.
''; '';
@ -26,12 +34,28 @@ with lib; let
`"top"|"bottom"`. `"top"|"bottom"`.
''; '';
position = mkEnum ["left" "top" "right" "bottom"] position '' position =
mkEnum
[
"left"
"top"
"right"
"bottom"
]
position
''
Determines where the panel is positioned (only when Determines where the panel is positioned (only when
`type="split"`). `type="split"`).
''; '';
relative = mkEnum ["editor" "win"] "editor" '' relative =
mkEnum
[
"editor"
"win"
]
"editor"
''
Determines what the `position` is relative to (when Determines what the `position` is relative to (when
`type="split"`). `type="split"`).
''; '';
@ -47,8 +71,10 @@ with lib; let
These options are applied whenever the window is opened. These options are applied whenever the window is opened.
''; '';
}; };
in { in
options.plugins.diffview = with helpers.defaultNullOpts; {
options.plugins.diffview =
with helpers.defaultNullOpts;
helpers.neovim-plugin.extraOptionsOptions helpers.neovim-plugin.extraOptionsOptions
// { // {
enable = mkEnableOption "diffview"; enable = mkEnableOption "diffview";
@ -103,7 +129,8 @@ in {
done = mkStr "" ""; done = mkStr "" "";
}; };
view = let view =
let
layoutsDescription = '' layoutsDescription = ''
Configure the layout and behavior of different types of views. Configure the layout and behavior of different types of views.
For more info, see ':h diffview-config-view.x.layout'. For more info, see ':h diffview-config-view.x.layout'.
@ -123,9 +150,17 @@ in {
B B
''; '';
in { in
{
default = { default = {
layout = mkEnum ["diff2_horizontal" "diff2_vertical"] "diff2_horizontal" '' layout =
mkEnum
[
"diff2_horizontal"
"diff2_vertical"
]
"diff2_horizontal"
''
Config for changed files, and staged files in diff views. Config for changed files, and staged files in diff views.
${layoutsDescription} ${layoutsDescription}
- A: Old state - A: Old state
@ -142,7 +177,17 @@ in {
}; };
mergeTool = { mergeTool = {
layout = mkEnum ["diff1_plain" "diff3_horizontal" "diff3_vertical" "diff3_mixed" "diff4_mixed"] "diff3_horizontal" '' layout =
mkEnum
[
"diff1_plain"
"diff3_horizontal"
"diff3_vertical"
"diff3_mixed"
"diff4_mixed"
]
"diff3_horizontal"
''
Config for conflicted files in diff views during a merge or rebase. Config for conflicted files in diff views during a merge or rebase.
${layoutsDescription} ${layoutsDescription}
- A: OURS (current branch) - A: OURS (current branch)
@ -190,7 +235,14 @@ in {
}; };
fileHistory = { fileHistory = {
layout = mkEnum ["diff2_horizontal" "diff2_vertical"] "diff2_horizontal" '' layout =
mkEnum
[
"diff2_horizontal"
"diff2_vertical"
]
"diff2_horizontal"
''
Config for changed files in file history views. Config for changed files in file history views.
${layoutsDescription} ${layoutsDescription}
- A: Old state - A: Old state
@ -208,19 +260,36 @@ in {
}; };
filePanel = { filePanel = {
listingStyle = mkEnum ["list" "tree"] "tree" '' listingStyle =
mkEnum
[
"list"
"tree"
]
"tree"
''
One of 'list' or 'tree' One of 'list' or 'tree'
''; '';
treeOptions = let treeOptions =
let
commonDesc = "Only applies when listing_style is 'tree'"; commonDesc = "Only applies when listing_style is 'tree'";
in { in
{
flattenDirs = mkBool true '' flattenDirs = mkBool true ''
Flatten dirs that only contain one single dir Flatten dirs that only contain one single dir
${commonDesc} ${commonDesc}
''; '';
folderStatuses = mkEnum ["never" "only_folded" "always"] "only_folded" '' folderStatuses =
mkEnum
[
"never"
"only_folded"
"always"
]
"only_folded"
''
One of 'never', 'only_folded' or 'always'. One of 'never', 'only_folded' or 'always'.
${commonDesc} ${commonDesc}
''; '';
@ -228,7 +297,8 @@ in {
winConfig = mkWinConfig "split" 35 "" "left"; winConfig = mkWinConfig "split" 35 "" "left";
}; };
fileHistoryPanel = { fileHistoryPanel = {
logOptions = let logOptions =
let
mkNullStr = helpers.mkNullOrOption types.str; mkNullStr = helpers.mkNullOrOption types.str;
mkNullBool = helpers.mkNullOrOption types.bool; mkNullBool = helpers.mkNullOrOption types.bool;
logOptions = { logOptions = {
@ -307,7 +377,18 @@ in {
or by the function name regex <funcname>, within the <file>. or by the function name regex <funcname>, within the <file>.
''; '';
diffMerges = helpers.mkNullOrOption (types.enum ["off" "on" "first-parent" "separate" "combined" "dense-combined" "remerge"]) '' diffMerges =
helpers.mkNullOrOption
(types.enum [
"off"
"on"
"first-parent"
"separate"
"combined"
"dense-combined"
"remerge"
])
''
Determines how merge commits are treated. Determines how merge commits are treated.
''; '';
@ -333,7 +414,8 @@ in {
file. file.
''; '';
}; };
in { in
{
git = { git = {
singleFile = logOptions; singleFile = logOptions;
@ -352,17 +434,21 @@ in {
winConfig = mkWinConfig "float" "" "" ""; winConfig = mkWinConfig "float" "" "" "";
}; };
defaultArgs = let defaultArgs =
let
commonDesc = "Default args prepended to the arg-list for the listed commands"; commonDesc = "Default args prepended to the arg-list for the listed commands";
in { in
{
diffviewOpen = mkNullable (types.listOf types.str) "[ ]" commonDesc; diffviewOpen = mkNullable (types.listOf types.str) "[ ]" commonDesc;
diffviewFileHistory = mkNullable (types.listOf types.str) "[ ]" commonDesc; diffviewFileHistory = mkNullable (types.listOf types.str) "[ ]" commonDesc;
}; };
hooks = let hooks =
let
mkNullStr = helpers.mkNullOrOption types.str; mkNullStr = helpers.mkNullOrOption types.str;
in { in
{
viewOpened = mkNullStr '' viewOpened = mkNullStr ''
{view_opened} (`fun(view: View)`) {view_opened} (`fun(view: View)`)
@ -466,10 +552,13 @@ in {
''; '';
}; };
keymaps = let keymaps =
keymapList = desc: let
keymapList =
desc:
mkOption { mkOption {
type = types.listOf (types.submodule { type = types.listOf (
types.submodule {
options = { options = {
mode = mkOption { mode = mkOption {
type = types.str; type = types.str;
@ -492,7 +581,8 @@ in {
default = null; default = null;
}; };
}; };
}); }
);
description = '' description = ''
List of keybindings. List of keybindings.
${desc} ${desc}
@ -507,7 +597,8 @@ in {
} }
]; ];
}; };
in { in
{
disableDefaults = mkBool false '' disableDefaults = mkBool false ''
Disable the default keymaps. Disable the default keymaps.
''; '';
@ -549,7 +640,8 @@ in {
''; '';
}; };
config = let config =
let
setupOptions = with cfg; { setupOptions = with cfg; {
diff_binaries = diffBinaries; diff_binaries = diffBinaries;
enhanced_diff_hl = enhancedDiffHl; enhanced_diff_hl = enhancedDiffHl;
@ -608,9 +700,11 @@ in {
}; };
file_history_panel = with fileHistoryPanel; { file_history_panel = with fileHistoryPanel; {
log_options = with logOptions; let log_options =
setupLogOptions = opts: with logOptions;
with opts; { let
setupLogOptions =
opts: with opts; {
inherit base; inherit base;
rev_range = revRange; rev_range = revRange;
path_args = pathArgs; path_args = pathArgs;
@ -633,7 +727,8 @@ in {
G = g; G = g;
S = s; S = s;
}; };
in { in
{
git = with git; { git = with git; {
single_file = setupLogOptions singleFile; single_file = setupLogOptions singleFile;
multi_file = setupLogOptions multiFile; multi_file = setupLogOptions multiFile;
@ -683,9 +778,17 @@ in {
diff_buf_win_enter = diffBufWinEnter; diff_buf_win_enter = diffBufWinEnter;
}; };
keymaps = with keymaps; let keymaps =
convertToKeybinding = attr: [attr.mode attr.key attr.action {"desc" = attr.description;}]; with keymaps;
in { let
convertToKeybinding = attr: [
attr.mode
attr.key
attr.action
{ "desc" = attr.description; }
];
in
{
view = map convertToKeybinding view; view = map convertToKeybinding view;
diff1 = map convertToKeybinding diff1; diff1 = map convertToKeybinding diff1;
diff2 = map convertToKeybinding diff2; diff2 = map convertToKeybinding diff2;
@ -698,12 +801,8 @@ in {
}; };
}; };
in in
mkIf mkIf cfg.enable {
cfg.enable extraPlugins = [ cfg.package ] ++ (optional cfg.useIcons pkgs.vimPlugins.nvim-web-devicons);
{
extraPlugins =
[cfg.package]
++ (optional cfg.useIcons pkgs.vimPlugins.nvim-web-devicons);
extraConfigLua = '' extraConfigLua = ''
require("diffview").setup(${helpers.toLuaObject setupOptions}) require("diffview").setup(${helpers.toLuaObject setupOptions})
''; '';

View file

@ -5,9 +5,11 @@
pkgs, pkgs,
... ...
}: }:
with lib; let with lib;
let
cfg = config.plugins.git-worktree; cfg = config.plugins.git-worktree;
in { in
{
options = { options = {
plugins.git-worktree = { plugins.git-worktree = {
enable = mkEnableOption "git-worktree"; enable = mkEnableOption "git-worktree";
@ -43,7 +45,8 @@ in {
}; };
}; };
config = let config =
let
setupOptions = with cfg; { setupOptions = with cfg; {
enabled = cfg.enable; enabled = cfg.enable;
change_directory_command = cfg.changeDirectoryCommand; change_directory_command = cfg.changeDirectoryCommand;
@ -68,15 +71,13 @@ in {
extraPackages = [ pkgs.git ]; extraPackages = [ pkgs.git ];
extraConfigLua = let extraConfigLua =
let
telescopeCfg = ''require("telescope").load_extension("git_worktree")''; telescopeCfg = ''require("telescope").load_extension("git_worktree")'';
in '' in
''
require('git-worktree').setup(${helpers.toLuaObject setupOptions}) require('git-worktree').setup(${helpers.toLuaObject setupOptions})
${ ${if cfg.enableTelescope then telescopeCfg else ""}
if cfg.enableTelescope
then telescopeCfg
else ""
}
''; '';
}; };
} }

View file

@ -5,9 +5,11 @@
pkgs, pkgs,
... ...
}: }:
with lib; let with lib;
let
cfg = config.plugins.gitblame; cfg = config.plugins.gitblame;
in { in
{
options = { options = {
plugins.gitblame = { plugins.gitblame = {
enable = mkEnableOption "gitblame"; enable = mkEnableOption "gitblame";
@ -22,19 +24,28 @@ in {
highlightGroup = helpers.defaultNullOpts.mkStr "Comment" "The highlight group for virtual text."; highlightGroup = helpers.defaultNullOpts.mkStr "Comment" "The highlight group for virtual text.";
displayVirtualText = helpers.defaultNullOpts.mkNullable (types.nullOr types.bool) (toString true) "If the blame message should be displayed as virtual text. You may want to disable this if you display the blame message in statusline."; displayVirtualText =
helpers.defaultNullOpts.mkNullable (types.nullOr types.bool) (toString true)
"If the blame message should be displayed as virtual text. You may want to disable this if you display the blame message in statusline.";
ignoredFiletypes = helpers.defaultNullOpts.mkNullable (types.listOf types.str) (toString []) "A list of filetypes for which gitblame information will not be displayed."; ignoredFiletypes = helpers.defaultNullOpts.mkNullable (types.listOf types.str) (toString
[ ]
) "A list of filetypes for which gitblame information will not be displayed.";
delay = helpers.defaultNullOpts.mkUnsignedInt 0 "The delay in milliseconds after which the blame info will be displayed."; delay =
helpers.defaultNullOpts.mkUnsignedInt 0
"The delay in milliseconds after which the blame info will be displayed.";
virtualTextColumn = helpers.defaultNullOpts.mkNullable types.ints.unsigned (toString null) "Have the blame message start at a given column instead of EOL. If the current line is longer than the specified column value the blame message will default to being displayed at EOL."; virtualTextColumn =
helpers.defaultNullOpts.mkNullable types.ints.unsigned (toString null)
"Have the blame message start at a given column instead of EOL. If the current line is longer than the specified column value the blame message will default to being displayed at EOL.";
extmarkOptions = helpers.defaultNullOpts.mkAttributeSet (toString null) "nvim_buf_set_extmark optional parameters. (Warning: overwriting id and virt_text will break the plugin behavior)"; extmarkOptions = helpers.defaultNullOpts.mkAttributeSet (toString null) "nvim_buf_set_extmark optional parameters. (Warning: overwriting id and virt_text will break the plugin behavior)";
}; };
}; };
config = let config =
let
setupOptions = { setupOptions = {
enabled = cfg.enable; enabled = cfg.enable;
message_template = cfg.messageTemplate; message_template = cfg.messageTemplate;
@ -42,9 +53,7 @@ in {
message_when_not_committed = cfg.messageWhenNotCommitted; message_when_not_committed = cfg.messageWhenNotCommitted;
highlight_group = cfg.highlightGroup; highlight_group = cfg.highlightGroup;
display_virtual_text = helpers.ifNonNull' cfg.displayVirtualText ( display_virtual_text = helpers.ifNonNull' cfg.displayVirtualText (
if cfg.displayVirtualText if cfg.displayVirtualText then 1 else 0
then 1
else 0
); );
ignored_filetypes = cfg.ignoredFiletypes; ignored_filetypes = cfg.ignoredFiletypes;
inherit (cfg) delay; inherit (cfg) delay;

View file

@ -5,9 +5,11 @@
pkgs, pkgs,
... ...
}: }:
with lib; let with lib;
let
cfg = config.plugins.gitgutter; cfg = config.plugins.gitgutter;
in { in
{
options = { options = {
plugins.gitgutter = { plugins.gitgutter = {
enable = mkEnableOption "gitgutter"; enable = mkEnableOption "gitgutter";
@ -57,8 +59,10 @@ in {
}; };
signs = mkOption { signs = mkOption {
type = let type =
signOption = desc: let
signOption =
desc:
mkOption { mkOption {
type = types.nullOr types.str; type = types.nullOr types.str;
default = null; default = null;
@ -99,7 +103,8 @@ in {
}; };
grep = mkOption { grep = mkOption {
type = types.nullOr (types.oneOf [ type = types.nullOr (
types.oneOf [
(types.submodule { (types.submodule {
options = { options = {
command = mkOption { command = mkOption {
@ -114,7 +119,8 @@ in {
}; };
}) })
types.str types.str
]); ]
);
default = null; default = null;
description = "A non-standard grep to use instead of the default"; description = "A non-standard grep to use instead of the default";
}; };
@ -169,15 +175,10 @@ in {
}; };
}; };
config = let config =
grepPackage = let
if builtins.isAttrs cfg.grep grepPackage = if builtins.isAttrs cfg.grep then [ cfg.grep.package ] else [ ];
then [cfg.grep.package] grepCommand = if builtins.isAttrs cfg.grep then cfg.grep.command else cfg.grep;
else [];
grepCommand =
if builtins.isAttrs cfg.grep
then cfg.grep.command
else cfg.grep;
in in
mkIf cfg.enable { mkIf cfg.enable {
extraPlugins = [ cfg.package ]; extraPlugins = [ cfg.package ];
@ -200,8 +201,12 @@ in {
gitgutter_sign_added = mkIf (cfg.signs.added != null) cfg.signs.added; gitgutter_sign_added = mkIf (cfg.signs.added != null) cfg.signs.added;
gitgutter_sign_modified = mkIf (cfg.signs.modified != null) cfg.signs.modified; gitgutter_sign_modified = mkIf (cfg.signs.modified != null) cfg.signs.modified;
gitgutter_sign_removed = mkIf (cfg.signs.removed != null) cfg.signs.removed; gitgutter_sign_removed = mkIf (cfg.signs.removed != null) cfg.signs.removed;
gitgutter_sign_removed_first_line = mkIf (cfg.signs.removedFirstLine != null) cfg.signs.removedFirstLine; gitgutter_sign_removed_first_line = mkIf (
gitgutter_sign_removed_above_and_bellow = mkIf (cfg.signs.removedAboveAndBelow != null) cfg.signs.removedAboveAndBelow; cfg.signs.removedFirstLine != null
) cfg.signs.removedFirstLine;
gitgutter_sign_removed_above_and_bellow = mkIf (
cfg.signs.removedAboveAndBelow != null
) cfg.signs.removedAboveAndBelow;
gitgutter_sign_modified_above = mkIf (cfg.signs.modifiedAbove != null) cfg.signs.modifiedAbove; gitgutter_sign_modified_above = mkIf (cfg.signs.modifiedAbove != null) cfg.signs.modifiedAbove;
gitgutter_diff_relative_to = mkIf cfg.diffRelativeToWorkingTree "working_tree"; gitgutter_diff_relative_to = mkIf cfg.diffRelativeToWorkingTree "working_tree";

View file

@ -17,12 +17,10 @@ with lib;
extraOptions = { extraOptions = {
keymap = mkOption { keymap = mkOption {
type = with types; type =
nullOr with types;
( nullOr (
either either str (submodule {
str
(submodule {
options = { options = {
key = mkOption { key = mkOption {
type = str; type = str;
@ -49,16 +47,15 @@ with lib;
}; };
extraConfig = cfg: { extraConfig = cfg: {
keymaps = keymaps = optional (cfg.keymap != null) (
optional (cfg.keymap != null)
( (
( if isString cfg.keymap then
if isString cfg.keymap {
then {
mode = "n"; mode = "n";
key = cfg.keymap; key = cfg.keymap;
} }
else cfg.keymap else
cfg.keymap
) )
// { // {
action.__raw = "require('gitignore').generate"; action.__raw = "require('gitignore').generate";

View file

@ -5,10 +5,9 @@
pkgs, pkgs,
... ...
}: }:
with lib; { with lib;
options.plugins.gitlinker = {
helpers.neovim-plugin.extraOptionsOptions options.plugins.gitlinker = helpers.neovim-plugin.extraOptionsOptions // {
// {
enable = mkEnableOption "gitlinker.nvim"; enable = mkEnableOption "gitlinker.nvim";
package = helpers.mkPackageOption "gitlinker.nvim" pkgs.vimPlugins.gitlinker-nvim; package = helpers.mkPackageOption "gitlinker.nvim" pkgs.vimPlugins.gitlinker-nvim;
@ -40,16 +39,7 @@ with lib; {
mappings = helpers.defaultNullOpts.mkStr "<leader>gy" "Mapping to call url generation."; mappings = helpers.defaultNullOpts.mkStr "<leader>gy" "Mapping to call url generation.";
callbacks = callbacks =
helpers.defaultNullOpts.mkNullable helpers.defaultNullOpts.mkNullable (with types; attrsOf (either str helpers.nixvimTypes.rawLua))
(
with types;
attrsOf
(
either
str
helpers.nixvimTypes.rawLua
)
)
'' ''
{ {
"github.com" = "get_github_type_url"; "github.com" = "get_github_type_url";
@ -79,40 +69,39 @@ with lib; {
''; '';
}; };
config = let config =
let
cfg = config.plugins.gitlinker; cfg = config.plugins.gitlinker;
in in
mkIf cfg.enable { mkIf cfg.enable {
extraPlugins = [ cfg.package ]; extraPlugins = [ cfg.package ];
extraConfigLua = let extraConfigLua =
setupOptions = with cfg; let
setupOptions =
with cfg;
{ {
opts = { opts = {
inherit remote; inherit remote;
add_current_line_on_normal_mode = addCurrentLineOnNormalMode; add_current_line_on_normal_mode = addCurrentLineOnNormalMode;
action_callback = action_callback =
if isString actionCallback if isString actionCallback then
then helpers.mkRaw "require('gitlinker.actions').${actionCallback}" helpers.mkRaw "require('gitlinker.actions').${actionCallback}"
else actionCallback; else
actionCallback;
print_url = printUrl; print_url = printUrl;
inherit mappings; inherit mappings;
}; };
callbacks = callbacks = helpers.ifNonNull' callbacks (
helpers.ifNonNull' callbacks mapAttrs (
(
mapAttrs
(
source: callback: source: callback:
if isString callback if isString callback then helpers.mkRaw "require('gitlinker.hosts').${callback}" else callback
then helpers.mkRaw "require('gitlinker.hosts').${callback}" ) callbacks
else callback
)
callbacks
); );
} }
// cfg.extraOptions; // cfg.extraOptions;
in '' in
''
require('gitlinker').setup(${helpers.toLuaObject setupOptions}) require('gitlinker').setup(${helpers.toLuaObject setupOptions})
''; '';
}; };

View file

@ -5,7 +5,8 @@
pkgs, pkgs,
... ...
}: }:
with lib; { with lib;
{
meta.maintainers = [ maintainers.traxys ]; meta.maintainers = [ maintainers.traxys ];
options.plugins.gitmessenger = { options.plugins.gitmessenger = {
@ -17,7 +18,14 @@ with lib; {
A popup window is no longer closed automatically when moving a cursor after the window is A popup window is no longer closed automatically when moving a cursor after the window is
shown up. shown up.
''; '';
includeDiff = helpers.defaultNullOpts.mkEnumFirstDefault ["none" "current" "all"] '' includeDiff =
helpers.defaultNullOpts.mkEnumFirstDefault
[
"none"
"current"
"all"
]
''
When this value is not set to "none", a popup window includes diff hunks of the commit at When this value is not set to "none", a popup window includes diff hunks of the commit at
showing up. "current" includes diff hunks of only current file in the commit. "all" includes showing up. "current" includes diff hunks of only current file in the commit. "all" includes
all diff hunks in the commit. all diff hunks in the commit.
@ -25,12 +33,8 @@ with lib; {
Please note that typing d/D or r/R in popup window toggle showing diff hunks even if this Please note that typing d/D or r/R in popup window toggle showing diff hunks even if this
value is set to "none". value is set to "none".
''; '';
gitCommand = gitCommand = helpers.defaultNullOpts.mkStr "git" "git command to retrieve commit messages.";
helpers.defaultNullOpts.mkStr "git" noDefaultMappings = helpers.defaultNullOpts.mkBool false "When this value is set, it does not define any key mappings";
"git command to retrieve commit messages.";
noDefaultMappings =
helpers.defaultNullOpts.mkBool false
"When this value is set, it does not define any key mappings";
intoPopupAfterShow = helpers.defaultNullOpts.mkBool true '' intoPopupAfterShow = helpers.defaultNullOpts.mkBool true ''
When this value is set to v:false, running :GitMessenger or <plug>(git-messenger) again after When this value is set to v:false, running :GitMessenger or <plug>(git-messenger) again after
showing a popup does not move the cursor in the window. showing a popup does not move the cursor in the window.
@ -92,7 +96,8 @@ with lib; {
''; '';
}; };
config = let config =
let
cfg = config.plugins.gitmessenger; cfg = config.plugins.gitmessenger;
in in
mkIf cfg.enable { mkIf cfg.enable {

View file

@ -16,42 +16,157 @@ with lib;
# TODO: introduced 2024-03-12, remove on 2024-05-12 # TODO: introduced 2024-03-12, remove on 2024-05-12
deprecateExtraOptions = true; deprecateExtraOptions = true;
optionsRenamedToSettings = [ optionsRenamedToSettings = [
["signs" "add" "hl"] [
["signs" "add" "text"] "signs"
["signs" "add" "numhl"] "add"
["signs" "add" "linehl"] "hl"
["signs" "add" "showCount"] ]
["signs" "change" "hl"] [
["signs" "change" "text"] "signs"
["signs" "change" "numhl"] "add"
["signs" "change" "linehl"] "text"
["signs" "change" "showCount"] ]
["signs" "topdelete" "hl"] [
["signs" "topdelete" "text"] "signs"
["signs" "topdelete" "numhl"] "add"
["signs" "topdelete" "linehl"] "numhl"
["signs" "topdelete" "showCount"] ]
["signs" "changedelete" "hl"] [
["signs" "changedelete" "text"] "signs"
["signs" "changedelete" "numhl"] "add"
["signs" "changedelete" "linehl"] "linehl"
["signs" "changedelete" "showCount"] ]
["signs" "untracked" "hl"] [
["signs" "untracked" "text"] "signs"
["signs" "untracked" "numhl"] "add"
["signs" "untracked" "linehl"] "showCount"
["signs" "untracked" "showCount"] ]
[
"signs"
"change"
"hl"
]
[
"signs"
"change"
"text"
]
[
"signs"
"change"
"numhl"
]
[
"signs"
"change"
"linehl"
]
[
"signs"
"change"
"showCount"
]
[
"signs"
"topdelete"
"hl"
]
[
"signs"
"topdelete"
"text"
]
[
"signs"
"topdelete"
"numhl"
]
[
"signs"
"topdelete"
"linehl"
]
[
"signs"
"topdelete"
"showCount"
]
[
"signs"
"changedelete"
"hl"
]
[
"signs"
"changedelete"
"text"
]
[
"signs"
"changedelete"
"numhl"
]
[
"signs"
"changedelete"
"linehl"
]
[
"signs"
"changedelete"
"showCount"
]
[
"signs"
"untracked"
"hl"
]
[
"signs"
"untracked"
"text"
]
[
"signs"
"untracked"
"numhl"
]
[
"signs"
"untracked"
"linehl"
]
[
"signs"
"untracked"
"showCount"
]
"worktrees" "worktrees"
"signPriority" "signPriority"
"signcolumn" "signcolumn"
"numhl" "numhl"
"linehl" "linehl"
"showDeleted" "showDeleted"
["diffOpts" "algorithm"] [
["diffOpts" "internal"] "diffOpts"
["diffOpts" "indentHeuristic"] "algorithm"
["diffOpts" "vertical"] ]
["diffOpts" "linematch"] [
"diffOpts"
"internal"
]
[
"diffOpts"
"indentHeuristic"
]
[
"diffOpts"
"vertical"
]
[
"diffOpts"
"linematch"
]
"base" "base"
"countChars" "countChars"
"maxFileLength" "maxFileLength"
@ -59,55 +174,110 @@ with lib;
"attachToUntracked" "attachToUntracked"
"updateDebounce" "updateDebounce"
"currentLineBlame" "currentLineBlame"
["currentLineBlameOpts" "virtText"] [
["currentLineBlameOpts" "virtTextPos"] "currentLineBlameOpts"
["currentLineBlameOpts" "delay"] "virtText"
["currentLineBlameOpts" "ignoreWhitespace"] ]
["currentLineBlameOpts" "virtTextPriority"] [
"currentLineBlameOpts"
"virtTextPos"
]
[
"currentLineBlameOpts"
"delay"
]
[
"currentLineBlameOpts"
"ignoreWhitespace"
]
[
"currentLineBlameOpts"
"virtTextPriority"
]
"trouble" "trouble"
["yadm" "enable"] [
"yadm"
"enable"
]
"wordDiff" "wordDiff"
"debugMode" "debugMode"
]; ];
imports = let imports =
basePluginPaths = ["plugins" "gitsigns"]; let
basePluginPaths = [
"plugins"
"gitsigns"
];
settingsPath = basePluginPaths ++ [ "settings" ]; settingsPath = basePluginPaths ++ [ "settings" ];
in [ in
[
(mkRenamedOptionModule (
basePluginPaths
++ [
"onAttach"
"function"
]
) (settingsPath ++ [ "on_attach" ]))
(mkRenamedOptionModule
( (
mkRenamedOptionModule basePluginPaths
(basePluginPaths ++ ["onAttach" "function"]) ++ [
(settingsPath ++ ["on_attach"]) "watchGitDir"
"enable"
]
) )
( (
mkRenamedOptionModule settingsPath
(basePluginPaths ++ ["watchGitDir" "enable"]) ++ [
(settingsPath ++ ["watch_gitdir" "enable"]) "watch_gitdir"
"enable"
]
)
)
(mkRemovedOptionModule (
basePluginPaths
++ [
"watchGitDir"
"interval"
]
) "The option has been removed from upstream.")
(mkRenamedOptionModule
(
basePluginPaths
++ [
"watchGitDir"
"followFiles"
]
) )
( (
mkRemovedOptionModule settingsPath
(basePluginPaths ++ ["watchGitDir" "interval"]) ++ [
"The option has been removed from upstream." "watch_gitdir"
"follow_files"
]
) )
(
mkRenamedOptionModule
(basePluginPaths ++ ["watchGitDir" "followFiles"])
(settingsPath ++ ["watch_gitdir" "follow_files"])
)
(
mkRenamedOptionModule
(basePluginPaths ++ ["statusFormatter" "function"])
(settingsPath ++ ["status_formatter"])
)
(
mkRenamedOptionModule
(basePluginPaths ++ ["currentLineBlameFormatter" "normal"])
(settingsPath ++ ["current_line_blame_formatter"])
)
(
mkRenamedOptionModule
(basePluginPaths ++ ["currentLineBlameFormatter" "nonCommitted"])
(settingsPath ++ ["current_line_blame_formatter_nc"])
) )
(mkRenamedOptionModule (
basePluginPaths
++ [
"statusFormatter"
"function"
]
) (settingsPath ++ [ "status_formatter" ]))
(mkRenamedOptionModule (
basePluginPaths
++ [
"currentLineBlameFormatter"
"normal"
]
) (settingsPath ++ [ "current_line_blame_formatter" ]))
(mkRenamedOptionModule (
basePluginPaths
++ [
"currentLineBlameFormatter"
"nonCommitted"
]
) (settingsPath ++ [ "current_line_blame_formatter_nc" ]))
]; ];
extraOptions = { extraOptions = {
@ -143,8 +313,7 @@ with lib;
extraConfig = cfg: { extraConfig = cfg: {
warnings = warnings =
optional optional ((isBool cfg.settings.trouble && cfg.settings.trouble) && !config.plugins.trouble.enable)
((isBool cfg.settings.trouble && cfg.settings.trouble) && !config.plugins.trouble.enable)
'' ''
Nixvim (plugins.gitsigns): You have enabled `plugins.gitsigns.settings.trouble` but Nixvim (plugins.gitsigns): You have enabled `plugins.gitsigns.settings.trouble` but
`plugins.trouble.enable` is `false`. `plugins.trouble.enable` is `false`.

View file

@ -1,9 +1,8 @@
{ lib, helpers }:
with lib;
{ {
lib, signs =
helpers, let
}:
with lib; {
signs = let
signOptions = defaults: { signOptions = defaults: {
hl = helpers.defaultNullOpts.mkStr defaults.hl '' hl = helpers.defaultNullOpts.mkStr defaults.hl ''
Specifies the highlight group to use for the sign. Specifies the highlight group to use for the sign.
@ -25,7 +24,8 @@ with lib; {
Showing count of hunk, e.g. number of deleted lines. Showing count of hunk, e.g. number of deleted lines.
''; '';
}; };
in { in
{
add = signOptions { add = signOptions {
hl = "GitSignsAdd"; hl = "GitSignsAdd";
text = ""; text = "";
@ -64,17 +64,14 @@ with lib; {
}; };
}; };
worktrees = let worktrees =
let
worktreeType = types.submodule { worktreeType = types.submodule {
freeformType = with types; attrsOf anything; freeformType = with types; attrsOf anything;
options = { options = {
toplevel = mkOption { toplevel = mkOption { type = with helpers.nixvimTypes; maybeRaw str; };
type = with helpers.nixvimTypes; maybeRaw str;
};
gitdir = mkOption { gitdir = mkOption { type = with helpers.nixvimTypes; maybeRaw str; };
type = with helpers.nixvimTypes; maybeRaw str;
};
}; };
}; };
in in
@ -149,13 +146,19 @@ with lib; {
Note: Virtual lines currently use the highlight `GitSignsDeleteVirtLn`. Note: Virtual lines currently use the highlight `GitSignsDeleteVirtLn`.
''; '';
diff_opts = let diff_opts =
let
diffOptType = types.submodule { diffOptType = types.submodule {
freeformType = with types; attrsOf anything; freeformType = with types; attrsOf anything;
options = { options = {
algorithm = algorithm =
helpers.defaultNullOpts.mkEnumFirstDefault helpers.defaultNullOpts.mkEnumFirstDefault
["myers" "minimal" "patience" "histogram"] [
"myers"
"minimal"
"patience"
"histogram"
]
'' ''
Diff algorithm to use. Values: Diff algorithm to use. Values:
- "myers" the default algorithm - "myers" the default algorithm
@ -236,9 +239,7 @@ with lib; {
- to define characters to be used for counts greater than 9. - to define characters to be used for counts greater than 9.
''; '';
status_formatter = status_formatter = helpers.defaultNullOpts.mkLuaFn ''
helpers.defaultNullOpts.mkLuaFn
''
function(status) function(status)
local added, changed, removed = status.added, status.changed, status.removed local added, changed, removed = status.added, status.changed, status.removed
local status_txt = {} local status_txt = {}
@ -253,8 +254,7 @@ with lib; {
end end
return table.concat(status_txt, ' ') return table.concat(status_txt, ' ')
end end
'' '' "Function used to format `b:gitsigns_status`.";
"Function used to format `b:gitsigns_status`.";
max_file_length = helpers.defaultNullOpts.mkUnsignedInt 40000 '' max_file_length = helpers.defaultNullOpts.mkUnsignedInt 40000 ''
Max file length (in lines) to attach to. Max file length (in lines) to attach to.
@ -298,7 +298,14 @@ with lib; {
Whether to show a virtual text blame annotation Whether to show a virtual text blame annotation
''; '';
virt_text_pos = helpers.defaultNullOpts.mkEnumFirstDefault ["eol" "overlay" "right_align"] '' virt_text_pos =
helpers.defaultNullOpts.mkEnumFirstDefault
[
"eol"
"overlay"
"right_align"
]
''
Blame annotation position. Blame annotation position.
Available values: Available values:
@ -320,10 +327,7 @@ with lib; {
''; '';
}; };
current_line_blame_formatter = current_line_blame_formatter = helpers.defaultNullOpts.mkStr " <author>, <author_time> - <summary> " ''
helpers.defaultNullOpts.mkStr
" <author>, <author_time> - <summary> "
''
String or function used to format the virtual text of `current_line_blame`. String or function used to format the virtual text of `current_line_blame`.
When a string, accepts the following format specifiers: When a string, accepts the following format specifiers:
@ -395,10 +399,7 @@ with lib; {
`|nvim_buf_set_extmark|` and thus must be a list of `[text, highlight]` tuples. `|nvim_buf_set_extmark|` and thus must be a list of `[text, highlight]` tuples.
''; '';
current_line_blame_formatter_nc = current_line_blame_formatter_nc = helpers.defaultNullOpts.mkStr " <author>" ''
helpers.defaultNullOpts.mkStr
" <author>"
''
String or function used to format the virtual text of `|gitsigns-config-current_line_blame|` String or function used to format the virtual text of `|gitsigns-config-current_line_blame|`
for lines that aren't committed. for lines that aren't committed.

View file

@ -20,12 +20,11 @@ with lib;
''; '';
floating_window_scaling_factor = floating_window_scaling_factor =
helpers.defaultNullOpts.mkNullable types.numbers.nonnegative helpers.defaultNullOpts.mkNullable types.numbers.nonnegative "0.9"
"0.9" "Set the scaling factor for floating window."; "Set the scaling factor for floating window.";
floating_window_border_chars = floating_window_border_chars =
helpers.defaultNullOpts.mkListOf types.str helpers.defaultNullOpts.mkListOf types.str ''["" "" "" "" "" "" "" ""]''
''["" "" "" "" "" "" "" ""]''
"Customize lazygit popup window border characters."; "Customize lazygit popup window border characters.";
floating_window_use_plenary = helpers.defaultNullOpts.mkBool false '' floating_window_use_plenary = helpers.defaultNullOpts.mkBool false ''
@ -40,21 +39,24 @@ with lib;
Config file path is evaluated if this value is `true`. Config file path is evaluated if this value is `true`.
''; '';
config_file_path = config_file_path = helpers.defaultNullOpts.mkNullable (
helpers.defaultNullOpts.mkNullable with types; either str (listOf str)
( ) "[]" "Custom config file path or list of custom config file paths.";
with types;
either
str (listOf str)
)
"[]"
"Custom config file path or list of custom config file paths.";
}; };
settingsExample = { settingsExample = {
floating_window_winblend = 0; floating_window_winblend = 0;
floating_window_scaling_factor = 0.9; floating_window_scaling_factor = 0.9;
floating_window_border_chars = ["" "" "" "" "" "" "" ""]; floating_window_border_chars = [
""
""
""
""
""
""
""
""
];
floating_window_use_plenary = false; floating_window_use_plenary = false;
use_neovim_remote = true; use_neovim_remote = true;
use_custom_config_file_path = false; use_custom_config_file_path = false;

View file

@ -16,10 +16,17 @@ with lib;
# TODO introduced 2024-02-29: remove 2024-04-29 # TODO introduced 2024-02-29: remove 2024-04-29
deprecateExtraOptions = true; deprecateExtraOptions = true;
imports = imports =
map ( map
(
optionPath: optionPath:
mkRemovedOptionModule mkRemovedOptionModule
(["plugins" "neogit"] ++ optionPath) (
[
"plugins"
"neogit"
]
++ optionPath
)
"This option has been removed upstream. Please refer to the plugin documentation to update your configuration." "This option has been removed upstream. Please refer to the plugin documentation to update your configuration."
) )
[ [
@ -27,8 +34,14 @@ with lib;
[ "disableBuiltinNotifications" ] [ "disableBuiltinNotifications" ]
[ "useMagitKeybindings " ] [ "useMagitKeybindings " ]
[ "commitPopup" ] [ "commitPopup" ]
["sections" "unmerged"] [
["sections" "unpulled"] "sections"
"unmerged"
]
[
"sections"
"unpulled"
]
]; ];
optionsRenamedToSettings = [ optionsRenamedToSettings = [
"disableSigns" "disableSigns"
@ -39,11 +52,26 @@ with lib;
"kind" "kind"
"signs" "signs"
"integrations" "integrations"
["sections" "untracked"] [
["sections" "unstaged"] "sections"
["sections" "staged"] "untracked"
["sections" "stashes"] ]
["sections" "recent"] [
"sections"
"unstaged"
]
[
"sections"
"staged"
]
[
"sections"
"stashes"
]
[
"sections"
"recent"
]
"mappings" "mappings"
]; ];
@ -77,28 +105,25 @@ with lib;
extraConfig = cfg: { extraConfig = cfg: {
assertions = assertions =
map map
( (name: {
name: { assertion =
assertion = let let
enabled = cfg.settings.integrations.${name}; enabled = cfg.settings.integrations.${name};
isEnabled = (isBool enabled) && enabled; isEnabled = (isBool enabled) && enabled;
in in
isEnabled isEnabled -> config.plugins.${name}.enable;
-> config.plugins.${name}.enable;
message = '' message = ''
Nixvim (plugins.neogit): You have enabled the `${name}` integration, but `plugins.${name}.enable` is `false`. Nixvim (plugins.neogit): You have enabled the `${name}` integration, but `plugins.${name}.enable` is `false`.
''; '';
} })
)
[ [
"telescope" "telescope"
"diffview" "diffview"
"fzf-lua" "fzf-lua"
]; ];
extraPackages = extraPackages = optional (hasInfix "which" (
optional cfg.settings.commit_view.verify_commit.__raw or ""
(hasInfix "which" (cfg.settings.commit_view.verify_commit.__raw or "")) )) pkgs.which;
pkgs.which;
}; };
} }

Some files were not shown because too many files have changed in this diff Show more