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
( lock = builtins.fromJSON (builtins.readFile ./flake.lock);
let in
lock = builtins.fromJSON (builtins.readFile ./flake.lock); fetchTarball {
in url =
fetchTarball { lock.nodes.flake-compat.locked.url
url = lock.nodes.flake-compat.locked.url or "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; 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,18 +2,19 @@
rawModules, rawModules,
helpers, helpers,
pkgs, pkgs,
}: let }:
let
pkgsDoc = pkgsDoc =
import (pkgs.applyPatches { import
name = "nixpkgs-nixvim-doc"; (pkgs.applyPatches {
src = pkgs.path; name = "nixpkgs-nixvim-doc";
patches = [ src = pkgs.path;
./either_recursive.patch patches = [ ./either_recursive.patch ];
]; })
}) { {
inherit (pkgs) system; inherit (pkgs) system;
config.allowUnfree = true; config.allowUnfree = true;
}; };
inherit (pkgsDoc) lib; inherit (pkgsDoc) lib;
@ -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) then
if lib.hasPrefix nixvimPath (toString decl) gitHubDeclaration "nix-community" "nixvim" "main" (
then lib.removePrefix "/" (lib.removePrefix nixvimPath (toString decl))
gitHubDeclaration "nix-community" "nixvim" "main" )
(lib.removePrefix "/" (lib.removePrefix nixvimPath (toString decl))) else if decl == "lib/modules.nix" then
else if decl == "lib/modules.nix" gitHubDeclaration "NixOS" "nixpkgs" "master" decl
then gitHubDeclaration "NixOS" "nixpkgs" "master" decl else
else decl decl
) ) opt.declarations;
opt.declarations;
}; };
nixvmConfigType = lib.mkOptionType { nixvmConfigType = lib.mkOptionType {
@ -48,61 +49,51 @@
# 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" { options.files = lib.mkOption {
options.files = lib.mkOption { type = lib.types.attrsOf nixvmConfigType;
type = lib.types.attrsOf nixvmConfigType; description = "Extra files to add to the runtimepath";
description = "Extra files to add to the runtimepath"; example = {
example = { "ftplugin/nix.lua" = {
"ftplugin/nix.lua" = { options = {
options = { tabstop = 2;
tabstop = 2; shiftwidth = 2;
shiftwidth = 2; expandtab = true;
expandtab = true;
};
}; };
}; };
}; };
}) };
]
++ (rawModules pkgsDoc);
hmOptions =
builtins.removeAttrs
(lib.evalModules {
modules = [
(import ../wrappers/modules/hm.nix {inherit lib;})
];
}) })
.options ] ++ (rawModules pkgsDoc);
["_module"];
hmOptions = builtins.removeAttrs (lib.evalModules {
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; specialArgs.helpers = helpers;
specialArgs.helpers = helpers;
})
options
;
inherit transformOptions;
warningsAreErrors = false;
}) })
.optionsJSON; options
man-docs = pkgsDoc.callPackage ./man {inherit options-json;}; ;
}
# Do not check if documentation builds fine on darwin as it fails:
# > sandbox-exec: pattern serialization length 69298 exceeds maximum (65535)
// lib.optionalAttrs (!pkgsDoc.stdenv.isDarwin) {
docs = pkgsDoc.callPackage ./mdbook {
inherit transformOptions; inherit transformOptions;
modules = topLevelModules; warningsAreErrors = false;
inherit helpers hmOptions; }).optionsJSON;
}; man-docs = pkgsDoc.callPackage ./man { inherit options-json; };
} }
# Do not check if documentation builds fine on darwin as it fails:
# > sandbox-exec: pattern serialization length 69298 exceeds maximum (65535)
// lib.optionalAttrs (!pkgsDoc.stdenv.isDarwin) {
docs = pkgsDoc.callPackage ./mdbook {
inherit transformOptions;
modules = topLevelModules;
inherit helpers hmOptions;
};
}

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,26 +24,34 @@
end end
''; '';
manHeader = let manHeader =
mkMDSection = file: "<(pandoc --lua-filter <(echo \"$manualFilter\") -f gfm -t man ${file})"; let
in mkMDSection = file: "<(pandoc --lua-filter <(echo \"$manualFilter\") -f gfm -t man ${file})";
runCommand "nixvim-general-doc-manpage" { in
nativeBuildInputs = [pandoc]; runCommand "nixvim-general-doc-manpage"
inherit manualFilter; {
} '' nativeBuildInputs = [ pandoc ];
mkdir -p $out inherit manualFilter;
cat \ }
${./nixvim-header-start.5} \ ''
${mkMDSection ../user-guide/helpers.md} \ mkdir -p $out
${mkMDSection ../user-guide/faq.md} \ cat \
${./nixvim-header-end.5} \ ${./nixvim-header-start.5} \
>$out/nixvim-header.5 ${mkMDSection ../user-guide/helpers.md} \
''; ${mkMDSection ../user-guide/faq.md} \
# FIXME add platform specific docs to manpage ${./nixvim-header-end.5} \
>$out/nixvim-header.5
'';
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"
@ -31,215 +35,199 @@ with lib; let
"content" "content"
]; ];
removeWhitespace = builtins.replaceStrings [" "] [""]; removeWhitespace = builtins.replaceStrings [ " " ] [ "" ];
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) == { };
in in
!hasEmptyIndex || !hasEmptyComponents; !hasEmptyIndex || !hasEmptyComponents;
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;
in in
"# ${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
subOpts = getSubOptions opts (path ++ [name]); g =
name: opts:
if !isOption opts then
wrapModule (path ++ [ name ]) (recurse (path ++ [ name ]) opts) false
else
let
subOpts = getSubOptions opts (path ++ [ name ]);
in
if subOpts != { } then
wrapModule (path ++ [ name ]) (
(recurse (path ++ [ name ]) subOpts)
// {
# This is necessary to include the submodule option's definition in the docs (description, type, etc.)
# For instance, this helps submodules like "autoCmd" to include their base definitions and examples in the docs
# Though there might be a better, less "hacky" solution than this.
${name} = recursiveUpdate opts {
isOption = true;
type.getSubOptions = _: _: { }; # Used to exclude suboptions from the submodule definition itself
};
}
) false
else
wrapModule (path ++ [ name ]) opts true;
in in
if subOpts != {} mapAttrs g mods;
then
wrapModule
(path ++ [name])
(
(recurse (path ++ [name]) subOpts)
// {
# This is necessary to include the submodule option's definition in the docs (description, type, etc.)
# For instance, this helps submodules like "autoCmd" to include their base definitions and examples in the docs
# Though there might be a better, less "hacky" solution than this.
${name} = recursiveUpdate opts {
isOption = true;
type.getSubOptions = _: _: {}; # Used to exclude suboptions from the submodule definition itself
};
}
)
false
else wrapModule (path ++ [name]) opts true;
in in
mapAttrs g mods; foldlAttrs (
in acc: name: opts:
foldlAttrs let
( group = if !opts.hasComponents then "Neovim Options" else "none";
acc: name: opts: let
group =
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}";
moduleDoc = null; moduleDoc = null;
}; };
components = {}; components = { };
isGroup = true; isGroup = true;
hasComponents = false; hasComponents = false;
}; };
isOpt = !opts.hasComponents && (isOption opts.index.options); isOpt = !opts.hasComponents && (isOption opts.index.options);
in in
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 "/" hasComponents = true;
(
(optional (group != "none") group) ++ [opts.index.path]
)
);
hasComponents = true;
};
}; };
hasComponents = last.components != {};
}; };
}
)
{}
(recurse [] modules);
mapModulesToString = f: modules: let hasComponents = last.components != { };
recurse = mods: let };
g = name: opts: }
if (opts ? "isGroup") ) { } (recurse [ ] modules);
then
if name != "none" mapModulesToString =
then (f name opts) + ("\n" + recurse opts.components) f: modules:
else recurse opts.components let
else if opts.hasComponents recurse =
then (f name opts) + ("\n" + recurse opts.components) mods:
else f name opts; let
g =
name: opts:
if (opts ? "isGroup") then
if name != "none" then (f name opts) + ("\n" + recurse opts.components) else recurse opts.components
else if opts.hasComponents then
(f name opts) + ("\n" + recurse opts.components)
else
f name opts;
in
concatStringsSep "\n" (mapAttrsToList g mods);
in in
concatStringsSep "\n" (mapAttrsToList g mods);
in
recurse modules; recurse modules;
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) in
then true (optionalString isBranch "mkdir -p ${opts.index.path}\n")
else opts.hasComponents; + (
path = if opts.index.moduleDoc == null then
if isBranch "cp ${mkMDDoc opts.index.options} ${path}"
then "${opts.index.path}/index.md" else
else "${opts.index.path}.md"; # Including moduleDoc's text directly will result in bash interpreting special chars,
in # write it to the nix store and `cat` the file instead.
(optionalString isBranch ''
"mkdir -p ${opts.index.path}\n") {
+ ( cat ${pkgs.writeText "module-doc" opts.index.moduleDoc}
if opts.index.moduleDoc == null cat ${mkMDDoc opts.index.options}
then "cp ${mkMDDoc opts.index.options} ${path}" } > ${path}
else ''
# Including moduleDoc's text directly will result in bash interpreting special chars,
# write it to the nix store and `cat` the file instead.
''
{
cat ${pkgs.writeText "module-doc" opts.index.moduleDoc}
cat ${mkMDDoc opts.index.options}
} > ${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 = ''
@ -262,19 +250,23 @@ with lib; let
--replace-fail "@HM_OPTIONS@" "$(cat ${mkMDDoc hmOptions})" --replace-fail "@HM_OPTIONS@" "$(cat ${mkMDDoc hmOptions})"
''; '';
in in
pkgs.stdenv.mkDerivation { pkgs.stdenv.mkDerivation {
name = "nixvim-docs"; name = "nixvim-docs";
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
mkdir -p $dest mkdir -p $dest
${prepareMD} ${prepareMD}
mdbook build mdbook build
cp -r ./book/* $dest cp -r ./book/* $dest
''; '';
} }

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"
]
]; ];
}; };
@ -80,6 +89,6 @@
# What about plugins not available as a module? # What about plugins not available as a module?
# Use extraPlugins: # Use extraPlugins:
extraPlugins = with pkgs.vimPlugins; [vim-toml]; extraPlugins = with pkgs.vimPlugins; [ vim-toml ];
}; };
} }

View file

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

View file

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

View file

@ -1,66 +1,69 @@
{inputs, ...}: { { inputs, ... }:
imports = [ {
inputs.devshell.flakeModule imports = [ inputs.devshell.flakeModule ];
];
perSystem = { perSystem =
pkgs, {
config, pkgs,
system, config,
... system,
}: { ...
devshells.default = { }:
devshell.startup.pre-commit.text = config.pre-commit.installationScript; {
devshells.default = {
devshell.startup.pre-commit.text = config.pre-commit.installationScript;
commands = let commands =
# Thanks to this, the user can choose to use `nix-output-monitor` (`nom`) instead of plain `nix` let
nix = "$([ '$\{NIXVIM_NOM:-0}' = '1' ] && echo ${pkgs.lib.getExe pkgs.nom} || echo nix)"; # Thanks to this, the user can choose to use `nix-output-monitor` (`nom`) instead of plain `nix`
in [ nix = "$([ '$\{NIXVIM_NOM:-0}' = '1' ] && echo ${pkgs.lib.getExe pkgs.nom} || echo nix)";
{ in
name = "checks"; [
help = "Run all nixvim checks"; {
command = "nix flake check"; name = "checks";
} help = "Run all nixvim checks";
{ command = "nix flake check";
name = "tests"; }
help = "Run nixvim tests"; {
command = '' name = "tests";
echo "=> Running nixvim tests for the '${system}' architecture..." help = "Run nixvim tests";
command = ''
echo "=> Running nixvim tests for the '${system}' architecture..."
${nix} build .#checks.${system}.tests "$@" ${nix} build .#checks.${system}.tests "$@"
''; '';
} }
{ {
name = "format"; name = "format";
help = "Format the entire codebase"; help = "Format the entire codebase";
command = "nix fmt"; command = "nix fmt";
} }
{ {
name = "docs"; name = "docs";
help = "Build nixvim documentation"; help = "Build nixvim documentation";
command = '' command = ''
echo "=> Building nixvim documentation..." echo "=> Building nixvim documentation..."
${nix} build .#docs "$@" ${nix} build .#docs "$@"
''; '';
} }
{ {
name = "serve-docs"; name = "serve-docs";
help = "Build and serve documentation locally"; help = "Build and serve documentation locally";
command = '' command = ''
echo -e "=> Building nixvim documentation...\n" echo -e "=> Building nixvim documentation...\n"
doc_derivation=$(${nix} build .#docs --no-link --print-out-paths) doc_derivation=$(${nix} build .#docs --no-link --print-out-paths)
echo -e "\n=> Documentation successfully built ('$doc_derivation')" echo -e "\n=> Documentation successfully built ('$doc_derivation')"
port=8000 port=8000
echo -e "\n=> Now open your browser and navigate to 'localhost:$port'\n" echo -e "\n=> Now open your browser and navigate to 'localhost:$port'\n"
${pkgs.lib.getExe pkgs.python3} -m http.server -d "$doc_derivation"/share/doc ${pkgs.lib.getExe pkgs.python3} -m http.server -d "$doc_derivation"/share/doc
''; '';
} }
]; ];
};
}; };
};
} }

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,18 +1,21 @@
{ {
perSystem = { perSystem =
pkgs, {
config, pkgs,
makeNixvimWithModule, config,
... makeNixvimWithModule,
}: { ...
legacyPackages = rec { }:
inherit makeNixvimWithModule; {
makeNixvim = configuration: legacyPackages = rec {
makeNixvimWithModule { inherit makeNixvimWithModule;
module = { makeNixvim =
config = configuration; configuration:
makeNixvimWithModule {
module = {
config = configuration;
};
}; };
}; };
}; };
};
} }

View file

@ -3,18 +3,15 @@
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, import ../lib {
config, inherit pkgs lib;
... inherit (config.legacyPackages) makeNixvim makeNixvimWithModule;
}: }
import ../lib {
inherit pkgs lib;
inherit (config.legacyPackages) makeNixvim makeNixvimWithModule;
}
) )
); );
} }

View file

@ -1,37 +1,41 @@
{modules, ...}: { { modules, ... }:
{
_module.args = { _module.args = {
modules = pkgs: let modules =
nixpkgsMaintainersList = pkgs.path + "/nixos/modules/misc/meta.nix"; pkgs:
let
nixpkgsMaintainersList = pkgs.path + "/nixos/modules/misc/meta.nix";
nixvimExtraArgsModule = rec { nixvimExtraArgsModule = rec {
_file = ./flake.nix; _file = ./flake.nix;
key = _file; key = _file;
config = { config = {
_module.args = { _module.args = {
pkgs = pkgs.lib.mkForce pkgs; pkgs = pkgs.lib.mkForce pkgs;
inherit (pkgs) lib; inherit (pkgs) lib;
};
}; };
}; };
}; in
in [ [
../modules ../modules
nixpkgsMaintainersList nixpkgsMaintainersList
nixvimExtraArgsModule nixvimExtraArgsModule
({lib, ...}: (
with lib; { { lib, ... }:
# Attribute may contain the following fields: with lib;
# - name: Name of the module {
# - kind: Either colorschemes or plugins # Attribute may contain the following fields:
# - description: A short description of the plugin # - name: Name of the module
# - url: Url for the plugin # - kind: Either colorschemes or plugins
# # - description: A short description of the plugin
# [kind name] will identify the plugin # - url: Url for the plugin
# #
# We need to use an attrs instead of a submodule to handle the merge. # [kind name] will identify the plugin
options.meta.nixvimInfo = mkOption { #
type = # We need to use an attrs instead of a submodule to handle the merge.
(types.nullOr types.attrs) options.meta.nixvimInfo = mkOption {
// { type = (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,37 +47,41 @@
# 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.recursiveUpdate acc { lib.foldl'
"${def.value.kind}"."${def.value.name}" = { (
inherit (def.value) url description; acc: def:
inherit (def) file; lib.recursiveUpdate acc {
}; "${def.value.kind}"."${def.value.name}" = {
}) { inherit (def.value) url description;
plugins = {}; inherit (def) file;
colorschemes = {}; };
} }
defs; )
{
plugins = { };
colorschemes = { };
}
defs;
}; };
internal = true; internal = true;
default = null; default = null;
description = '' description = ''
Nixvim related information on the module Nixvim related information on the module
''; '';
}; };
}) }
]; )
];
}; };
perSystem = { perSystem =
pkgs, { pkgs, config, ... }:
config, {
... _module.args = {
}: { modules = modules pkgs;
_module.args = { rawModules = modules;
modules = modules pkgs; };
rawModules = modules;
}; };
};
} }

View file

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

View file

@ -1,16 +1,16 @@
{ {
perSystem = { perSystem =
pkgs, {
config, pkgs,
rawModules, config,
helpers, rawModules,
... 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,49 +9,48 @@
# 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, {
system, pkgs,
lib, system,
... lib,
}: { ...
checks = let }:
# Approximates https://github.com/NixOS/nix/blob/7cd08ae379746749506f2e33c3baeb49b58299b8/src/libexpr/flake/call-flake.nix#L46 {
# s/flake.outputs/args.outputs/ checks =
callFlake = args @ { let
inputs, # Approximates https://github.com/NixOS/nix/blob/7cd08ae379746749506f2e33c3baeb49b58299b8/src/libexpr/flake/call-flake.nix#L46
outputs, # s/flake.outputs/args.outputs/
sourceInfo, callFlake =
}: let args@{
outputs = args.outputs (inputs // {self = result;}); inputs,
result = outputs,
outputs sourceInfo,
// sourceInfo }:
// { let
inherit inputs outputs sourceInfo; outputs = args.outputs (inputs // { self = result; });
_type = "flake"; result =
outputs
// sourceInfo
// {
inherit inputs outputs sourceInfo;
_type = "flake";
};
in
result;
templateFlakeOutputs = callFlake {
inputs = {
inherit (inputs) flake-parts nixpkgs;
nixvim = self;
};
# Import and read the `outputs` field of the template flake.
inherit (import ../templates/simple/flake.nix) outputs;
sourceInfo = { };
}; };
in
result;
templateFlakeOutputs = callFlake { templateChecks = templateFlakeOutputs.checks.${system};
inputs = { in
inherit (inputs) flake-parts nixpkgs; lib.concatMapAttrs (checkName: check: { "template-${checkName}" = check; }) templateChecks;
nixvim = self; };
};
# Import and read the `outputs` field of the template flake.
inherit (import ../templates/simple/flake.nix) outputs;
sourceInfo = {};
};
templateChecks = templateFlakeOutputs.checks.${system};
in
lib.concatMapAttrs
(
checkName: check: {
"template-${checkName}" = check;
}
)
templateChecks;
};
} }

View file

@ -1,49 +1,51 @@
{self, ...}: { { self, ... }:
perSystem = { {
pkgs, perSystem =
config, {
system, pkgs,
helpers, config,
makeNixvimWithModuleUnfree, system,
makeNixvimWithModule, helpers,
... makeNixvimWithModuleUnfree,
}: { makeNixvimWithModule,
checks = { ...
tests = import ../tests { }:
inherit pkgs helpers makeNixvimWithModule; {
inherit (pkgs) lib; checks = {
makeNixvim = configuration: tests = import ../tests {
makeNixvimWithModuleUnfree { inherit pkgs helpers makeNixvimWithModule;
module = { inherit (pkgs) lib;
config = configuration; makeNixvim =
configuration:
makeNixvimWithModuleUnfree {
module = {
config = configuration;
};
}; };
}; };
};
extra-args-tests = import ../tests/extra-args.nix { extra-args-tests = import ../tests/extra-args.nix {
inherit pkgs; inherit pkgs;
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;
inherit (self.lib.${system}.check) mkTestDerivationFromNixvimModule; inherit (self.lib.${system}.check) mkTestDerivationFromNixvimModule;
}; };
no-flake = import ../tests/no-flake.nix { no-flake = import ../tests/no-flake.nix {
inherit system; inherit system;
inherit (self.lib.${system}.check) mkTestDerivationFromNvim; inherit (self.lib.${system}.check) mkTestDerivationFromNvim;
nixvim = "${self}"; nixvim = "${self}";
}; };
lib-tests = import ../tests/lib-tests.nix { lib-tests = import ../tests/lib-tests.nix {
inherit pkgs helpers; inherit pkgs helpers;
inherit (pkgs) lib; inherit (pkgs) lib;
};
}; };
}; };
};
} }

View file

@ -4,64 +4,56 @@
getHelpers, getHelpers,
self, self,
... ...
}: let }:
let
wrapperArgs = { wrapperArgs = {
inherit modules; inherit modules;
inherit self; inherit self;
inherit getHelpers; inherit getHelpers;
}; };
in { in
perSystem = { {
system, perSystem =
pkgs, {
pkgsUnfree, system,
config, pkgs,
... pkgsUnfree,
}: { config,
_module.args = { ...
makeNixvimWithModule = }:
import ../wrappers/standalone.nix {
pkgs _module.args = {
wrapperArgs; makeNixvimWithModule = import ../wrappers/standalone.nix pkgs wrapperArgs;
makeNixvimWithModuleUnfree = makeNixvimWithModuleUnfree = import ../wrappers/standalone.nix pkgsUnfree wrapperArgs;
import ../wrappers/standalone.nix
pkgsUnfree
wrapperArgs;
};
checks =
{
home-manager-module =
(import ../tests/modules/hm.nix {
inherit pkgs;
inherit (inputs) home-manager;
nixvim = self;
})
.activationPackage;
}
// pkgs.lib.optionalAttrs (!pkgs.stdenv.isDarwin) {
nixos-module =
(import ../tests/modules/nixos.nix {
inherit system;
inherit (inputs) nixpkgs;
nixvim = self;
})
.config
.system
.build
.toplevel;
}
// pkgs.lib.optionalAttrs pkgs.stdenv.isDarwin {
darwin-module =
(import ../tests/modules/darwin.nix {
inherit system;
inherit (inputs) nix-darwin;
nixvim = self;
})
.system;
}; };
};
checks =
{
home-manager-module =
(import ../tests/modules/hm.nix {
inherit pkgs;
inherit (inputs) home-manager;
nixvim = self;
}).activationPackage;
}
// pkgs.lib.optionalAttrs (!pkgs.stdenv.isDarwin) {
nixos-module =
(import ../tests/modules/nixos.nix {
inherit system;
inherit (inputs) nixpkgs;
nixvim = self;
}).config.system.build.toplevel;
}
// pkgs.lib.optionalAttrs pkgs.stdenv.isDarwin {
darwin-module =
(import ../tests/modules/darwin.nix {
inherit system;
inherit (inputs) nix-darwin;
nixvim = self;
}).system;
};
};
flake = { flake = {
nixosModules.nixvim = import ../wrappers/nixos.nix wrapperArgs; nixosModules.nixvim = import ../wrappers/nixos.nix wrapperArgs;

View file

@ -30,8 +30,9 @@
}; };
}; };
outputs = inputs: outputs =
inputs.flake-parts.lib.mkFlake {inherit inputs;} { inputs:
inputs.flake-parts.lib.mkFlake { inherit inputs; } {
systems = [ systems = [
"x86_64-linux" "x86_64-linux"
"aarch64-linux" "aarch64-linux"
@ -39,6 +40,6 @@
"aarch64-darwin" "aarch64-darwin"
]; ];
imports = [./flake-modules]; imports = [ ./flake-modules ];
}; };
} }

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,23 +1,22 @@
{ 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.
# Type # Type
``` ```
writeLua :: String -> String -> Derivation writeLua :: String -> String -> Derivation
``` ```
# Arguments # Arguments
- [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 =
pkgs.runCommand name {inherit text;} '' name: text:
pkgs.runCommand name { inherit text; } ''
echo -n "$text" > "$out" echo -n "$text" > "$out"
${lib.getExe pkgs.stylua} \ ${lib.getExe pkgs.stylua} \

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,22 +3,30 @@
pkgs, pkgs,
_nixvimTests, _nixvimTests,
... ...
}: let }:
nixvimBuilders = import ./builders.nix {inherit lib pkgs;}; let
nixvimTypes = import ./types.nix {inherit lib nixvimOptions;}; nixvimBuilders = import ./builders.nix { inherit lib pkgs; };
nixvimUtils = import ./utils.nix {inherit lib _nixvimTests;}; nixvimTypes = import ./types.nix { inherit lib nixvimOptions; };
nixvimOptions = import ./options.nix {inherit lib nixvimTypes nixvimUtils;}; nixvimUtils = import ./utils.nix { inherit lib _nixvimTests; };
inherit (import ./to-lua.nix {inherit lib;}) toLuaObject; nixvimOptions = import ./options.nix { inherit lib nixvimTypes nixvimUtils; };
inherit (import ./to-lua.nix { inherit lib; }) toLuaObject;
in 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 {
vim-plugin = import ./vim-plugin.nix {inherit lib nixvimOptions nixvimUtils;}; inherit
inherit nixvimTypes; lib
inherit toLuaObject; nixvimOptions
} nixvimUtils
// nixvimUtils toLuaObject
// nixvimOptions ;
// nixvimBuilders };
vim-plugin = import ./vim-plugin.nix { inherit lib nixvimOptions nixvimUtils; };
inherit nixvimTypes;
inherit toLuaObject;
}
// nixvimUtils
// nixvimOptions
// nixvimBuilders

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 = {
@ -70,80 +55,75 @@ 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 =
submodule { defaults:
options = { (
key = mkOption ({ with types;
type = str; submodule {
description = "The key to map."; options = {
example = "<C-m>"; key = mkOption (
} {
// ( type = str;
optionalAttrs description = "The key to map.";
(defaults ? key) example = "<C-m>";
{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; {
description = "The action to execute."; type = nixvimTypes.maybeRaw str;
} description = "The action to execute.";
// ( }
optionalAttrs // (optionalAttrs (defaults ? action) { default = defaults.action; })
(defaults ? action) );
{default = defaults.action;}
));
lua = mkOption { lua = mkOption {
type = bool; type = bool;
description = '' description = ''
If true, `action` is considered to be lua code. If true, `action` is considered to be lua code.
Thus, it will not be wrapped in `""`. Thus, it will not be wrapped in `""`.
''; '';
default = defaults.lua or false; default = defaults.lua or false;
};
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 =
# First, merge the `options` attrs of both options. defaults: keymap:
mergedOpts = (defaults.options or {}) // (keymap.options or {}); let
in # First, merge the `options` attrs of both options.
mergedOpts = (defaults.options or { }) // (keymap.options or { });
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,24 +4,25 @@
toLuaObject, toLuaObject,
nixvimUtils, nixvimUtils,
}: }:
with lib; rec { with lib;
mkSettingsOption = { rec {
pluginName ? null, mkSettingsOption =
options ? {}, {
description ? pluginName ? null,
if pluginName != null options ? { },
then "Options provided to the `require('${pluginName}').setup` function." description ?
else throw "mkSettingsOption: Please provide either a `pluginName` or `description`.", if pluginName != null then
example ? null, "Options provided to the `require('${pluginName}').setup` function."
}: else
nixvimOptions.mkSettingsOption { throw "mkSettingsOption: Please provide either a `pluginName` or `description`.",
inherit options description example; example ? null,
}; }:
nixvimOptions.mkSettingsOption { inherit options description example; };
# TODO: DEPRECATED: use the `settings` option instead # TODO: DEPRECATED: use the `settings` option instead
extraOptionsOptions = { extraOptionsOptions = {
extraOptions = mkOption { extraOptions = mkOption {
default = {}; default = { };
type = with types; attrsOf anything; type = with types; attrsOf anything;
description = '' description = ''
These attributes will be added to the table parameter for the setup function. These attributes will be added to the table parameter for the setup function.
@ -30,82 +31,68 @@ with lib; rec {
}; };
}; };
mkNeovimPlugin = config: { mkNeovimPlugin =
name, config:
maintainers, {
url ? defaultPackage.meta.homepage, name,
imports ? [], maintainers,
description ? null, url ? defaultPackage.meta.homepage,
# deprecations imports ? [ ],
deprecateExtraOptions ? false, description ? null,
optionsRenamedToSettings ? [], # deprecations
# colorscheme deprecateExtraOptions ? false,
isColorscheme ? false, optionsRenamedToSettings ? [ ],
colorscheme ? name, # colorscheme
# options isColorscheme ? false,
originalName ? name, colorscheme ? name,
defaultPackage, # options
settingsOptions ? {}, originalName ? name,
settingsExample ? null, defaultPackage,
extraOptions ? {}, settingsOptions ? { },
# config settingsExample ? null,
luaName ? name, extraOptions ? { },
extraConfig ? cfg: {}, # config
extraPlugins ? [], luaName ? name,
extraPackages ? [], extraConfig ? cfg: { },
callSetup ? true, extraPlugins ? [ ],
}: let extraPackages ? [ ],
namespace = callSetup ? true,
if isColorscheme }:
then "colorschemes" let
else "plugins"; namespace = if isColorscheme then "colorschemes" else "plugins";
in {
meta = {
inherit maintainers;
nixvimInfo = {
inherit
description
name
url
;
kind = namespace;
};
};
imports = let
basePluginPath = [namespace name];
settingsPath = basePluginPath ++ ["settings"];
in in
imports {
++ ( meta = {
optional inherit maintainers;
deprecateExtraOptions nixvimInfo = {
( inherit description name url;
mkRenamedOptionModule kind = namespace;
(basePluginPath ++ ["extraOptions"]) };
settingsPath };
)
) imports =
++ ( let
map basePluginPath = [
( namespace
option: let name
optionPath = ];
if isString option settingsPath = basePluginPath ++ [ "settings" ];
then [option] in
else option; # option is already a path (i.e. a list) imports
++ (optional deprecateExtraOptions (
mkRenamedOptionModule (basePluginPath ++ [ "extraOptions" ]) settingsPath
))
++ (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,31 +102,24 @@ with lib; rec {
options = settingsOptions; options = settingsOptions;
example = settingsExample; example = settingsExample;
}; };
} } // extraOptions;
// extraOptions;
config = let config =
cfg = config.${namespace}.${name}; let
extraConfigNamespace = cfg = config.${namespace}.${name};
if isColorscheme extraConfigNamespace = if isColorscheme then "extraConfigLuaPre" else "extraConfigLua";
then "extraConfigLuaPre" in
else "extraConfigLua"; mkIf cfg.enable (mkMerge [
in
mkIf cfg.enable (
mkMerge [
{ {
extraPlugins = [cfg.package] ++ extraPlugins; extraPlugins = [ cfg.package ] ++ extraPlugins;
inherit extraPackages; inherit extraPackages;
${extraConfigNamespace} = optionalString callSetup '' ${extraConfigNamespace} = optionalString callSetup ''
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:
defaultDesc = "default: `${default}`"; mkNullOrStrLuaOr type (
in let
if desc == "" defaultDesc = "default: `${default}`";
then defaultDesc in
else '' if desc == "" then
${desc} defaultDesc
else
''
${desc}
${defaultDesc} ${defaultDesc}
''); ''
);
mkStrLuaFnOr = type: default: desc: mkStrLuaFnOr =
mkNullOrStrLuaFnOr type (let type: default: desc:
defaultDesc = "default: `${default}`"; mkNullOrStrLuaFnOr type (
in let
if desc == "" defaultDesc = "default: `${default}`";
then defaultDesc in
else '' if desc == "" then
${desc} defaultDesc
else
''
${desc}
${defaultDesc} ${defaultDesc}
''); ''
);
mkLua = default: desc: mkLua =
mkNullOrLua default: desc:
( mkNullOrLua (
(optionalString (desc != "") '' (optionalString (desc != "") ''
${desc} ${desc}
@ -109,18 +118,20 @@ with nixvimUtils; rec {
'' ''
); );
mkLuaFn = default: desc: let mkLuaFn =
defaultDesc = "default: `${default}`"; default: desc:
in let
mkNullOrLuaFn defaultDesc = "default: `${default}`";
( in
if desc == "" mkNullOrLuaFn (
then defaultDesc if desc == "" then
else '' defaultDesc
${desc} else
''
${desc}
${defaultDesc} ${defaultDesc}
'' ''
); );
mkNum = default: mkNullable (with nixvimTypes; maybeRaw number) (toString default); mkNum = default: mkNullable (with nixvimTypes; maybeRaw number) (toString default);
@ -129,137 +140,124 @@ 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
if desc == ""
then defaultDesc
else ''
${desc}
${defaultDesc}
'');
mkSeverity = default: desc:
mkOption {
type = with types;
nullOr
(
either ints.unsigned
(
enum
["error" "warn" "info" "hint"]
)
);
default = null;
apply =
mapNullable
(
value:
if isInt value
then value
else mkRaw "vim.diagnostic.severity.${strings.toUpper value}"
);
description = let
defaultDesc = "default: `${toString default}`";
in
if desc == ""
then defaultDesc
else ''
${desc}
${defaultDesc}
''; '';
};
mkLogLevel = default: desc:
mkOption {
type = with types;
nullOr
(
either
ints.unsigned
nixvimTypes.logLevel
);
default = null;
apply =
mapNullable
(
value:
if isInt value
then value
else mkRaw "vim.log.levels.${strings.toUpper value}"
);
description = let
defaultDesc = "default: `${toString default}`";
in in
if desc == "" if desc == "" then
then defaultDesc defaultDesc
else '' else
''
${desc} ${desc}
${defaultDesc} ${defaultDesc}
''; ''
};
mkHighlight = default: name: desc:
mkNullable
nixvimTypes.highlight
default
(
if desc == ""
then "Highlight settings."
else desc
); );
mkSeverity =
default: desc:
mkOption {
type =
with types;
nullOr (
either ints.unsigned (enum [
"error"
"warn"
"info"
"hint"
])
);
default = null;
apply = mapNullable (
value: if isInt value then value else mkRaw "vim.diagnostic.severity.${strings.toUpper value}"
);
description =
let
defaultDesc = "default: `${toString default}`";
in
if desc == "" then
defaultDesc
else
''
${desc}
${defaultDesc}
'';
};
mkLogLevel =
default: desc:
mkOption {
type = with types; nullOr (either ints.unsigned nixvimTypes.logLevel);
default = null;
apply = mapNullable (
value: if isInt value then value else mkRaw "vim.log.levels.${strings.toUpper value}"
);
description =
let
defaultDesc = "default: `${toString default}`";
in
if desc == "" then
defaultDesc
else
''
${desc}
${defaultDesc}
'';
};
mkHighlight =
default: name: desc:
mkNullable nixvimTypes.highlight 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 ? {}, {
description, options ? { },
example ? null, description,
}: example ? null,
}:
mkOption { mkOption {
type = with types; type =
with types;
submodule { submodule {
freeformType = attrsOf anything; freeformType = attrsOf anything;
inherit options; inherit options;
}; };
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 = ''
function() function()
print('nixvim') print('nixvim')
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: n: v:
if (builtins.match "__unkeyed.*" n) != null if (builtins.match "__unkeyed.*" n) != null then
then toLuaObject v toLuaObject v
else if n == "__emptyString" else if n == "__emptyString" then
then "[''] = " + (toLuaObject v) "[''] = " + (toLuaObject v)
else "[${toLuaObject n}] = " + (toLuaObject v)) else
(filterAttrs "[${toLuaObject n}] = " + (toLuaObject v)
( ) (filterAttrs (n: v: v != null && (toLuaObject v != "{}")) args)
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;
@ -15,68 +13,73 @@ with lib.types; let
merge = lib.options.mergeEqualOption; merge = lib.options.mergeEqualOption;
}; };
in in
rec { rec {
isRawType = v: lib.isAttrs v && lib.hasAttr "__raw" v && lib.isString v.__raw; isRawType = v: lib.isAttrs v && lib.hasAttr "__raw" v && lib.isString v.__raw;
rawLua = mkOptionType { rawLua = mkOptionType {
name = "rawLua"; name = "rawLua";
description = "raw lua code"; description = "raw lua code";
descriptionClass = "noun"; descriptionClass = "noun";
merge = mergeEqualOption; merge = mergeEqualOption;
check = isRawType; check = isRawType;
};
maybeRaw = type: types.either type rawLua;
border =
with types;
oneOf [
str
(listOf str)
(listOf (listOf str))
];
logLevel = types.enum [
"off"
"error"
"warn"
"info"
"debug"
"trace"
];
highlight = types.submodule {
# Adds flexibility for other keys
freeformType = types.attrs;
# :help nvim_set_hl()
options = with types; {
fg = mkNullOrStr "Color for the foreground (color name or '#RRGGBB').";
bg = mkNullOrStr "Color for the background (color name or '#RRGGBB').";
sp = mkNullOrStr "Special color (color name or '#RRGGBB').";
blend = mkNullOrOption (numbers.between 0 100) "Integer between 0 and 100.";
bold = mkNullOrOption bool "";
standout = mkNullOrOption bool "";
underline = mkNullOrOption bool "";
undercurl = mkNullOrOption bool "";
underdouble = mkNullOrOption bool "";
underdotted = mkNullOrOption bool "";
underdashed = mkNullOrOption bool "";
strikethrough = mkNullOrOption bool "";
italic = mkNullOrOption bool "";
reverse = mkNullOrOption bool "";
nocombine = mkNullOrOption bool "";
link = mkNullOrStr "Name of another highlight group to link to.";
default = mkNullOrOption bool "Don't override existing definition.";
ctermfg = mkNullOrStr "Sets foreground of cterm color.";
ctermbg = mkNullOrStr "Sets background of cterm color.";
cterm = mkNullOrOption (either str attrs) ''
cterm attribute map, like |highlight-args|.
If not set, cterm attributes will match those from the attribute map documented above.
'';
}; };
};
maybeRaw = type: strLua = strLikeType "lua code string";
types.either strLuaFn = strLikeType "lua function string";
type
rawLua;
border = with types; # Overridden when building the documentation
oneOf [ eitherRecursive = either;
str }
(listOf str) # Allow to do `with nixvimTypes;` instead of `with types;`
(listOf (listOf str)) // lib.types
];
logLevel = types.enum ["off" "error" "warn" "info" "debug" "trace"];
highlight = types.submodule {
# Adds flexibility for other keys
freeformType = types.attrs;
# :help nvim_set_hl()
options = with types; {
fg = mkNullOrStr "Color for the foreground (color name or '#RRGGBB').";
bg = mkNullOrStr "Color for the background (color name or '#RRGGBB').";
sp = mkNullOrStr "Special color (color name or '#RRGGBB').";
blend = mkNullOrOption (numbers.between 0 100) "Integer between 0 and 100.";
bold = mkNullOrOption bool "";
standout = mkNullOrOption bool "";
underline = mkNullOrOption bool "";
undercurl = mkNullOrOption bool "";
underdouble = mkNullOrOption bool "";
underdotted = mkNullOrOption bool "";
underdashed = mkNullOrOption bool "";
strikethrough = mkNullOrOption bool "";
italic = mkNullOrOption bool "";
reverse = mkNullOrOption bool "";
nocombine = mkNullOrOption bool "";
link = mkNullOrStr "Name of another highlight group to link to.";
default = mkNullOrOption bool "Don't override existing definition.";
ctermfg = mkNullOrStr "Sets foreground of cterm color.";
ctermbg = mkNullOrStr "Sets background of cterm color.";
cterm = mkNullOrOption (either str attrs) ''
cterm attribute map, like |highlight-args|.
If not set, cterm attributes will match those from the attribute map documented above.
'';
};
};
strLua = strLikeType "lua code string";
strLuaFn = strLikeType "lua function string";
# Overridden when building the documentation
eitherRecursive = either;
}
# Allow to do `with nixvimTypes;` instead of `with types;`
// lib.types

View file

@ -1,45 +1,38 @@
{ 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 =
splitByWords = builtins.split "([A-Z])"; let
processWord = s: splitByWords = builtins.split "([A-Z])";
if isString s processWord = s: if isString s then s else "_" + toLower (elemAt s 0);
then s in
else "_" + toLower (elemAt s 0); string:
in let
string: let
words = splitByWords string; words = splitByWords string;
in in
concatStrings (map processWord words); concatStrings (map processWord words);
mkIfNonNull' = x: y: (mkIf (x != null) y); mkIfNonNull' = x: y: (mkIf (x != null) y);
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,56 +3,51 @@
nixvimOptions, nixvimOptions,
nixvimUtils, nixvimUtils,
}: }:
with lib; { with lib;
mkVimPlugin = config: { {
name, mkVimPlugin =
url ? config:
if defaultPackage != null {
then defaultPackage.meta.homepage name,
else null, url ? if defaultPackage != null then defaultPackage.meta.homepage else null,
maintainers, maintainers,
imports ? [], imports ? [ ],
description ? null, description ? null,
# deprecations # deprecations
deprecateExtraConfig ? false, deprecateExtraConfig ? false,
optionsRenamedToSettings ? [], optionsRenamedToSettings ? [ ],
# colorscheme # colorscheme
isColorscheme ? false, isColorscheme ? false,
colorscheme ? name, colorscheme ? name,
# options # options
originalName ? name, originalName ? name,
defaultPackage ? null, defaultPackage ? null,
settingsOptions ? {}, settingsOptions ? { },
settingsExample ? null, settingsExample ? null,
globalPrefix ? "", globalPrefix ? "",
extraOptions ? {}, extraOptions ? { },
# config # config
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};
globals = cfg.settings or {}; globals = cfg.settings or { };
# 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 {
meta = {
inherit maintainers;
nixvimInfo = {
inherit
description
name
url
;
kind = namespace;
};
};
options.${namespace}.${name} =
{
enable = mkEnableOption originalName;
}
// settingsOption
// packageOption
// extraOptions;
imports = let
basePluginPath = [namespace name];
settingsPath = basePluginPath ++ ["settings"];
in in
imports {
++ ( meta = {
optional inherit maintainers;
(deprecateExtraConfig && createSettingsOption) nixvimInfo = {
( inherit description name url;
mkRenamedOptionModule kind = namespace;
(basePluginPath ++ ["extraConfig"]) };
settingsPath };
) options.${namespace}.${name} = {
) enable = mkEnableOption originalName;
++ ( } // settingsOption // packageOption // extraOptions;
map
( imports =
option: let let
optionPath = basePluginPath = [
if isString option namespace
then [option] name
else option; # option is already a path (i.e. a list) ];
settingsPath = basePluginPath ++ [ "settings" ];
in
imports
++ (optional (deprecateExtraConfig && createSettingsOption) (
mkRenamedOptionModule (basePluginPath ++ [ "extraConfig" ]) settingsPath
))
++ (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 {
( inherit extraPackages;
mkMerge [ globals = mapAttrs' (n: nameValuePair (globalPrefix + n)) globals;
{ # does this evaluate package? it would not be desired to evaluate package if we use another package.
inherit extraPackages; extraPlugins = extraPlugins ++ optional (defaultPackage != null) cfg.package;
globals = mapAttrs' (n: nameValuePair (globalPrefix + n)) globals; }
# does this evaluate package? it would not be desired to evaluate package if we use another package. (optionalAttrs (isColorscheme && (colorscheme != null)) { inherit colorscheme; })
extraPlugins = extraPlugins ++ optional (defaultPackage != null) cfg.package; (extraConfig cfg)
} ]);
(optionalAttrs (isColorscheme && (colorscheme != null)) { };
inherit colorscheme;
})
(extraConfig cfg)
]
);
};
} }

View file

@ -4,11 +4,12 @@
config, config,
... ...
}: }:
with lib; { with lib;
{
options = { options = {
autoGroups = mkOption { autoGroups = mkOption {
type = types.attrsOf helpers.autocmd.autoGroupOption; type = types.attrsOf helpers.autocmd.autoGroupOption;
default = {}; default = { };
description = "augroup definitions"; description = "augroup definitions";
example = '' example = ''
autoGroups = { autoGroups = {
@ -21,7 +22,7 @@ with lib; {
autoCmd = mkOption { autoCmd = mkOption {
type = types.listOf helpers.autocmd.autoCmdOption; type = types.listOf helpers.autocmd.autoCmdOption;
default = []; default = [ ];
description = "autocmd definitions"; description = "autocmd definitions";
example = '' example = ''
autoCmd = [ autoCmd = [
@ -35,18 +36,16 @@ with lib; {
}; };
}; };
config = let config =
inherit (config) autoGroups autoCmd; let
in inherit (config) autoGroups autoCmd;
mkIf (autoGroups != {} || autoCmd != {}) { in
mkIf (autoGroups != { } || autoCmd != { }) {
# Introduced early October 2023. # Introduced early October 2023.
# TODO remove in early December 2023. # TODO remove in early December 2023.
assertions = [ assertions = [
{ {
assertion = 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.
@ -55,7 +54,7 @@ with lib; {
]; ];
extraConfigLuaPost = extraConfigLuaPost =
(optionalString (autoGroups != {}) '' (optionalString (autoGroups != { }) ''
-- Set up autogroups {{ -- Set up autogroups {{
do do
local __nixvim_autogroups = ${helpers.toLuaObject autoGroups} local __nixvim_autogroups = ${helpers.toLuaObject autoGroups}
@ -66,7 +65,7 @@ with lib; {
end end
-- }} -- }}
'') '')
+ (optionalString (autoCmd != []) '' + (optionalString (autoCmd != [ ]) ''
-- Set up autocommands {{ -- Set up autocommands {{
do do
local __nixvim_autocommands = ${helpers.toLuaObject autoCmd} local __nixvim_autocommands = ${helpers.toLuaObject autoCmd}

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,19 +25,17 @@ 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"; xsel = "xsel";
xsel = "xsel"; };
};
}; };
default = {}; default = { };
description = '' description = ''
Package(s) to use as the clipboard provider. Package(s) to use as the clipboard provider.
Learn more at `:h clipboard`. Learn more at `:h clipboard`.
@ -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,15 +13,34 @@ with lib; let
description = "The command to run."; description = "The command to run.";
}; };
nargs = helpers.mkNullOrOption (types.enum ["0" "1" "*" "?" "+"]) '' nargs =
The number of arguments to expect, see :h command-nargs. helpers.mkNullOrOption
''; (types.enum [
"0"
"1"
"*"
"?"
"+"
])
''
The number of arguments to expect, see :h command-nargs.
'';
complete = helpers.mkNullOrOption (with types; either str helpers.nixvimTypes.rawLua) '' 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 =
Whether the command accepts a range, see :h command-range. helpers.mkNullOrOption
''; (
with types;
oneOf [
bool
int
(enum [ "%" ])
]
)
''
Whether the command accepts a range, see :h command-range.
'';
count = helpers.mkNullOrOption (with types; either bool int) '' count = helpers.mkNullOrOption (with types; either bool int) ''
Whether the command accepts a count, see :h command-range. Whether the command accepts a count, see :h command-range.
''; '';
@ -37,20 +57,22 @@ with lib; let
# TODO: command-preview, need to grab a function here. # 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 =
cleanupCommand = _: cmd: { let
inherit (cmd) command; cleanupCommand = _: cmd: {
options = filterAttrs (name: _: name != "command") cmd; inherit (cmd) command;
}; options = filterAttrs (name: _: name != "command") cmd;
in };
mkIf (config.userCommands != {}) { in
mkIf (config.userCommands != { }) {
extraConfigLua = helpers.wrapDo '' extraConfigLua = helpers.wrapDo ''
local cmds = ${helpers.toLuaObject (mapAttrs cleanupCommand config.userCommands)}; local cmds = ${helpers.toLuaObject (mapAttrs cleanupCommand config.userCommands)};
for name,cmd in pairs(cmds) do for name,cmd in pairs(cmds) do

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 = {
@ -18,7 +29,7 @@ with lib; {
properties = mkOption { properties = mkOption {
type = types.attrsOf types.str; type = types.attrsOf types.str;
default = {}; default = { };
description = '' description = ''
The table key is a property name and the value is a callback function which accepts the The table key is a property name and the value is a callback function which accepts the
number of the buffer to be modified, the value of the property in the .editorconfig file, number of the buffer to be modified, the value of the property in the .editorconfig file,
@ -39,23 +50,26 @@ with lib; {
}; };
}; };
config = let config =
cfg = config.editorconfig; let
in { cfg = config.editorconfig;
globals.editorconfig = mkIf (!cfg.enable) false;
extraConfigLua = let
mkProperty = name: function: ''
__editorconfig.properties.${name} = ${function}
'';
propertiesString = lib.concatLines (lib.mapAttrsToList mkProperty cfg.properties);
in in
mkIf (propertiesString != "" && cfg.enable) '' {
do globals.editorconfig = mkIf (!cfg.enable) false;
local __editorconfig = require('editorconfig')
${propertiesString} extraConfigLua =
end let
''; mkProperty = name: function: ''
}; __editorconfig.properties.${name} = ${function}
'';
propertiesString = lib.concatLines (lib.mapAttrsToList mkProperty cfg.properties);
in
mkIf (propertiesString != "" && cfg.enable) ''
do
local __editorconfig = require('editorconfig')
${propertiesString}
end
'';
};
} }

View file

@ -4,38 +4,40 @@
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 (
(listOf (either str (submodule { 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 ''
taking the filepath and the buffer number. Define additional filetypes. The values can either be a literal filetype or a function
taking the filepath and the buffer number.
For more information check `:h vim.filetype.add()` For more information check `:h vim.filetype.add()`
'' { ''
extension = filetypeDefinition "set filetypes matching the file extension"; {
filename = filetypeDefinition "set filetypes matching the file name (or path)"; extension = filetypeDefinition "set filetypes matching the file extension";
pattern = filetypeDefinition "set filetypes matching the specified pattern"; filename = filetypeDefinition "set filetypes matching the file name (or path)";
}; pattern = filetypeDefinition "set filetypes matching the specified pattern";
};
config.extraConfigLua = helpers.mkIfNonNull' config.filetype '' config.extraConfigLua = helpers.mkIfNonNull' config.filetype ''
vim.filetype.add(${helpers.toLuaObject config.filetype}) vim.filetype.add(${helpers.toLuaObject config.filetype})

View file

@ -4,11 +4,12 @@
config, config,
... ...
}: }:
with lib; { with lib;
{
options = { options = {
highlight = mkOption { highlight = mkOption {
type = types.attrsOf helpers.nixvimTypes.highlight; type = types.attrsOf helpers.nixvimTypes.highlight;
default = {}; default = { };
description = "Define new highlight groups"; description = "Define new highlight groups";
example = '' example = ''
highlight = { highlight = {
@ -19,7 +20,7 @@ with lib; {
highlightOverride = mkOption { highlightOverride = mkOption {
type = types.attrsOf helpers.nixvimTypes.highlight; type = types.attrsOf helpers.nixvimTypes.highlight;
default = {}; default = { };
description = "Define highlight groups to override existing highlight"; description = "Define highlight groups to override existing highlight";
example = '' example = ''
highlight = { highlight = {
@ -30,7 +31,7 @@ with lib; {
match = mkOption { match = mkOption {
type = types.attrsOf types.str; type = types.attrsOf types.str;
default = {}; default = { };
description = "Define match groups"; description = "Define match groups";
example = '' example = ''
match = { match = {
@ -42,10 +43,8 @@ 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,23 +69,22 @@ with lib; {
end end
end end
-- }} -- }}
''); ''
);
extraConfigLuaPost = extraConfigLuaPost =
optionalString (config.highlightOverride != {}) optionalString (config.highlightOverride != { })
/* # lua
lua ''
*/ -- Highlight groups {{
'' do
-- Highlight groups {{ local highlights = ${helpers.toLuaObject config.highlightOverride}
do
local highlights = ${helpers.toLuaObject config.highlightOverride}
for k,v in pairs(highlights) do for k,v in pairs(highlights) do
vim.api.nvim_set_hl(0, k, v) vim.api.nvim_set_hl(0, k, v)
end
end end
end -- }}
-- }} '';
'';
}; };
} }

View file

@ -4,13 +4,12 @@
config, config,
... ...
}: }:
with lib; { with lib;
{
options = { options = {
keymaps = mkOption { keymaps = mkOption {
type = type = types.listOf helpers.keymaps.mapOptionSubmodule;
types.listOf default = [ ];
helpers.keymaps.mapOptionSubmodule;
default = [];
example = [ example = [
{ {
key = "<C-m>"; key = "<C-m>";
@ -22,7 +21,7 @@ with lib; {
keymapsOnEvents = mkOption { keymapsOnEvents = mkOption {
type = types.attrsOf (types.listOf helpers.keymaps.mapOptionSubmodule); type = types.attrsOf (types.listOf helpers.keymaps.mapOptionSubmodule);
default = {}; default = { };
example = { example = {
"InsertEnter" = [ "InsertEnter" = [
{ {
@ -44,24 +43,16 @@ with lib; {
}; };
}; };
config = let config =
normalizeMapping = keyMapping: { let
inherit normalizeMapping = keyMapping: {
(keyMapping) inherit (keyMapping) mode key options;
mode
key
options
;
action = action = if keyMapping.lua then helpers.mkRaw keyMapping.action else keyMapping.action;
if keyMapping.lua };
then helpers.mkRaw keyMapping.action in
else keyMapping.action; {
}; extraConfigLua = optionalString (config.keymaps != [ ]) ''
in {
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,27 +63,24 @@ with lib; {
-- }}} -- }}}
''; '';
autoGroups = mapAttrs' (event: mappings: nameValuePair "nixvim_binds_${event}" {clear = true;}) config.keymapsOnEvents; autoGroups = mapAttrs' (
event: mappings: nameValuePair "nixvim_binds_${event}" { clear = true; }
) config.keymapsOnEvents;
autoCmd = autoCmd = mapAttrsToList (event: mappings: {
mapAttrsToList inherit event;
( group = "nixvim_binds_${event}";
event: mappings: { callback = helpers.mkRaw ''
inherit event; function()
group = "nixvim_binds_${event}"; do
callback = helpers.mkRaw '' local __nixvim_binds = ${helpers.toLuaObject (map normalizeMapping mappings)}
function() for i, map in ipairs(__nixvim_binds) do
do vim.keymap.set(map.mode, map.key, map.action, map.options)
local __nixvim_binds = ${helpers.toLuaObject (map normalizeMapping mappings)}
for i, map in ipairs(__nixvim_binds) do
vim.keymap.set(map.mode, map.key, map.action, map.options)
end
end end
end 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,59 +35,51 @@ 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 options = "opts";
(old: new: mkRenamedOptionModule [old] [new]) globalOptions = "globalOpts";
{ localOptions = "localOpts";
options = "opts"; };
globalOptions = "globalOpts";
localOptions = "localOpts";
};
config = { config = {
extraConfigLuaPre = extraConfigLuaPre = concatLines (
concatLines mapAttrsToList (
( optionName:
mapAttrsToList {
( prettyName,
optionName: { luaVariableName,
prettyName, luaApi,
luaVariableName, ...
luaApi, }:
... let
}: let varName = "nixvim_${luaVariableName}";
varName = "nixvim_${luaVariableName}"; optionDefinitions = config.${optionName};
optionDefinitions = config.${optionName}; in
in optionalString (optionDefinitions != { }) ''
optionalString -- Set up ${prettyName} {{{
(optionDefinitions != {}) do
'' local ${varName} = ${helpers.toLuaObject optionDefinitions}
-- Set up ${prettyName} {{{
do
local ${varName} = ${helpers.toLuaObject optionDefinitions}
for k,v in pairs(${varName}) do for k,v in pairs(${varName}) do
vim.${luaApi}[k] = v vim.${luaApi}[k] = v
end end
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,11 +9,9 @@ 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)";
};
plugin = mkOption { plugin = mkOption {
type = types.package; type = types.package;
@ -24,24 +19,25 @@ 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);
default = []; default = [ ];
description = "List of vim plugins to install"; description = "List of vim plugins to install";
}; };
extraPackages = mkOption { extraPackages = mkOption {
type = with types; listOf (nullOr package); type = with types; listOf (nullOr package);
default = []; default = [ ];
description = "Extra packages to be made available to neovim"; description = "Extra packages to be made available to neovim";
apply = builtins.filter (p: p != null); apply = builtins.filter (p: p != null);
}; };
extraPython3Packages = mkOption { extraPython3Packages = mkOption {
type = with types; functionTo (listOf package); type = with types; functionTo (listOf package);
default = p: []; default = p: [ ];
defaultText = literalExpression "p: with p; [ ]"; defaultText = literalExpression "p: with p; [ ]";
description = "Python packages to add to the `PYTHONPATH` of neovim."; description = "Python packages to add to the `PYTHONPATH` of neovim.";
example = lib.literalExpression '' example = lib.literalExpression ''
@ -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";
}; };
@ -94,40 +93,39 @@ in {
extraLuaPackages = mkOption { extraLuaPackages = mkOption {
type = types.functionTo (types.listOf types.package); type = types.functionTo (types.listOf types.package);
description = "Extra lua packages to include with neovim"; description = "Extra lua packages to include with neovim";
default = _: []; default = _: [ ];
}; };
extraFiles = mkOption { extraFiles = mkOption {
type = types.attrsOf types.str; type = types.attrsOf types.str;
description = "Extra files to add to the runtime path"; description = "Extra files to add to the runtime path";
default = {}; default = { };
}; };
}; };
config = let config =
contentLua = '' let
${config.extraConfigLuaPre} contentLua = ''
vim.cmd([[
${config.extraConfigVim}
]])
${config.extraConfigLua}
${config.extraConfigLuaPost}
'';
contentVim = ''
lua << EOF
${config.extraConfigLuaPre} ${config.extraConfigLuaPre}
EOF vim.cmd([[
${config.extraConfigVim} ${config.extraConfigVim}
lua << EOF ]])
${config.extraConfigLua} ${config.extraConfigLua}
${config.extraConfigLuaPost} ${config.extraConfigLuaPost}
EOF '';
'';
in { contentVim = ''
content = lua << EOF
if config.type == "lua" ${config.extraConfigLuaPre}
then contentLua EOF
else contentVim; ${config.extraConfigVim}
}; lua << EOF
${config.extraConfigLua}
${config.extraConfigLuaPost}
EOF
'';
in
{
content = if config.type == "lua" then contentLua else contentVim;
};
} }

View file

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

View file

@ -1,15 +1,16 @@
{lib, ...}: { lib, ... }:
with lib; { with lib;
{
options = { options = {
warnings = mkOption { warnings = mkOption {
type = types.listOf types.str; type = types.listOf types.str;
visible = false; visible = false;
default = []; default = [ ];
}; };
assertions = mkOption { assertions = mkOption {
type = types.listOf types.attrs; # Not sure what the correct type is here type = types.listOf types.attrs; # Not sure what the correct type is here
visible = false; visible = false;
default = []; default = [ ];
}; };
}; };
} }

View file

@ -10,7 +10,7 @@ helpers.neovim-plugin.mkNeovimPlugin config {
originalName = "my-plugin.nvim"; # TODO replace (or remove entirely if it is the same as `name`) originalName = "my-plugin.nvim"; # TODO replace (or remove entirely if it is the same as `name`)
defaultPackage = pkgs.vimPlugins.my-plugin-nvim; # TODO replace defaultPackage = pkgs.vimPlugins.my-plugin-nvim; # TODO replace
maintainers = [lib.maintainers.MyName]; # TODO replace with your name maintainers = [ lib.maintainers.MyName ]; # TODO replace with your name
# Optionally, explicitly declare some options. You don't have to. # Optionally, explicitly declare some options. You don't have to.
settingsOptions = { settingsOptions = {

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,30 +15,31 @@ 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"
name: "warn"
"info"
"hint"
]
(
name:
helpers.mkCompositeOption "${name} diagnostic icon." { helpers.mkCompositeOption "${name} diagnostic icon." {
enable = helpers.defaultNullOpts.mkBool false "Enable the ${name} diagnostic symbol"; enable = helpers.defaultNullOpts.mkBool false "Enable the ${name} diagnostic symbol";
icon = helpers.mkNullOrOption types.str "${name} diagnostic symbol"; icon = helpers.mkNullOrOption types.str "${name} diagnostic symbol";
} }
); );
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,160 +78,141 @@ 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
- left-click: go to buffer - left-click: go to buffer
- middle-click: delete buffer - middle-click: delete buffer
''; '';
excludeFileTypes = helpers.defaultNullOpts.mkNullable (types.listOf types.str) "[]" '' excludeFileTypes = helpers.defaultNullOpts.mkNullable (types.listOf types.str) "[]" ''
Excludes buffers of certain filetypes from the tabline Excludes buffers of certain filetypes from the tabline
''; '';
excludeFileNames = helpers.defaultNullOpts.mkNullable (types.listOf types.str) "[]" '' excludeFileNames = helpers.defaultNullOpts.mkNullable (types.listOf types.str) "[]" ''
Excludes buffers with certain filenames from the tabline Excludes buffers with certain filenames from the tabline
''; '';
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:
mkOption {
type = types.submodule {
options = stateOptions;
};
default = {};
inherit description;
})
{
alternate = "The icons used for an alternate buffer.";
current = "The icons for the current buffer.";
inactive = "The icons for inactive buffers.";
visible = "The icons for visible buffers.";
}
);
hide = {
alternate = helpers.mkNullOrOption types.bool "Hide alternate buffers";
current = helpers.mkNullOrOption types.bool "Hide current buffer";
extensions = helpers.mkNullOrOption types.bool "Hide file extensions";
inactive = helpers.mkNullOrOption types.bool "Hide inactive buffers";
visible = helpers.mkNullOrOption types.bool "Hide visible buffers";
};
insertAtEnd = helpers.defaultNullOpts.mkBool false ''
If true, new buffers will be inserted at the end of the list.
Default is to insert after current buffer.
'';
insertAtStart = helpers.defaultNullOpts.mkBool false ''
If true, new buffers will be inserted at the start of the list.
Default is to insert after current buffer.
'';
maximumPadding =
helpers.defaultNullOpts.mkInt 4
"Sets the maximum padding width with which to surround each tab";
minimumPadding =
helpers.defaultNullOpts.mkInt 1
"Sets the minimum padding width with which to surround each tab";
maximumLength =
helpers.defaultNullOpts.mkInt 30
"Sets the maximum buffer name length.";
semanticLetters = helpers.defaultNullOpts.mkBool true ''
If set, the letters for each buffer in buffer-pick mode will be assigned based on their
name.
Otherwise or in case all letters are already assigned, the behavior is to assign letters in
order of usability (see `letters` option)
'';
letters =
helpers.defaultNullOpts.mkStr
"asdfjkl;ghnmxcvbziowerutyqpASDFJKLGHNMXCVBZIOWERUTYQP"
''
New buffer letters are assigned in this order.
This order is optimal for the qwerty keyboard layout but might need adjustment for other layouts.
'';
sidebarFiletypes =
helpers.mkNullOrOption
( (
with types; name: description:
attrsOf ( mkOption {
either type = types.submodule { options = stateOptions; };
(enum [true]) default = { };
(types.submodule { inherit description;
options = { }
text = helpers.mkNullOrOption types.str "The text used for the offset";
event =
helpers.mkNullOrOption types.str
"The event which the sidebar executes when leaving.";
};
})
)
) )
"Set the filetypes which barbar will offset itself for";
noNameTitle = helpers.mkNullOrOption types.str ''
Sets the name of unnamed buffers.
By default format is "[Buffer X]" where X is the buffer number.
But only a static string is accepted here.
'';
keymaps =
{ {
silent = mkEnableOption "silent keymaps for barbar"; alternate = "The icons used for an alternate buffer.";
current = "The icons for the current buffer.";
inactive = "The icons for inactive buffers.";
visible = "The icons for visible buffers.";
} }
// ( );
mapAttrs
( hide = {
optionName: funcName: alternate = helpers.mkNullOrOption types.bool "Hide alternate buffers";
helpers.mkNullOrOption types.str "Keymap for function Buffer${funcName}" current = helpers.mkNullOrOption types.bool "Hide current buffer";
) extensions = helpers.mkNullOrOption types.bool "Hide file extensions";
keymapsActions inactive = helpers.mkNullOrOption types.bool "Hide inactive buffers";
); visible = helpers.mkNullOrOption types.bool "Hide visible buffers";
}; };
config = let insertAtEnd = helpers.defaultNullOpts.mkBool false ''
setupOptions = If true, new buffers will be inserted at the end of the list.
Default is to insert after current buffer.
'';
insertAtStart = helpers.defaultNullOpts.mkBool false ''
If true, new buffers will be inserted at the start of the list.
Default is to insert after current buffer.
'';
maximumPadding =
helpers.defaultNullOpts.mkInt 4
"Sets the maximum padding width with which to surround each tab";
minimumPadding =
helpers.defaultNullOpts.mkInt 1
"Sets the minimum padding width with which to surround each tab";
maximumLength = helpers.defaultNullOpts.mkInt 30 "Sets the maximum buffer name length.";
semanticLetters = helpers.defaultNullOpts.mkBool true ''
If set, the letters for each buffer in buffer-pick mode will be assigned based on their
name.
Otherwise or in case all letters are already assigned, the behavior is to assign letters in
order of usability (see `letters` option)
'';
letters = helpers.defaultNullOpts.mkStr "asdfjkl;ghnmxcvbziowerutyqpASDFJKLGHNMXCVBZIOWERUTYQP" ''
New buffer letters are assigned in this order.
This order is optimal for the qwerty keyboard layout but might need adjustment for other layouts.
'';
sidebarFiletypes = helpers.mkNullOrOption (
with types;
attrsOf (
either (enum [ true ]) (
types.submodule {
options = {
text = helpers.mkNullOrOption types.str "The text used for the offset";
event = helpers.mkNullOrOption types.str "The event which the sidebar executes when leaving.";
};
}
)
)
) "Set the filetypes which barbar will offset itself for";
noNameTitle = helpers.mkNullOrOption types.str ''
Sets the name of unnamed buffers.
By default format is "[Buffer X]" where X is the buffer number.
But only a static string is accepted here.
'';
keymaps =
{ {
silent = mkEnableOption "silent keymaps for barbar";
}
// (mapAttrs (
optionName: funcName: helpers.mkNullOrOption types.str "Keymap for function Buffer${funcName}"
) keymapsActions);
};
config =
let
setupOptions = {
inherit (cfg) animation; inherit (cfg) animation;
auto_hide = cfg.autoHide; auto_hide = cfg.autoHide;
inherit (cfg) tabpages; inherit (cfg) tabpages;
@ -242,74 +223,58 @@ 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 =
buffer_index = bufferIndex; bufferOption: with bufferOption; {
buffer_number = bufferNumber; buffer_index = bufferIndex;
inherit button; buffer_number = bufferNumber;
diagnostics = inherit button;
/* diagnostics =
Because the keys of this lua table are not strings (but /*
`vim.diagnostic.severity.XXXX`), we have to manually build a raw lua string here. Because the keys of this lua table are not strings (but
*/ `vim.diagnostic.severity.XXXX`), we have to manually build a raw lua string here.
let */
setIcons = filterAttrs (n: v: v != null) cfg.icons.diagnostics; let
setIconsList = setIcons = filterAttrs (n: v: v != null) cfg.icons.diagnostics;
mapAttrsToList setIconsList = mapAttrsToList (name: value: {
(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 (
enabled = value.enable; helpers.toLuaObject {
inherit (value) icon; enabled = value.enable;
}); inherit (value) icon;
}) }
setIcons; );
in }) setIcons;
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; {
custom_color = customColors; custom_color = customColors;
enabled = enable; enabled = enable;
};
inherit separator;
}; };
inherit separator;
};
handleStateOption = stateOption: handleStateOption =
with stateOption; stateOption:
with stateOption;
{ {
modified = handleBufferOption modified; modified = handleBufferOption modified;
pinned = handleBufferOption pinned; pinned = handleBufferOption pinned;
} }
// ( // (handleBufferOption (getAttrs (attrNames stateOption) stateOption));
handleBufferOption in
( (handleStateOption (getAttrs (attrNames stateOptions) cfg.icons))
getAttrs (attrNames stateOption) // (genAttrs [
stateOption "alternate"
) "current"
); "inactive"
in "visible"
( ] (optionName: handleStateOption cfg.icons.${optionName}));
handleStateOption
(
getAttrs
(attrNames stateOptions)
cfg.icons
)
)
// (
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,29 +285,23 @@ 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";
{ inherit key;
mode = "n"; action = "<Cmd>Buffer${funcName}<CR>";
inherit key; options.silent = cfg.keymaps.silent;
action = "<Cmd>Buffer${funcName}<CR>"; }
options.silent = cfg.keymaps.silent; ) keymapsActions
}
)
keymapsActions
); );
in in
mkIf cfg.enable { mkIf cfg.enable {
extraPlugins = with pkgs.vimPlugins; [ extraPlugins = with pkgs.vimPlugins; [
cfg.package cfg.package

View file

@ -5,61 +5,61 @@
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;
attachNavic = helpers.defaultNullOpts.mkBool true '' attachNavic = helpers.defaultNullOpts.mkBool true ''
Whether to attach navic to language servers automatically. Whether to attach navic to language servers automatically.
'';
createAutocmd = helpers.defaultNullOpts.mkBool true ''
Whether to create winbar updater autocmd.
'';
includeBuftypes = mkListStr ''[""]'' ''
Buftypes to enable winbar in.
'';
excludeFiletypes = mkListStr ''["netrw" "toggleterm"]'' ''
Filetypes not to enable winbar in.
'';
modifiers = {
dirname = helpers.defaultNullOpts.mkStr ":~:." ''
Filename modifiers applied to dirname.
See: `:help filename-modifiers`
''; '';
createAutocmd = helpers.defaultNullOpts.mkBool true '' basename = helpers.defaultNullOpts.mkStr "" ''
Whether to create winbar updater autocmd. Filename modifiers applied to basename.
See: `:help filename-modifiers`
''; '';
};
includeBuftypes = mkListStr ''[""]'' '' showDirname = helpers.defaultNullOpts.mkBool true ''
Buftypes to enable winbar in. Whether to display path to file.
''; '';
excludeFiletypes = mkListStr ''["netrw" "toggleterm"]'' '' showBasename = helpers.defaultNullOpts.mkBool true ''
Filetypes not to enable winbar in. Whether to display file name.
''; '';
modifiers = { showModified = helpers.defaultNullOpts.mkBool false ''
dirname = helpers.defaultNullOpts.mkStr ":~:." '' Whether to replace file icon with the modified symbol when buffer is modified.
Filename modifiers applied to dirname. '';
See: `:help filename-modifiers` modified =
''; helpers.defaultNullOpts.mkLuaFn
basename = helpers.defaultNullOpts.mkStr "" ''
Filename modifiers applied to basename.
See: `:help filename-modifiers`
'';
};
showDirname = helpers.defaultNullOpts.mkBool true ''
Whether to display path to file.
'';
showBasename = helpers.defaultNullOpts.mkBool true ''
Whether to display file name.
'';
showModified = helpers.defaultNullOpts.mkBool false ''
Whether to replace file icon with the modified symbol when buffer is modified.
'';
modified =
helpers.defaultNullOpts.mkLuaFn
'' ''
function(bufnr) function(bufnr)
return vim.bo[bufnr].modified return vim.bo[bufnr].modified
@ -70,12 +70,12 @@ in {
NOTE: This can be used to get file modified status from SCM (e.g. git) NOTE: This can be used to get file modified status from SCM (e.g. git)
''; '';
showNavic = helpers.defaultNullOpts.mkBool true '' showNavic = helpers.defaultNullOpts.mkBool true ''
Whether to show/use navic in the winbar. Whether to show/use navic in the winbar.
''; '';
leadCustomSection = leadCustomSection =
helpers.defaultNullOpts.mkLuaFn helpers.defaultNullOpts.mkLuaFn
'' ''
function() function()
return " " return " "
@ -86,8 +86,8 @@ in {
NOTE: This function shouldn't do any expensive actions as it is run on each render. NOTE: This function shouldn't do any expensive actions as it is run on each render.
''; '';
customSection = customSection =
helpers.defaultNullOpts.mkLuaFn helpers.defaultNullOpts.mkLuaFn
'' ''
function() function()
return " " return " "
@ -98,101 +98,88 @@ in {
NOTE: This function shouldn't do any expensive actions as it is run on each render. NOTE: This function shouldn't do any expensive actions as it is run on each render.
''; '';
theme = helpers.defaultNullOpts.mkStr "auto" '' theme = helpers.defaultNullOpts.mkStr "auto" ''
Theme to be used for generating highlight groups dynamically. Theme to be used for generating highlight groups dynamically.
'';
contextFollowIconColor = helpers.defaultNullOpts.mkBool false ''
Whether context text should follow its icon's color.
'';
symbols = {
modified = helpers.defaultNullOpts.mkStr "" ''
Modification indicator.
''; '';
contextFollowIconColor = helpers.defaultNullOpts.mkBool false '' ellipsis = helpers.defaultNullOpts.mkStr "" ''
Whether context text should follow its icon's color. Truncation indicator.
''; '';
symbols = { separator = helpers.defaultNullOpts.mkStr "" ''
modified = helpers.defaultNullOpts.mkStr "" '' Entry separator.
Modification indicator. '';
'';
ellipsis = helpers.defaultNullOpts.mkStr "" ''
Truncation indicator.
'';
separator = helpers.defaultNullOpts.mkStr "" ''
Entry separator.
'';
};
kinds =
mapAttrs
(
name: default:
helpers.defaultNullOpts.mkStr default "icon for ${name}."
)
{
File = "";
Module = "";
Namespace = "";
Package = "";
Class = "";
Method = "";
Property = "";
Field = "";
Constructor = "";
Enum = "";
Interface = "";
Function = "";
Variable = "";
Constant = "";
String = "";
Number = "";
Boolean = "";
Array = "";
Object = "";
Key = "";
Null = "";
EnumMember = "";
Struct = "";
Event = "";
Operator = "";
TypeParameter = "";
};
}; };
config = let kinds = mapAttrs (name: default: helpers.defaultNullOpts.mkStr default "icon for ${name}.") {
setupOptions = with cfg; File = "";
{ Module = "";
attach_navic = attachNavic; Namespace = "";
create_autocmd = createAutocmd; Package = "";
include_buftypes = includeBuftypes; Class = "";
exclude_filetypes = excludeFiletypes; Method = "";
modifiers = { Property = "";
inherit Field = "";
(modifiers) Constructor = "";
dirname Enum = "";
basename Interface = "";
; Function = "";
}; Variable = "";
show_dirname = showDirname; Constant = "";
show_basename = showBasename; String = "";
show_modified = showModified; Number = "";
inherit modified; Boolean = "";
show_navic = showNavic; Array = "";
lead_custom_section = leadCustomSection; Object = "";
custom_section = customSection; Key = "";
inherit theme; Null = "";
context_follow_icon_color = contextFollowIconColor; EnumMember = "";
symbols = { Struct = "";
inherit Event = "";
(symbols) Operator = "";
modified TypeParameter = "";
ellipsis };
separator };
;
}; config =
inherit kinds; let
} setupOptions =
// cfg.extraOptions; with cfg;
in {
attach_navic = attachNavic;
create_autocmd = createAutocmd;
include_buftypes = includeBuftypes;
exclude_filetypes = excludeFiletypes;
modifiers = {
inherit (modifiers) dirname basename;
};
show_dirname = showDirname;
show_basename = showBasename;
show_modified = showModified;
inherit modified;
show_navic = showNavic;
lead_custom_section = leadCustomSection;
custom_section = customSection;
inherit theme;
context_follow_icon_color = contextFollowIconColor;
symbols = {
inherit (symbols) modified ellipsis separator;
};
inherit kinds;
}
// cfg.extraOptions;
in
mkIf cfg.enable { mkIf cfg.enable {
extraPlugins = [cfg.package]; extraPlugins = [ cfg.package ];
extraConfigLua = '' extraConfigLua = ''
require('barbecue').setup(${helpers.toLuaObject setupOptions}) require('barbecue').setup(${helpers.toLuaObject setupOptions})

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"
'' ''
@ -121,166 +125,137 @@ 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"
leftTruncMarker = helpers.defaultNullOpts.mkStr "" "left trunc marker"; ] "style";
rightTruncMarker = helpers.defaultNullOpts.mkStr "" "right trunc marker";
separatorStyle =
helpers.defaultNullOpts.mkEnum ["slant" "padded_slant" "slope" "padded_slope" "thick" "thin"] "thin"
"Separator style";
nameFormatter =
helpers.defaultNullOpts.mkLuaFn "null"
''
A lua function that can be used to modify the buffer's label.
The argument 'buf' containing a name, path and bufnr is supplied.
'';
truncateNames = helpers.defaultNullOpts.mkBool true "Whether to truncate names.";
tabSize = helpers.defaultNullOpts.mkInt 18 "Size of the tabs";
maxNameLength = helpers.defaultNullOpts.mkInt 18 "Max length of a buffer name.";
colorIcons = helpers.defaultNullOpts.mkBool true "Enable color icons.";
showBufferIcons = helpers.defaultNullOpts.mkBool true "Show buffer icons";
showBufferCloseIcons = helpers.defaultNullOpts.mkBool true "Show buffer close icons";
getElementIcon =
helpers.defaultNullOpts.mkLuaFn "null"
''
Lua function returning an element icon.
```
fun(opts: IconFetcherOpts): string?, string?
```
'';
showCloseIcon = helpers.defaultNullOpts.mkBool true "Whether to show the close icon.";
showTabIndicators =
helpers.defaultNullOpts.mkBool true
"Whether to show the tab indicators.";
showDuplicatePrefix =
helpers.defaultNullOpts.mkBool true
"Whether to show the prefix of duplicated files.";
enforceRegularTabs =
helpers.defaultNullOpts.mkBool false
"Whether to enforce regular tabs.";
alwaysShowBufferline =
helpers.defaultNullOpts.mkBool true
"Whether to always show the bufferline.";
persistBufferSort =
helpers.defaultNullOpts.mkBool true
"Whether to make the buffer sort persistent.";
maxPrefixLength = helpers.defaultNullOpts.mkInt 15 "Maximum prefix length";
sortBy = helpers.defaultNullOpts.mkStr "id" "sort by";
diagnostics =
helpers.defaultNullOpts.mkNullable
(with types; either bool (enum ["nvim_lsp" "coc"])) "false" "diagnostics";
diagnosticsIndicator =
helpers.defaultNullOpts.mkLuaFn "null"
"Either `null` or a function that returns the diagnostics indicator.";
diagnosticsUpdateInInsert =
helpers.defaultNullOpts.mkBool true
"Whether diagnostics should update in insert mode";
offsets = helpers.defaultNullOpts.mkNullable (types.listOf types.attrs) "null" "offsets";
groups = {
items =
helpers.defaultNullOpts.mkNullable (types.listOf types.attrs) "[]"
"List of groups.";
options = {
toggleHiddenOnEnter =
helpers.defaultNullOpts.mkBool true
"Re-open hidden groups on bufenter.";
};
};
hover = {
enabled = mkEnableOption "hover";
reveal = helpers.defaultNullOpts.mkNullable (types.listOf types.str) "[]" "reveal";
delay = helpers.defaultNullOpts.mkInt 200 "delay";
};
debug = {
logging = helpers.defaultNullOpts.mkBool false "Whether to enable logging";
};
customFilter =
helpers.defaultNullOpts.mkLuaFn "null"
''
```
fun(buf: number, bufnums: number[]): boolean
```
'';
highlights =
genAttrs
(attrValues highlightOptions)
(
name:
helpers.mkNullOrOption helpers.nixvimTypes.highlight ''
Highlight group definition for ${name}.
''
);
}; };
leftTruncMarker = helpers.defaultNullOpts.mkStr "" "left trunc marker";
rightTruncMarker = helpers.defaultNullOpts.mkStr "" "right trunc marker";
separatorStyle = helpers.defaultNullOpts.mkEnum [
"slant"
"padded_slant"
"slope"
"padded_slope"
"thick"
"thin"
] "thin" "Separator style";
nameFormatter = helpers.defaultNullOpts.mkLuaFn "null" ''
A lua function that can be used to modify the buffer's label.
The argument 'buf' containing a name, path and bufnr is supplied.
'';
truncateNames = helpers.defaultNullOpts.mkBool true "Whether to truncate names.";
tabSize = helpers.defaultNullOpts.mkInt 18 "Size of the tabs";
maxNameLength = helpers.defaultNullOpts.mkInt 18 "Max length of a buffer name.";
colorIcons = helpers.defaultNullOpts.mkBool true "Enable color icons.";
showBufferIcons = helpers.defaultNullOpts.mkBool true "Show buffer icons";
showBufferCloseIcons = helpers.defaultNullOpts.mkBool true "Show buffer close icons";
getElementIcon = helpers.defaultNullOpts.mkLuaFn "null" ''
Lua function returning an element icon.
```
fun(opts: IconFetcherOpts): string?, string?
```
'';
showCloseIcon = helpers.defaultNullOpts.mkBool true "Whether to show the close icon.";
showTabIndicators = helpers.defaultNullOpts.mkBool true "Whether to show the tab indicators.";
showDuplicatePrefix = helpers.defaultNullOpts.mkBool true "Whether to show the prefix of duplicated files.";
enforceRegularTabs = helpers.defaultNullOpts.mkBool false "Whether to enforce regular tabs.";
alwaysShowBufferline = helpers.defaultNullOpts.mkBool true "Whether to always show the bufferline.";
persistBufferSort = helpers.defaultNullOpts.mkBool true "Whether to make the buffer sort persistent.";
maxPrefixLength = helpers.defaultNullOpts.mkInt 15 "Maximum prefix length";
sortBy = helpers.defaultNullOpts.mkStr "id" "sort by";
diagnostics = helpers.defaultNullOpts.mkNullable (
with types;
either bool (enum [
"nvim_lsp"
"coc"
])
) "false" "diagnostics";
diagnosticsIndicator = helpers.defaultNullOpts.mkLuaFn "null" "Either `null` or a function that returns the diagnostics indicator.";
diagnosticsUpdateInInsert = helpers.defaultNullOpts.mkBool true "Whether diagnostics should update in insert mode";
offsets = helpers.defaultNullOpts.mkNullable (types.listOf types.attrs) "null" "offsets";
groups = {
items = helpers.defaultNullOpts.mkNullable (types.listOf types.attrs) "[]" "List of groups.";
options = {
toggleHiddenOnEnter = helpers.defaultNullOpts.mkBool true "Re-open hidden groups on bufenter.";
};
};
hover = {
enabled = mkEnableOption "hover";
reveal = helpers.defaultNullOpts.mkNullable (types.listOf types.str) "[]" "reveal";
delay = helpers.defaultNullOpts.mkInt 200 "delay";
};
debug = {
logging = helpers.defaultNullOpts.mkBool false "Whether to enable logging";
};
customFilter = helpers.defaultNullOpts.mkLuaFn "null" ''
```
fun(buf: number, bufnums: number[]): boolean
```
'';
highlights = genAttrs (attrValues highlightOptions) (
name:
helpers.mkNullOrOption helpers.nixvimTypes.highlight ''
Highlight group definition for ${name}.
''
);
};
}; };
config = let config =
setupOptions = with cfg; { let
options = setupOptions = with cfg; {
{ options = {
inherit inherit mode themable numbers;
mode
themable
numbers
;
buffer_close_icon = bufferCloseIcon; buffer_close_icon = bufferCloseIcon;
modified_icon = modifiedIcon; modified_icon = modifiedIcon;
close_icon = closeIcon; close_icon = closeIcon;
@ -319,29 +294,19 @@ 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} in
)
highlightOptions;
};
in
mkIf cfg.enable { mkIf cfg.enable {
extraPlugins = with pkgs.vimPlugins; [ extraPlugins = with pkgs.vimPlugins; [
cfg.package cfg.package

View file

@ -5,113 +5,109 @@
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 File = "󰈙 ";
( Module = " ";
name: default: Namespace = "󰌗 ";
helpers.defaultNullOpts.mkStr default "icon for ${name}." Package = " ";
) Class = "󰌗 ";
{ Method = "󰆧 ";
File = "󰈙 "; Property = " ";
Module = " "; Field = " ";
Namespace = "󰌗 "; Constructor = " ";
Package = " "; Enum = "󰕘";
Class = "󰌗 "; Interface = "󰕘";
Method = "󰆧 "; Function = "󰊕 ";
Property = " "; Variable = "󰆧 ";
Field = " "; Constant = "󰏿 ";
Constructor = " "; String = "󰀬 ";
Enum = "󰕘"; Number = "󰎠 ";
Interface = "󰕘"; Boolean = " ";
Function = "󰊕 "; Array = "󰅪 ";
Variable = "󰆧 "; Object = "󰅩 ";
Constant = "󰏿 "; Key = "󰌋 ";
String = "󰀬 "; Null = "󰟢 ";
Number = "󰎠 "; EnumMember = " ";
Boolean = " "; Struct = "󰌗 ";
Array = "󰅪 "; Event = " ";
Object = "󰅩 "; Operator = "󰆕 ";
Key = "󰌋 "; TypeParameter = "󰊄 ";
Null = "󰟢 "; };
EnumMember = " ";
Struct = "󰌗 ";
Event = " ";
Operator = "󰆕 ";
TypeParameter = "󰊄 ";
};
lsp = { lsp = {
autoAttach = helpers.defaultNullOpts.mkBool false '' autoAttach = helpers.defaultNullOpts.mkBool false ''
Enable to have nvim-navic automatically attach to every LSP for current buffer. Its disabled by default. Enable to have nvim-navic automatically attach to every LSP for current buffer. Its disabled by default.
'';
preference = helpers.defaultNullOpts.mkNullable (with types; listOf str) "[]" ''
Table ranking lsp_servers. Lower the index, higher the priority of the server. If there are more than one server attached to a buffer. In the example below will prefer clangd over pyright
Example: `[ "clangd" "pyright" ]`.
'';
};
highlight = helpers.defaultNullOpts.mkBool false ''
If set to true, will add colors to icons and text as defined by highlight groups NavicIcons* (NavicIconsFile, NavicIconsModule.. etc.), NavicText and NavicSeparator.
''; '';
separator = helpers.defaultNullOpts.mkStr " > " '' preference = helpers.defaultNullOpts.mkNullable (with types; listOf str) "[]" ''
Icon to separate items. to use between items. Table ranking lsp_servers. Lower the index, higher the priority of the server. If there are more than one server attached to a buffer. In the example below will prefer clangd over pyright
'';
depthLimit = helpers.defaultNullOpts.mkInt 0 '' Example: `[ "clangd" "pyright" ]`.
Maximum depth of context to be shown. If the context hits this depth limit, it is truncated.
'';
depthLimitIndicator = helpers.defaultNullOpts.mkStr ".." ''
Icon to indicate that depth_limit was hit and the shown context is truncated.
'';
safeOutput = helpers.defaultNullOpts.mkBool true ''
Sanitize the output for use in statusline and winbar.
'';
lazyUpdateContext = helpers.defaultNullOpts.mkBool false ''
If true, turns off context updates for the "CursorMoved" event.
'';
click = helpers.defaultNullOpts.mkBool false ''
Single click to goto element, double click to open nvim-navbuddy on the clicked element.
''; '';
}; };
config = let highlight = helpers.defaultNullOpts.mkBool false ''
setupOptions = with cfg; If set to true, will add colors to icons and text as defined by highlight groups NavicIcons* (NavicIconsFile, NavicIconsModule.. etc.), NavicText and NavicSeparator.
{ '';
inherit
icons separator = helpers.defaultNullOpts.mkStr " > " ''
highlight Icon to separate items. to use between items.
separator '';
click
; depthLimit = helpers.defaultNullOpts.mkInt 0 ''
lsp = with lsp; { Maximum depth of context to be shown. If the context hits this depth limit, it is truncated.
auto_attach = autoAttach; '';
inherit preference;
}; depthLimitIndicator = helpers.defaultNullOpts.mkStr ".." ''
depth_limit = depthLimit; Icon to indicate that depth_limit was hit and the shown context is truncated.
safe_output = safeOutput; '';
lazy_update_context = lazyUpdateContext;
} safeOutput = helpers.defaultNullOpts.mkBool true ''
// cfg.extraOptions; Sanitize the output for use in statusline and winbar.
in '';
lazyUpdateContext = helpers.defaultNullOpts.mkBool false ''
If true, turns off context updates for the "CursorMoved" event.
'';
click = helpers.defaultNullOpts.mkBool false ''
Single click to goto element, double click to open nvim-navbuddy on the clicked element.
'';
};
config =
let
setupOptions =
with cfg;
{
inherit
icons
highlight
separator
click
;
lsp = with lsp; {
auto_attach = autoAttach;
inherit preference;
};
depth_limit = depthLimit;
safe_output = safeOutput;
lazy_update_context = lazyUpdateContext;
}
// cfg.extraOptions;
in
mkIf cfg.enable { mkIf cfg.enable {
extraPlugins = [cfg.package]; extraPlugins = [ cfg.package ];
extraConfigLua = '' extraConfigLua = ''
require('nvim-navic').setup(${helpers.toLuaObject setupOptions}) require('nvim-navic').setup(${helpers.toLuaObject setupOptions})

View file

@ -6,48 +6,44 @@
... ...
}: }:
with lib; with lib;
helpers.neovim-plugin.mkNeovimPlugin config { helpers.neovim-plugin.mkNeovimPlugin config {
name = "ayu"; name = "ayu";
isColorscheme = true; isColorscheme = true;
originalName = "neovim-ayu"; originalName = "neovim-ayu";
defaultPackage = pkgs.vimPlugins.neovim-ayu; defaultPackage = pkgs.vimPlugins.neovim-ayu;
# The colorscheme option is set by the `setup` function. # The colorscheme option is set by the `setup` function.
colorscheme = null; colorscheme = null;
callSetup = false; callSetup = false;
maintainers = [maintainers.GaetanLepage]; maintainers = [ maintainers.GaetanLepage ];
deprecateExtraOptions = true; deprecateExtraOptions = true;
optionsRenamedToSettings = [ optionsRenamedToSettings = [
"mirage" "mirage"
"overrides" "overrides"
]; ];
settingsOptions = { settingsOptions = {
mirage = helpers.defaultNullOpts.mkBool false '' mirage = helpers.defaultNullOpts.mkBool false ''
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 A dictionary of group names, each associated with a dictionary of parameters
(with helpers.nixvimTypes; attrsOf highlight) (`bg`, `fg`, `sp` and `style`) and colors in hex.
"{}"
''
A dictionary of group names, each associated with a dictionary of parameters
(`bg`, `fg`, `sp` and `style`) and colors in hex.
Alternatively, `overrides` can be a function that returns a dictionary of the same Alternatively, `overrides` can be a function that returns a dictionary of the same
format. format.
You can use the function to override based on a dynamic condition, such as the value of You can use the function to override based on a dynamic condition, such as the value of
`background`. `background`.
''; '';
}; };
extraConfig = cfg: { extraConfig = cfg: {
extraConfigLuaPre = '' extraConfigLuaPre = ''
local ayu = require("ayu") local ayu = require("ayu")
ayu.setup(${helpers.toLuaObject cfg.settings}) ayu.setup(${helpers.toLuaObject cfg.settings})
ayu.colorscheme() ayu.colorscheme()
''; '';
}; };
} }

View file

@ -8,111 +8,123 @@
with lib; with lib;
# We configure this plugin manually (no `settings` option) so there is no point in using # We configure this plugin manually (no `settings` option) so there is no point in using
# `mkNeovimPlugin` here. # `mkNeovimPlugin` here.
helpers.vim-plugin.mkVimPlugin config { helpers.vim-plugin.mkVimPlugin config {
name = "base16"; name = "base16";
isColorscheme = true; isColorscheme = true;
originalName = "base16.nvim"; originalName = "base16.nvim";
defaultPackage = pkgs.vimPlugins.base16-nvim; defaultPackage = pkgs.vimPlugins.base16-nvim;
maintainers = [maintainers.GaetanLepage]; maintainers = [ maintainers.GaetanLepage ];
# We manually set the colorscheme if needed. # We manually set the colorscheme if needed.
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
( (colorId: rec {
map name = "base0" + colorId;
( value = mkOption {
colorId: rec { type = types.str;
name = "base0" + colorId; description = "The value for color `${name}`.";
value = mkOption { example = "#16161D";
type = types.str; };
description = "The value for color `${name}`."; })
example = "#16161D"; [
}; "0"
} "1"
) "2"
["0" "1" "2" "3" "4" "5" "6" "7" "8" "9" "A" "B" "C" "D" "E" "F"] "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 description = ''
(enum (import ./theme-list.nix)) The base16 colorscheme to use.
customColorschemeType; It can either be the name of a builtin colorscheme or an attrs specifying each color explicitly.
description = ''
The base16 colorscheme to use.
It can either be the name of a builtin colorscheme or an attrs specifying each color explicitly.
Example for the latter: Example for the latter:
```nix ```nix
{ {
base00 = "#16161D"; base00 = "#16161D";
base01 = "#2c313c"; base01 = "#2c313c";
base02 = "#3e4451"; base02 = "#3e4451";
base03 = "#6c7891"; base03 = "#6c7891";
base04 = "#565c64"; base04 = "#565c64";
base05 = "#abb2bf"; base05 = "#abb2bf";
base06 = "#9a9bb3"; base06 = "#9a9bb3";
base07 = "#c5c8e6"; base07 = "#c5c8e6";
base08 = "#e06c75"; base08 = "#e06c75";
base09 = "#d19a66"; base09 = "#d19a66";
base0A = "#e5c07b"; base0A = "#e5c07b";
base0B = "#98c379"; base0B = "#98c379";
base0C = "#56b6c2"; base0C = "#56b6c2";
base0D = "#0184bc"; base0D = "#0184bc";
base0E = "#c678dd"; base0E = "#c678dd";
base0F = "#a06949"; base0F = "#a06949";
} }
``` ```
''; '';
example = "edge-light"; example = "edge-light";
};
setUpBar = mkOption {
type = types.bool;
default = true;
description = "Whether to set your status bar theme to 'base16'.";
}; };
setUpBar = mkOption {
type = types.bool;
default = true;
description = "Whether to set your status bar theme to 'base16'.";
}; };
};
extraConfig = cfg: extraConfig =
mkMerge [ cfg:
{ mkMerge [
plugins.airline.settings.theme = mkIf cfg.setUpBar "base16"; {
plugins.lualine.theme = mkIf cfg.setUpBar "base16"; plugins.airline.settings.theme = mkIf cfg.setUpBar "base16";
plugins.lightline.colorscheme = null; plugins.lualine.theme = mkIf cfg.setUpBar "base16";
plugins.lightline.colorscheme = null;
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) {
}) extraConfigLuaPre = ''
(mkIf (isAttrs cfg.colorscheme) { require('base16-colorscheme').setup(${helpers.toLuaObject cfg.colorscheme})
extraConfigLuaPre = '' '';
require('base16-colorscheme').setup(${helpers.toLuaObject cfg.colorscheme}) })
''; ];
}) }
];
}

View file

@ -6,44 +6,105 @@
... ...
}: }:
with lib; with lib;
helpers.neovim-plugin.mkNeovimPlugin config { helpers.neovim-plugin.mkNeovimPlugin config {
name = "catppuccin"; name = "catppuccin";
isColorscheme = true; isColorscheme = true;
defaultPackage = pkgs.vimPlugins.catppuccin-nvim; defaultPackage = pkgs.vimPlugins.catppuccin-nvim;
maintainers = [maintainers.GaetanLepage]; maintainers = [ maintainers.GaetanLepage ];
# 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"
"transparentBackground" "light"
["dimInactive" "enabled"] ]
["dimInactive" "shade"] [
["dimInactive" "percentage"] "background"
["styles" "comments"] "dark"
["styles" "conditionals"] ]
["styles" "loops"] "transparentBackground"
["styles" "functions"] [
["styles" "keywords"] "dimInactive"
["styles" "strings"] "enabled"
["styles" "variables"] ]
["styles" "numbers"] [
["styles" "booleans"] "dimInactive"
["styles" "properties"] "shade"
["styles" "types"] ]
["styles" "operators"] [
"colorOverrides" "dimInactive"
"customHighlights" "percentage"
"integrations" ]
]; [
imports = "styles"
mapAttrsToList ( "comments"
]
[
"styles"
"conditionals"
]
[
"styles"
"loops"
]
[
"styles"
"functions"
]
[
"styles"
"keywords"
]
[
"styles"
"strings"
]
[
"styles"
"variables"
]
[
"styles"
"numbers"
]
[
"styles"
"booleans"
]
[
"styles"
"properties"
]
[
"styles"
"types"
]
[
"styles"
"operators"
]
"colorOverrides"
"customHighlights"
"integrations"
];
imports =
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,33 +114,35 @@ 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
helpers.defaultNullOpts.mkEnumFirstDefault flavours '' mkBackgroundStyle =
Background for `${name}` background. name:
''; helpers.defaultNullOpts.mkEnumFirstDefault flavours ''
in { Background for `${name}` background.
light = mkBackgroundStyle "light"; '';
in
{
light = mkBackgroundStyle "light";
dark = mkBackgroundStyle "dark"; dark = mkBackgroundStyle "dark";
}; };
transparent_background = helpers.defaultNullOpts.mkBool false '' transparent_background = helpers.defaultNullOpts.mkBool false ''
Enable Transparent background. Enable Transparent background.
@ -169,19 +232,15 @@ with lib;
''; '';
}; };
color_overrides = color_overrides = genAttrs (flavours ++ [ "all" ]) (
genAttrs flavour:
(flavours ++ ["all"]) helpers.defaultNullOpts.mkAttrsOf types.str "{}" (
( if flavour == "all" then
flavour: "Override colors for all the flavours."
helpers.defaultNullOpts.mkAttrsOf types.str else
"{}" "Override colors for the ${flavour} flavour."
( )
if flavour == "all" );
then "Override colors for all the flavours."
else "Override colors for the ${flavour} flavour."
)
);
custom_highlights = helpers.mkNullOrStrLuaFnOr (with types; attrsOf anything) '' custom_highlights = helpers.mkNullOrStrLuaFnOr (with types; attrsOf anything) ''
Override specific highlight groups to use other groups or a hex color. Override specific highlight groups to use other groups or a hex color.
@ -230,29 +289,30 @@ with lib;
''; '';
}; };
settingsExample = { settingsExample = {
flavour = "mocha"; flavour = "mocha";
disable_underline = true; disable_underline = true;
term_colors = true; term_colors = true;
color_overrides.mocha.base = "#1e1e2f"; color_overrides.mocha.base = "#1e1e2f";
styles = { styles = {
booleans = ["bold" "italic"]; booleans = [
conditionals = ["bold"]; "bold"
}; "italic"
integrations = { ];
cmp = true; conditionals = [ "bold" ];
gitsigns = true; };
nvimtree = true; integrations = {
treesitter = true; cmp = true;
notify = false; gitsigns = true;
mini = { nvimtree = true;
enabled = true; treesitter = true;
indentscope_color = ""; notify = false;
}; mini = {
enabled = true;
indentscope_color = "";
}; };
}; };
};
extraConfig = cfg: { extraConfig = cfg: { opts.termguicolors = mkDefault true; };
opts.termguicolors = mkDefault true; }
};
}

View file

@ -6,83 +6,83 @@
... ...
}: }:
with lib; with lib;
helpers.neovim-plugin.mkNeovimPlugin config { helpers.neovim-plugin.mkNeovimPlugin config {
name = "cyberdream"; name = "cyberdream";
isColorscheme = true; isColorscheme = true;
originalName = "cyberdream.nvim"; originalName = "cyberdream.nvim";
defaultPackage = pkgs.vimPlugins.cyberdream-nvim; defaultPackage = pkgs.vimPlugins.cyberdream-nvim;
maintainers = [helpers.maintainers.AndresBermeoMarinelli]; maintainers = [ helpers.maintainers.AndresBermeoMarinelli ];
settingsOptions = { settingsOptions = {
transparent = helpers.defaultNullOpts.mkBool false '' transparent = helpers.defaultNullOpts.mkBool false ''
Enable transparent background. Enable transparent background.
''; '';
italic_comments = helpers.defaultNullOpts.mkBool false '' italic_comments = helpers.defaultNullOpts.mkBool false ''
Enable italics comments. Enable italics comments.
''; '';
hide_fillchars = helpers.defaultNullOpts.mkBool false '' hide_fillchars = helpers.defaultNullOpts.mkBool false ''
Replace all fillchars with ' ' for the ultimate clean look. Replace all fillchars with ' ' for the ultimate clean look.
''; '';
borderless_telescope = helpers.defaultNullOpts.mkBool true '' borderless_telescope = helpers.defaultNullOpts.mkBool true ''
Modern borderless telescope theme. Modern borderless telescope theme.
''; '';
terminal_colors = helpers.defaultNullOpts.mkBool true '' terminal_colors = helpers.defaultNullOpts.mkBool true ''
Set terminal colors used in `:terminal`. Set terminal colors used in `:terminal`.
''; '';
theme = { theme = {
highlights = helpers.defaultNullOpts.mkAttrsOf helpers.nixvimTypes.highlight "{}" '' highlights = helpers.defaultNullOpts.mkAttrsOf helpers.nixvimTypes.highlight "{}" ''
Highlight groups to override, adding new groups is also possible. Highlight groups to override, adding new groups is also possible.
See `:h highlight-groups` for a list of highlight groups. See `:h highlight-groups` for a list of highlight groups.
Example: Example:
```nix ```nix
{ {
Comment = {
fg = "#696969";
bg = "NONE";
italic = true;
};
}
```
Complete list can be found in `lua/cyberdream/theme.lua` in upstream repository.
'';
colors = helpers.defaultNullOpts.mkAttrsOf types.str "{}" ''
Override the default colors used.
For a full list of colors, see upstream documentation.
'';
};
};
settingsExample = {
transparent = true;
italic_comments = true;
hide_fillchars = true;
borderless_telescope = true;
terminal_colors = true;
theme = {
highlights = {
Comment = { Comment = {
fg = "#696969"; fg = "#696969";
bg = "NONE"; bg = "NONE";
italic = true; italic = true;
}; };
}; }
colors = { ```
bg = "#000000";
green = "#00ff00"; Complete list can be found in `lua/cyberdream/theme.lua` in upstream repository.
magenta = "#ff00ff"; '';
colors = helpers.defaultNullOpts.mkAttrsOf types.str "{}" ''
Override the default colors used.
For a full list of colors, see upstream documentation.
'';
};
};
settingsExample = {
transparent = true;
italic_comments = true;
hide_fillchars = true;
borderless_telescope = true;
terminal_colors = true;
theme = {
highlights = {
Comment = {
fg = "#696969";
bg = "NONE";
italic = true;
}; };
}; };
colors = {
bg = "#000000";
green = "#00ff00";
magenta = "#ff00ff";
};
}; };
} };
}

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";
@ -63,7 +65,7 @@ in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
colorscheme = "dracula"; colorscheme = "dracula";
extraPlugins = [cfg.package]; extraPlugins = [ cfg.package ];
globals = { globals = {
dracula_bold = mkIf (!cfg.bold) 0; dracula_bold = mkIf (!cfg.bold) 0;

View file

@ -11,41 +11,43 @@ helpers.neovim-plugin.mkNeovimPlugin config {
originalName = "gruvbox.nvim"; originalName = "gruvbox.nvim";
defaultPackage = pkgs.vimPlugins.gruvbox-nvim; defaultPackage = pkgs.vimPlugins.gruvbox-nvim;
maintainers = [lib.maintainers.GaetanLepage]; maintainers = [ lib.maintainers.GaetanLepage ];
# Introduced January 31 2024 # Introduced January 31 2024
# TODO remove in early March 2024. # TODO remove in early March 2024.
imports = imports =
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" )
"bold" [
"underline" "italics"
"undercurl" "bold"
"contrastDark" "underline"
"contrastLight" "undercurl"
"highlightSearchCursor" "contrastDark"
"numberColumn" "contrastLight"
"signColumn" "highlightSearchCursor"
"colorColumn" "numberColumn"
"vertSplitColor" "signColumn"
"italicizeComments" "colorColumn"
"italicizeStrings" "vertSplitColor"
"invertSelection" "italicizeComments"
"invertSigns" "italicizeStrings"
"invertIndentGuides" "invertSelection"
"invertTabline" "invertSigns"
"improvedStrings" "invertIndentGuides"
"improvedWarnings" "invertTabline"
"transparentBg" "improvedStrings"
"trueColor" "improvedWarnings"
]; "transparentBg"
"trueColor"
];
settingsExample = { settingsExample = {
terminal_colors = true; terminal_colors = true;

View file

@ -6,110 +6,121 @@
... ...
}: }:
with lib; with lib;
helpers.neovim-plugin.mkNeovimPlugin config { helpers.neovim-plugin.mkNeovimPlugin config {
name = "kanagawa"; name = "kanagawa";
isColorscheme = true; isColorscheme = true;
originalName = "kanagawa.nvim"; originalName = "kanagawa.nvim";
defaultPackage = pkgs.vimPlugins.kanagawa-nvim; defaultPackage = pkgs.vimPlugins.kanagawa-nvim;
description = '' description = ''
You can select the theme in two ways: You can select the theme in two ways:
- Set `colorschemes.kanagawa.settings.theme` AND explicitly unset `vim.o.background` (i.e. `options.background = ""`). - Set `colorschemes.kanagawa.settings.theme` AND explicitly unset `vim.o.background` (i.e. `options.background = ""`).
- Set `colorschemes.kanagawa.settings.background` (the active theme will depend on the value of `vim.o.background`). - Set `colorschemes.kanagawa.settings.background` (the active theme will depend on the value of `vim.o.background`).
'';
maintainers = [ maintainers.GaetanLepage ];
# TODO introduced 2024-03-15: remove 2024-05-15
deprecateExtraOptions = true;
imports =
let
basePluginPath = [
"colorschemes"
"kanagawa"
];
in
(map
(
optionPath:
mkRenamedOptionModule (basePluginPath ++ optionPath) (
basePluginPath ++ [ "settings" ] ++ optionPath
)
)
[
[ "compile" ]
[ "undercurl" ]
[ "commentStyle" ]
[ "functionStyle" ]
[ "keywordStyle" ]
[ "statementStyle" ]
[ "typeStyle" ]
[ "transparent" ]
[ "dimInactive" ]
[ "terminalColors" ]
[
"colors"
"palette"
]
[
"colors"
"theme"
]
[ "theme" ]
[
"background"
"dark"
]
[
"background"
"light"
]
]
)
++ [
(mkRemovedOptionModule (basePluginPath ++ [ "overrides" ]) ''
Use `colorschemes.kanagawa.settings.overrides` but you now have to add the full function definition:
```
function(colors)
...
end
```
'')
];
settingsOptions = {
compile = helpers.defaultNullOpts.mkBool false ''
Enable compiling the colorscheme.
''; '';
maintainers = [maintainers.GaetanLepage]; undercurl = helpers.defaultNullOpts.mkBool true ''
Enable undercurls.
'';
# TODO introduced 2024-03-15: remove 2024-05-15 commentStyle = helpers.defaultNullOpts.mkAttrsOf types.anything "{italic = true;}" ''
deprecateExtraOptions = true; Highlight options for comments.
imports = let '';
basePluginPath = ["colorschemes" "kanagawa"];
in
(
map
(
optionPath:
mkRenamedOptionModule
(basePluginPath ++ optionPath)
(basePluginPath ++ ["settings"] ++ optionPath)
)
[
["compile"]
["undercurl"]
["commentStyle"]
["functionStyle"]
["keywordStyle"]
["statementStyle"]
["typeStyle"]
["transparent"]
["dimInactive"]
["terminalColors"]
["colors" "palette"]
["colors" "theme"]
["theme"]
["background" "dark"]
["background" "light"]
]
)
++ [
(
mkRemovedOptionModule
(basePluginPath ++ ["overrides"])
''
Use `colorschemes.kanagawa.settings.overrides` but you now have to add the full function definition:
```
function(colors)
...
end
```
''
)
];
settingsOptions = { functionStyle = helpers.defaultNullOpts.mkAttrsOf types.anything "{}" ''
compile = helpers.defaultNullOpts.mkBool false '' Highlight options for functions.
Enable compiling the colorscheme. '';
'';
undercurl = helpers.defaultNullOpts.mkBool true '' keywordStyle = helpers.defaultNullOpts.mkAttrsOf types.anything "{italic = true;}" ''
Enable undercurls. Highlight options for keywords.
''; '';
commentStyle = helpers.defaultNullOpts.mkAttrsOf types.anything "{italic = true;}" '' statementStyle = helpers.defaultNullOpts.mkAttrsOf types.anything "{bold = true;}" ''
Highlight options for comments. Highlight options for statements.
''; '';
functionStyle = helpers.defaultNullOpts.mkAttrsOf types.anything "{}" '' typeStyle = helpers.defaultNullOpts.mkAttrsOf types.anything "{}" ''
Highlight options for functions. Highlight options for types.
''; '';
keywordStyle = helpers.defaultNullOpts.mkAttrsOf types.anything "{italic = true;}" '' transparent = helpers.defaultNullOpts.mkBool false ''
Highlight options for keywords. Whether to set a background color.
''; '';
statementStyle = helpers.defaultNullOpts.mkAttrsOf types.anything "{bold = true;}" '' dimInactive = helpers.defaultNullOpts.mkBool false ''
Highlight options for statements. Whether dim inactive window `:h hl-NormalNC`.
''; '';
typeStyle = helpers.defaultNullOpts.mkAttrsOf types.anything "{}" '' terminalColors = helpers.defaultNullOpts.mkBool true ''
Highlight options for types. If true, defines `vim.g.terminal_color_{0,17}`.
''; '';
transparent = helpers.defaultNullOpts.mkBool false '' colors = {
Whether to set a background color. theme =
''; helpers.defaultNullOpts.mkAttrsOf types.attrs
dimInactive = helpers.defaultNullOpts.mkBool false ''
Whether dim inactive window `:h hl-NormalNC`.
'';
terminalColors = helpers.defaultNullOpts.mkBool true ''
If true, defines `vim.g.terminal_color_{0,17}`.
'';
colors = {
theme =
helpers.defaultNullOpts.mkAttrsOf types.attrs
'' ''
{ {
wave = {}; wave = {};
@ -145,21 +156,21 @@ with lib;
``` ```
''; '';
palette = helpers.defaultNullOpts.mkAttrsOf types.str "{}" '' palette = helpers.defaultNullOpts.mkAttrsOf types.str "{}" ''
Change all usages of these colors. Change all usages of these colors.
Example: Example:
```nix ```nix
{ {
sumiInk0 = "#000000"; sumiInk0 = "#000000";
fujiWhite = "#FFFFFF"; fujiWhite = "#FFFFFF";
} }
``` ```
''; '';
}; };
overrides = overrides =
helpers.defaultNullOpts.mkLuaFn helpers.defaultNullOpts.mkLuaFn
'' ''
function(colors) function(colors)
return {} return {}
@ -189,41 +200,41 @@ with lib;
``` ```
''; '';
theme = helpers.defaultNullOpts.mkStr "wave" '' theme = helpers.defaultNullOpts.mkStr "wave" ''
The theme to load when background is not set. The theme to load when background is not set.
'';
background = {
light = helpers.defaultNullOpts.mkStr "lotus" ''
The theme to use when `vim.o.background = "light"`.
''; '';
background = { dark = helpers.defaultNullOpts.mkStr "wave" ''
light = helpers.defaultNullOpts.mkStr "lotus" '' The theme to use when `vim.o.background = "dark"`.
The theme to use when `vim.o.background = "light"`. '';
''; };
};
dark = helpers.defaultNullOpts.mkStr "wave" '' settingsExample = {
The theme to use when `vim.o.background = "dark"`. compile = false;
''; undercurl = true;
commentStyle.italic = true;
functionStyle = { };
transparent = false;
dimInactive = false;
terminalColors = true;
colors = {
theme = {
wave.ui.float.bg = "none";
dragon.syn.parameter = "yellow";
all.ui.bg_gutter = "none";
};
palette = {
sumiInk0 = "#000000";
fujiWhite = "#FFFFFF";
}; };
}; };
overrides = "function(colors) return {} end";
settingsExample = { theme = "wave";
compile = false; };
undercurl = true; }
commentStyle.italic = true;
functionStyle = {};
transparent = false;
dimInactive = false;
terminalColors = true;
colors = {
theme = {
wave.ui.float.bg = "none";
dragon.syn.parameter = "yellow";
all.ui.bg_gutter = "none";
};
palette = {
sumiInk0 = "#000000";
fujiWhite = "#FFFFFF";
};
};
overrides = "function(colors) return {} end";
theme = "wave";
};
}

View file

@ -6,15 +6,13 @@
... ...
}: }:
with lib; with lib;
helpers.vim-plugin.mkVimPlugin config { helpers.vim-plugin.mkVimPlugin config {
name = "melange"; name = "melange";
isColorscheme = true; isColorscheme = true;
originalName = "melange-nvim"; originalName = "melange-nvim";
defaultPackage = pkgs.vimPlugins.melange-nvim; defaultPackage = pkgs.vimPlugins.melange-nvim;
maintainers = [maintainers.GaetanLepage]; maintainers = [ maintainers.GaetanLepage ];
extraConfig = cfg: { extraConfig = cfg: { opts.termguicolors = mkDefault true; };
opts.termguicolors = mkDefault true; }
};
}

View file

@ -12,7 +12,7 @@ helpers.vim-plugin.mkVimPlugin config {
defaultPackage = pkgs.vimPlugins.nord-nvim; defaultPackage = pkgs.vimPlugins.nord-nvim;
globalPrefix = "nord_"; globalPrefix = "nord_";
maintainers = [lib.maintainers.GaetanLepage]; maintainers = [ lib.maintainers.GaetanLepage ];
# TODO introduced 2024-02-20: remove 2024-04-20 # TODO introduced 2024-02-20: remove 2024-04-20
deprecateExtraConfig = true; deprecateExtraConfig = true;

View file

@ -12,7 +12,7 @@ helpers.vim-plugin.mkVimPlugin config {
defaultPackage = pkgs.vimPlugins.vim-one; defaultPackage = pkgs.vimPlugins.vim-one;
globalPrefix = "one_"; globalPrefix = "one_";
maintainers = [lib.maintainers.GaetanLepage]; maintainers = [ lib.maintainers.GaetanLepage ];
settingsOptions = { settingsOptions = {
allow_italics = helpers.defaultNullOpts.mkBool false '' allow_italics = helpers.defaultNullOpts.mkBool false ''
@ -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

@ -11,7 +11,7 @@ helpers.neovim-plugin.mkNeovimPlugin config {
originalName = "onedark.nvim"; originalName = "onedark.nvim";
defaultPackage = pkgs.vimPlugins.onedark-nvim; defaultPackage = pkgs.vimPlugins.onedark-nvim;
maintainers = [lib.maintainers.GaetanLepage]; maintainers = [ lib.maintainers.GaetanLepage ];
settingsExample = { settingsExample = {
colors = { colors = {

View file

@ -11,9 +11,7 @@ helpers.vim-plugin.mkVimPlugin config {
originalName = "oxocarbon.nvim"; originalName = "oxocarbon.nvim";
defaultPackage = pkgs.vimPlugins.oxocarbon-nvim; defaultPackage = pkgs.vimPlugins.oxocarbon-nvim;
maintainers = [lib.maintainers.GaetanLepage]; maintainers = [ lib.maintainers.GaetanLepage ];
extraConfig = cfg: { extraConfig = cfg: { opts.termguicolors = lib.mkDefault true; };
opts.termguicolors = lib.mkDefault true;
};
} }

View file

@ -6,70 +6,67 @@
... ...
}: }:
with lib; with lib;
helpers.neovim-plugin.mkNeovimPlugin config { helpers.neovim-plugin.mkNeovimPlugin config {
name = "palette"; name = "palette";
isColorscheme = true; isColorscheme = true;
originalName = "palette.nvim"; originalName = "palette.nvim";
defaultPackage = pkgs.vimPlugins.palette-nvim; defaultPackage = pkgs.vimPlugins.palette-nvim;
maintainers = [maintainers.GaetanLepage]; maintainers = [ maintainers.GaetanLepage ];
extraPlugins = [ extraPlugins = [
# Annoyingly, lspconfig is required, otherwise this line is breaking: # Annoyingly, lspconfig is required, otherwise this line is breaking:
# https://github.com/roobert/palette.nvim/blob/a808c190a4f74f73782302152ebf323660d8db5f/lua/palette/init.lua#L45 # https://github.com/roobert/palette.nvim/blob/a808c190a4f74f73782302152ebf323660d8db5f/lua/palette/init.lua#L45
# An issue has been opened upstream to warn the maintainer: https://github.com/roobert/palette.nvim/issues/2 # An issue has been opened upstream to warn the maintainer: https://github.com/roobert/palette.nvim/issues/2
pkgs.vimPlugins.nvim-lspconfig pkgs.vimPlugins.nvim-lspconfig
]; ];
# TODO introduced 2024-04-07: remove 2024-06-07 # TODO introduced 2024-04-07: remove 2024-06-07
deprecateExtraOptions = true; deprecateExtraOptions = true;
optionsRenamedToSettings = [ optionsRenamedToSettings = [
"palettes" "palettes"
"customPalettes" "customPalettes"
"italics" "italics"
"transparentBackground" "transparentBackground"
"caching" "caching"
"cacheDir" "cacheDir"
]; ];
settingsOptions = { settingsOptions = {
palettes = { palettes = {
main = helpers.defaultNullOpts.mkStr "dark" '' main = helpers.defaultNullOpts.mkStr "dark" ''
Palette for the main colors. Palette for the main colors.
''; '';
accent = helpers.defaultNullOpts.mkStr "pastel" '' accent = helpers.defaultNullOpts.mkStr "pastel" ''
Palette for the accent colors. Palette for the accent colors.
''; '';
state = helpers.defaultNullOpts.mkStr "pastel" '' state = helpers.defaultNullOpts.mkStr "pastel" ''
Palette for the state colors. Palette for the state colors.
''; '';
}; };
customPalettes = customPalettes =
mapAttrs mapAttrs
( (
name: colorNames: name: colorNames:
helpers.defaultNullOpts.mkAttrsOf ( helpers.defaultNullOpts.mkAttrsOf
types.submodule { (types.submodule {
options = options = genAttrs colorNames (
genAttrs colorName:
colorNames mkOption {
( type = types.str;
colorName: description = "Definition of color '${colorName}'";
mkOption { }
type = types.str; );
description = "Definition of color '${colorName}'"; })
}
);
}
)
"{}" "{}"
'' ''
Custom palettes for ${name} colors. Custom palettes for ${name} colors.
'' ''
) { )
{
main = [ main = [
"color0" "color0"
"color1" "color1"
@ -101,35 +98,35 @@ with lib;
]; ];
}; };
italics = helpers.defaultNullOpts.mkBool true '' italics = helpers.defaultNullOpts.mkBool true ''
Whether to use italics. Whether to use italics.
''; '';
transparent_background = helpers.defaultNullOpts.mkBool false '' transparent_background = helpers.defaultNullOpts.mkBool false ''
Whether to use transparent background. Whether to use transparent background.
''; '';
caching = helpers.defaultNullOpts.mkBool true '' caching = helpers.defaultNullOpts.mkBool true ''
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

@ -6,68 +6,68 @@
... ...
}: }:
with lib; with lib;
helpers.neovim-plugin.mkNeovimPlugin config { helpers.neovim-plugin.mkNeovimPlugin config {
name = "poimandres"; name = "poimandres";
isColorscheme = true; isColorscheme = true;
originalName = "poimandres.nvim"; originalName = "poimandres.nvim";
defaultPackage = pkgs.vimPlugins.poimandres-nvim; defaultPackage = pkgs.vimPlugins.poimandres-nvim;
maintainers = [maintainers.GaetanLepage]; maintainers = [ maintainers.GaetanLepage ];
# TODO introduced 2024-04-15: remove 2024-06-15 # TODO introduced 2024-04-15: remove 2024-06-15
deprecateExtraOptions = true; deprecateExtraOptions = true;
optionsRenamedToSettings = [ optionsRenamedToSettings = [
"boldVertSplit" "boldVertSplit"
"darkVariant" "darkVariant"
"disableBackground" "disableBackground"
"disableFloatBackground" "disableFloatBackground"
"disableItalics" "disableItalics"
"dimNcBackground" "dimNcBackground"
"groups" "groups"
"highlightGroups" "highlightGroups"
]; ];
settingsOptions = { settingsOptions = {
bold_vert_split = helpers.defaultNullOpts.mkBool false '' bold_vert_split = helpers.defaultNullOpts.mkBool false ''
Use bold vertical separators. Use bold vertical separators.
''; '';
dim_nc_background = helpers.defaultNullOpts.mkBool false '' dim_nc_background = helpers.defaultNullOpts.mkBool false ''
Dim 'non-current' window backgrounds. Dim 'non-current' window backgrounds.
''; '';
disable_background = helpers.defaultNullOpts.mkBool false '' disable_background = helpers.defaultNullOpts.mkBool false ''
Whether to disable the background. Whether to disable the background.
''; '';
disable_float_background = helpers.defaultNullOpts.mkBool false '' disable_float_background = helpers.defaultNullOpts.mkBool false ''
Whether to disable the background for floats. Whether to disable the background for floats.
''; '';
disable_italics = helpers.defaultNullOpts.mkBool false '' disable_italics = helpers.defaultNullOpts.mkBool false ''
Whether to disable italics. Whether to disable italics.
''; '';
dark_variant = helpers.defaultNullOpts.mkStr "main" '' dark_variant = helpers.defaultNullOpts.mkStr "main" ''
Dark variant. Dark variant.
''; '';
groups = helpers.mkNullOrOption (with types; attrsOf (either str (attrsOf str))) '' groups = helpers.mkNullOrOption (with types; attrsOf (either str (attrsOf str))) ''
Which color to use for each group. Which color to use for each group.
default: see [source](https://github.com/olivercederborg/poimandres.nvim/blob/main/lua/poimandres/init.lua) default: see [source](https://github.com/olivercederborg/poimandres.nvim/blob/main/lua/poimandres/init.lua)
''; '';
highlight_groups = helpers.defaultNullOpts.mkAttrsOf types.str "{}" '' highlight_groups = helpers.defaultNullOpts.mkAttrsOf types.str "{}" ''
Highlight groups. Highlight groups.
''; '';
}; };
settingsExample = { settingsExample = {
bold_vert_split = false; bold_vert_split = false;
dim_nc_background = true; dim_nc_background = true;
disable_background = false; disable_background = false;
disable_float_background = false; disable_float_background = false;
disable_italics = true; disable_italics = true;
}; };
} }

View file

@ -6,136 +6,155 @@
... ...
}: }:
with lib; with lib;
helpers.neovim-plugin.mkNeovimPlugin config { helpers.neovim-plugin.mkNeovimPlugin config {
name = "rose-pine"; name = "rose-pine";
isColorscheme = true; isColorscheme = true;
defaultPackage = pkgs.vimPlugins.rose-pine; defaultPackage = pkgs.vimPlugins.rose-pine;
maintainers = [maintainers.GaetanLepage]; maintainers = [ maintainers.GaetanLepage ];
# TODO introduced 2024-04-15: remove 2024-06-15 # TODO introduced 2024-04-15: remove 2024-06-15
optionsRenamedToSettings = [ optionsRenamedToSettings = [
"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 =
Set the desired variant: "auto" will follow the vim background, defaulting to `dark_variant` helpers.mkNullOrOption
or "main" for dark and "dawn" for light. (types.enum [
''; "auto"
"main"
"moon"
"dawn"
])
''
Set the desired variant: "auto" will follow the vim background, defaulting to `dark_variant`
or "main" for dark and "dawn" for light.
'';
dark_variant = helpers.defaultNullOpts.mkEnumFirstDefault ["main" "moon" "dawn"] '' dark_variant =
Set the desired dark variant when `settings.variant` is set to "auto". helpers.defaultNullOpts.mkEnumFirstDefault
''; [
"main"
"moon"
"dawn"
]
''
Set the desired dark variant when `settings.variant` is set to "auto".
'';
dim_inactive_windows = helpers.defaultNullOpts.mkBool false '' dim_inactive_windows = helpers.defaultNullOpts.mkBool false ''
Differentiate between active and inactive windows and panels. Differentiate between active and inactive windows and panels.
''; '';
extend_background_behind_borders = helpers.defaultNullOpts.mkBool true '' extend_background_behind_borders = helpers.defaultNullOpts.mkBool true ''
Extend background behind borders. Extend background behind borders.
Appearance differs based on which border characters you are using. Appearance differs based on which border characters you are using.
''; '';
enable = { enable = {
legacy_highlights = helpers.defaultNullOpts.mkBool true "Enable legacy highlights."; legacy_highlights = helpers.defaultNullOpts.mkBool true "Enable legacy highlights.";
migrations = helpers.defaultNullOpts.mkBool true "Enable migrations."; migrations = helpers.defaultNullOpts.mkBool true "Enable migrations.";
terminal = helpers.defaultNullOpts.mkBool true "Enable terminal."; terminal = helpers.defaultNullOpts.mkBool true "Enable terminal.";
};
styles = {
bold = helpers.defaultNullOpts.mkBool true "Enable bold.";
italic = helpers.defaultNullOpts.mkBool true "Enable italic.";
transparency = helpers.defaultNullOpts.mkBool true "Enable transparency.";
};
groups = helpers.mkNullOrOption (with types; attrsOf (either str (attrsOf str))) ''
Highlight groups.
default: see [source](https://github.com/rose-pine/neovim/blob/main/lua/rose-pine/config.lua)
'';
highlight_groups = helpers.defaultNullOpts.mkAttrsOf helpers.nixvimTypes.highlight "{}" ''
Custom highlight groups.
'';
before_highlight = helpers.defaultNullOpts.mkLuaFn "function(group, highlight, palette) end" ''
Called before each highlight group, before setting the highlight.
`function(group, highlight, palette)`
```lua
@param group string
@param highlight Highlight
@param palette Palette
```
'';
}; };
settingsExample = { styles = {
variant = "auto"; bold = helpers.defaultNullOpts.mkBool true "Enable bold.";
dark_variant = "moon";
dim_inactive_windows = true; italic = helpers.defaultNullOpts.mkBool true "Enable italic.";
extend_background_behind_borders = true;
enable = { transparency = helpers.defaultNullOpts.mkBool true "Enable transparency.";
legacy_highlights = false;
migrations = true;
terminal = false;
};
styles = {
bold = false;
italic = true;
transparency = true;
};
groups = {
border = "muted";
link = "iris";
panel = "surface";
};
highlight_groups = {};
before_highlight = "function(group, highlight, palette) end";
}; };
extraConfig = cfg: { groups = helpers.mkNullOrOption (with types; attrsOf (either str (attrsOf str))) ''
opts.termguicolors = mkDefault true; Highlight groups.
default: see [source](https://github.com/rose-pine/neovim/blob/main/lua/rose-pine/config.lua)
'';
highlight_groups = helpers.defaultNullOpts.mkAttrsOf helpers.nixvimTypes.highlight "{}" ''
Custom highlight groups.
'';
before_highlight = helpers.defaultNullOpts.mkLuaFn "function(group, highlight, palette) end" ''
Called before each highlight group, before setting the highlight.
`function(group, highlight, palette)`
```lua
@param group string
@param highlight Highlight
@param palette Palette
```
'';
};
settingsExample = {
variant = "auto";
dark_variant = "moon";
dim_inactive_windows = true;
extend_background_behind_borders = true;
enable = {
legacy_highlights = false;
migrations = true;
terminal = false;
}; };
} styles = {
bold = false;
italic = true;
transparency = true;
};
groups = {
border = "muted";
link = "iris";
panel = "surface";
};
highlight_groups = { };
before_highlight = "function(group, highlight, palette) end";
};
extraConfig = cfg: { opts.termguicolors = mkDefault true; };
}

View file

@ -6,56 +6,87 @@
... ...
}: }:
with lib; with lib;
helpers.neovim-plugin.mkNeovimPlugin config { helpers.neovim-plugin.mkNeovimPlugin config {
name = "tokyonight"; name = "tokyonight";
isColorscheme = true; isColorscheme = true;
originalName = "tokyonight.nvim"; originalName = "tokyonight.nvim";
defaultPackage = pkgs.vimPlugins.tokyonight-nvim; defaultPackage = pkgs.vimPlugins.tokyonight-nvim;
maintainers = [maintainers.GaetanLepage]; maintainers = [ maintainers.GaetanLepage ];
# TODO introduced 2024-04-15: remove 2024-06-15 # TODO introduced 2024-04-15: remove 2024-06-15
optionsRenamedToSettings = [ optionsRenamedToSettings = [
"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" "sidebars"
"dayBrightness" ]
"hideInactiveStatusline" [
"dimInactive" "styles"
"lualineBold" "floats"
"onColors" ]
"onHighlights" "sidebars"
]; "dayBrightness"
"hideInactiveStatusline"
"dimInactive"
"lualineBold"
"onColors"
"onHighlights"
];
settingsOptions = { settingsOptions = {
style = helpers.defaultNullOpts.mkEnumFirstDefault ["storm" "night" "day"] '' style =
The theme comes in three styles, `storm`, a darker variant `night` and `day`. helpers.defaultNullOpts.mkEnumFirstDefault
''; [
"storm"
"night"
"day"
]
''
The theme comes in three styles, `storm`, a darker variant `night` and `day`.
'';
light_style = helpers.defaultNullOpts.mkStr "day" '' light_style = helpers.defaultNullOpts.mkStr "day" ''
The theme to use when the background is set to `light`. The theme to use when the background is set to `light`.
''; '';
transparent = helpers.defaultNullOpts.mkBool false '' transparent = helpers.defaultNullOpts.mkBool false ''
Disable setting the background color. Disable setting the background color.
''; '';
terminal_colors = helpers.defaultNullOpts.mkBool true '' terminal_colors = helpers.defaultNullOpts.mkBool true ''
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.
''; '';
@ -77,65 +108,68 @@ with lib;
floats = mkBackgroundStyle "floats"; floats = mkBackgroundStyle "floats";
}; };
sidebars = helpers.defaultNullOpts.mkListOf types.str ''["qf" "help"]'' '' sidebars = helpers.defaultNullOpts.mkListOf types.str ''["qf" "help"]'' ''
Set a darker background on sidebar-like windows. Set a darker background on sidebar-like windows.
''; '';
day_brightness = helpers.defaultNullOpts.mkNullable (types.numbers.between 0.0 1.0) "0.3" '' day_brightness = helpers.defaultNullOpts.mkNullable (types.numbers.between 0.0 1.0) "0.3" ''
Adjusts the brightness of the colors of the **Day** style. Adjusts the brightness of the colors of the **Day** style.
Number between 0 and 1, from dull to vibrant colors. Number between 0 and 1, from dull to vibrant colors.
''; '';
hide_inactive_statusline = helpers.defaultNullOpts.mkBool false '' hide_inactive_statusline = helpers.defaultNullOpts.mkBool false ''
Enabling this option will hide inactive statuslines and replace them with a thin border instead. Enabling this option will hide inactive statuslines and replace them with a thin border instead.
Should work with the standard **StatusLine** and **LuaLine**. Should work with the standard **StatusLine** and **LuaLine**.
''; '';
dim_inactive = helpers.defaultNullOpts.mkBool false '' dim_inactive = helpers.defaultNullOpts.mkBool false ''
Dims inactive windows. Dims inactive windows.
''; '';
lualine_bold = helpers.defaultNullOpts.mkBool false '' lualine_bold = helpers.defaultNullOpts.mkBool false ''
When true, section headers in the lualine theme will be bold. When true, section headers in the lualine theme will be bold.
''; '';
on_colors = helpers.defaultNullOpts.mkLuaFn "function(colors) end" '' on_colors = helpers.defaultNullOpts.mkLuaFn "function(colors) end" ''
Override specific color groups to use other groups or a hex color. Override specific color groups to use other groups or a hex color.
Function will be called with a `ColorScheme` table. Function will be called with a `ColorScheme` table.
`@param colors ColorScheme` `@param colors ColorScheme`
''; '';
on_highlights = helpers.defaultNullOpts.mkLuaFn "function(highlights, colors) end" '' on_highlights = helpers.defaultNullOpts.mkLuaFn "function(highlights, colors) end" ''
Override specific highlights to use other groups or a hex color. Override specific highlights to use other groups or a hex color.
Function will be called with a `Highlights` and `ColorScheme` table. Function will be called with a `Highlights` and `ColorScheme` table.
`@param highlights Highlights` `@param highlights Highlights`
`@param colors ColorScheme` `@param colors ColorScheme`
''; '';
};
settingsExample = {
style = "storm";
light_style = "day";
transparent = false;
terminal_colors = true;
styles = {
comments.italic = true;
keywords.italic = true;
functions = { };
variables = { };
sidebars = "dark";
floats = "dark";
}; };
sidebars = [
"qf"
"vista_kind"
"terminal"
"packer"
];
day_brightness = 0.3;
hide_inactive_statusline = false;
dim_inactive = false;
lualine_bold = false;
on_colors = "function(colors) end";
on_highlights = "function(highlights, colors) end";
};
settingsExample = { extraConfig = cfg: { opts.termguicolors = mkDefault true; };
style = "storm"; }
light_style = "day";
transparent = false;
terminal_colors = true;
styles = {
comments.italic = true;
keywords.italic = true;
functions = {};
variables = {};
sidebars = "dark";
floats = "dark";
};
sidebars = ["qf" "vista_kind" "terminal" "packer"];
day_brightness = 0.3;
hide_inactive_statusline = false;
dim_inactive = false;
lualine_bold = false;
on_colors = "function(colors) end";
on_highlights = "function(highlights, colors) end";
};
extraConfig = cfg: {
opts.termguicolors = mkDefault true;
};
}

View file

@ -6,42 +6,38 @@
... ...
}: }:
with lib; with lib;
helpers.neovim-plugin.mkNeovimPlugin config { helpers.neovim-plugin.mkNeovimPlugin config {
name = "vscode"; name = "vscode";
isColorscheme = true; isColorscheme = true;
originalName = "vscode-nvim"; originalName = "vscode-nvim";
defaultPackage = pkgs.vimPlugins.vscode-nvim; defaultPackage = pkgs.vimPlugins.vscode-nvim;
colorscheme = null; # Color scheme is set by `require.("vscode").load()` colorscheme = null; # Color scheme is set by `require.("vscode").load()`
callSetup = false; callSetup = false;
maintainers = [maintainers.loicreynier]; maintainers = [ maintainers.loicreynier ];
settingsOptions = { settingsOptions = {
transparent = helpers.defaultNullOpts.mkBool false "Whether to enable transparent background"; transparent = helpers.defaultNullOpts.mkBool false "Whether to enable transparent background";
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.
"{}" See https://github.com/Mofiqul/vscode.nvim/blob/main/lua/vscode/colors.lua for color names.
'' '';
A dictionary of color overrides. group_overrides =
See https://github.com/Mofiqul/vscode.nvim/blob/main/lua/vscode/colors.lua for color names. with helpers;
''; defaultNullOpts.mkAttrsOf nixvimTypes.highlight "{}" ''
group_overrides = with helpers; A dictionary of group names, each associated with a dictionary of parameters
defaultNullOpts.mkAttrsOf nixvimTypes.highlight (`bg`, `fg`, `sp` and `style`) and colors in hex.
"{}"
''
A dictionary of group names, each associated with a dictionary of parameters
(`bg`, `fg`, `sp` and `style`) and colors in hex.
'';
};
extraConfig = cfg: {
extraConfigLuaPre = ''
local _vscode = require("vscode")
_vscode.setup(${helpers.toLuaObject cfg.settings})
_vscode.load()
''; '';
}; };
}
extraConfig = cfg: {
extraConfigLuaPre = ''
local _vscode = require("vscode")
_vscode.setup(${helpers.toLuaObject cfg.settings})
_vscode.load()
'';
};
}

View file

@ -6,81 +6,61 @@
... ...
}: }:
with helpers.vim-plugin; with helpers.vim-plugin;
with lib; rec { with lib;
mkCmpSourcePlugin = { rec {
name, mkCmpSourcePlugin =
extraPlugins ? [], {
useDefaultPackage ? true, name,
... extraPlugins ? [ ],
}: useDefaultPackage ? true,
...
}:
mkVimPlugin config { mkVimPlugin config {
inherit name; inherit name;
extraPlugins = extraPlugins ++ (lists.optional useDefaultPackage pkgs.vimPlugins.${name}); extraPlugins = extraPlugins ++ (lists.optional useDefaultPackage pkgs.vimPlugins.${name});
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.setup.sources cfg:
setupSources = extractSourcesFromOptionValue cfg.settings.sources; let
# cfg.filetype.<name>.sources # cfg.setup.sources
filetypeSources = setupSources = extractSourcesFromOptionValue cfg.settings.sources;
mapAttrsToList # cfg.filetype.<name>.sources
(_: filetypeConfig: filetypeSources = mapAttrsToList (
extractSourcesFromOptionValue filetypeConfig.sources) _: filetypeConfig: extractSourcesFromOptionValue filetypeConfig.sources
cfg.filetype; ) 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' name = pluginName;
( value.enable = mkIf (elem sourceName foundSources) true;
sourceName: pluginName: { }) (import ./sources.nix);
name = pluginName;
value.enable =
mkIf
(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())
''; '';
}; };
in in
mkMerge [ mkMerge [
(mkIf cfg.autoEnableSources attrsEnabled) (mkIf cfg.autoEnableSources attrsEnabled)
lspCapabilities lspCapabilities

View file

@ -4,42 +4,45 @@
pkgs, pkgs,
config, config,
... ...
} @ args: let }@args:
cmpOptions = import ./options {inherit lib helpers;}; let
cmpOptions = import ./options { inherit lib helpers; };
in in
with lib; with lib;
helpers.neovim-plugin.mkNeovimPlugin config { helpers.neovim-plugin.mkNeovimPlugin config {
name = "cmp"; name = "cmp";
originalName = "nvim-cmp"; originalName = "nvim-cmp";
defaultPackage = pkgs.vimPlugins.nvim-cmp; defaultPackage = pkgs.vimPlugins.nvim-cmp;
maintainers = [maintainers.GaetanLepage]; maintainers = [ maintainers.GaetanLepage ];
# Introduced on 2024 February 21 # Introduced on 2024 February 21
# TODO: remove ~June 2024 # TODO: remove ~June 2024
imports = [ imports = [
./deprecations.nix ./deprecations.nix
./sources ./sources
]; ];
deprecateExtraOptions = true; deprecateExtraOptions = true;
extraOptions = { extraOptions = {
autoEnableSources = mkOption { autoEnableSources = mkOption {
type = types.bool; type = types.bool;
default = true; default = true;
description = '' description = ''
Scans the sources array and installs the plugins if they are known to nixvim. Scans the sources array and installs the plugins if they are known to nixvim.
''; '';
}; };
inherit (cmpOptions) filetype cmdline; inherit (cmpOptions) filetype cmdline;
}; };
inherit (cmpOptions) settingsOptions settingsExample; inherit (cmpOptions) settingsOptions settingsExample;
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.
@ -49,35 +52,25 @@ in
- Dismiss this warning by explicitly setting `autoEnableSources` to `false`; - Dismiss this warning by explicitly setting `autoEnableSources` to `false`;
''; '';
extraConfigLua = extraConfigLua =
'' ''
local cmp = require('cmp') local cmp = require('cmp')
cmp.setup(${helpers.toLuaObject cfg.settings}) cmp.setup(${helpers.toLuaObject cfg.settings})
'' ''
+ ( + (concatStringsSep "\n" (
concatStringsSep "\n" mapAttrsToList (
( filetype: settings: "cmp.setup.filetype('${filetype}', ${helpers.toLuaObject settings})\n"
mapAttrsToList ) cfg.filetype
( ))
filetype: settings: "cmp.setup.filetype('${filetype}', ${helpers.toLuaObject settings})\n" + (concatStringsSep "\n" (
) mapAttrsToList (
cfg.filetype cmdtype: settings: "cmp.setup.cmdline('${cmdtype}', ${helpers.toLuaObject settings})\n"
) ) cfg.cmdline
) ));
+ (
concatStringsSep "\n"
(
mapAttrsToList
(
cmdtype: settings: "cmp.setup.cmdline('${cmdtype}', ${helpers.toLuaObject settings})\n"
)
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.
plugins = (import ./cmp-helpers.nix args).autoInstallSourcePluginsModule cfg; plugins = (import ./cmp-helpers.nix args).autoInstallSourcePluginsModule cfg;
}; };
} }

View file

@ -1,164 +1,360 @@
{lib, ...}: { lib, ... }:
with lib; let with lib;
oldPluginBasePath = ["plugins" "nvim-cmp"]; let
newPluginBasePath = ["plugins" "cmp"]; oldPluginBasePath = [
settingsPath = newPluginBasePath ++ ["settings"]; "plugins"
"nvim-cmp"
];
newPluginBasePath = [
"plugins"
"cmp"
];
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"
{old = ["mapping"];} ];
{ new = [
old = ["completion" "keywordLength"]; "performance"
new = ["completion" "keyword_length"]; "fetching_timeout"
];
} }
{ {
old = ["completion" "keywordPattern"]; old = [
new = ["completion" "keyword_pattern"]; "performance"
} "asyncBudget"
{old = ["completion" "autocomplete"];} ];
{old = ["completion" "completeopt"];} new = [
{ "performance"
old = ["confirmation" "getCommitCharacters"]; "async_budget"
new = ["confirmation" "get_commit_characters"]; ];
} }
{ {
old = ["formatting" "expandableIndicator"]; old = [
new = ["formatting" "expandable_indicator"]; "performance"
"maxViewEntries"
];
new = [
"performance"
"max_view_entries"
];
} }
{old = ["formatting" "fields"];} { old = [ "mapping" ]; }
{old = ["formatting" "format"];}
{ {
old = ["matching" "disallowFuzzyMatching"]; old = [
new = ["matching" "disallow_fuzzy_matching"]; "completion"
"keywordLength"
];
new = [
"completion"
"keyword_length"
];
} }
{ {
old = ["matching" "disallowFullfuzzyMatching"]; old = [
new = ["matching" "disallow_fullfuzzy_matching"]; "completion"
"keywordPattern"
];
new = [
"completion"
"keyword_pattern"
];
} }
{ {
old = ["matching" "disallowPartialFuzzyMatching"]; old = [
new = ["matching" "disallow_partial_fuzzy_matching"]; "completion"
"autocomplete"
];
} }
{ {
old = ["matching" "disallowPartialMatching"]; old = [
new = ["matching" "disallow_partial_matching"]; "completion"
"completeopt"
];
} }
{ {
old = ["matching" "disallowPrefixUnmatching"]; old = [
new = ["matching" "disallow_prefix_unmatching"]; "confirmation"
"getCommitCharacters"
];
new = [
"confirmation"
"get_commit_characters"
];
} }
{ {
old = ["sorting" "priorityWeight"]; old = [
new = ["sorting" "priority_weight"]; "formatting"
} "expandableIndicator"
{old = ["view" "entries"];} ];
{ new = [
old = ["view" "docs" "autoOpen"]; "formatting"
new = ["view" "docs" "auto_open"]; "expandable_indicator"
} ];
{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"]; "formatting"
} "fields"
{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"]; old = [
new = ["window" "documentation" "max_height"]; "formatting"
"format"
];
} }
{old = ["experimental"];} {
old = [
"matching"
"disallowFuzzyMatching"
];
new = [
"matching"
"disallow_fuzzy_matching"
];
}
{
old = [
"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" ]; }
]; ];
renameWarnings = renameWarnings = map (
map rename:
( mkRenamedOptionModule (oldPluginBasePath ++ rename.old) (settingsPath ++ (rename.new or rename.old))
rename: ) renamedOptions;
mkRenamedOptionModule in
(oldPluginBasePath ++ rename.old) {
(settingsPath ++ (rename.new or rename.old)) imports = renameWarnings ++ [
(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>`.
See the option documentation for more details.
'')
(mkRemovedOptionModule (oldPluginBasePath ++ [ "mappingPresets" ])
"If you want to have a complex mapping logic, express it in raw lua within the `plugins.cmp.settings.mapping` option."
) )
renamedOptions; (mkRemovedOptionModule
in {
imports =
renameWarnings
++ [
( (
mkRenamedOptionModule oldPluginBasePath
(oldPluginBasePath ++ ["enable"]) ++ [
(newPluginBasePath ++ ["enable"]) "snippet"
"expand"
]
) )
''
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:
```
plugins.cmp.settings.snippet.expand = "function(args) require('luasnip').lsp_expand(args.body) end";
```
''
)
(mkRemovedOptionModule
( (
mkRenamedOptionModule oldPluginBasePath
(oldPluginBasePath ++ ["autoEnableSources"]) ++ [
(newPluginBasePath ++ ["autoEnableSources"]) "sorting"
"comparators"
]
) )
( ''
mkRemovedOptionModule Use `plugins.cmp.settings.sorting.comparators` option. But watch out, you can no longer put only the name of the comparators.
(oldPluginBasePath ++ ["preselect"]) See the option documentation for more details.
'' ''
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. (mkRemovedOptionModule (oldPluginBasePath ++ [ "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.
( See the option documentation for more details.
mkRemovedOptionModule '')
(oldPluginBasePath ++ ["mappingPresets"]) ];
"If you want to have a complex mapping logic, express it in raw lua within the `plugins.cmp.settings.mapping` option."
)
(
mkRemovedOptionModule
(oldPluginBasePath ++ ["snippet" "expand"])
''
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:
```
plugins.cmp.settings.snippet.expand = "function(args) require('luasnip').lsp_expand(args.body) end";
```
''
)
(
mkRemovedOptionModule
(oldPluginBasePath ++ ["sorting" "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.
''
)
(
mkRemovedOptionModule
(oldPluginBasePath ++ ["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.
See the option documentation for more details.
''
)
];
} }

View file

@ -1,9 +1,7 @@
{ { lib, helpers }:
lib, with lib;
helpers, rec {
}: settingsOptions = import ./settings-options.nix { inherit lib helpers; };
with lib; rec {
settingsOptions = import ./settings-options.nix {inherit lib helpers;};
settingsExample = { settingsExample = {
snippet.expand = "function(args) require('luasnip').lsp_expand(args.body) end"; snippet.expand = "function(args) require('luasnip').lsp_expand(args.body) end";
@ -29,46 +27,44 @@ 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;
default = {}; default = { };
description = "Options for `cmp.filetype()`."; description = "Options for `cmp.filetype()`.";
example = { example = {
python = { python = {
sources = [ sources = [ { name = "nvim_lsp"; } ];
{name = "nvim_lsp";}
];
}; };
}; };
}; };
cmdline = mkOption { cmdline = mkOption {
type = attrsOfOptions; type = attrsOfOptions;
default = {}; default = { };
description = "Options for `cmp.cmdline()`."; description = "Options for `cmp.cmdline()`.";
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()";
sources = [ sources = [
{name = "path";} { name = "path"; }
{ {
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.
@ -39,16 +37,16 @@ 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 then
if helpers.nixvimTypes.isRawType v v
then 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,24 +108,16 @@ 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; ''["require('cmp.types').cmp.TriggerEvent.TextChanged"]''
either ''
(enum [false]) The event to trigger autocompletion.
(listOf strLua) If set to `false`, then completion is only invoked manually (e.g. by calling `cmp.complete`).
) '';
''["require('cmp.types').cmp.TriggerEvent.TextChanged"]''
''
The event to trigger autocompletion.
If set to `false`, then completion is only invoked manually (e.g. by calling `cmp.complete`).
'';
completeopt = helpers.defaultNullOpts.mkStr "menu,menuone,noselect" '' completeopt = helpers.defaultNullOpts.mkStr "menu,menuone,noselect" ''
Like vim's completeopt setting. Like vim's completeopt setting.
@ -138,15 +128,15 @@ with lib; {
confirmation = { confirmation = {
get_commit_characters = get_commit_characters =
helpers.defaultNullOpts.mkLuaFn helpers.defaultNullOpts.mkLuaFn
'' ''
function(commit_characters) function(commit_characters)
return commit_characters return commit_characters
end end
'' ''
'' ''
You can append or exclude `commitCharacters` via this configuration option function. You can append or exclude `commitCharacters` via this configuration option function.
The `commitCharacters` are defined by the LSP spec. The `commitCharacters` are defined by the LSP spec.
''; '';
}; };
formatting = { formatting = {
@ -160,21 +150,21 @@ with lib; {
format = format =
helpers.defaultNullOpts.mkLuaFn helpers.defaultNullOpts.mkLuaFn
'' ''
function(_, vim_item) function(_, vim_item)
return vim_item return vim_item
end end
'' ''
'' ''
`fun(entry: cmp.Entry, vim_item: vim.CompletedItem): vim.CompletedItem` `fun(entry: cmp.Entry, vim_item: vim.CompletedItem): vim.CompletedItem`
The function used to customize the appearance of the completion menu. The function used to customize the appearance of the completion menu.
See `|complete-items|`. See `|complete-items|`.
This value can also be used to modify the `dup` property. This value can also be used to modify the `dup` property.
NOTE: The `vim.CompletedItem` can contain the special properties `abbr_hl_group`, NOTE: The `vim.CompletedItem` can contain the special properties `abbr_hl_group`,
`kind_hl_group` and `menu_hl_group`. `kind_hl_group` and `menu_hl_group`.
''; '';
}; };
matching = { matching = {
@ -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.
@ -240,26 +225,20 @@ with lib; {
}; };
}; };
sources = import ./sources-option.nix {inherit lib helpers;}; sources = import ./sources-option.nix { inherit lib helpers; };
view = { view = {
entries = entries =
helpers.defaultNullOpts.mkNullable helpers.defaultNullOpts.mkNullable (with types; either str (attrsOf anything))
( ''
with types; {
either name = "custom";
str selection_order = "top_down";
(attrsOf anything) }
) ''
'' ''
{ The view class used to customize nvim-cmp's appearance.
name = "custom"; '';
selection_order = "top_down";
}
''
''
The view class used to customize nvim-cmp's appearance.
'';
docs = { docs = {
auto_open = helpers.defaultNullOpts.mkBool true '' auto_open = helpers.defaultNullOpts.mkBool true ''
@ -268,79 +247,71 @@ 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|`.
'';
zindex = helpers.mkNullOrOption types.ints.unsigned ''
The window's zindex.
See `|nvim_open_win|`. See `|nvim_open_win|`.
''; '';
in
{
completion = {
border =
helpers.defaultNullOpts.mkBorder ''[ "" "" "" "" "" "" "" "" ]'' "nvim-cmp completion popup menu"
"";
zindex = helpers.mkNullOrOption types.ints.unsigned '' winhighlight = mkWinhighlightOption "Normal:Pmenu,FloatBorder:Pmenu,CursorLine:PmenuSel,Search:None";
The window's zindex.
See `|nvim_open_win|`.
'';
in {
completion = {
border =
helpers.defaultNullOpts.mkBorder
''[ "" "" "" "" "" "" "" "" ]''
"nvim-cmp completion popup menu"
"";
winhighlight = inherit zindex;
mkWinhighlightOption
"Normal:Pmenu,FloatBorder:Pmenu,CursorLine:PmenuSel,Search:None";
inherit zindex; scrolloff = helpers.defaultNullOpts.mkUnsignedInt 0 ''
Specify the window's scrolloff option.
See |'scrolloff'|.
'';
scrolloff = helpers.defaultNullOpts.mkUnsignedInt 0 '' col_offset = helpers.defaultNullOpts.mkInt 0 ''
Specify the window's scrolloff option. Offsets the completion window relative to the cursor.
See |'scrolloff'|. '';
'';
col_offset = helpers.defaultNullOpts.mkInt 0 '' side_padding = helpers.defaultNullOpts.mkUnsignedInt 1 ''
Offsets the completion window relative to the cursor. The amount of padding to add on the completion window's sides.
''; '';
side_padding = helpers.defaultNullOpts.mkUnsignedInt 1 '' scrollbar = helpers.defaultNullOpts.mkBool true ''
The amount of padding to add on the completion window's sides. Whether the scrollbar should be enabled if there are more items that fit.
''; '';
};
scrollbar = helpers.defaultNullOpts.mkBool true '' documentation = {
Whether the scrollbar should be enabled if there are more items that fit. border =
''; helpers.defaultNullOpts.mkBorder ''[ "" "" "" " " "" "" "" " " ]''
}; "nvim-cmp documentation popup menu"
"";
documentation = { winhighlight = mkWinhighlightOption "FloatBorder:NormalFloat";
border =
helpers.defaultNullOpts.mkBorder
''[ "" "" "" " " "" "" "" " " ]''
"nvim-cmp documentation popup menu"
"";
winhighlight = mkWinhighlightOption "FloatBorder:NormalFloat"; inherit zindex;
inherit zindex; max_width = helpers.mkNullOrStrLuaOr types.ints.unsigned ''
max_width =
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))"
''; '';
};
}; };
};
# This can be kept as types.attrs since experimental features are often removed or completely # This can be kept as types.attrs since experimental features are often removed or completely
# changed after a while # changed after a while

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 = {
@ -81,27 +79,26 @@ 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. Or it can be a raw lua string which might be necessary for more advanced use cases.
Or it can be a raw lua string which might be necessary for more advanced use cases.
WARNING: WARNING:
If `plugins.cmp.autoEnableSources` Nixivm will automatically enable the corresponding source If `plugins.cmp.autoEnableSources` Nixivm will automatically enable the corresponding source
plugins. This will work only when this option is set to a list. plugins. This will work only when this option is set to a list.
If you use a raw lua string, you will need to explicitly enable the relevant source plugins in If you use a raw lua string, you will need to explicitly enable the relevant source plugins in
your nixvim configuration. your nixvim configuration.
Default: `[]` Default: `[]`
''; '';
example = [ example = [
{name = "nvim_lsp";} { name = "nvim_lsp"; }
{name = "luasnip";} { name = "luasnip"; }
{name = "path";} { name = "path"; }
{name = "buffer";} { name = "buffer"; }
]; ];
} }

View file

@ -4,10 +4,12 @@
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 = {
fishPackage = mkOption { fishPackage = mkOption {
@ -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 = {
@ -30,13 +32,13 @@ in {
sort_by = sort_by =
helpers.defaultNullOpts.mkNullable types.anything helpers.defaultNullOpts.mkNullable types.anything
''{__raw = "require('cmp_git.sort').git.commits";}'' ''{__raw = "require('cmp_git.sort').git.commits";}''
"Function used to sort the commits."; "Function used to sort the commits.";
format = format =
helpers.defaultNullOpts.mkNullable types.anything helpers.defaultNullOpts.mkNullable types.anything
''{__raw = "require('cmp_git.format').git.commits";}'' ''{__raw = "require('cmp_git.format').git.commits";}''
"Function used to format the commits."; "Function used to format the commits.";
}; };
}; };
@ -47,9 +49,8 @@ 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" ''
The filter to use when fetching issues. The filter to use when fetching issues.
@ -65,13 +66,13 @@ in {
sort_by = sort_by =
helpers.defaultNullOpts.mkNullable types.anything helpers.defaultNullOpts.mkNullable types.anything
''{__raw = "require('cmp_git.sort').github.issues";}'' ''{__raw = "require('cmp_git.sort').github.issues";}''
"Function used to sort the issues."; "Function used to sort the issues.";
format = format =
helpers.defaultNullOpts.mkNullable types.anything helpers.defaultNullOpts.mkNullable types.anything
''{__raw = "require('cmp_git.format').github.issues";}'' ''{__raw = "require('cmp_git.format').github.issues";}''
"Function used to format the issues."; "Function used to format the issues.";
}; };
mentions = { mentions = {
@ -81,20 +82,19 @@ in {
sort_by = sort_by =
helpers.defaultNullOpts.mkNullable types.anything helpers.defaultNullOpts.mkNullable types.anything
''{__raw = "require('cmp_git.sort').github.mentions";}'' ''{__raw = "require('cmp_git.sort').github.mentions";}''
"Function used to sort the mentions."; "Function used to sort the mentions.";
format = format =
helpers.defaultNullOpts.mkNullable types.anything helpers.defaultNullOpts.mkNullable types.anything
''{__raw = "require('cmp_git.format').github.mentions";}'' ''{__raw = "require('cmp_git.format').github.mentions";}''
"Function used to format the mentions."; "Function used to format the mentions.";
}; };
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 ''
Max number of pull requests to fetch. Max number of pull requests to fetch.
@ -106,13 +106,13 @@ in {
sort_by = sort_by =
helpers.defaultNullOpts.mkNullable types.anything helpers.defaultNullOpts.mkNullable types.anything
''{__raw = "require('cmp_git.sort').github.pull_requests";}'' ''{__raw = "require('cmp_git.sort').github.pull_requests";}''
"Function used to sort the pull requests."; "Function used to sort the pull requests.";
format = format =
helpers.defaultNullOpts.mkNullable types.anything helpers.defaultNullOpts.mkNullable types.anything
''{__raw = "require('cmp_git.format').github.pull_requests";}'' ''{__raw = "require('cmp_git.format').github.pull_requests";}''
"Function used to format the pull requests."; "Function used to format the pull requests.";
}; };
}; };
@ -132,13 +132,13 @@ in {
sort_by = sort_by =
helpers.defaultNullOpts.mkNullable types.anything helpers.defaultNullOpts.mkNullable types.anything
''{__raw = "require('cmp_git.sort').gitlab.issues";}'' ''{__raw = "require('cmp_git.sort').gitlab.issues";}''
"Function used to sort the issues."; "Function used to sort the issues.";
format = format =
helpers.defaultNullOpts.mkNullable types.anything helpers.defaultNullOpts.mkNullable types.anything
''{__raw = "require('cmp_git.format').gitlab.issues";}'' ''{__raw = "require('cmp_git.format').gitlab.issues";}''
"Function used to format the issues."; "Function used to format the issues.";
}; };
mentions = { mentions = {
@ -148,13 +148,13 @@ in {
sort_by = sort_by =
helpers.defaultNullOpts.mkNullable types.anything helpers.defaultNullOpts.mkNullable types.anything
''{__raw = "require('cmp_git.sort').gitlab.mentions";}'' ''{__raw = "require('cmp_git.sort').gitlab.mentions";}''
"Function used to sort the mentions."; "Function used to sort the mentions.";
format = format =
helpers.defaultNullOpts.mkNullable types.anything helpers.defaultNullOpts.mkNullable types.anything
''{__raw = "require('cmp_git.format').gitlab.mentions";}'' ''{__raw = "require('cmp_git.format').gitlab.mentions";}''
"Function used to format the mentions."; "Function used to format the mentions.";
}; };
merge_requests = { merge_requests = {
@ -168,114 +168,118 @@ in {
sort_by = sort_by =
helpers.defaultNullOpts.mkNullable types.anything helpers.defaultNullOpts.mkNullable types.anything
''{__raw = "require('cmp_git.sort').gitlab.merge_requests";}'' ''{__raw = "require('cmp_git.sort').gitlab.merge_requests";}''
"Function used to sort the merge requests."; "Function used to sort the merge requests.";
format = format =
helpers.defaultNullOpts.mkNullable types.anything helpers.defaultNullOpts.mkNullable types.anything
''{__raw = "require('cmp_git.format').gitlab.merge_requests";}'' ''{__raw = "require('cmp_git.format').gitlab.merge_requests";}''
"Function used to format the merge requests."; "Function used to format the merge requests.";
}; };
}; };
trigger_actions = trigger_actions =
helpers.defaultNullOpts.mkListOf helpers.defaultNullOpts.mkListOf
(types.submodule { (types.submodule {
options = { options = {
debug_name = helpers.mkNullOrStr "Debug name."; debug_name = helpers.mkNullOrStr "Debug name.";
trigger_character = mkOption { trigger_character = mkOption {
type = types.str; type = types.str;
example = ":"; example = ":";
description = '' description = ''
The trigger character. The trigger character.
Has to be a single character Has to be a single character
''; '';
}; };
action = mkOption { action = mkOption {
type = helpers.nixvimTypes.strLuaFn; type = helpers.nixvimTypes.strLuaFn;
apply = helpers.mkRaw; apply = helpers.mkRaw;
description = '' description = ''
The parameters to the action function are the different sources (currently `git`, The parameters to the action function are the different sources (currently `git`,
`gitlab` and `github`), the completion callback, the trigger character, the `gitlab` and `github`), the completion callback, the trigger character, the
parameters passed to complete from nvim-cmp, and the current git info. parameters passed to complete from nvim-cmp, and the current git info.
''; '';
example = '' example = ''
function(sources, trigger_char, callback, params, git_info) function(sources, trigger_char, callback, params, git_info)
return sources.git:get_commits(callback, params, trigger_char) return sources.git:get_commits(callback, params, trigger_char)
end end
''; '';
};
}; };
}; })
}) ''
'' [
[ {
{ debug_name = "git_commits";
debug_name = "git_commits"; trigger_character = ":";
trigger_character = ":"; action = \'\'
action = \'\' function(sources, trigger_char, callback, params, git_info)
function(sources, trigger_char, callback, params, git_info) return sources.git:get_commits(callback, params, trigger_char)
return sources.git:get_commits(callback, params, trigger_char) end
end \'\';
\'\'; }
} {
{ debug_name = "gitlab_issues";
debug_name = "gitlab_issues"; trigger_character = "#";
trigger_character = "#"; action = \'\'
action = \'\' function(sources, trigger_char, callback, params, git_info)
function(sources, trigger_char, callback, params, git_info) return sources.gitlab:get_issues(callback, git_info, trigger_char)
return sources.gitlab:get_issues(callback, git_info, trigger_char) end
end \'\';
\'\'; }
} {
{ debug_name = "gitlab_mentions";
debug_name = "gitlab_mentions"; trigger_character = "@";
trigger_character = "@"; action = \'\'
action = \'\' function(sources, trigger_char, callback, params, git_info)
function(sources, trigger_char, callback, params, git_info) return sources.gitlab:get_mentions(callback, git_info, trigger_char)
return sources.gitlab:get_mentions(callback, git_info, trigger_char) end
end \'\';
\'\'; }
} {
{ debug_name = "gitlab_mrs";
debug_name = "gitlab_mrs"; trigger_character = "!";
trigger_character = "!"; action = \'\'
action = \'\' function(sources, trigger_char, callback, params, git_info)
function(sources, trigger_char, callback, params, git_info) return sources.gitlab:get_merge_requests(callback, git_info, trigger_char)
return sources.gitlab:get_merge_requests(callback, git_info, trigger_char) end
end \'\';
\'\'; }
} {
{ debug_name = "github_issues_and_pr";
debug_name = "github_issues_and_pr"; trigger_character = "#";
trigger_character = "#"; action = \'\'
action = \'\' function(sources, trigger_char, callback, params, git_info)
function(sources, trigger_char, callback, params, git_info) return sources.github:get_issues_and_prs(callback, git_info, trigger_char)
return sources.github:get_issues_and_prs(callback, git_info, trigger_char) end
end \'\';
\'\'; }
} {
{ debug_name = "github_mentions";
debug_name = "github_mentions"; trigger_character = "@";
trigger_character = "@"; action = \'\'
action = \'\' function(sources, trigger_char, callback, params, git_info)
function(sources, trigger_char, callback, params, git_info) return sources.github:get_mentions(callback, git_info, trigger_char)
return sources.github:get_mentions(callback, git_info, trigger_char) end
end \'\';
\'\'; }
} ]
] ''
'' ''
'' If you want specific behaviour for a trigger or new behaviour for a trigger, you need to
If you want specific behaviour for a trigger or new behaviour for a trigger, you need to add an entry in the `trigger_actions` list of the config.
add an entry in the `trigger_actions` list of the config. The two necessary fields are the `trigger_character` and the `action`.
The two necessary fields are the `trigger_character` and the `action`. '';
'';
}; };
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,41 +4,44 @@
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" ''
// { The address of the tabby host server.
host = helpers.defaultNullOpts.mkStr "http://localhost:5000" '' '';
The address of the tabby host server.
'';
maxLines = helpers.defaultNullOpts.mkUnsignedInt 100 '' maxLines = helpers.defaultNullOpts.mkUnsignedInt 100 ''
The max number of lines to complete. The max number of lines to complete.
''; '';
runOnEveryKeyStroke = helpers.defaultNullOpts.mkBool true '' runOnEveryKeyStroke = helpers.defaultNullOpts.mkBool true ''
Whether to run the completion on every keystroke. Whether to run the completion on every keystroke.
''; '';
stop = helpers.defaultNullOpts.mkListOf types.str ''["\n"]'' ""; stop = helpers.defaultNullOpts.mkListOf types.str ''["\n"]'' "";
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
extraConfigLua = let extraConfigLua =
setupOptions = with cfg; let
{ setupOptions =
inherit host; with cfg;
max_lines = maxLines; {
run_on_every_keystroke = runOnEveryKeyStroke; inherit host;
inherit stop; max_lines = maxLines;
} run_on_every_keystroke = runOnEveryKeyStroke;
// cfg.extraOptions; inherit stop;
in '' }
require('cmp_tabby.config'):setup(${helpers.toLuaObject setupOptions}) // cfg.extraOptions;
''; in
''
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,85 +5,79 @@
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" ''
The hostname of the API server to use. The hostname of the API server to use.
''; '';
port = helpers.defaultNullOpts.mkPositiveInt 443 '' port = helpers.defaultNullOpts.mkPositiveInt 443 ''
The port of the API server to use. The port of the API server to use.
'';
};
tools = {
uname = helpers.mkNullOrOption types.str "The path to the `uname` binary.";
uuidgen = helpers.mkNullOrOption types.str "The path to the `uuidgen` binary.";
curl = helpers.mkNullOrOption types.str "The path to the `curl` binary.";
gzip = helpers.mkNullOrOption types.str "The path to the `gzip` binary.";
languageServer = helpers.mkNullOrOption types.str ''
The path to the language server downloaded from the official source.
'';
};
wrapper = helpers.mkNullOrOption types.str ''
The path to a wrapper script/binary that is used to execute any binaries not listed under
tools.
This is primarily useful for NixOS, where a FHS wrapper can be used for the downloaded
codeium server.
''; '';
}; };
config = mkIf cfg.enable { tools = {
extraConfigLua = let uname = helpers.mkNullOrOption types.str "The path to the `uname` binary.";
setupOptions = with cfg;
{ uuidgen = helpers.mkNullOrOption types.str "The path to the `uuidgen` binary.";
config_path = configPath;
bin_path = binPath; curl = helpers.mkNullOrOption types.str "The path to the `curl` binary.";
api = with api; {
inherit host; gzip = helpers.mkNullOrOption types.str "The path to the `gzip` binary.";
port =
if isInt port languageServer = helpers.mkNullOrOption types.str ''
then toString port The path to the language server downloaded from the official source.
else port; '';
}; };
tools = with tools; {
inherit wrapper = helpers.mkNullOrOption types.str ''
uname The path to a wrapper script/binary that is used to execute any binaries not listed under
uuidgen tools.
curl This is primarily useful for NixOS, where a FHS wrapper can be used for the downloaded
gzip codeium server.
;
language_server = languageServer;
};
inherit wrapper;
}
// cfg.extraOptions;
in ''
require('codeium').setup(${helpers.toLuaObject setupOptions})
''; '';
}; };
config = mkIf cfg.enable {
extraConfigLua =
let
setupOptions =
with cfg;
{
config_path = configPath;
bin_path = binPath;
api = with api; {
inherit host;
port = if isInt port then toString port else port;
};
tools = with tools; {
inherit
uname
uuidgen
curl
gzip
;
language_server = languageServer;
};
inherit wrapper;
}
// cfg.extraOptions;
in
''
require('codeium').setup(${helpers.toLuaObject setupOptions})
'';
};
} }

View file

@ -4,63 +4,58 @@
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 (with types; listOf str) ''["InsertEnter" "LspAttach"]''
helpers.defaultNullOpts.mkNullable
(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
to touch this. to touch this.
''; '';
fixPairs = helpers.defaultNullOpts.mkBool true '' fixPairs = helpers.defaultNullOpts.mkBool true ''
Suppose you have the following code: `print('h')`. Suppose you have the following code: `print('h')`.
Copilot might try to account for the `'` and `)` and complete it with this: `print('hello`. Copilot might try to account for the `'` and `)` and complete it with this: `print('hello`.
This is not good behavior for consistency reasons and will just end up deleting the two ending This is not good behavior for consistency reasons and will just end up deleting the two ending
characters. characters.
This option fixes that. This option fixes that.
Don't turn this off unless you are having problems with pairs and believe this might be Don't turn this off unless you are having problems with pairs and believe this might be
causing them. causing them.
''; '';
}; };
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 =
inherit event; with cfg;
fix_pairs = fixPairs; {
} inherit event;
// cfg.extraOptions; fix_pairs = fixPairs;
in '' }
require('copilot_cmp').setup(${helpers.toLuaObject setupOptions}) // cfg.extraOptions;
''; in
''
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,27 +5,28 @@
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 ./cmp-git.nix
./cmp-git.nix ./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-]>";
@ -34,36 +35,36 @@ with lib; let
}; };
}; };
in in
helpers.vim-plugin.mkVimPlugin config { helpers.vim-plugin.mkVimPlugin config {
name = "codeium-vim"; name = "codeium-vim";
originalName = "codeium.vim"; originalName = "codeium.vim";
defaultPackage = pkgs.vimPlugins.codeium-vim; defaultPackage = pkgs.vimPlugins.codeium-vim;
globalPrefix = "codeium_"; globalPrefix = "codeium_";
maintainers = [maintainers.GaetanLepage]; maintainers = [ maintainers.GaetanLepage ];
# TODO introduced 2024-02-19: remove 2024-03-19 # TODO introduced 2024-02-19: remove 2024-03-19
deprecateExtraConfig = true; deprecateExtraConfig = true;
optionsRenamedToSettings = [ optionsRenamedToSettings = [
"bin" "bin"
"filetypes" "filetypes"
"manual" "manual"
"noMapTab" "noMapTab"
"idleDelay" "idleDelay"
"render" "render"
"tabFallback" "tabFallback"
"disableBindings" "disableBindings"
]; ];
settingsOptions = { settingsOptions = {
bin = mkOption { bin = mkOption {
type = with types; nullOr str; type = with types; nullOr str;
default = "${pkgs.codeium}/bin/codeium_language_server"; default = "${pkgs.codeium}/bin/codeium_language_server";
description = "The path to the codeium language server executable."; description = "The path to the codeium language server executable.";
}; };
filetypes = filetypes =
helpers.defaultNullOpts.mkAttrsOf types.bool helpers.defaultNullOpts.mkAttrsOf types.bool
'' ''
{ {
help = false; help = false;
@ -77,65 +78,61 @@ in
This can be used to opt out of completions for certain filetypes. This can be used to opt out of completions for certain filetypes.
''; '';
manual = helpers.defaultNullOpts.mkBool false '' manual = helpers.defaultNullOpts.mkBool false ''
If true, codeium completions will never automatically trigger. If true, codeium completions will never automatically trigger.
''; '';
no_map_tab = helpers.defaultNullOpts.mkBool false '' no_map_tab = helpers.defaultNullOpts.mkBool false ''
Whether to disable the `<Tab>` keybinding. Whether to disable the `<Tab>` keybinding.
''; '';
idle_delay = helpers.defaultNullOpts.mkPositiveInt 75 '' idle_delay = helpers.defaultNullOpts.mkPositiveInt 75 ''
Delay in milliseconds before autocompletions are shown (limited by language server to a Delay in milliseconds before autocompletions are shown (limited by language server to a
minimum of 75). minimum of 75).
''; '';
render = helpers.defaultNullOpts.mkBool true '' render = helpers.defaultNullOpts.mkBool true ''
A global boolean flag that controls whether codeium renders are enabled or disabled. A global boolean flag that controls whether codeium renders are enabled or disabled.
''; '';
tab_fallback = helpers.mkNullOrOption types.str '' tab_fallback = helpers.mkNullOrOption types.str ''
The fallback key when there is no suggestion display in `codeium#Accept()`. The fallback key when there is no suggestion display in `codeium#Accept()`.
Default: "\<C-N>" when a popup menu is visible, else "\t". Default: "\<C-N>" when a popup menu is visible, else "\t".
''; '';
disable_bindings = helpers.defaultNullOpts.mkBool false '' disable_bindings = helpers.defaultNullOpts.mkBool false ''
Whether to disable default keybindings. Whether to disable default keybindings.
''; '';
}; };
extraOptions = { extraOptions = {
keymaps = keymaps = mapAttrs (
mapAttrs optionName: v:
( helpers.defaultNullOpts.mkStr v.default ''
${v.description}
Command: `${v.command}`
''
) keymapsDefinitions;
};
extraConfig = cfg: {
plugins.codeium-vim.settings.enabled = true;
keymaps =
let
processKeymap =
optionName: v: optionName: v:
helpers.defaultNullOpts.mkStr v.default '' optional (v != null) {
${v.description}
Command: `${v.command}`
''
)
keymapsDefinitions;
};
extraConfig = cfg: {
plugins.codeium-vim.settings.enabled = true;
keymaps = let
processKeymap = optionName: v:
optional
(v != null)
{
key = v; key = v;
action = let action =
inherit (keymapsDefinitions.${optionName}) command; let
in inherit (keymapsDefinitions.${optionName}) command;
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,13 +5,16 @@
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 =
keymapOption = helpers.defaultNullOpts.mkNullable (with types; either (enum [false]) str); let
in keymapOption = helpers.defaultNullOpts.mkNullable (with types; either (enum [ false ]) str);
in
helpers.neovim-plugin.extraOptionsOptions helpers.neovim-plugin.extraOptionsOptions
// { // {
enable = mkEnableOption "copilot.lua"; enable = mkEnableOption "copilot.lua";
@ -36,9 +39,18 @@ in {
}; };
layout = { layout = {
position = helpers.defaultNullOpts.mkEnum ["bottom" "top" "left" "right"] "bottom" '' position =
The panel position. helpers.defaultNullOpts.mkEnum
''; [
"bottom"
"top"
"left"
"right"
]
"bottom"
''
The panel position.
'';
ratio = helpers.defaultNullOpts.mkNullable (types.numbers.between 0.0 1.0) "0.4" '' ratio = helpers.defaultNullOpts.mkNullable (types.numbers.between 0.0 1.0) "0.4" ''
The panel ratio. The panel ratio.
@ -69,52 +81,51 @@ 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;
markdown = false;
help = false;
gitcommit = false;
gitrebase = false;
hgcommit = false;
svn = false;
cvs = false;
"." = false;
}
''
''
Specify filetypes for attaching copilot.
Each value can be either a boolean or a lua function that returns a boolean.
Example:
```nix
{ {
markdown = true; # overrides default yaml = false;
terraform = false; # disallow specific filetype markdown = false;
sh.__raw = \'\' help = false;
function () gitcommit = false;
if string.match(vim.fs.basename(vim.api.nvim_buf_get_name(0)), '^%.env.*') then gitrebase = false;
-- disable for .env files hgcommit = false;
return false svn = false;
cvs = false;
"." = false;
}
''
''
Specify filetypes for attaching copilot.
Each value can be either a boolean or a lua function that returns a boolean.
Example:
```nix
{
markdown = true; # overrides default
terraform = false; # disallow specific filetype
sh.__raw = \'\'
function ()
if string.match(vim.fs.basename(vim.api.nvim_buf_get_name(0)), '^%.env.*') then
-- disable for .env files
return false
end
return true
end end
return true \'\';
end }
\'\'; ```
}
```
The key `"*"` can be used to disable the default configuration. The key `"*"` can be used to disable the default configuration.
Example: Example:
```nix ```nix
{ {
javascript = true; # allow specific filetype javascript = true; # allow specific filetype
typescript = true; # allow specific filetype typescript = true; # allow specific filetype
"*" = false; # disable for all other filetypes and ignore default `filetypes` "*" = false; # disable for all other filetypes and ignore default `filetypes`
} }
``` ```
''; '';
copilotNodeCommand = mkOption { copilotNodeCommand = mkOption {
type = types.str; type = types.str;
@ -164,41 +175,44 @@ in {
} }
]; ];
extraPlugins = [cfg.package]; extraPlugins = [ cfg.package ];
extraConfigLua = let extraConfigLua =
setupOptions = with cfg; let
{ setupOptions =
panel = with panel; { with cfg;
inherit enabled; {
auto_refresh = autoRefresh; panel = with panel; {
keymap = with keymap; { inherit enabled;
jump_prev = jumpPrev; auto_refresh = autoRefresh;
jump_next = jumpNext; keymap = with keymap; {
inherit accept refresh open; jump_prev = jumpPrev;
jump_next = jumpNext;
inherit accept refresh open;
};
layout = with layout; {
inherit position ratio;
};
}; };
layout = with layout; { suggestion = with suggestion; {
inherit position ratio; inherit enabled;
auto_trigger = autoTrigger;
inherit debounce;
keymap = with keymap; {
inherit accept;
accept_word = acceptWord;
accept_line = acceptLine;
inherit next prev dismiss;
};
}; };
}; inherit filetypes;
suggestion = with suggestion; { copilot_node_command = copilotNodeCommand;
inherit enabled; server_opts_overrides = serverOptsOverrides;
auto_trigger = autoTrigger; }
inherit debounce; // cfg.extraOptions;
keymap = with keymap; { in
inherit accept; ''
accept_word = acceptWord; require('copilot').setup(${helpers.toLuaObject setupOptions})
accept_line = acceptLine; '';
inherit next prev dismiss;
};
};
inherit filetypes;
copilot_node_command = copilotNodeCommand;
server_opts_overrides = serverOptsOverrides;
}
// cfg.extraOptions;
in ''
require('copilot').setup(${helpers.toLuaObject setupOptions})
'';
}; };
} }

View file

@ -7,79 +7,79 @@
}: }:
with lib; with lib;
with helpers.vim-plugin; with helpers.vim-plugin;
helpers.vim-plugin.mkVimPlugin config { helpers.vim-plugin.mkVimPlugin config {
name = "copilot-vim"; name = "copilot-vim";
originalName = "copilot.vim"; originalName = "copilot.vim";
defaultPackage = pkgs.vimPlugins.copilot-vim; defaultPackage = pkgs.vimPlugins.copilot-vim;
globalPrefix = "copilot_"; globalPrefix = "copilot_";
maintainers = [maintainers.GaetanLepage]; maintainers = [ maintainers.GaetanLepage ];
# TODO introduced 2024-03-02: remove 2024-05-02 # TODO introduced 2024-03-02: remove 2024-05-02
deprecateExtraConfig = true; deprecateExtraConfig = true;
optionsRenamedToSettings = [ optionsRenamedToSettings = [
"nodeCommand" "nodeCommand"
"filetypes" "filetypes"
"proxy" "proxy"
]; ];
settingsOptions = { settingsOptions = {
node_command = mkOption { node_command = mkOption {
type = with types; nullOr str; type = with types; nullOr str;
default = "${pkgs.nodejs-18_x}/bin/node"; default = "${pkgs.nodejs-18_x}/bin/node";
description = "Tell Copilot what `node` binary to use."; description = "Tell Copilot what `node` binary to use.";
};
filetypes = mkOption {
type = with types; nullOr (attrsOf bool);
default = null;
description = "A dictionary mapping file types to their enabled status.";
example = {
"*" = false;
python = true;
};
};
proxy = mkOption {
type = with types; nullOr str;
default = null;
description = ''
Tell Copilot what proxy server to use.
If this is not set, Copilot will use the value of environment variables like
`$HTTPS_PROXY`.
'';
example = "localhost:3128";
};
proxy_strict_ssl = helpers.mkNullOrOption types.bool ''
Corporate proxies sometimes use a man-in-the-middle SSL certificate which is incompatible
with GitHub Copilot.
To work around this, SSL certificate verification can be disabled by setting this option to
`false`.
You can also tell `Node.js` to disable SSL verification by setting the
`$NODE_TLS_REJECT_UNAUTHORIZED` environment variable to `"0"`.
'';
workspace_folders = helpers.mkNullOrOption (with types; listOf str) ''
A list of "workspace folders" or project roots that Copilot may use to improve to improve
the quality of suggestions.
Example: ["~/Projects/myproject"]
You can also set `b:workspace_folder` for an individual buffer and newly seen values will be
added automatically.
'';
}; };
settingsExample = { filetypes = mkOption {
filetypes = { type = with types; nullOr (attrsOf bool);
default = null;
description = "A dictionary mapping file types to their enabled status.";
example = {
"*" = false; "*" = false;
python = true; python = true;
}; };
proxy = "localhost:3128";
proxy_strict_ssl = false;
workspace_folders = ["~/Projects/myproject"];
}; };
}
proxy = mkOption {
type = with types; nullOr str;
default = null;
description = ''
Tell Copilot what proxy server to use.
If this is not set, Copilot will use the value of environment variables like
`$HTTPS_PROXY`.
'';
example = "localhost:3128";
};
proxy_strict_ssl = helpers.mkNullOrOption types.bool ''
Corporate proxies sometimes use a man-in-the-middle SSL certificate which is incompatible
with GitHub Copilot.
To work around this, SSL certificate verification can be disabled by setting this option to
`false`.
You can also tell `Node.js` to disable SSL verification by setting the
`$NODE_TLS_REJECT_UNAUTHORIZED` environment variable to `"0"`.
'';
workspace_folders = helpers.mkNullOrOption (with types; listOf str) ''
A list of "workspace folders" or project roots that Copilot may use to improve to improve
the quality of suggestions.
Example: ["~/Projects/myproject"]
You can also set `b:workspace_folder` for an individual buffer and newly seen values will be
added automatically.
'';
};
settingsExample = {
filetypes = {
"*" = false;
python = true;
};
proxy = "localhost:3128";
proxy_strict_ssl = false;
workspace_folders = [ "~/Projects/myproject" ];
};
}

View file

@ -5,40 +5,44 @@
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 (
freeformType = types.attrs; types.submodule {
freeformType = types.attrs;
options = { options = {
src = mkOption { src = mkOption {
type = types.str; type = types.str;
description = "The name of the source"; description = "The name of the source";
}; };
short_name = mkOption { short_name = mkOption {
type = types.nullOr types.str; type = types.nullOr types.str;
description = '' description = ''
A short name for the source. A short name for the source.
If not specified, it is uppercase `src`. If not specified, it is uppercase `src`.
''; '';
example = "nLUA"; example = "nLUA";
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.
''; '';
default = []; default = [ ];
example = [ example = [
{ {
src = "nvimlua"; src = "nvimlua";
@ -53,13 +57,13 @@ in {
short_name = "COP"; short_name = "COP";
accept_key = "<c-f>"; accept_key = "<c-f>";
} }
{src = "demo";} { src = "demo"; }
]; ];
}; };
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
extraPlugins = [cfg.package]; extraPlugins = [ cfg.package ];
extraConfigLua = '' extraConfigLua = ''
require('coq_3p')(${helpers.toLuaObject cfg.sources}) require('coq_3p')(${helpers.toLuaObject cfg.sources})

View file

@ -6,78 +6,87 @@
... ...
}: }:
with lib; with lib;
helpers.neovim-plugin.mkNeovimPlugin config { helpers.neovim-plugin.mkNeovimPlugin config {
name = "coq-nvim"; name = "coq-nvim";
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";
artifactsPackage = mkOption { artifactsPackage = mkOption {
type = types.package; type = types.package;
description = "Package to use for coq-artifacts (when enabled with installArtifacts)"; description = "Package to use for coq-artifacts (when enabled with installArtifacts)";
default = pkgs.vimPlugins.coq-artifacts; default = pkgs.vimPlugins.coq-artifacts;
};
}; };
};
# TODO: Introduced 12-03-2022, remove 12-05-2022 # TODO: Introduced 12-03-2022, remove 12-05-2022
optionsRenamedToSettings = [ optionsRenamedToSettings = [
"xdg" "xdg"
"autoStart" "autoStart"
]; ];
imports = let imports =
basePath = ["plugins" "coq-nvim"]; let
settingsPath = basePath ++ ["settings"]; basePath = [
in [ "plugins"
( "coq-nvim"
mkRenamedOptionModule
(basePath ++ ["recommendedKeymaps"])
(settingsPath ++ ["keymap" "recommended"])
)
(
mkRenamedOptionModule
(basePath ++ ["alwaysComplete"])
(settingsPath ++ ["completion" "always"])
)
];
callSetup = false;
settingsOptions = {
auto_start =
helpers.mkNullOrOption
(with helpers.nixvimTypes; maybeRaw (either bool (enum ["shut-up"])))
"Auto-start or shut up";
xdg = mkOption {
type = types.bool;
default = true;
description = "Use XDG paths. May be required when installing coq with Nix.";
};
keymap.recommended = helpers.defaultNullOpts.mkBool true "Use the recommended keymaps";
completion.always = helpers.defaultNullOpts.mkBool true "Always trigger completion on keystroke";
};
extraConfig = cfg: {
extraPlugins = mkIf cfg.installArtifacts [
cfg.artifactsPackage
]; ];
settingsPath = basePath ++ [ "settings" ];
in
[
(mkRenamedOptionModule (basePath ++ [ "recommendedKeymaps" ]) (
settingsPath
++ [
"keymap"
"recommended"
]
))
globals = { (mkRenamedOptionModule (basePath ++ [ "alwaysComplete" ]) (
coq_settings = cfg.settings; settingsPath
}; ++ [
"completion"
"always"
]
))
];
extraConfigLua = "require('coq')"; callSetup = false;
settingsOptions = {
auto_start = helpers.mkNullOrOption (
with helpers.nixvimTypes; maybeRaw (either bool (enum [ "shut-up" ]))
) "Auto-start or shut up";
plugins.lsp = { xdg = mkOption {
preConfig = '' type = types.bool;
local coq = require 'coq' default = true;
''; description = "Use XDG paths. May be required when installing coq with Nix.";
setupWrappers = [(s: ''coq.lsp_ensure_capabilities(${s})'')];
};
}; };
}
keymap.recommended = helpers.defaultNullOpts.mkBool true "Use the recommended keymaps";
completion.always = helpers.defaultNullOpts.mkBool true "Always trigger completion on keystroke";
};
extraConfig = cfg: {
extraPlugins = mkIf cfg.installArtifacts [ cfg.artifactsPackage ];
globals = {
coq_settings = cfg.settings;
};
extraConfigLua = "require('coq')";
plugins.lsp = {
preConfig = ''
local coq = require 'coq'
'';
setupWrappers = [ (s: ''coq.lsp_ensure_capabilities(${s})'') ];
};
};
}

View file

@ -5,85 +5,86 @@
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";
cmp = { cmp = {
enable = mkOption { enable = mkOption {
type = types.bool; type = types.bool;
default = true; default = true;
description = "Integrate with nvim-cmp"; description = "Integrate with nvim-cmp";
};
maxWidth =
helpers.mkNullOrOption types.int
"Maximum number of characters to show in the popup";
ellipsisChar =
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";
after =
helpers.mkNullOrOption types.str
"Function to run after calculating the formatting. function(entry, vim_item, kind)";
}; };
};
config = let maxWidth = helpers.mkNullOrOption types.int "Maximum number of characters to show in the popup";
doCmp = cfg.cmp.enable && config.plugins.cmp.enable;
options = ellipsisChar = helpers.mkNullOrOption types.str "Character to show when the popup exceeds maxwidth";
{
inherit (cfg) mode preset; menu = helpers.mkNullOrOption (types.attrsOf types.str) "Show source names in the popup";
symbol_map = cfg.symbolMap;
} after = helpers.mkNullOrOption types.str "Function to run after calculating the formatting. function(entry, vim_item, kind)";
// ( };
if doCmp };
then {
maxwidth = cfg.cmp.maxWidth; config =
ellipsis_char = cfg.cmp.ellipsisChar; let
inherit (cfg.cmp) menu; doCmp = cfg.cmp.enable && config.plugins.cmp.enable;
options =
{
inherit (cfg) mode preset;
symbol_map = cfg.symbolMap;
} }
else {} // (
) if doCmp then
// cfg.extraOptions; {
in maxwidth = cfg.cmp.maxWidth;
ellipsis_char = cfg.cmp.ellipsisChar;
inherit (cfg.cmp) menu;
}
else
{ }
)
// cfg.extraOptions;
in
mkIf cfg.enable { mkIf cfg.enable {
extraPlugins = [cfg.package]; extraPlugins = [ cfg.package ];
extraConfigLua = optionalString (!doCmp) '' extraConfigLua = optionalString (!doCmp) ''
require('lspkind').init(${helpers.toLuaObject options}) require('lspkind').init(${helpers.toLuaObject options})
''; '';
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,19 +40,20 @@ in {
}; };
}; };
config = let config =
options = with cfg; { let
dap_configurations = dapConfigurations; options = with cfg; {
dap_configurations = dapConfigurations;
delve = with delve; { delve = with delve; {
inherit path port args; inherit path port args;
initialize_timeout_sec = initializeTimeoutSec; initialize_timeout_sec = initializeTimeoutSec;
build_flags = buildFlags; build_flags = buildFlags;
};
}; };
}; in
in
mkIf cfg.enable { mkIf cfg.enable {
extraPlugins = [cfg.package]; extraPlugins = [ cfg.package ];
plugins.dap = { plugins.dap = {
enable = true; enable = true;

View file

@ -5,22 +5,28 @@
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";
package = helpers.mkPackageOption "dap-python" pkgs.vimPlugins.nvim-dap-python; package = helpers.mkPackageOption "dap-python" pkgs.vimPlugins.nvim-dap-python;
adapterPythonPath = mkOption { adapterPythonPath = mkOption {
default = "${pkgs.python3.withPackages (ps: with ps; [debugpy])}/bin/python3"; default = "${pkgs.python3.withPackages (ps: with ps; [ debugpy ])}/bin/python3";
description = "Path to the python interpreter. Path must be absolute or in $PATH and needs to have the debugpy package installed."; description = "Path to the python interpreter. Path must be absolute or in $PATH and needs to have the debugpy package installed.";
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,30 +52,27 @@ in {
''; '';
}; };
config = let config =
options = with cfg; { let
inherit console; options = with cfg; {
include_configs = includeConfigs; inherit console;
}; include_configs = includeConfigs;
in };
in
mkIf cfg.enable { mkIf cfg.enable {
extraPlugins = [cfg.package]; extraPlugins = [ cfg.package ];
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 {
@ -32,7 +31,7 @@ with lib; let
layoutOption = types.submodule { layoutOption = types.submodule {
options = { options = {
elements = mkOption { elements = mkOption {
default = []; default = [ ];
description = "Elements to display in this layout."; description = "Elements to display in this layout.";
type = with types; listOf (either str elementOption); type = with types; listOf (either str elementOption);
}; };
@ -46,178 +45,185 @@ 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;
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"
icons = { "watches"
disconnect = helpers.defaultNullOpts.mkStr "" ""; "breakpoints"
pause = helpers.defaultNullOpts.mkStr "" ""; "console"
play = helpers.defaultNullOpts.mkStr "" ""; ] "Element to show the controls on.";
run_last = helpers.defaultNullOpts.mkStr "" "";
step_into = helpers.defaultNullOpts.mkStr "" "";
step_over = helpers.defaultNullOpts.mkStr "" "";
step_out = helpers.defaultNullOpts.mkStr "" "";
step_back = helpers.defaultNullOpts.mkStr "" "";
terminate = helpers.defaultNullOpts.mkStr "" "";
};
};
elementMappings = helpers.mkNullOrOption (
types.attrsOf (
types.submodule {
options = mkKeymapOptions "element mapping overrides" {
edit = "e";
expand = ''["<CR>" "<2-LeftMouse>"]'';
open = "o";
remove = "d";
repl = "r";
toggle = "t";
};
}
)
) "Per-element overrides of global mappings.";
expandLines = helpers.defaultNullOpts.mkBool true "Expand current line to hover window if larger than window size.";
floating = {
maxHeight = mkSizeOption "Maximum height of the floating window.";
maxWidth = mkSizeOption "Maximum width of the floating window.";
border = helpers.defaultNullOpts.mkBorder "single" "dap-ui floating window" "";
mappings =
helpers.mkNullOrOption (types.submodule {
options = mkKeymapOptions "dap-ui floating" {
close = ''["<ESC>" "q"]'';
};
})
"Keys to trigger actions in elements.";
};
forceBuffers = helpers.defaultNullOpts.mkBool true "Prevents other buffers being loaded into dap-ui windows.";
icons = { icons = {
collapsed = helpers.defaultNullOpts.mkStr "" ""; disconnect = helpers.defaultNullOpts.mkStr "" "";
current_frame = helpers.defaultNullOpts.mkStr "" ""; pause = helpers.defaultNullOpts.mkStr "" "";
expanded = helpers.defaultNullOpts.mkStr "" ""; play = helpers.defaultNullOpts.mkStr "" "";
run_last = helpers.defaultNullOpts.mkStr "" "";
step_into = helpers.defaultNullOpts.mkStr "" "";
step_over = helpers.defaultNullOpts.mkStr "" "";
step_out = helpers.defaultNullOpts.mkStr "" "";
step_back = helpers.defaultNullOpts.mkStr "" "";
terminate = helpers.defaultNullOpts.mkStr "" "";
}; };
layouts =
helpers.defaultNullOpts.mkNullable (types.listOf layoutOption)
''
```nix
[
{
elements = [
{
id = "scopes";
size = 0.25;
}
{
id = "breakpoints";
size = 0.25;
}
{
id = "stacks";
size = 0.25;
}
{
id = "watches";
size = 0.25;
}
];
position = "left";
size = 40;
}
{
elements = [
{
id = "repl";
size = 0.5;
}
{
id = "console";
size = 0.5;
}
];
position = "bottom";
size = 10;
}
];
```
''
"List of layouts for dap-ui.";
mappings =
helpers.mkNullOrOption (types.submodule {
options = mkKeymapOptions "dap-ui" {
edit = "e";
expand = ''["<CR>" "<2-LeftMouse>"]'';
open = "o";
remove = "d";
repl = "r";
toggle = "t";
};
})
"Keys to trigger actions in elements.";
render = {
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.";
maxValueLines = helpers.defaultNullOpts.mkInt 100 "Maximum number of lines to allow a value to fill before trimming.";
};
selectWindow = helpers.defaultNullOpts.mkLuaFn "null" ''
A function which returns a window to be used for opening buffers such as a stack frame location.
'';
}; };
config = let elementMappings = helpers.mkNullOrOption (types.attrsOf (
options = with cfg; types.submodule {
{ options = mkKeymapOptions "element mapping overrides" {
inherit controls icons layouts mappings; edit = "e";
expand = ''["<CR>" "<2-LeftMouse>"]'';
element_mappings = elementMappings; open = "o";
remove = "d";
floating = with floating; { repl = "r";
inherit border mappings; toggle = "t";
max_height = maxHeight;
max_width = maxWidth;
}; };
force_buffers = forceBuffers;
render = with render; {
inherit indent;
max_type_length = maxTypeLength;
max_value_lines = maxValueLines;
};
select_window = selectWindow;
} }
// cfg.extraOptions; )) "Per-element overrides of global mappings.";
in
expandLines = helpers.defaultNullOpts.mkBool true "Expand current line to hover window if larger than window size.";
floating = {
maxHeight = mkSizeOption "Maximum height of the floating window.";
maxWidth = mkSizeOption "Maximum width of the floating window.";
border = helpers.defaultNullOpts.mkBorder "single" "dap-ui floating window" "";
mappings = helpers.mkNullOrOption (types.submodule {
options = mkKeymapOptions "dap-ui floating" { close = ''["<ESC>" "q"]''; };
}) "Keys to trigger actions in elements.";
};
forceBuffers = helpers.defaultNullOpts.mkBool true "Prevents other buffers being loaded into dap-ui windows.";
icons = {
collapsed = helpers.defaultNullOpts.mkStr "" "";
current_frame = helpers.defaultNullOpts.mkStr "" "";
expanded = helpers.defaultNullOpts.mkStr "" "";
};
layouts = helpers.defaultNullOpts.mkNullable (types.listOf layoutOption) ''
```nix
[
{
elements = [
{
id = "scopes";
size = 0.25;
}
{
id = "breakpoints";
size = 0.25;
}
{
id = "stacks";
size = 0.25;
}
{
id = "watches";
size = 0.25;
}
];
position = "left";
size = 40;
}
{
elements = [
{
id = "repl";
size = 0.5;
}
{
id = "console";
size = 0.5;
}
];
position = "bottom";
size = 10;
}
];
```
'' "List of layouts for dap-ui.";
mappings = helpers.mkNullOrOption (types.submodule {
options = mkKeymapOptions "dap-ui" {
edit = "e";
expand = ''["<CR>" "<2-LeftMouse>"]'';
open = "o";
remove = "d";
repl = "r";
toggle = "t";
};
}) "Keys to trigger actions in elements.";
render = {
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.";
maxValueLines =
helpers.defaultNullOpts.mkInt 100
"Maximum number of lines to allow a value to fill before trimming.";
};
selectWindow = helpers.defaultNullOpts.mkLuaFn "null" ''
A function which returns a window to be used for opening buffers such as a stack frame location.
'';
};
config =
let
options =
with cfg;
{
inherit
controls
icons
layouts
mappings
;
element_mappings = elementMappings;
floating = with floating; {
inherit border mappings;
max_height = maxHeight;
max_width = maxWidth;
};
force_buffers = forceBuffers;
render = with render; {
inherit indent;
max_type_length = maxTypeLength;
max_value_lines = maxValueLines;
};
select_window = selectWindow;
}
// cfg.extraOptions;
in
mkIf cfg.enable { mkIf cfg.enable {
extraPlugins = [cfg.package]; extraPlugins = [ cfg.package ];
plugins.dap = { plugins.dap = {
enable = true; enable = true;

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,26 +63,27 @@ in {
''; '';
}; };
config = let config =
options = with cfg; { let
inherit commented; options = with cfg; {
inherit commented;
enabled_commands = enabledCommands; enabled_commands = enabledCommands;
highlight_changed_variables = highlightChangedVariables; highlight_changed_variables = highlightChangedVariables;
highlight_new_as_changed = highlightNewAsChanged; highlight_new_as_changed = highlightNewAsChanged;
show_stop_reason = showStopReason; show_stop_reason = showStopReason;
only_first_definition = onlyFirstDefinition; only_first_definition = onlyFirstDefinition;
all_references = allReferences; all_references = allReferences;
clear_on_continue = clearOnContinue; clear_on_continue = clearOnContinue;
display_callback = displayCallback; display_callback = displayCallback;
virt_text_pos = virtTextPos; virt_text_pos = virtTextPos;
all_frames = allFrames; all_frames = allFrames;
virt_lines = virtLines; virt_lines = virtLines;
virt_text_win_col = virtTextWinCol; virt_text_win_col = virtTextWinCol;
}; };
in in
mkIf cfg.enable { mkIf cfg.enable {
extraPlugins = [cfg.package]; extraPlugins = [ cfg.package ];
plugins.dap = { plugins.dap = {
enable = true; enable = true;

View file

@ -1,40 +1,37 @@
{ { 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. For most debug adapters setting this is not necessary.
For most debug adapters setting this is not necessary. '';
enrichConfig = helpers.mkNullOrLuaFn ''
A lua function (`func(config, on_config)`) which allows an adapter to enrich a
configuration with additional information. It receives a configuration as first
argument, and a callback that must be called with the final configuration as second argument.
'';
options = {
initializeTimeoutSec = helpers.defaultNullOpts.mkInt 4 ''
How many seconds the client waits for a response on a initialize request before emitting a warning.
''; '';
enrichConfig = helpers.mkNullOrLuaFn '' disconnectTimeoutSec = helpers.defaultNullOpts.mkInt 3 ''
A lua function (`func(config, on_config)`) which allows an adapter to enrich a How many seconds the client waits for a disconnect response from the debug
configuration with additional information. It receives a configuration as first adapter before emitting a warning and closing the connection.
argument, and a callback that must be called with the final configuration as second argument.
''; '';
options = { sourceFiletype = helpers.mkNullOrOption types.str ''
initializeTimeoutSec = helpers.defaultNullOpts.mkInt 4 '' The filetype to use for content retrieved via a source request.
How many seconds the client waits for a response on a initialize request before emitting a warning. '';
''; };
} // attrs;
disconnectTimeoutSec = helpers.defaultNullOpts.mkInt 3 ''
How many seconds the client waits for a disconnect response from the debug
adapter before emitting a warning and closing the connection.
'';
sourceFiletype = helpers.mkNullOrOption types.str ''
The filetype to use for content retrieved via a source request.
'';
};
}
// attrs;
}; };
executableAdapterOption = mkAdapterType { executableAdapterOption = mkAdapterType {
@ -54,7 +51,7 @@ with lib; rec {
serverAdapterOption = mkAdapterType { serverAdapterOption = mkAdapterType {
host = helpers.defaultNullOpts.mkStr "127.0.0.1" "Host to connect to."; host = helpers.defaultNullOpts.mkStr "127.0.0.1" "Host to connect to.";
port = helpers.mkNullOrOption (types.either types.int (types.enum ["$\{port}"])) '' port = helpers.mkNullOrOption (types.either types.int (types.enum [ "$\{port}" ])) ''
Port to connect to. Port to connect to.
If "$\{port}" dap resolves a free port. If "$\{port}" dap resolves a free port.
This is intended to be used with `executable.args`. This is intended to be used with `executable.args`.
@ -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,18 +121,20 @@ 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
else helpers.mkRaw adapter
filterAttrs (n: _: n != "enrichConfig") ( else
adapter filterAttrs (n: _: n != "enrichConfig") (
// { adapter
inherit type; // {
enrich_config = adapter.enrichConfig; inherit type;
} enrich_config = adapter.enrichConfig;
)) }
adapters; )
) adapters;
} }

View file

@ -5,70 +5,70 @@
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 = [ {
./dap-go.nix imports = [
./dap-python.nix ./dap-go.nix
./dap-ui.nix ./dap-python.nix
./dap-virtual-text.nix ./dap-ui.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;
adapters = helpers.mkCompositeOption "Dap adapters." { adapters = helpers.mkCompositeOption "Dap adapters." {
executables = mkAdapterOption "executable" executableAdapterOption; executables = mkAdapterOption "executable" executableAdapterOption;
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.
''; '';
signs = helpers.mkCompositeOption "Signs for dap." { signs = helpers.mkCompositeOption "Signs for dap." {
dapBreakpoint = mkSignOption "B" "Sign for breakpoints."; dapBreakpoint = mkSignOption "B" "Sign for breakpoints.";
dapBreakpointCondition = mkSignOption "C" "Sign for conditional breakpoints."; dapBreakpointCondition = mkSignOption "C" "Sign for conditional breakpoints.";
dapLogPoint = mkSignOption "L" "Sign for log points."; dapLogPoint = mkSignOption "L" "Sign for log points.";
dapStopped = mkSignOption "" "Sign to indicate where the debuggee is stopped."; dapStopped = mkSignOption "" "Sign to indicate where the debuggee is stopped.";
dapBreakpointRejected = mkSignOption "R" "Sign to indicate breakpoints rejected by the debug adapter."; dapBreakpointRejected = mkSignOption "R" "Sign to indicate breakpoints rejected by the debug adapter.";
}; };
extensionConfigLua = mkOption { extensionConfigLua = mkOption {
type = types.lines; type = types.lines;
description = '' description = ''
Extension configuration for dap. Don't use this directly ! Extension configuration for dap. Don't use this directly !
''; '';
default = ""; default = "";
internal = true; internal = true;
}; };
}; };
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;
@ -80,22 +80,22 @@ in
} }
// cfg.extraOptions; // cfg.extraOptions;
in in
mkIf cfg.enable { mkIf cfg.enable {
extraPlugins = [cfg.package]; extraPlugins = [ cfg.package ];
extraConfigLua = extraConfigLua =
(optionalString (cfg.adapters != null) '' (optionalString (cfg.adapters != null) ''
require("dap").adapters = ${helpers.toLuaObject options.adapters} require("dap").adapters = ${helpers.toLuaObject options.adapters}
'') '')
+ (optionalString (options.configurations != null) '' + (optionalString (options.configurations != null) ''
require("dap").configurations = ${helpers.toLuaObject options.configurations} require("dap").configurations = ${helpers.toLuaObject options.configurations}
'') '')
+ (optionalString (cfg.signs != null) '' + (optionalString (cfg.signs != null) ''
local __dap_signs = ${helpers.toLuaObject options.signs} local __dap_signs = ${helpers.toLuaObject options.signs}
for sign_name, sign in pairs(__dap_signs) do for sign_name, sign in pairs(__dap_signs) do
vim.fn.sign_define(sign_name, sign) vim.fn.sign_define(sign_name, sign)
end end
'') '')
+ cfg.extensionConfigLua; + cfg.extensionConfigLua;
}; };
} }

View file

@ -5,92 +5,100 @@
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;
options = { options = {
follow = helpers.defaultNullOpts.mkBool true '' follow = helpers.defaultNullOpts.mkBool true ''
CHADTree will highlight currently open file, and open all its parents. CHADTree will highlight currently open file, and open all its parents.
'';
lang = helpers.mkNullOrOption types.str ''
CHADTree will guess your locale from unix environmental variables.
Set to `c` to disable emojis.
'';
mimetypes = {
warn = mkListStr ''["audio" "font" "image" "video"]'' ''
Show a warning before opening these datatypes.
''; '';
lang = helpers.mkNullOrOption types.str '' allowExts = mkListStr ''[".ts"]'' ''
CHADTree will guess your locale from unix environmental variables. Skip warning for these extensions.
Set to `c` to disable emojis.
''; '';
mimetypes = {
warn = mkListStr ''["audio" "font" "image" "video"]'' ''
Show a warning before opening these datatypes.
'';
allowExts = mkListStr ''[".ts"]'' ''
Skip warning for these extensions.
'';
};
pageIncrement = helpers.defaultNullOpts.mkInt 5 ''
Change how many lines `{` and `}` scroll.
'';
pollingRate = helpers.defaultNullOpts.mkNum 2.0 ''
CHADTree's background refresh rate.
'';
session = helpers.defaultNullOpts.mkBool true ''
Save & restore currently open folders.
'';
showHidden = helpers.defaultNullOpts.mkBool false ''
Hide some files and folders by default. By default this can be toggled using the `.` key.
see `chadtree_settings.ignore` for more details.
'';
versionControl = helpers.defaultNullOpts.mkBool true ''
Enable version control. This can also be toggled. But unlike `show_hidden`, does not have a default keybind.
'';
ignore = {
nameExact = mkListStr ''[".DS_Store" ".directory" "thumbs.db" ".git"]'' ''
Files whose name match these exactly will be ignored.
'';
nameGlob = mkListStr "[]" ''
Files whose name match these glob patterns will be ignored.
ie. `*.py` will match all python files
'';
pathGlob = mkListStr "[]" ''
Files whose full path match these glob patterns will be ignored.
'';
};
}; };
view = { pageIncrement = helpers.defaultNullOpts.mkInt 5 ''
openDirection = helpers.defaultNullOpts.mkEnum ["left" "right"] "left" '' Change how many lines `{` and `}` scroll.
Which way does CHADTree open? '';
pollingRate = helpers.defaultNullOpts.mkNum 2.0 ''
CHADTree's background refresh rate.
'';
session = helpers.defaultNullOpts.mkBool true ''
Save & restore currently open folders.
'';
showHidden = helpers.defaultNullOpts.mkBool false ''
Hide some files and folders by default. By default this can be toggled using the `.` key.
see `chadtree_settings.ignore` for more details.
'';
versionControl = helpers.defaultNullOpts.mkBool true ''
Enable version control. This can also be toggled. But unlike `show_hidden`, does not have a default keybind.
'';
ignore = {
nameExact = mkListStr ''[".DS_Store" ".directory" "thumbs.db" ".git"]'' ''
Files whose name match these exactly will be ignored.
''; '';
sortBy = mkListStr ''["is_folder" "ext" "file_name"]'' '' nameGlob = mkListStr "[]" ''
CHADTree can sort by the following criterion. Files whose name match these glob patterns will be ignored.
Reorder them if you want a different sorting order. ie. `*.py` will match all python files
legal keys: some of
`["is_folder" "ext" "file_name"]`
''; '';
width = helpers.defaultNullOpts.mkInt 40 '' pathGlob = mkListStr "[]" ''
How big is CHADTree when initially opened? Files whose full path match these glob patterns will be ignored.
''; '';
};
};
windowOptions = view = {
helpers.defaultNullOpts.mkAttributeSet '' openDirection =
helpers.defaultNullOpts.mkEnum
[
"left"
"right"
]
"left"
''
Which way does CHADTree open?
'';
sortBy = mkListStr ''["is_folder" "ext" "file_name"]'' ''
CHADTree can sort by the following criterion.
Reorder them if you want a different sorting order.
legal keys: some of
`["is_folder" "ext" "file_name"]`
'';
width = helpers.defaultNullOpts.mkInt 40 ''
How big is CHADTree when initially opened?
'';
windowOptions =
helpers.defaultNullOpts.mkAttributeSet
''
{ {
cursorline = true; cursorline = true;
number = false; number = false;
@ -103,34 +111,44 @@ in {
'' ''
Set of window local options to for CHADTree windows. Set of window local options to for CHADTree windows.
''; '';
}; };
theme = { theme = {
highlights = { highlights = {
ignored = helpers.defaultNullOpts.mkStr "Comment" '' ignored = helpers.defaultNullOpts.mkStr "Comment" ''
These are used for files that are ignored by user supplied pattern These are used for files that are ignored by user supplied pattern
in `chadtree.ignore` and by version control. in `chadtree.ignore` and by version control.
'';
bookmarks = helpers.defaultNullOpts.mkStr "Title" ''
These are used to show bookmarks.
'';
quickfix = helpers.defaultNullOpts.mkStr "Label" ''
These are used to notify the number of times a file / folder appears in the `quickfix` list.
'';
versionControl = helpers.defaultNullOpts.mkStr "Comment" ''
These are used to put a version control status beside each file.
'';
};
iconGlyphSet = helpers.defaultNullOpts.mkEnum ["devicons" "emoji" "ascii" "ascii_hollow"] "devicons" ''
Icon glyph set to use.
''; '';
textColourSet = bookmarks = helpers.defaultNullOpts.mkStr "Title" ''
helpers.defaultNullOpts.mkEnum [ These are used to show bookmarks.
'';
quickfix = helpers.defaultNullOpts.mkStr "Label" ''
These are used to notify the number of times a file / folder appears in the `quickfix` list.
'';
versionControl = helpers.defaultNullOpts.mkStr "Comment" ''
These are used to put a version control status beside each file.
'';
};
iconGlyphSet =
helpers.defaultNullOpts.mkEnum
[
"devicons"
"emoji"
"ascii"
"ascii_hollow"
]
"devicons"
''
Icon glyph set to use.
'';
textColourSet =
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,282 +168,294 @@ 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 =
Right now you all the file icons are coloured according to Github colours. helpers.defaultNullOpts.mkEnum
[
"github"
"none"
]
"github"
''
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.
'';
};
keymap = {
windowManagement = {
quit = mkListStr ''["q"]'' ''
Close CHADTree window, quit if it is the last window.
'';
bigger = mkListStr ''["+" "="]'' ''
Resize CHADTree window bigger.
'';
smaller = mkListStr ''["-" "_"]'' ''
Resize CHADTree window smaller.
'';
refresh = mkListStr ''["<c-r>"]'' ''
Refresh CHADTree.
''; '';
}; };
keymap = { rerooting = {
windowManagement = { changeDir = mkListStr ''["b"]'' ''
quit = mkListStr ''["q"]'' '' Change vim's working directory.
Close CHADTree window, quit if it is the last window. '';
'';
bigger = mkListStr ''["+" "="]'' '' changeFocus = mkListStr ''["c"]'' ''
Resize CHADTree window bigger. Set CHADTree's root to folder at cursor. Does not change working directory.
''; '';
smaller = mkListStr ''["-" "_"]'' '' changeFocusUp = mkListStr ''["C"]'' ''
Resize CHADTree window smaller. Set CHADTree's root one level up.
''; '';
};
refresh = mkListStr ''["<c-r>"]'' '' openFileFolder = {
Refresh CHADTree. primary = mkListStr ''["<enter>"]'' ''
''; Open file at cursor.
}; '';
rerooting = { secondary = mkListStr ''["<tab> <2-leftmouse>"]'' ''
changeDir = mkListStr ''["b"]'' '' Open file at cursor, keep cursor in CHADTree's window.
Change vim's working directory. '';
'';
changeFocus = mkListStr ''["c"]'' '' tertiary = mkListStr ''["<m-enter>" <middlemouse>]'' ''
Set CHADTree's root to folder at cursor. Does not change working directory. Open file at cursor in a new tab.
''; '';
changeFocusUp = mkListStr ''["C"]'' '' vSplit = mkListStr ''["w"]'' ''
Set CHADTree's root one level up. Open file at cursor in vertical split.
''; '';
};
openFileFolder = { hSplit = mkListStr ''["W"]'' ''
primary = mkListStr ''["<enter>"]'' '' Open file at cursor in horizontal split.
Open file at cursor. '';
'';
secondary = mkListStr ''["<tab> <2-leftmouse>"]'' '' openSys = mkListStr ''["o"]'' ''
Open file at cursor, keep cursor in CHADTree's window. Open file with GUI tools using `open` or `xdg open`.
''; This will open third party tools such as Finder or KDE Dolphin or GNOME nautilus, etc.
Depends on platform and user setup.
'';
tertiary = mkListStr ''["<m-enter>" <middlemouse>]'' '' collapse = mkListStr ''["o"]'' ''
Open file at cursor in a new tab. Collapse all subdirectories for directory at cursor.
''; '';
};
vSplit = mkListStr ''["w"]'' '' cursor = {
Open file at cursor in vertical split. refocus = mkListStr ''["~"]'' ''
''; Put cursor at the root of CHADTree.
'';
hSplit = mkListStr ''["W"]'' '' jumpToCurrent = mkListStr ''["J"]'' ''
Open file at cursor in horizontal split. Position cursor in CHADTree at currently open buffer, if the buffer points to a location visible under CHADTree.
''; '';
openSys = mkListStr ''["o"]'' '' stat = mkListStr ''["K"]'' ''
Open file with GUI tools using `open` or `xdg open`. Print `ls --long` stat for file under cursor.
This will open third party tools such as Finder or KDE Dolphin or GNOME nautilus, etc. '';
Depends on platform and user setup.
'';
collapse = mkListStr ''["o"]'' '' copyName = mkListStr ''["y"]'' ''
Collapse all subdirectories for directory at cursor. Copy paths of files under cursor or visual block.
''; '';
};
cursor = { copyBasename = mkListStr ''["Y"]'' ''
refocus = mkListStr ''["~"]'' '' Copy names of files under cursor or visual block.
Put cursor at the root of CHADTree. '';
'';
jumpToCurrent = mkListStr ''["J"]'' '' copyRelname = mkListStr ''["<c-y>"]'' ''
Position cursor in CHADTree at currently open buffer, if the buffer points to a location visible under CHADTree. Copy relative paths of files under cursor or visual block.
''; '';
};
stat = mkListStr ''["K"]'' '' filtering = {
Print `ls --long` stat for file under cursor. filter = mkListStr ''["f"]'' ''
''; Set a glob pattern to narrow down visible files.
'';
copyName = mkListStr ''["y"]'' '' clearFilter = mkListStr ''["F"]'' ''
Copy paths of files under cursor or visual block. Clear filter.
''; '';
};
copyBasename = mkListStr ''["Y"]'' '' bookmarks = {
Copy names of files under cursor or visual block. bookmarkGoto = mkListStr ''["m"]'' ''
''; Goto bookmark `A-Z`.
'';
};
copyRelname = mkListStr ''["<c-y>"]'' '' selecting = {
Copy relative paths of files under cursor or visual block. select = mkListStr ''["s"]'' ''
''; Select files under cursor or visual block.
}; '';
filtering = { clearSelection = mkListStr ''["S"]'' ''
filter = mkListStr ''["f"]'' '' Clear selection.
Set a glob pattern to narrow down visible files. '';
''; };
clearFilter = mkListStr ''["F"]'' '' fileOperations = {
Clear filter. new = mkListStr ''["a"]'' ''
''; Create new file at location under cursor. Files ending with platform specific path separator will be folders.
};
bookmarks = { Intermediary folders are created automatically.
bookmarkGoto = mkListStr ''["m"]'' ''
Goto bookmark `A-Z`.
'';
};
selecting = { ie. `uwu/owo/` under unix will create `uwu/` then `owo/` under it. Both are folders.
select = mkListStr ''["s"]'' '' '';
Select files under cursor or visual block.
'';
clearSelection = mkListStr ''["S"]'' '' link = mkListStr ''["A"]'' ''
Clear selection. Create links at location under cursor from selection.
'';
};
fileOperations = { Links are always relative.
new = mkListStr ''["a"]'' ''
Create new file at location under cursor. Files ending with platform specific path separator will be folders.
Intermediary folders are created automatically. Intermediary folders are created automatically.
'';
ie. `uwu/owo/` under unix will create `uwu/` then `owo/` under it. Both are folders. rename = mkListStr ''["r"]'' ''
''; Rename file under cursor.
'';
link = mkListStr ''["A"]'' '' toggleExec = mkListStr ''["X"]'' ''
Create links at location under cursor from selection. Toggle all the `+x` bits of the selected / highlighted files.
Links are always relative. Except for directories, where `-x` will prevent reading.
'';
Intermediary folders are created automatically. copy = mkListStr ''["p"]'' ''
''; Copy the selected files to location under cursor.
'';
rename = mkListStr ''["r"]'' '' cut = mkListStr ''["x"]'' ''
Rename file under cursor. Move the selected files to location under cursor.
''; '';
toggleExec = mkListStr ''["X"]'' '' delete = mkListStr ''["d"]'' ''
Toggle all the `+x` bits of the selected / highlighted files. Delete the selected files. Items deleted cannot be recovered.
'';
Except for directories, where `-x` will prevent reading. trash = mkListStr ''[t]'' ''
''; Trash the selected files using platform specific `trash` command, if they are available.
Items trashed may be recovered.
'';
};
copy = mkListStr ''["p"]'' '' toggles = {
Copy the selected files to location under cursor. toggleHidden = mkListStr ''["."]'' ''
''; Toggle show_hidden on and off. See `chadtree.showHidden` for details.
'';
cut = mkListStr ''["x"]'' '' toggleFollow = mkListStr ''["u"]'' ''
Move the selected files to location under cursor. Toggle `follow` on and off. See `chadtree.follow` for details.
''; '';
delete = mkListStr ''["d"]'' '' toggleVersionControl = mkListStr ''["i"]'' ''
Delete the selected files. Items deleted cannot be recovered. Toggle version control integration on and off.
''; '';
trash = mkListStr ''[t]'' ''
Trash the selected files using platform specific `trash` command, if they are available.
Items trashed may be recovered.
'';
};
toggles = {
toggleHidden = mkListStr ''["."]'' ''
Toggle show_hidden on and off. See `chadtree.showHidden` for details.
'';
toggleFollow = mkListStr ''["u"]'' ''
Toggle `follow` on and off. See `chadtree.follow` for details.
'';
toggleVersionControl = mkListStr ''["i"]'' ''
Toggle version control integration on and off.
'';
};
}; };
}; };
};
config = let config =
setupOptions = with cfg; { let
xdg = true; setupOptions = with cfg; {
options = with options; { xdg = true;
inherit follow; options = with options; {
inherit lang; inherit follow;
mimetypes = with mimetypes; { inherit lang;
inherit warn; mimetypes = with mimetypes; {
allow_exts = allowExts; inherit warn;
}; allow_exts = allowExts;
page_increment = pageIncrement; };
polling_rate = pollingRate; page_increment = pageIncrement;
inherit session; polling_rate = pollingRate;
show_hidden = showHidden; inherit session;
version_control = versionControl; show_hidden = showHidden;
ignore = with ignore; {
name_exact = nameExact;
name_glob = nameGlob;
path_glob = pathGlob;
};
};
view = with view; {
open_direction = openDirection;
sort_by = sortBy;
inherit width;
window_options = windowOptions;
};
theme = with theme; {
highlights = with highlights; {
inherit ignored;
inherit bookmarks;
inherit quickfix;
version_control = versionControl; version_control = versionControl;
ignore = with ignore; {
name_exact = nameExact;
name_glob = nameGlob;
path_glob = pathGlob;
};
}; };
icon_glyph_set = iconGlyphSet; view = with view; {
text_colour_set = textColourSet; open_direction = openDirection;
icon_colour_set = iconColourSet; sort_by = sortBy;
inherit width;
window_options = windowOptions;
};
theme = with theme; {
highlights = with highlights; {
inherit ignored;
inherit bookmarks;
inherit quickfix;
version_control = versionControl;
};
icon_glyph_set = iconGlyphSet;
text_colour_set = textColourSet;
icon_colour_set = iconColourSet;
};
keymap =
with keymap;
with windowManagement;
with rerooting;
with openFileFolder;
with cursor;
with filtering;
with bookmarks;
with selecting;
with fileOperations;
with toggles;
{
inherit quit;
inherit bigger;
inherit smaller;
inherit refresh;
change_dir = changeDir;
change_focus = changeFocus;
change_focus_up = changeFocusUp;
inherit primary;
inherit secondary;
inherit tertiary;
v_split = vSplit;
h_split = hSplit;
open_sys = openSys;
inherit collapse;
inherit refocus;
jump_to_current = jumpToCurrent;
inherit stat;
copy_name = copyName;
copy_basename = copyBasename;
copy_relname = copyRelname;
inherit filter;
clear_filter = clearFilter;
bookmark_goto = bookmarkGoto;
inherit select;
clear_selection = clearSelection;
inherit new;
inherit link;
inherit rename;
toggle_exec = toggleExec;
inherit copy;
inherit cut;
inherit delete;
inherit trash;
toggle_hidden = toggleHidden;
toggle_follow = toggleFollow;
toggle_version_control = toggleVersionControl;
};
}; };
keymap = with keymap; in
with windowManagement;
with rerooting;
with openFileFolder;
with cursor;
with filtering;
with bookmarks;
with selecting;
with fileOperations;
with toggles; {
inherit quit;
inherit bigger;
inherit smaller;
inherit refresh;
change_dir = changeDir;
change_focus = changeFocus;
change_focus_up = changeFocusUp;
inherit primary;
inherit secondary;
inherit tertiary;
v_split = vSplit;
h_split = hSplit;
open_sys = openSys;
inherit collapse;
inherit refocus;
jump_to_current = jumpToCurrent;
inherit stat;
copy_name = copyName;
copy_basename = copyBasename;
copy_relname = copyRelname;
inherit filter;
clear_filter = clearFilter;
bookmark_goto = bookmarkGoto;
inherit select;
clear_selection = clearSelection;
inherit new;
inherit link;
inherit rename;
toggle_exec = toggleExec;
inherit copy;
inherit cut;
inherit delete;
inherit trash;
toggle_hidden = toggleHidden;
toggle_follow = toggleFollow;
toggle_version_control = toggleVersionControl;
};
};
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})

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -9,9 +9,9 @@ helpers.vim-plugin.mkVimPlugin config {
originalName = "committia.vim"; originalName = "committia.vim";
defaultPackage = pkgs.vimPlugins.committia-vim; defaultPackage = pkgs.vimPlugins.committia-vim;
globalPrefix = "committia_"; globalPrefix = "committia_";
extraPackages = [pkgs.git]; extraPackages = [ pkgs.git ];
maintainers = [helpers.maintainers.alisonjenkins]; maintainers = [ helpers.maintainers.alisonjenkins ];
settingsOptions = { settingsOptions = {
open_only_vim_starting = helpers.defaultNullOpts.mkBool true '' open_only_vim_starting = helpers.defaultNullOpts.mkBool true ''

File diff suppressed because it is too large Load diff

View file

@ -9,9 +9,9 @@ helpers.vim-plugin.mkVimPlugin config {
name = "fugitive"; name = "fugitive";
originalName = "vim-fugitive"; originalName = "vim-fugitive";
defaultPackage = pkgs.vimPlugins.vim-fugitive; defaultPackage = pkgs.vimPlugins.vim-fugitive;
extraPackages = [pkgs.git]; extraPackages = [ pkgs.git ];
maintainers = [lib.maintainers.GaetanLepage]; maintainers = [ lib.maintainers.GaetanLepage ];
# In typical tpope fashion, this plugin has no config options # In typical tpope fashion, this plugin has no config options
} }

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,16 +45,17 @@ in {
}; };
}; };
config = let config =
setupOptions = with cfg; { let
enabled = cfg.enable; setupOptions = with cfg; {
change_directory_command = cfg.changeDirectoryCommand; enabled = cfg.enable;
update_on_change = cfg.updateOnChange; change_directory_command = cfg.changeDirectoryCommand;
update_on_change_command = cfg.updateOnChangeCommand; update_on_change = cfg.updateOnChange;
clearjumps_on_change = cfg.clearJumpsOnChange; update_on_change_command = cfg.updateOnChangeCommand;
inherit autopush; clearjumps_on_change = cfg.clearJumpsOnChange;
}; inherit autopush;
in };
in
mkIf cfg.enable { mkIf cfg.enable {
assertions = [ assertions = [
{ {
@ -66,17 +69,15 @@ in {
plenary-nvim plenary-nvim
]; ];
extraPackages = [pkgs.git]; extraPackages = [ pkgs.git ];
extraConfigLua = let extraConfigLua =
telescopeCfg = ''require("telescope").load_extension("git_worktree")''; let
in '' telescopeCfg = ''require("telescope").load_extension("git_worktree")'';
require('git-worktree').setup(${helpers.toLuaObject setupOptions}) in
${ ''
if cfg.enableTelescope require('git-worktree').setup(${helpers.toLuaObject setupOptions})
then telescopeCfg ${if cfg.enableTelescope then telescopeCfg else ""}
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,40 +24,47 @@ 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 =
setupOptions = { let
enabled = cfg.enable; setupOptions = {
message_template = cfg.messageTemplate; enabled = cfg.enable;
date_format = cfg.dateFormat; message_template = cfg.messageTemplate;
message_when_not_committed = cfg.messageWhenNotCommitted; date_format = cfg.dateFormat;
highlight_group = cfg.highlightGroup; message_when_not_committed = cfg.messageWhenNotCommitted;
display_virtual_text = helpers.ifNonNull' cfg.displayVirtualText ( highlight_group = cfg.highlightGroup;
if cfg.displayVirtualText display_virtual_text = helpers.ifNonNull' cfg.displayVirtualText (
then 1 if cfg.displayVirtualText then 1 else 0
else 0 );
); ignored_filetypes = cfg.ignoredFiletypes;
ignored_filetypes = cfg.ignoredFiletypes; inherit (cfg) delay;
inherit (cfg) delay; virtual_text_column = cfg.virtualTextColumn;
virtual_text_column = cfg.virtualTextColumn; set_extmark_options = cfg.extmarkOptions;
set_extmark_options = cfg.extmarkOptions; };
}; in
in
mkIf cfg.enable { mkIf cfg.enable {
extraPlugins = [cfg.package]; extraPlugins = [ cfg.package ];
extraPackages = [pkgs.git]; extraPackages = [ pkgs.git ];
extraConfigLua = '' extraConfigLua = ''
require('gitblame').setup${helpers.toLuaObject setupOptions} require('gitblame').setup${helpers.toLuaObject setupOptions}

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