added formatter + reformat existing codebase (#175)

This commit is contained in:
Gaétan Lepage 2023-02-20 11:42:13 +01:00 committed by GitHub
parent 0bf4313f22
commit 264de8cefb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
96 changed files with 3727 additions and 3341 deletions

View file

@ -1,7 +1,9 @@
(import ( (import (
fetchTarball { fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/c75e76f80c57784a6734356315b306140646ee84.tar.gz"; url = "https://github.com/edolstra/flake-compat/archive/c75e76f80c57784a6734356315b306140646ee84.tar.gz";
sha256 = "071aal00zp2m9knnhddgr2wqzlx6i6qa1263lv1y7bdn2w20h10h"; } sha256 = "071aal00zp2m9knnhddgr2wqzlx6i6qa1263lv1y7bdn2w20h10h";
}
) { ) {
src = ./.; src = ./.;
}).defaultNix })
.defaultNix

View file

@ -1,5 +1,9 @@
{ pkgs, lib, modules, ... }: {
let pkgs,
lib,
modules,
...
}: let
options = lib.evalModules { options = lib.evalModules {
modules = modules; modules = modules;
specialArgs = {inherit pkgs lib;}; specialArgs = {inherit pkgs lib;};

View file

@ -1,5 +1,4 @@
{ 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

View file

@ -6,15 +6,21 @@
inputs.beautysh.url = "github:lovesegfault/beautysh"; inputs.beautysh.url = "github:lovesegfault/beautysh";
inputs.beautysh.inputs.nixpkgs.follows = "nixpkgs"; inputs.beautysh.inputs.nixpkgs.follows = "nixpkgs";
outputs = { self, nixpkgs, flake-utils, ... }@inputs: outputs = {
self,
nixpkgs,
flake-utils,
...
} @ inputs:
with nixpkgs.lib; with nixpkgs.lib;
with builtins; with builtins; let
let
# TODO: Support nesting # TODO: Support nesting
nixvimModules = map (f: ./modules + "/${f}") (attrNames (builtins.readDir ./modules)); nixvimModules = map (f: ./modules + "/${f}") (attrNames (builtins.readDir ./modules));
modules = pkgs: nixvimModules ++ [ modules = pkgs:
(rec { nixvimModules
++ [
rec {
_file = ./flake.nix; _file = ./flake.nix;
key = _file; key = _file;
config = { config = {
@ -25,17 +31,20 @@
inputs = inputs; inputs = inputs;
}; };
}; };
}) }
# ./plugins/default.nix # ./plugins/default.nix
]; ];
flakeOutput = flakeOutput =
flake-utils.lib.eachDefaultSystem flake-utils.lib.eachDefaultSystem
(system: (system: let
let
pkgs = import nixpkgs {inherit system;}; pkgs = import nixpkgs {inherit system;};
extractRustAnalyzer = { stdenv, pkgs }: stdenv.mkDerivation { extractRustAnalyzer = {
stdenv,
pkgs,
}:
stdenv.mkDerivation {
pname = "extract_rust_analyzer"; pname = "extract_rust_analyzer";
version = "master"; version = "master";
@ -51,14 +60,18 @@
''; '';
}; };
extractRustAnalyzerPkg = pkgs.callPackage extractRustAnalyzer {}; extractRustAnalyzerPkg = pkgs.callPackage extractRustAnalyzer {};
in in {
{
packages = { packages = {
docs = pkgs.callPackage (import ./docs.nix) { docs = pkgs.callPackage (import ./docs.nix) {
modules = nixvimModules; modules = nixvimModules;
}; };
runUpdates = pkgs.callPackage runUpdates =
({ pkgs, stdenv }: stdenv.mkDerivation { pkgs.callPackage
({
pkgs,
stdenv,
}:
stdenv.mkDerivation {
pname = "run-updates"; pname = "run-updates";
version = pkgs.rust-analyzer.version; version = pkgs.rust-analyzer.version;
@ -81,15 +94,18 @@
}; };
legacyPackages = rec { legacyPackages = rec {
makeNixvimWithModule = import ./wrappers/standalone.nix pkgs modules; makeNixvimWithModule = import ./wrappers/standalone.nix pkgs modules;
makeNixvim = configuration: makeNixvimWithModule { makeNixvim = configuration:
makeNixvimWithModule {
module = { module = {
config = configuration; config = configuration;
}; };
}; };
}; };
formatter = pkgs.alejandra;
}); });
in in
flakeOutput // { flakeOutput
// {
nixosModules.nixvim = import ./wrappers/nixos.nix modules; nixosModules.nixvim = import ./wrappers/nixos.nix modules;
homeManagerModules.nixvim = import ./wrappers/hm.nix modules; homeManagerModules.nixvim = import ./wrappers/hm.nix modules;
nixDarwinModules.nixvim = import ./wrappers/darwin.nix modules; nixDarwinModules.nixvim = import ./wrappers/darwin.nix modules;

View file

@ -1,48 +1,52 @@
{lib, ...}: {lib, ...}:
with lib; with lib; rec {
rec {
# vim dictionaries are, in theory, compatible with JSON # vim dictionaries are, in theory, compatible with JSON
toVimDict = args: toJSON toVimDict = args:
toJSON
(lib.filterAttrs (n: v: !isNull v) args); (lib.filterAttrs (n: v: !isNull v) args);
# 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 = args:
if builtins.isAttrs args then if builtins.isAttrs args
if hasAttr "__raw" args then then
args.__raw if hasAttr "__raw" args
then args.__raw
else else
"{" + (concatStringsSep "," "{"
+ (concatStringsSep ","
(mapAttrsToList (mapAttrsToList
(n: v: (n: v:
if head (stringToCharacters n) == "@" then if head (stringToCharacters n) == "@"
toLuaObject v then toLuaObject v
else "[${toLuaObject n}] = " + (toLuaObject v)) else "[${toLuaObject n}] = " + (toLuaObject v))
(filterAttrs (n: v: !isNull v && toLuaObject v != "{}") args))) + "}" (filterAttrs (n: v: !isNull v && toLuaObject v != "{}") args)))
else if builtins.isList args then + "}"
"{" + concatMapStringsSep "," toLuaObject args + "}" else if builtins.isList args
else if builtins.isString args then then "{" + concatMapStringsSep "," toLuaObject args + "}"
else if builtins.isString args
then
# This should be enough! # This should be enough!
builtins.toJSON args builtins.toJSON args
else if builtins.isPath args then else if builtins.isPath args
builtins.toJSON (toString args) then builtins.toJSON (toString args)
else if builtins.isBool args then else if builtins.isBool args
"${ boolToString args }" then "${boolToString args}"
else if builtins.isFloat args then else if builtins.isFloat args
"${ toString args }" then "${toString args}"
else if builtins.isInt args then else if builtins.isInt args
"${ toString args }" then "${toString args}"
else if isNull args then else if isNull args
"nil" then "nil"
else ""; else "";
# Generates maps for a lua config # Generates maps for a lua config
genMaps = mode: maps: genMaps = mode: maps: let
let normalized =
normalized = builtins.mapAttrs builtins.mapAttrs
(key: action: (key: action:
if builtins.isString action then if builtins.isString action
{ then {
silent = false; silent = false;
expr = false; expr = false;
unique = false; unique = false;
@ -55,8 +59,7 @@ rec {
maps; maps;
in in
builtins.attrValues (builtins.mapAttrs builtins.attrValues (builtins.mapAttrs
(key: action: (key: action: {
{
action = action.action; action = action.action;
config = lib.filterAttrs (_: v: v) { config = lib.filterAttrs (_: v: v) {
inherit (action) silent expr unique noremap script nowait; inherit (action) silent expr unique noremap script nowait;
@ -67,7 +70,8 @@ rec {
normalized); normalized);
# 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: lib.mkOption { mkNullOrOption = type: desc:
lib.mkOption {
type = lib.types.nullOr type; type = lib.types.nullOr type;
default = null; default = null;
description = desc; description = desc;
@ -76,11 +80,14 @@ rec {
mkIfNonNull = c: mkIf (!isNull c) c; mkIfNonNull = c: mkIf (!isNull c) c;
defaultNullOpts = rec { defaultNullOpts = rec {
mkNullable = type: default: desc: mkNullOrOption type ( mkNullable = type: default: desc:
mkNullOrOption type (
let let
defaultDesc = "default: `${default}`"; defaultDesc = "default: `${default}`";
in in
if desc == "" then defaultDesc else '' if desc == ""
then defaultDesc
else ''
${desc} ${desc}
${defaultDesc} ${defaultDesc}
@ -88,45 +95,64 @@ rec {
); );
mkInt = default: mkNullable lib.types.int (toString default); mkInt = default: mkNullable lib.types.int (toString default);
mkBool = default: mkNullable lib.types.bool (if default then "true" else "false"); mkBool = default:
mkNullable lib.types.bool (
if default
then "true"
else "false"
);
mkStr = default: mkNullable lib.types.str ''${builtins.toString default}''; mkStr = default: mkNullable lib.types.str ''${builtins.toString default}'';
mkEnum = enum: default: mkNullable (lib.types.enum enum) ''"${default}"''; mkEnum = enum: default: mkNullable (lib.types.enum enum) ''"${default}"'';
mkEnumFirstDefault = enum: mkEnum enum (head enum); mkEnumFirstDefault = enum: mkEnum enum (head enum);
}; };
mkPackageOption = name: default: mkOption { mkPackageOption = name: default:
mkOption {
type = types.package; type = types.package;
inherit default; inherit default;
description = "Plugin to use for ${name}"; description = "Plugin to use for ${name}";
}; };
mkPlugin = { config, lib, ... }: { name mkPlugin = {
, description config,
, package ? null lib,
, extraPlugins ? [ ] ...
, extraPackages ? [ ] }: {
, options ? { } name,
, ... description,
}: package ? null,
let extraPlugins ? [],
extraPackages ? [],
options ? {},
...
}: let
cfg = config.plugins.${name}; cfg = config.plugins.${name};
# TODO support nested options! # TODO support nested options!
pluginOptions = mapAttrs (k: v: v.option) options; pluginOptions = mapAttrs (k: v: v.option) options;
globals = mapAttrs' globals =
mapAttrs'
(name: opt: { (name: opt: {
name = opt.global; name = opt.global;
value = if cfg.${name} != null then opt.value cfg.${name} else null; value =
if cfg.${name} != null
then opt.value cfg.${name}
else null;
}) })
options; options;
# does this evaluate package? # does this evaluate package?
packageOption = if package == null then { } else { packageOption =
if package == null
then {}
else {
package = mkPackageOption name package; package = mkPackageOption name package;
}; };
in in {
options.plugins.${name} =
{ {
options.plugins.${name} = {
enable = mkEnableOption description; enable = mkEnableOption description;
} // packageOption // pluginOptions; }
// packageOption
// pluginOptions;
config = mkIf cfg.enable { config = mkIf cfg.enable {
inherit extraPackages globals; inherit extraPackages globals;
@ -136,11 +162,24 @@ rec {
}; };
globalVal = val: globalVal = val:
if builtins.isBool val then if builtins.isBool val
(if val == false then 0 else 1) then
(
if val == false
then 0
else 1
)
else val; else val;
mkDefaultOpt = { type, global, description ? null, example ? null, default ? null, value ? v: (globalVal v), ... }: { mkDefaultOpt = {
type,
global,
description ? null,
example ? null,
default ? null,
value ? v: (globalVal v),
...
}: {
option = mkOption { option = mkOption {
type = types.nullOr type; type = types.nullOr type;
default = default; default = default;

View file

@ -1,48 +1,47 @@
{lib, ...}: {lib, ...}:
with lib; with lib; rec {
rec {
# This should be used instead of mkRemovedOptionModule, when the option still works, # This should be used instead of mkRemovedOptionModule, when the option still works,
# but is just deprecated and should be changed now and for the future # but is just deprecated and should be changed now and for the future
mkDeprecatedOption = mkDeprecatedOption = {
{ option # an array of the path to the option option, # an array of the path to the option
, alternative ? null alternative ? null,
, message ? null message ? null,
, visible ? false visible ? false,
}: }: {
{ options, config, ... }: options,
let config,
...
}: let
fromOpt = getAttrFromPath option options; fromOpt = getAttrFromPath option options;
fromValue = getAttrFromPath option config; fromValue = getAttrFromPath option config;
fullMessage = "The option `${showOption option}` has been deprecated, but might still work." + fullMessage =
(optionalString (alternative != null) " You may want to use `${showOption alternative}` instead.") + "The option `${showOption option}` has been deprecated, but might still work."
(optionalString (message != null) " Message: ${message}"); + (optionalString (alternative != null) " You may want to use `${showOption alternative}` instead.")
in + (optionalString (message != null) " Message: ${message}");
{ in {
config = mkIf (fromOpt.isDefined && fromValue != fromOpt.default) { config = mkIf (fromOpt.isDefined && fromValue != fromOpt.default) {
warnings = [ warnings = [
("Nixvim: ${fullMessage}") "Nixvim: ${fullMessage}"
]; ];
}; };
}; };
mkRenamedOption = mkRenamedOption = {
{ option option,
, newOption newOption,
, visible ? false visible ? false,
, warn ? true warn ? true,
, overrideDescription ? null overrideDescription ? null,
}: }: {options, ...}: let
{ options, ... }:
let
fromOpt = getAttrFromPath option options; fromOpt = getAttrFromPath option options;
# toOf = attrByPath newOption # toOf = attrByPath newOption
# (abort "Renaming error: option `${showOption newOption}` does not exist."); # (abort "Renaming error: option `${showOption newOption}` does not exist.");
toType = let opt = attrByPath newOption { } options; in toType = let
opt = attrByPath newOption {} options;
in
opt.type or (types.submodule {}); opt.type or (types.submodule {});
message = "`${showOption option}` has been renamed to `${showOption newOption}`, but can still be used for compatibility"; message = "`${showOption option}` has been renamed to `${showOption newOption}`, but can still be used for compatibility";
in in {
{
options = setAttrByPath option (mkOption options = setAttrByPath option (mkOption
{ {
inherit visible; inherit visible;
@ -50,7 +49,8 @@ rec {
if overrideDescription == null if overrideDescription == null
then message then message
else overrideDescription; else overrideDescription;
} // optionalAttrs (toType != null) { }
// optionalAttrs (toType != null) {
type = toType; type = toType;
}); });
config = mkMerge [ config = mkMerge [
@ -61,7 +61,8 @@ rec {
]; ];
}; };
mkAliasOption = option: newOption: mkRenamedOption { mkAliasOption = option: newOption:
mkRenamedOption {
inherit option newOption; inherit option newOption;
visible = true; visible = true;
warn = false; warn = false;

View file

@ -1,6 +1,9 @@
{ config, lib, ... }: {
with lib; config,
let lib,
...
}:
with lib; let
helpers = import ../lib/helpers.nix {inherit lib;}; helpers = import ../lib/helpers.nix {inherit lib;};
autoGroupOption = types.submodule { autoGroupOption = types.submodule {
@ -47,9 +50,7 @@ let
nested = helpers.defaultNullOpts.mkBool false "Run nested autocommands."; nested = helpers.defaultNullOpts.mkBool false "Run nested autocommands.";
}; };
}; };
in {
in
{
options = { options = {
autoGroups = mkOption { autoGroups = mkOption {
type = types.attrsOf autoGroupOption; type = types.attrsOf autoGroupOption;
@ -81,7 +82,8 @@ in
}; };
config = mkIf (config.autoGroups != {} || config.autoCmd != {}) { config = mkIf (config.autoGroups != {} || config.autoCmd != {}) {
extraConfigLuaPost = (optionalString (config.autoGroups != { }) '' extraConfigLuaPost =
(optionalString (config.autoGroups != {}) ''
-- Set up autogroups {{ -- Set up autogroups {{
do do
local __nixvim_autogroups = ${helpers.toLuaObject config.autoGroups} local __nixvim_autogroups = ${helpers.toLuaObject config.autoGroups}
@ -91,8 +93,8 @@ in
end end
end end
-- }} -- }}
'') + '')
(optionalString (config.autoCmd != [ ]) '' + (optionalString (config.autoCmd != []) ''
-- Set up autocommands {{ -- Set up autocommands {{
do do
local __nixvim_autocommands = ${helpers.toLuaObject config.autoCmd} local __nixvim_autocommands = ${helpers.toLuaObject config.autoCmd}

View file

@ -1,6 +1,9 @@
{ 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

@ -1,9 +1,11 @@
{ config, lib, ... }: {
let config,
lib,
...
}: let
helpers = import ../lib/helpers.nix {inherit lib;}; helpers = import ../lib/helpers.nix {inherit lib;};
in in
with lib; with lib; {
{
options = { options = {
highlight = mkOption { highlight = mkOption {
type = types.attrsOf types.anything; type = types.attrsOf types.anything;
@ -29,7 +31,8 @@ with lib;
}; };
config = mkIf (config.highlight != {} || config.match != {}) { config = mkIf (config.highlight != {} || config.match != {}) {
extraConfigLuaPost = (optionalString (config.highlight != { }) '' extraConfigLuaPost =
(optionalString (config.highlight != {}) ''
-- Highlight groups {{ -- Highlight groups {{
do do
local highlights = ${helpers.toLuaObject config.highlight} local highlights = ${helpers.toLuaObject config.highlight}
@ -39,8 +42,8 @@ with lib;
end end
end end
-- }} -- }}
'') + '')
(optionalString (config.match != { }) '' + (optionalString (config.match != {}) ''
-- Match groups {{ -- Match groups {{
do do
local match = ${helpers.toLuaObject config.match} local match = ${helpers.toLuaObject config.match}
@ -53,4 +56,3 @@ with lib;
''); '');
}; };
} }

View file

@ -1,6 +1,9 @@
{ config, lib, ... }: {
with lib; config,
let lib,
...
}:
with lib; let
helpers = import ../lib/helpers.nix {inherit lib;}; helpers = import ../lib/helpers.nix {inherit lib;};
mapOption = types.oneOf [ mapOption = types.oneOf [
@ -57,13 +60,13 @@ let
}) })
]; ];
mapOptions = mode: mkOption { mapOptions = mode:
mkOption {
description = "Mappings for ${mode} mode"; description = "Mappings for ${mode} mode";
type = types.attrsOf mapOption; type = types.attrsOf mapOption;
default = {}; default = {};
}; };
in in {
{
options = { options = {
maps = mkOption { maps = mkOption {
type = types.submodule { type = types.submodule {
@ -101,22 +104,20 @@ in
}; };
}; };
config = config = let
let
mappings = mappings =
(helpers.genMaps "" config.maps.normalVisualOp) ++ (helpers.genMaps "" config.maps.normalVisualOp)
(helpers.genMaps "n" config.maps.normal) ++ ++ (helpers.genMaps "n" config.maps.normal)
(helpers.genMaps "i" config.maps.insert) ++ ++ (helpers.genMaps "i" config.maps.insert)
(helpers.genMaps "v" config.maps.visual) ++ ++ (helpers.genMaps "v" config.maps.visual)
(helpers.genMaps "x" config.maps.visualOnly) ++ ++ (helpers.genMaps "x" config.maps.visualOnly)
(helpers.genMaps "s" config.maps.select) ++ ++ (helpers.genMaps "s" config.maps.select)
(helpers.genMaps "t" config.maps.terminal) ++ ++ (helpers.genMaps "t" config.maps.terminal)
(helpers.genMaps "o" config.maps.operator) ++ ++ (helpers.genMaps "o" config.maps.operator)
(helpers.genMaps "l" config.maps.lang) ++ ++ (helpers.genMaps "l" config.maps.lang)
(helpers.genMaps "!" config.maps.insertCommand) ++ ++ (helpers.genMaps "!" config.maps.insertCommand)
(helpers.genMaps "c" config.maps.command); ++ (helpers.genMaps "c" config.maps.command);
in in {
{
extraConfigLua = optionalString (mappings != []) '' extraConfigLua = optionalString (mappings != []) ''
-- Set up keybinds {{{ -- Set up keybinds {{{
do do

View file

@ -1,9 +1,11 @@
{ config, lib, ... }:
with lib;
let
helpers = import ../lib/helpers.nix { inherit lib; };
in
{ {
config,
lib,
...
}:
with lib; let
helpers = import ../lib/helpers.nix {inherit lib;};
in {
options = { options = {
options = mkOption { options = mkOption {
type = types.attrsOf types.anything; type = types.attrsOf types.anything;
@ -19,7 +21,8 @@ in
}; };
config = { config = {
extraConfigLuaPre = optionalString (config.globals != { }) '' extraConfigLuaPre =
optionalString (config.globals != {}) ''
-- Set up globals {{{ -- Set up globals {{{
do do
local nixvim_globals = ${helpers.toLuaObject config.globals} local nixvim_globals = ${helpers.toLuaObject config.globals}
@ -29,7 +32,8 @@ in
end end
end end
-- }}} -- }}}
'' + optionalString (config.options != { }) '' ''
+ optionalString (config.options != {}) ''
-- Set up options {{{ -- Set up options {{{
do do
local nixvim_options = ${helpers.toLuaObject config.options} local nixvim_options = ${helpers.toLuaObject config.options}

View file

@ -1,6 +1,10 @@
{ pkgs, config, lib, ... }: {
with lib; pkgs,
let config,
lib,
...
}:
with lib; let
pluginWithConfigType = types.submodule { pluginWithConfigType = types.submodule {
options = { options = {
config = mkOption { config = mkOption {
@ -9,7 +13,9 @@ let
default = ""; default = "";
}; };
optional = mkEnableOption "optional" // { optional =
mkEnableOption "optional"
// {
description = "Don't load by default (load with :packadd)"; description = "Don't load by default (load with :packadd)";
}; };
@ -19,8 +25,7 @@ let
}; };
}; };
}; };
in in {
{
options = { options = {
viAlias = mkOption { viAlias = mkOption {
type = types.bool; type = types.bool;
@ -74,7 +79,6 @@ in
description = "Extra contents for init.lua after everything else"; description = "Extra contents for init.lua after everything else";
}; };
extraConfigVim = mkOption { extraConfigVim = mkOption {
type = types.lines; type = types.lines;
default = ""; default = "";
@ -101,16 +105,21 @@ in
}; };
}; };
config = config = let
let
defaultPlugin = { defaultPlugin = {
plugin = null; plugin = null;
config = ""; config = "";
optional = false; optional = false;
}; };
normalizedPlugins = map (x: defaultPlugin // (if x ? plugin then x else { plugin = x; })) config.extraPlugins; normalizedPlugins = map (x:
defaultPlugin
// (
if x ? plugin
then x
else {plugin = x;}
))
config.extraPlugins;
neovimConfig = pkgs.neovimUtils.makeNeovimConfig ({ neovimConfig = pkgs.neovimUtils.makeNeovimConfig ({
inherit (config) viAlias vimAlias; inherit (config) viAlias vimAlias;
@ -121,8 +130,12 @@ in
# or more generally before the commit: # or more generally before the commit:
# cda1f8ae468 - neovim: pass packpath via the wrapper # cda1f8ae468 - neovim: pass packpath via the wrapper
// optionalAttrs (functionArgs pkgs.neovimUtils.makeNeovimConfig ? configure) { // optionalAttrs (functionArgs pkgs.neovimUtils.makeNeovimConfig ? configure) {
configure.packages = configure.packages = {
{ nixvim = { start = map (x: x.plugin) normalizedPlugins; opt = [ ]; }; }; nixvim = {
start = map (x: x.plugin) normalizedPlugins;
opt = [];
};
};
}); });
customRC = customRC =
@ -130,16 +143,16 @@ in
vim.cmd([[ vim.cmd([[
${neovimConfig.neovimRcContent} ${neovimConfig.neovimRcContent}
]]) ]])
'' + ''
(optionalString (config.extraConfigLuaPre != "") '' + (optionalString (config.extraConfigLuaPre != "") ''
${config.extraConfigLuaPre} ${config.extraConfigLuaPre}
'') + '')
(optionalString (config.extraConfigVim != "") '' + (optionalString (config.extraConfigVim != "") ''
vim.cmd([[ vim.cmd([[
${config.extraConfigVim} ${config.extraConfigVim}
]]) ]])
'') + '')
(optionalString (config.extraConfigLua != "" || config.extraConfigLuaPost != "") '' + (optionalString (config.extraConfigLua != "" || config.extraConfigLuaPost != "") ''
${config.extraConfigLua} ${config.extraConfigLua}
${config.extraConfigLuaPost} ${config.extraConfigLuaPost}
''); '');
@ -147,17 +160,16 @@ in
extraWrapperArgs = builtins.concatStringsSep " " ( extraWrapperArgs = builtins.concatStringsSep " " (
(optional (config.extraPackages != []) (optional (config.extraPackages != [])
''--prefix PATH : "${makeBinPath config.extraPackages}"'') ''--prefix PATH : "${makeBinPath config.extraPackages}"'')
++ ++ (optional (config.wrapRc)
(optional (config.wrapRc)
''--add-flags -u --add-flags "${pkgs.writeText "init.lua" customRC}"'') ''--add-flags -u --add-flags "${pkgs.writeText "init.lua" customRC}"'')
); );
wrappedNeovim = pkgs.wrapNeovimUnstable config.package (neovimConfig // { wrappedNeovim = pkgs.wrapNeovimUnstable config.package (neovimConfig
// {
wrapperArgs = lib.escapeShellArgs neovimConfig.wrapperArgs + " " + extraWrapperArgs; wrapperArgs = lib.escapeShellArgs neovimConfig.wrapperArgs + " " + extraWrapperArgs;
wrapRc = false; wrapRc = false;
}); });
in in {
{
finalPackage = wrappedNeovim; finalPackage = wrappedNeovim;
initContent = customRC; initContent = customRC;
}; };

View file

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

View file

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

View file

@ -1,10 +1,13 @@
{ lib, pkgs, config, ... }: {
with lib; lib,
let pkgs,
config,
...
}:
with lib; let
cfg = config.plugins.barbar; cfg = config.plugins.barbar;
helpers = import ../helpers.nix {inherit lib;}; helpers = import ../helpers.nix {inherit lib;};
in in {
{
options.plugins.barbar = { options.plugins.barbar = {
enable = mkEnableOption "barbar.nvim"; enable = mkEnableOption "barbar.nvim";
@ -65,9 +68,9 @@ in
highlightVisible = helpers.defaultNullOpts.mkBool true "Highlight visible buffers"; highlightVisible = helpers.defaultNullOpts.mkBool true "Highlight visible buffers";
icons = { icons = {
enable = helpers.defaultNullOpts.mkNullable enable =
helpers.defaultNullOpts.mkNullable
(with types; (either bool (enum ["numbers" "both"]))) (with types; (either bool (enum ["numbers" "both"])))
"true" "true"
'' ''
@ -75,7 +78,8 @@ in
'both', will show buffer index and icons in the tabline 'both', will show buffer index and icons in the tabline
''; '';
customColors = helpers.defaultNullOpts.mkNullable customColors =
helpers.defaultNullOpts.mkNullable
(types.either types.bool types.str) (types.either types.bool types.str)
"false" "false"
'' ''
@ -122,7 +126,6 @@ in
But only a static string is accepted here. But only a static string is accepted here.
''; '';
# Keybinds concept: # Keybinds concept:
# keys = { # keys = {
# previousBuffer = mkBindDef "normal" "Previous buffer" { action = ":BufferPrevious<CR>"; silent = true; } "<A-,>"; # previousBuffer = mkBindDef "normal" "Previous buffer" { action = ":BufferPrevious<CR>"; silent = true; } "<A-,>";

View file

@ -1,6 +1,10 @@
{ config, pkgs, lib, ... }@args: {
with lib; config,
let pkgs,
lib,
...
} @ args:
with lib; let
cfg = config.plugins.bufferline; cfg = config.plugins.bufferline;
optionWarnings = import ../../lib/option-warnings.nix args; optionWarnings = import ../../lib/option-warnings.nix args;
helpers = import ../helpers.nix args; helpers = import ../helpers.nix args;
@ -22,8 +26,7 @@ let
})); }));
default = {}; default = {};
}; };
in in {
{
imports = [ imports = [
(optionWarnings.mkDeprecatedOption { (optionWarnings.mkDeprecatedOption {
option = ["plugins" "bufferline" "indicatorIcon"]; option = ["plugins" "bufferline" "indicatorIcon"];
@ -252,10 +255,10 @@ in
}; };
}; };
config = config = let
let
setupOptions = { setupOptions = {
options = { options =
{
numbers = cfg.numbers; numbers = cfg.numbers;
close_command = cfg.closeCommand; close_command = cfg.closeCommand;
right_mouse_command = cfg.rightMouseCommand; right_mouse_command = cfg.rightMouseCommand;
@ -264,10 +267,13 @@ in
# deprecated, but might still work # deprecated, but might still work
indicator_icon = cfg.indicatorIcon; indicator_icon = cfg.indicatorIcon;
indicator = indicator =
if cfg.indicator != null then with cfg.indicator; { if cfg.indicator != null
then
with cfg.indicator; {
icon = icon; icon = icon;
style = style; style = style;
} else null; }
else null;
buffer_close_icon = cfg.bufferCloseIcon; buffer_close_icon = cfg.bufferCloseIcon;
modified_icon = cfg.modifiedIcon; modified_icon = cfg.modifiedIcon;
close_icon = cfg.closeIcon; close_icon = cfg.closeIcon;
@ -290,8 +296,13 @@ in
enforce_regular_tabs = cfg.enforceRegularTabs; enforce_regular_tabs = cfg.enforceRegularTabs;
always_show_bufferline = cfg.alwaysShowBufferline; always_show_bufferline = cfg.alwaysShowBufferline;
sort_by = cfg.sortBy; sort_by = cfg.sortBy;
} // cfg.extraOptions; }
highlights = if builtins.isNull cfg.highlights then null else with cfg.highlights; { // cfg.extraOptions;
highlights =
if builtins.isNull cfg.highlights
then null
else
with cfg.highlights; {
fill = fill; fill = fill;
background = background; background = background;
@ -350,7 +361,6 @@ in
pick = pick; pick = pick;
pick_visible = pickVisible; pick_visible = pickVisible;
pick_selected = pickSelected; pick_selected = pickSelected;
}; };
}; };
in in

View file

@ -1,11 +1,14 @@
{ pkgs, config, lib, ... }: {
with lib; pkgs,
let config,
lib,
...
}:
with lib; let
cfg = config.colorschemes.base16; cfg = config.colorschemes.base16;
helpers = import ../helpers.nix {inherit lib;}; helpers = import ../helpers.nix {inherit lib;};
themes = import ./base16-list.nix; themes = import ./base16-list.nix;
in in {
{
options = { options = {
colorschemes.base16 = { colorschemes.base16 = {
enable = mkEnableOption "base16"; enable = mkEnableOption "base16";

View file

@ -1,11 +1,14 @@
{ pkgs, config, lib, ... }: {
with lib; pkgs,
let config,
lib,
...
}:
with lib; let
cfg = config.colorschemes.gruvbox; cfg = config.colorschemes.gruvbox;
helpers = import ../helpers.nix {inherit lib;}; helpers = import ../helpers.nix {inherit lib;};
colors = types.enum ["bg" "red" "green" "yellow" "blue" "purple" "aqua" "gray" "fg" "bg0_h" "bg0" "bg1" "bg2" "bg3" "bg4" "gray" "orange" "bg0_s" "fg0" "fg1" "fg2" "fg3" "fg4"]; colors = types.enum ["bg" "red" "green" "yellow" "blue" "purple" "aqua" "gray" "fg" "bg0_h" "bg0" "bg1" "bg2" "bg3" "bg4" "gray" "orange" "bg0_s" "fg0" "fg1" "fg2" "fg3" "fg4"];
in in {
{
options = { options = {
colorschemes.gruvbox = { colorschemes.gruvbox = {
enable = mkEnableOption "gruvbox"; enable = mkEnableOption "gruvbox";
@ -110,7 +113,6 @@ in
transparentBg = mkEnableOption "transparent background"; transparentBg = mkEnableOption "transparent background";
trueColor = mkEnableOption "true color support"; trueColor = mkEnableOption "true color support";
}; };
}; };

View file

@ -1,29 +1,37 @@
{ pkgs, config, lib, ... }: {
with lib; pkgs,
let config,
lib,
...
}:
with lib; let
cfg = config.colorschemes.nord; cfg = config.colorschemes.nord;
helpers = import ../helpers.nix {inherit lib;}; helpers = import ../helpers.nix {inherit lib;};
in in {
{
options = { options = {
colorschemes.nord = { colorschemes.nord = {
enable = mkEnableOption "nord"; enable = mkEnableOption "nord";
package = helpers.mkPackageOption "nord.vim" pkgs.vimPlugins.nord-nvim; package = helpers.mkPackageOption "nord.vim" pkgs.vimPlugins.nord-nvim;
contrast = mkEnableOption contrast =
mkEnableOption
"Make sidebars and popup menus like nvim-tree and telescope have a different background"; "Make sidebars and popup menus like nvim-tree and telescope have a different background";
borders = mkEnableOption borders =
mkEnableOption
"Enable the border between verticaly split windows visable"; "Enable the border between verticaly split windows visable";
disable_background = mkEnableOption disable_background =
mkEnableOption
"Disable the setting of background color so that NeoVim can use your terminal background"; "Disable the setting of background color so that NeoVim can use your terminal background";
cursorline_transparent = mkEnableOption cursorline_transparent =
mkEnableOption
"Set the cursorline transparent/visible"; "Set the cursorline transparent/visible";
enable_sidebar_background = mkEnableOption enable_sidebar_background =
mkEnableOption
"Re-enables the background of the sidebar if you disabled the background of everything"; "Re-enables the background of the sidebar if you disabled the background of everything";
italic = mkOption { italic = mkOption {

View file

@ -1,10 +1,13 @@
{ pkgs, config, lib, ... }: {
with lib; pkgs,
let config,
lib,
...
}:
with lib; let
cfg = config.colorschemes.one; cfg = config.colorschemes.one;
helpers = import ../helpers.nix {inherit lib;}; helpers = import ../helpers.nix {inherit lib;};
in in {
{
options = { options = {
colorschemes.one = { colorschemes.one = {
enable = mkEnableOption "vim-one"; enable = mkEnableOption "vim-one";

View file

@ -1,10 +1,13 @@
{ pkgs, config, lib, ... }: {
with lib; pkgs,
let config,
lib,
...
}:
with lib; let
cfg = config.colorschemes.onedark; cfg = config.colorschemes.onedark;
helpers = import ../helpers.nix {inherit lib;}; helpers = import ../helpers.nix {inherit lib;};
in in {
{
options = { options = {
colorschemes.onedark = { colorschemes.onedark = {
enable = mkEnableOption "onedark"; enable = mkEnableOption "onedark";

View file

@ -1,13 +1,13 @@
{ pkgs {
, config pkgs,
, lib config,
, ... lib,
...
} @ args: } @ args:
with lib; let with lib; let
cfg = config.colorschemes.tokyonight; cfg = config.colorschemes.tokyonight;
helpers = import ../helpers.nix args; helpers = import ../helpers.nix args;
in in {
{
options = { options = {
colorschemes.tokyonight = { colorschemes.tokyonight = {
enable = mkEnableOption "tokyonight"; enable = mkEnableOption "tokyonight";
@ -17,13 +17,11 @@ in
helpers.defaultNullOpts.mkBool true helpers.defaultNullOpts.mkBool true
"Configure the colors used when opening a :terminal in Neovim"; "Configure the colors used when opening a :terminal in Neovim";
transparent = helpers.defaultNullOpts.mkBool false "disable setting the background color"; transparent = helpers.defaultNullOpts.mkBool false "disable setting the background color";
styles = styles = let
let
mkBackgroundStyle = name: mkBackgroundStyle = name:
helpers.defaultNullOpts.mkEnumFirstDefault ["dark" "transparent" "normal"] helpers.defaultNullOpts.mkEnumFirstDefault ["dark" "transparent" "normal"]
"Background style for ${name}"; "Background style for ${name}";
in in {
{
comments = comments =
helpers.defaultNullOpts.mkNullable (types.attrsOf types.anything) "{italic = true;}" helpers.defaultNullOpts.mkNullable (types.attrsOf types.anything) "{italic = true;}"
"Define comments highlight properties"; "Define comments highlight properties";
@ -58,8 +56,7 @@ in
colorscheme = "tokyonight"; colorscheme = "tokyonight";
extraPlugins = [cfg.package]; extraPlugins = [cfg.package];
options = {termguicolors = true;}; options = {termguicolors = true;};
extraConfigLuaPre = extraConfigLuaPre = let
let
setupOptions = with cfg; { setupOptions = with cfg; {
inherit (cfg) style transparent styles sidebars; inherit (cfg) style transparent styles sidebars;
terminal_colors = terminalColors; terminal_colors = terminalColors;
@ -68,8 +65,7 @@ in
lualine_bold = lualineBold; lualine_bold = lualineBold;
day_brightness = dayBrightness; day_brightness = dayBrightness;
}; };
in in ''
''
require("tokyonight").setup(${helpers.toLuaObject setupOptions}) require("tokyonight").setup(${helpers.toLuaObject setupOptions})
''; '';
}; };

View file

@ -1,10 +1,13 @@
{ config, pkgs, lib, ... }: {
with lib; config,
let pkgs,
lib,
...
}:
with lib; let
cfg = config.plugins.copilot; cfg = config.plugins.copilot;
helpers = import ../helpers.nix {inherit lib;}; helpers = import ../helpers.nix {inherit lib;};
in in {
{
options = { options = {
plugins.copilot = { plugins.copilot = {
enable = mkEnableOption "copilot"; enable = mkEnableOption "copilot";
@ -27,12 +30,17 @@ in
}; };
}; };
config = config = mkIf cfg.enable {
mkIf cfg.enable {
extraPlugins = [cfg.package]; extraPlugins = [cfg.package];
globals = { globals =
{
copilot_node_command = "${pkgs.nodejs-16_x}/bin/node"; copilot_node_command = "${pkgs.nodejs-16_x}/bin/node";
copilot_filetypes = cfg.filetypes; copilot_filetypes = cfg.filetypes;
} // (if cfg.proxy != null then { copilot_proxy = cfg.proxy; } else { }); }
// (
if cfg.proxy != null
then {copilot_proxy = cfg.proxy;}
else {}
);
}; };
} }

View file

@ -1,12 +1,14 @@
{ pkgs, lib, config, ... }: {
with lib; pkgs,
let lib,
config,
...
}:
with lib; let
cfg = config.plugins.coq-nvim; cfg = config.plugins.coq-nvim;
helpers = import ../helpers.nix {inherit lib;}; helpers = import ../helpers.nix {inherit lib;};
plugins = import ../plugin-defs.nix {inherit pkgs;}; plugins = import ../plugin-defs.nix {inherit pkgs;};
in {
in
{
options = { options = {
plugins.coq-nvim = { plugins.coq-nvim = {
enable = mkEnableOption "coq-nvim"; enable = mkEnableOption "coq-nvim";
@ -28,17 +30,18 @@ in
}; };
}; };
}; };
config = config = let
let
settings = { settings = {
auto_start = cfg.autoStart; auto_start = cfg.autoStart;
"keymap.recommended" = cfg.recommendedKeymaps; "keymap.recommended" = cfg.recommendedKeymaps;
}; };
in in
mkIf cfg.enable { mkIf cfg.enable {
extraPlugins = [ extraPlugins =
[
cfg.package cfg.package
] ++ optional cfg.installArtifacts plugins.coq-artifacts; ]
++ optional cfg.installArtifacts plugins.coq-artifacts;
plugins.lsp = { plugins.lsp = {
preConfig = '' preConfig = ''
vim.g.coq_settings = ${helpers.toLuaObject settings} vim.g.coq_settings = ${helpers.toLuaObject settings}

View file

@ -1,10 +1,13 @@
{ config, pkgs, lib, ... }: {
with lib; config,
let pkgs,
lib,
...
}:
with lib; let
cfg = config.plugins.lspkind; cfg = config.plugins.lspkind;
helpers = import ../helpers.nix {inherit lib;}; helpers = import ../helpers.nix {inherit lib;};
in in {
{
options.plugins.lspkind = { options.plugins.lspkind = {
enable = mkEnableOption "lspkind.nvim"; enable = mkEnableOption "lspkind.nvim";
@ -61,18 +64,23 @@ in
}; };
}; };
config = config = let
let
doCmp = cfg.cmp.enable && config.plugins.nvim-cmp.enable; doCmp = cfg.cmp.enable && config.plugins.nvim-cmp.enable;
options = { options =
{
mode = cfg.mode; mode = cfg.mode;
preset = cfg.preset; preset = cfg.preset;
symbol_map = cfg.symbolMap; symbol_map = cfg.symbolMap;
} // (if doCmp then { }
// (
if doCmp
then {
maxwidth = cfg.cmp.maxWidth; maxwidth = cfg.cmp.maxWidth;
ellipsis_char = cfg.cmp.ellipsisChar; ellipsis_char = cfg.cmp.ellipsisChar;
menu = cfg.cmp.menu; menu = cfg.cmp.menu;
} else { }); }
else {}
);
in in
mkIf cfg.enable { mkIf cfg.enable {
extraPlugins = [cfg.package]; extraPlugins = [cfg.package];
@ -82,13 +90,15 @@ in
''; '';
plugins.nvim-cmp.formatting.format = plugins.nvim-cmp.formatting.format =
if cfg.cmp.after != null then '' if cfg.cmp.after != null
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

@ -1,9 +1,19 @@
{ lib, pkgs, ... }@attrs:
let
helpers = import ../../helpers.nix { inherit lib; };
in with helpers; with lib;
{ {
mkCmpSourcePlugin = { name, extraPlugins ? [], useDefaultPackage ? true, ... }: mkPlugin attrs { lib,
pkgs,
...
} @ attrs: let
helpers = import ../../helpers.nix {inherit lib;};
in
with helpers;
with lib; {
mkCmpSourcePlugin = {
name,
extraPlugins ? [],
useDefaultPackage ? true,
...
}:
mkPlugin attrs {
inherit name; inherit name;
extraPlugins = extraPlugins ++ (lists.optional useDefaultPackage pkgs.vimPlugins.${name}); extraPlugins = extraPlugins ++ (lists.optional useDefaultPackage pkgs.vimPlugins.${name});
description = "Enable ${name}"; description = "Enable ${name}";

View file

@ -1,19 +1,20 @@
{ pkgs, config, lib, ... }@args: {
with lib; pkgs,
let config,
lib,
...
} @ args:
with lib; let
cfg = config.plugins.nvim-cmp; cfg = config.plugins.nvim-cmp;
helpers = import ../../helpers.nix {inherit lib;}; helpers = import ../../helpers.nix {inherit lib;};
mkNullOrOption = helpers.mkNullOrOption; mkNullOrOption = helpers.mkNullOrOption;
cmpLib = import ./cmp-helpers.nix args; cmpLib = import ./cmp-helpers.nix args;
# functionName should be a string # functionName should be a string
# parameters should be a list of strings # parameters should be a list of strings
wrapWithFunction = functionName: parameters: wrapWithFunction = functionName: parameters: let
let
parameterString = strings.concatStringsSep "," parameters; parameterString = strings.concatStringsSep "," parameters;
in in ''${functionName}(${parameterString})'';
''${functionName}(${parameterString})''; in {
in
{
options.plugins.nvim-cmp = { options.plugins.nvim-cmp = {
enable = mkEnableOption "nvim-cmp"; enable = mkEnableOption "nvim-cmp";
@ -218,8 +219,7 @@ in
''; '';
}; };
sources = sources = let
let
source_config = types.submodule ({...}: { source_config = types.submodule ({...}: {
options = { options = {
name = mkOption { name = mkOption {
@ -296,8 +296,7 @@ in
})); }));
}; };
window = window = let
let
# Reusable options # Reusable options
border = with types; mkNullOrOption (either str (listOf str)) null; border = with types; mkNullOrOption (either str (listOf str)) null;
winhighlight = mkNullOrOption types.str null; winhighlight = mkNullOrOption types.str null;
@ -336,58 +335,89 @@ in
experimental = mkNullOrOption types.attrs "Experimental features"; experimental = mkNullOrOption types.attrs "Experimental features";
}; };
config = config = let
let
options = { options = {
enabled = cfg.enable; enabled = cfg.enable;
performance = cfg.performance; performance = cfg.performance;
preselect = if (isNull cfg.preselect) then null else helpers.mkRaw "cmp.PreselectMode.${cfg.preselect}"; preselect =
if (isNull cfg.preselect)
then null
else helpers.mkRaw "cmp.PreselectMode.${cfg.preselect}";
# Not very readable sorry # Not very readable sorry
# If null then null # If null then null
# If an attribute is a string, just treat it as lua code for that mapping # If an attribute is a string, just treat it as lua code for that mapping
# If an attribute is a module, create a mapping with cmp.mapping() using the action as the first input and the modes as the second. # If an attribute is a module, create a mapping with cmp.mapping() using the action as the first input and the modes as the second.
mapping = mapping = let
let
mappings = mappings =
if (isNull cfg.mapping) then null if (isNull cfg.mapping)
then null
else else
mapAttrs mapAttrs
(bind: mapping: helpers.mkRaw (if isString mapping then mapping (bind: mapping:
else "cmp.mapping(${mapping.action}${optionalString (mapping.modes != null && length mapping.modes >= 1) ("," + (helpers.toLuaObject mapping.modes))})")) helpers.mkRaw (
if isString mapping
then mapping
else "cmp.mapping(${mapping.action}${optionalString (mapping.modes != null && length mapping.modes >= 1) ("," + (helpers.toLuaObject mapping.modes))})"
))
cfg.mapping; cfg.mapping;
luaMappings = (helpers.toLuaObject mappings); luaMappings = helpers.toLuaObject mappings;
wrapped = lists.fold (presetName: prevString: ''cmp.mapping.preset.${presetName}(${prevString})'') luaMappings cfg.mappingPresets; wrapped = lists.fold (presetName: prevString: ''cmp.mapping.preset.${presetName}(${prevString})'') luaMappings cfg.mappingPresets;
in in
helpers.mkRaw wrapped; helpers.mkRaw wrapped;
snippet = { snippet = {
expand = if (isNull cfg.snippet || isNull cfg.snippet.expand) then null else helpers.mkRaw cfg.snippet.expand; expand =
if (isNull cfg.snippet || isNull cfg.snippet.expand)
then null
else helpers.mkRaw cfg.snippet.expand;
}; };
completion = if (isNull cfg.completion) then null else { completion =
if (isNull cfg.completion)
then null
else {
keyword_length = cfg.completion.keyword_length; keyword_length = cfg.completion.keyword_length;
keyword_pattern = cfg.completion.keyword_pattern; keyword_pattern = cfg.completion.keyword_pattern;
autocomplete = if (isNull cfg.completion.autocomplete) then null else mkRaw cfg.completion.autocomplete; autocomplete =
if (isNull cfg.completion.autocomplete)
then null
else mkRaw cfg.completion.autocomplete;
completeopt = cfg.completion.completeopt; completeopt = cfg.completion.completeopt;
}; };
confirmation = if (isNull cfg.confirmation) then null else { confirmation =
if (isNull cfg.confirmation)
then null
else {
get_commit_characters = get_commit_characters =
if (isString cfg.confirmation.get_commit_characters) then helpers.mkRaw cfg.confirmation.get_commit_characters if (isString cfg.confirmation.get_commit_characters)
then helpers.mkRaw cfg.confirmation.get_commit_characters
else cfg.confirmation.get_commit_characters; else cfg.confirmation.get_commit_characters;
}; };
formatting = if (isNull cfg.formatting) then null else { formatting =
if (isNull cfg.formatting)
then null
else {
fields = cfg.formatting.fields; fields = cfg.formatting.fields;
format = if (isNull cfg.formatting.format) then null else helpers.mkRaw cfg.formatting.format; format =
if (isNull cfg.formatting.format)
then null
else helpers.mkRaw cfg.formatting.format;
}; };
matching = cfg.matching; matching = cfg.matching;
sorting = if (isNull cfg.sorting) then null else { sorting =
if (isNull cfg.sorting)
then null
else {
priority_weight = cfg.sorting.priority_weight; priority_weight = cfg.sorting.priority_weight;
comparators = if (isNull cfg.sorting.comparators) then null else helpers.mkRaw cfg.sorting.comparators; comparators =
if (isNull cfg.sorting.comparators)
then null
else helpers.mkRaw cfg.sorting.comparators;
}; };
sources = cfg.sources; sources = cfg.sources;
@ -406,9 +436,11 @@ in
# If auto_enable_sources is set to true, figure out which are provided by the user # If auto_enable_sources is set to true, figure out which are provided by the user
# and enable the corresponding plugins. # and enable the corresponding plugins.
plugins = plugins = let
let flattened_sources =
flattened_sources = if (isNull cfg.sources) then [ ] else flatten cfg.sources; if (isNull cfg.sources)
then []
else flatten cfg.sources;
# Take only the names from the sources provided by the user # Take only the names from the sources provided by the user
found_sources = lists.unique (lists.map (source: source.name) flattened_sources); found_sources = lists.unique (lists.map (source: source.name) flattened_sources);
# A list of known source names # A list of known source names

View file

@ -1,12 +1,16 @@
{ lib, pkgs, ... }@attrs: {
with lib; lib,
let pkgs,
...
} @ attrs:
with lib; let
cmpLib = import ../cmp-helpers.nix attrs; cmpLib = import ../cmp-helpers.nix attrs;
cmpSourcesPluginNames = lib.attrValues cmpLib.pluginAndSourceNames; cmpSourcesPluginNames = lib.attrValues cmpLib.pluginAndSourceNames;
pluginModules = lists.map (name: cmpLib.mkCmpSourcePlugin {inherit name;}) cmpSourcesPluginNames; pluginModules = lists.map (name: cmpLib.mkCmpSourcePlugin {inherit name;}) cmpSourcesPluginNames;
in in {
{
# For extra cmp plugins # For extra cmp plugins
imports = [ imports =
] ++ pluginModules; [
]
++ pluginModules;
} }

View file

@ -1,7 +1,12 @@
{ lib, pkgs, ... }@attrs: {
let lib,
pkgs,
...
} @ attrs: let
helpers = import ../helpers.nix {inherit lib;}; helpers = import ../helpers.nix {inherit lib;};
in with helpers; with lib; in
with helpers;
with lib;
mkPlugin attrs { mkPlugin attrs {
name = "fugitive"; name = "fugitive";
description = "Enable vim-fugitive"; description = "Enable vim-fugitive";

View file

@ -1,10 +1,13 @@
{ pkgs, config, lib, ... }: {
with lib; pkgs,
let config,
lib,
...
}:
with lib; let
cfg = config.plugins.gitgutter; cfg = config.plugins.gitgutter;
helpers = import ../helpers.nix {inherit lib;}; helpers = import ../helpers.nix {inherit lib;};
in in {
{
options = { options = {
plugins.gitgutter = { plugins.gitgutter = {
enable = mkEnableOption "gitgutter"; enable = mkEnableOption "gitgutter";
@ -54,9 +57,9 @@ in
}; };
signs = mkOption { signs = mkOption {
type = type = let
let signOption = desc:
signOption = desc: mkOption { mkOption {
type = types.nullOr types.str; type = types.nullOr types.str;
default = null; default = null;
description = "Sign for ${desc}"; description = "Sign for ${desc}";
@ -166,10 +169,15 @@ in
}; };
}; };
config = config = let
let grepPackage =
grepPackage = if builtins.isAttrs cfg.grep then [ cfg.grep.package ] else [ ]; if builtins.isAttrs cfg.grep
grepCommand = if builtins.isAttrs cfg.grep then cfg.grep.command else cfg.grep; then [cfg.grep.package]
else [];
grepCommand =
if builtins.isAttrs cfg.grep
then cfg.grep.command
else cfg.grep;
in in
mkIf cfg.enable { mkIf cfg.enable {
extraPlugins = [cfg.package]; extraPlugins = [cfg.package];

View file

@ -1,12 +1,12 @@
{ pkgs {
, lib pkgs,
, config lib,
, ... config,
...
} @ args: } @ args:
with lib; let with lib; let
helpers = import ../helpers.nix args; helpers = import ../helpers.nix args;
in in {
{
options.plugins.gitmessenger = { options.plugins.gitmessenger = {
enable = mkEnableOption "Enable the gitmessenger plugin"; enable = mkEnableOption "Enable the gitmessenger plugin";
@ -91,8 +91,7 @@ in
''; '';
}; };
config = config = let
let
cfg = config.plugins.gitmessenger; cfg = config.plugins.gitmessenger;
in in
mkIf cfg.enable { mkIf cfg.enable {

View file

@ -1,7 +1,8 @@
{ config {
, lib config,
, pkgs lib,
, ... pkgs,
...
} @ args: } @ args:
with lib; let with lib; let
helpers = import ../helpers.nix args; helpers = import ../helpers.nix args;
@ -33,8 +34,7 @@ with lib; let
description = "Lua function definition"; description = "Lua function definition";
}; };
}; };
in in {
{
options.plugins.gitsigns = { options.plugins.gitsigns = {
enable = mkEnableOption "Enable gitsigns plugin"; enable = mkEnableOption "Enable gitsigns plugin";
package = helpers.mkPackageOption "gitsigns" pkgs.vimPlugins.gitsigns-nvim; package = helpers.mkPackageOption "gitsigns" pkgs.vimPlugins.gitsigns-nvim;
@ -76,8 +76,7 @@ in
linehl = "GitSignsAddLn"; linehl = "GitSignsAddLn";
}; };
}; };
worktrees = worktrees = let
let
worktreeModule = { worktreeModule = {
options = { options = {
toplevel = mkOption { toplevel = mkOption {
@ -164,8 +163,7 @@ in
Note: Virtual lines currently use the highlight `GitSignsDeleteVirtLn`. Note: Virtual lines currently use the highlight `GitSignsDeleteVirtLn`.
''; '';
diffOpts = diffOpts = let
let
diffOptModule = { diffOptModule = {
options = { options = {
algorithm = algorithm =
@ -316,14 +314,12 @@ in
''; '';
}; };
config = config = let
let
cfg = config.plugins.gitsigns; cfg = config.plugins.gitsigns;
in in
mkIf cfg.enable { mkIf cfg.enable {
extraPlugins = [cfg.package]; extraPlugins = [cfg.package];
extraConfigLua = extraConfigLua = let
let
luaFnOrStrToObj = val: luaFnOrStrToObj = val:
if val == null if val == null
then null then null
@ -350,8 +346,7 @@ in
inherit (cfg.diffOpts) algorithm internal vertical linematch; inherit (cfg.diffOpts) algorithm internal vertical linematch;
indent_heuristic = cfg.diffOpts.indentHeuristic; indent_heuristic = cfg.diffOpts.indentHeuristic;
}; };
count_chars = count_chars = let
let
isStrInt = s: (builtins.match "[0-9]+" s) != null; isStrInt = s: (builtins.match "[0-9]+" s) != null;
in in
if cfg.countChars != null if cfg.countChars != null
@ -380,11 +375,9 @@ in
attach_to_untracked = cfg.attachToUntracked; attach_to_untracked = cfg.attachToUntracked;
update_debounce = cfg.updateDebounce; update_debounce = cfg.updateDebounce;
current_line_blame = cfg.currentLineBlame; current_line_blame = cfg.currentLineBlame;
current_line_blame_opts = current_line_blame_opts = let
let
cfgCl = cfg.currentLineBlameOpts; cfgCl = cfg.currentLineBlameOpts;
in in {
{
inherit (cfgCl) delay; inherit (cfgCl) delay;
virt_text = cfgCl.virtText; virt_text = cfgCl.virtText;
virt_text_pos = cfgCl.virtTextPos; virt_text_pos = cfgCl.virtTextPos;
@ -396,8 +389,7 @@ in
word_diff = cfg.wordDiff; word_diff = cfg.wordDiff;
debug_mode = cfg.debugMode; debug_mode = cfg.debugMode;
}; };
in in ''
''
require('gitsigns').setup(${helpers.toLuaObject setupOptions}) require('gitsigns').setup(${helpers.toLuaObject setupOptions})
''; '';
}; };

View file

@ -1,6 +1,10 @@
{ config, lib, pkgs, ... }: {
with lib; config,
let lib,
pkgs,
...
}:
with lib; let
cfg = config.plugins.neogit; cfg = config.plugins.neogit;
helpers = import ../helpers.nix {inherit lib;}; helpers = import ../helpers.nix {inherit lib;};
@ -12,8 +16,7 @@ let
}; };
}; };
}; };
in in {
{
options = { options = {
plugins.neogit = { plugins.neogit = {
enable = mkEnableOption "neogit"; enable = mkEnableOption "neogit";
@ -203,9 +206,9 @@ in
}; };
}; };
config = config = let
let setupOptions = with cfg;
setupOptions = with cfg; helpers.toLuaObject { helpers.toLuaObject {
inherit kind integrations signs sections mappings; inherit kind integrations signs sections mappings;
disable_signs = disableSigns; disable_signs = disableSigns;
disable_hint = disableHint; disable_hint = disableHint;
@ -218,10 +221,12 @@ in
}; };
in in
mkIf cfg.enable { mkIf cfg.enable {
extraPlugins = with pkgs.vimPlugins; [ extraPlugins = with pkgs.vimPlugins;
[
cfg.package cfg.package
plenary-nvim plenary-nvim
] ++ optional cfg.integrations.diffview diffview-nvim; ]
++ optional cfg.integrations.diffview diffview-nvim;
extraPackages = [pkgs.git]; extraPackages = [pkgs.git];

View file

@ -1,5 +1,10 @@
{ pkgs, lib, ... }@args: {
with lib; with import ../helpers.nix { inherit lib; }; pkgs,
lib,
...
} @ args:
with lib;
with import ../helpers.nix {inherit lib;};
mkPlugin args { mkPlugin args {
name = "ledger"; name = "ledger";
description = "Enable ledger language features"; description = "Enable ledger language features";

View file

@ -1,10 +1,13 @@
{ config, pkgs, lib, ... }: {
with lib; config,
let pkgs,
lib,
...
}:
with lib; let
cfg = config.plugins.markdown-preview; cfg = config.plugins.markdown-preview;
helpers = import ../helpers.nix {inherit lib;}; helpers = import ../helpers.nix {inherit lib;};
in in {
{
options = { options = {
plugins.markdown-preview = { plugins.markdown-preview = {
enable = mkEnableOption "markdown-preview"; enable = mkEnableOption "markdown-preview";
@ -92,8 +95,7 @@ in
}; };
}; };
config = config = let
let
previewOptions = mapAttrs (name: value: cfg.previewOptions.${name}) cfg.previewOptions; previewOptions = mapAttrs (name: value: cfg.previewOptions.${name}) cfg.previewOptions;
in in
mkIf cfg.enable { mkIf cfg.enable {

View file

@ -1,7 +1,12 @@
{ lib, pkgs, ... }@attrs: {
let lib,
pkgs,
...
} @ attrs: let
helpers = import ../helpers.nix {inherit lib;}; helpers = import ../helpers.nix {inherit lib;};
in with helpers; with lib; in
with helpers;
with lib;
mkPlugin attrs { mkPlugin attrs {
name = "nix"; name = "nix";
description = "Enable nix"; description = "Enable nix";

View file

@ -1,10 +1,10 @@
{ pkgs {
, lib pkgs,
, config lib,
, ... config,
...
}: }:
with lib; with lib; let
let
helpers = import ../helpers.nix {inherit lib;}; helpers = import ../helpers.nix {inherit lib;};
in { in {
options.plugins.plantuml-syntax = { options.plugins.plantuml-syntax = {
@ -24,8 +24,7 @@ in {
}; };
}; };
config = config = let
let
cfg = config.plugins.plantuml-syntax; cfg = config.plugins.plantuml-syntax;
in in
mkIf cfg.enable { mkIf cfg.enable {

View file

@ -1,19 +1,17 @@
{ pkgs {
, config pkgs,
, lib config,
, ... lib,
...
}: }:
with lib; with lib; let
let
helpers = import ../helpers.nix {inherit lib;}; helpers = import ../helpers.nix {inherit lib;};
in { in {
options.plugins.rust-tools = options.plugins.rust-tools = let
let mkNullableOptionWithDefault = {
mkNullableOptionWithDefault = type,
{ type description,
, description default,
, default
,
}: }:
mkOption { mkOption {
type = types.nullOr type; type = types.nullOr type;
@ -45,8 +43,7 @@ in {
type = types.int; type = types.int;
default = toString default; default = toString default;
}; };
in in {
{
enable = mkEnableOption "rust tools plugins"; enable = mkEnableOption "rust tools plugins";
package = helpers.mkPackageOption "rust-tools" pkgs.vimPlugins.rust-tools-nvim; package = helpers.mkPackageOption "rust-tools" pkgs.vimPlugins.rust-tools-nvim;
serverPackage = mkOption { serverPackage = mkOption {
@ -157,16 +154,14 @@ in {
} }
// (import ../nvim-lsp/rust-analyzer-config.nix lib); // (import ../nvim-lsp/rust-analyzer-config.nix lib);
}; };
config = config = let
let
cfg = config.plugins.rust-tools; cfg = config.plugins.rust-tools;
in in
mkIf cfg.enable { mkIf cfg.enable {
extraPlugins = with pkgs.vimPlugins; [nvim-lspconfig cfg.package]; extraPlugins = with pkgs.vimPlugins; [nvim-lspconfig cfg.package];
extraPackages = [cfg.serverPackage]; extraPackages = [cfg.serverPackage];
plugins.lsp.postConfig = plugins.lsp.postConfig = let
let
setupOptions = { setupOptions = {
tools = { tools = {
executor = executor =
@ -180,11 +175,9 @@ in {
else null; else null;
reload_workspace_from_cargo_toml = cfg.reloadWorkspaceFromCargoToml; reload_workspace_from_cargo_toml = cfg.reloadWorkspaceFromCargoToml;
inlay_hints = inlay_hints = let
let
cfgIH = cfg.inlayHints; cfgIH = cfg.inlayHints;
in in {
{
auto = cfgIH.auto; auto = cfgIH.auto;
only_current_line = cfgIH.onlyCurrentLine; only_current_line = cfgIH.onlyCurrentLine;
show_parameter_hints = cfgIH.showParameterHints; show_parameter_hints = cfgIH.showParameterHints;
@ -197,22 +190,18 @@ in {
highlight = cfgIH.highlight; highlight = cfgIH.highlight;
}; };
hover_actions = hover_actions = let
let
cfgHA = cfg.hoverActions; cfgHA = cfg.hoverActions;
in in {
{
border = cfgHA.border; border = cfgHA.border;
max_width = cfgHA.maxWidth; max_width = cfgHA.maxWidth;
max_height = cfgHA.maxHeight; max_height = cfgHA.maxHeight;
auto_focus = cfgHA.autoFocus; auto_focus = cfgHA.autoFocus;
}; };
crate_graph = crate_graph = let
let
cfgCG = cfg.crateGraph; cfgCG = cfg.crateGraph;
in in {
{
backend = cfgCG.backend; backend = cfgCG.backend;
output = cfgCG.output; output = cfgCG.output;
full = cfgCG.full; full = cfgCG.full;
@ -225,8 +214,7 @@ in {
on_attach = {__raw = "__lspOnAttach";}; on_attach = {__raw = "__lspOnAttach";};
}; };
}; };
in in ''
''
require('rust-tools').setup(${helpers.toLuaObject setupOptions}) require('rust-tools').setup(${helpers.toLuaObject setupOptions})
''; '';
}; };

View file

@ -1,16 +1,14 @@
{ pkgs {
, lib pkgs,
, config lib,
, ... config,
}: ...
let }: let
cfg = config.plugins.tagbar; cfg = config.plugins.tagbar;
helpers = import ../helpers.nix {inherit lib;}; helpers = import ../helpers.nix {inherit lib;};
in in
with lib; with lib; {
{
options.plugins.tagbar = { options.plugins.tagbar = {
enable = mkEnableOption "tagbar"; enable = mkEnableOption "tagbar";
package = helpers.mkPackageOption "tagbar" pkgs.vimPlugins.tagbar; package = helpers.mkPackageOption "tagbar" pkgs.vimPlugins.tagbar;
@ -25,7 +23,6 @@ with lib;
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
extraPlugins = [cfg.package]; extraPlugins = [cfg.package];
extraPackages = [pkgs.ctags]; extraPackages = [pkgs.ctags];

View file

@ -1,10 +1,10 @@
{ pkgs {
, lib pkgs,
, config lib,
, ... config,
...
}: }:
with lib; with lib; let
let
helpers = import ../helpers.nix {inherit lib;}; helpers = import ../helpers.nix {inherit lib;};
in { in {
options.plugins.treesitter-context = { options.plugins.treesitter-context = {
@ -45,8 +45,7 @@ in {
}; };
}; };
config = config = let
let
cfg = config.plugins.treesitter-context; cfg = config.plugins.treesitter-context;
in in
mkIf cfg.enable { mkIf cfg.enable {

View file

@ -1,22 +1,19 @@
{ pkgs
, config
, lib
, ...
}:
with lib;
let
helpers = import ../helpers.nix { inherit lib; };
in
{ {
options.plugins.treesitter-refactor = pkgs,
let config,
lib,
...
}:
with lib; let
helpers = import ../helpers.nix {inherit lib;};
in {
options.plugins.treesitter-refactor = let
disable = mkOption { disable = mkOption {
type = types.listOf types.str; type = types.listOf types.str;
default = []; default = [];
description = "List of languages to disable the module on"; description = "List of languages to disable the module on";
}; };
in in {
{
enable = enable =
mkEnableOption mkEnableOption
"treesitter-refactor (requires plugins.treesitter.enable to be true)"; "treesitter-refactor (requires plugins.treesitter.enable to be true)";
@ -103,8 +100,7 @@ in
}; };
}; };
config = config = let
let
cfg = config.plugins.treesitter-refactor; cfg = config.plugins.treesitter-refactor;
in in
mkIf cfg.enable { mkIf cfg.enable {
@ -122,11 +118,9 @@ in
}; };
navigation = { navigation = {
inherit (cfg.navigation) enable disable; inherit (cfg.navigation) enable disable;
keymaps = keymaps = let
let
cfgK = cfg.navigation.keymaps; cfgK = cfg.navigation.keymaps;
in in {
{
goto_definition = cfgK.gotoDefinition; goto_definition = cfgK.gotoDefinition;
goto_definition_lsp_fallback = cfgK.gotoDefinitionLspFallback; goto_definition_lsp_fallback = cfgK.gotoDefinitionLspFallback;
list_definitions = cfgK.listDefinitons; list_definitions = cfgK.listDefinitons;

View file

@ -1,10 +1,13 @@
{ pkgs, lib, config, ... }: {
with lib; pkgs,
let lib,
config,
...
}:
with lib; let
cfg = config.plugins.treesitter; cfg = config.plugins.treesitter;
helpers = import ../helpers.nix {inherit lib;}; helpers = import ../helpers.nix {inherit lib;};
in in {
{
options = { options = {
plugins.treesitter = { plugins.treesitter = {
enable = mkEnableOption "tree-sitter syntax highlighting"; enable = mkEnableOption "tree-sitter syntax highlighting";
@ -32,8 +35,7 @@ in
default = default =
if cfg.nixGrammars if cfg.nixGrammars
then null then null
else "$XDG_DATA_HOME/nvim/treesitter" else "$XDG_DATA_HOME/nvim/treesitter";
;
description = '' description = ''
Location of the parsers to be installed by the plugin (only needed when nixGrammars is disabled). Location of the parsers to be installed by the plugin (only needed when nixGrammars is disabled).
This default might not work on your own install, please make sure that $XDG_DATA_HOME is set if you want to use the default. Otherwise, change it to something that will work for you! This default might not work on your own install, please make sure that $XDG_DATA_HOME is set if you want to use the default. Otherwise, change it to something that will work for you!
@ -58,14 +60,13 @@ in
description = "Custom capture group highlighting"; description = "Custom capture group highlighting";
}; };
incrementalSelection = incrementalSelection = let
let keymap = default:
keymap = default: mkOption { mkOption {
type = types.str; type = types.str;
inherit default; inherit default;
}; };
in in {
{
enable = mkEnableOption "incremental selection based on the named nodes from the grammar"; enable = mkEnableOption "incremental selection based on the named nodes from the grammar";
keymaps = { keymaps = {
initSelection = keymap "gnn"; initSelection = keymap "gnn";
@ -93,18 +94,25 @@ in
}; };
}; };
config = config = let
let tsOptions =
tsOptions = { {
highlight = { highlight = {
enable = cfg.enable; enable = cfg.enable;
disable = if (cfg.disabledLanguages != [ ]) then cfg.disabledLanguages else null; disable =
if (cfg.disabledLanguages != [])
then cfg.disabledLanguages
else null;
custom_captures = if (cfg.customCaptures != { }) then cfg.customCaptures else null; custom_captures =
if (cfg.customCaptures != {})
then cfg.customCaptures
else null;
}; };
incremental_selection = incremental_selection =
if cfg.incrementalSelection.enable then { if cfg.incrementalSelection.enable
then {
enable = true; enable = true;
keymaps = { keymaps = {
init_selection = cfg.incrementalSelection.keymaps.initSelection; init_selection = cfg.incrementalSelection.keymaps.initSelection;
@ -112,27 +120,37 @@ in
scope_incremental = cfg.incrementalSelection.keymaps.scopeIncremental; scope_incremental = cfg.incrementalSelection.keymaps.scopeIncremental;
node_decremental = cfg.incrementalSelection.keymaps.nodeDecremental; node_decremental = cfg.incrementalSelection.keymaps.nodeDecremental;
}; };
} else null; }
else null;
indent = indent =
if cfg.indent then { if cfg.indent
then {
enable = true; enable = true;
} else null; }
else null;
ensure_installed = if cfg.nixGrammars then [ ] else cfg.ensureInstalled; ensure_installed =
if cfg.nixGrammars
then []
else cfg.ensureInstalled;
ignore_install = cfg.ignoreInstall; ignore_install = cfg.ignoreInstall;
parser_install_dir = cfg.parserInstallDir; parser_install_dir = cfg.parserInstallDir;
} // cfg.moduleConfig; }
// cfg.moduleConfig;
in in
mkIf cfg.enable { mkIf cfg.enable {
extraConfigLua = (optionalString (cfg.parserInstallDir != null) '' extraConfigLua =
(optionalString (cfg.parserInstallDir != null) ''
vim.opt.runtimepath:append("${cfg.parserInstallDir}") vim.opt.runtimepath:append("${cfg.parserInstallDir}")
'') + '' '')
+ ''
require('nvim-treesitter.configs').setup(${helpers.toLuaObject tsOptions}) require('nvim-treesitter.configs').setup(${helpers.toLuaObject tsOptions})
''; '';
extraPlugins = with pkgs; if cfg.nixGrammars then extraPlugins = with pkgs;
[ (cfg.package.withPlugins (_: cfg.grammarPackages)) ] if cfg.nixGrammars
then [(cfg.package.withPlugins (_: cfg.grammarPackages))]
else [cfg.package]; else [cfg.package];
extraPackages = [pkgs.tree-sitter pkgs.nodejs]; extraPackages = [pkgs.tree-sitter pkgs.nodejs];
@ -142,4 +160,3 @@ in
}; };
}; };
} }

View file

@ -1,16 +1,14 @@
{ pkgs {
, lib pkgs,
, config lib,
, ... config,
}: ...
let }: let
cfg = config.plugins.vimtex; cfg = config.plugins.vimtex;
helpers = import ../helpers.nix {inherit lib;}; helpers = import ../helpers.nix {inherit lib;};
in in
with lib; with lib; {
{
options.plugins.vimtex = { options.plugins.vimtex = {
enable = mkEnableOption "vimtex"; enable = mkEnableOption "vimtex";
package = helpers.mkPackageOption "vimtex" pkgs.vimPlugins.vimtex; package = helpers.mkPackageOption "vimtex" pkgs.vimPlugins.vimtex;
@ -24,14 +22,14 @@ with lib;
''; '';
}; };
config = config = let
let globals =
globals = { {
enabled = cfg.enable; enabled = cfg.enable;
} // cfg.extraConfig; }
// cfg.extraConfig;
in in
mkIf cfg.enable { mkIf cfg.enable {
extraPlugins = [cfg.package]; extraPlugins = [cfg.package];
# Usefull for inverse search # Usefull for inverse search

View file

@ -1,7 +1,12 @@
{ lib, pkgs, ... }@attrs: {
let lib,
pkgs,
...
} @ attrs: let
helpers = import ../helpers.nix {inherit lib;}; helpers = import ../helpers.nix {inherit lib;};
in with helpers; with lib; in
with helpers;
with lib;
mkPlugin attrs { mkPlugin attrs {
name = "zig"; name = "zig";
description = "Enable zig"; description = "Enable zig";

View file

@ -1,10 +1,13 @@
{ config, pkgs, lib, ... }:
with lib;
let
cfg = config.plugins.null-ls;
helpers = (import ../helpers.nix { inherit lib; });
in
{ {
config,
pkgs,
lib,
...
}:
with lib; let
cfg = config.plugins.null-ls;
helpers = import ../helpers.nix {inherit lib;};
in {
imports = [ imports = [
./servers.nix ./servers.nix
]; ];
@ -36,8 +39,7 @@ in
# }; # };
}; };
config = config = let
let
options = { options = {
debug = cfg.debug; debug = cfg.debug;
sources = cfg.sourcesItems; sources = cfg.sourcesItems;

View file

@ -1,30 +1,41 @@
{ pkgs, config, lib, ... }:
{ {
mkServer = pkgs,
{ name config,
, sourceType lib,
, description ? "${name} source, for null-ls." ...
, package ? null }: {
, extraPackages ? [ ] mkServer = {
, ... name,
sourceType,
description ? "${name} source, for null-ls.",
package ? null,
extraPackages ? [],
...
}: }:
# returns a module # returns a module
{ pkgs, config, lib, ... }@args: {
with lib; pkgs,
let config,
lib,
...
} @ args:
with lib; let
helpers = import ../helpers.nix args; helpers = import ../helpers.nix args;
cfg = config.plugins.null-ls.sources.${sourceType}.${name}; cfg = config.plugins.null-ls.sources.${sourceType}.${name};
# does this evaluate package? # does this evaluate package?
packageOption = if package == null then { } else { packageOption =
if package == null
then {}
else {
package = mkOption { package = mkOption {
type = types.package; type = types.package;
default = package; default = package;
description = "Package to use for ${name} by null-ls"; description = "Package to use for ${name} by null-ls";
}; };
}; };
in in {
options.plugins.null-ls.sources.${sourceType}.${name} =
{ {
options.plugins.null-ls.sources.${sourceType}.${name} = {
enable = mkEnableOption description; enable = mkEnableOption description;
# TODO: withArgs can exist outside of the module in a generalized manner # TODO: withArgs can exist outside of the module in a generalized manner
@ -37,20 +48,22 @@
# '\'{ extra_args = { "--no-semi", "--single-quote", "--jsx-single-quote" } }'\' # '\'{ extra_args = { "--no-semi", "--single-quote", "--jsx-single-quote" } }'\'
# ''; # '';
}; };
} // packageOption; }
// packageOption;
config = mkIf cfg.enable { config = mkIf cfg.enable {
# Does this evaluate package? # Does this evaluate package?
extraPackages = extraPackages ++ optional (package != null) cfg.package; extraPackages = extraPackages ++ optional (package != null) cfg.package;
# Add source to list of sources # Add source to list of sources
plugins.null-ls.sourcesItems = plugins.null-ls.sourcesItems = let
let
sourceItem = "${sourceType}.${name}"; sourceItem = "${sourceType}.${name}";
withArgs = if (isNull cfg.withArgs) then sourceItem else "${sourceItem}.with ${cfg.withArgs}"; withArgs =
if (isNull cfg.withArgs)
then sourceItem
else "${sourceItem}.with ${cfg.withArgs}";
finalString = ''require("null-ls").builtins.${withArgs}''; finalString = ''require("null-ls").builtins.${withArgs}'';
in in [(helpers.mkRaw finalString)];
[ (helpers.mkRaw finalString) ];
}; };
}; };
} }

View file

@ -1,5 +1,9 @@
{ pkgs, config, lib, ... }@args: {
let pkgs,
config,
lib,
...
} @ args: let
helpers = import ./helpers.nix args; helpers = import ./helpers.nix args;
serverData = { serverData = {
code_actions = { code_actions = {
@ -65,18 +69,18 @@ let
# sourceType = "formatting"; # sourceType = "formatting";
# packages = [...]; # packages = [...];
# }] # }]
serverDataFormatted = lib.mapAttrsToList serverDataFormatted =
(sourceType: sourceSet: lib.mapAttrsToList
(
sourceType: sourceSet:
lib.mapAttrsToList (name: attrs: attrs // {inherit sourceType name;}) sourceSet lib.mapAttrsToList (name: attrs: attrs // {inherit sourceType name;}) sourceSet
) )
serverData; serverData;
dataFlattened = lib.flatten serverDataFormatted; dataFlattened = lib.flatten serverDataFormatted;
in in {
{
imports = lib.lists.map (helpers.mkServer) dataFlattened; imports = lib.lists.map (helpers.mkServer) dataFlattened;
config = config = let
let
cfg = config.plugins.null-ls; cfg = config.plugins.null-ls;
in in
lib.mkIf cfg.enable { lib.mkIf cfg.enable {

View file

@ -1,6 +1,10 @@
{ pkgs, config, lib, ... }@args: {
with lib; pkgs,
let config,
lib,
...
} @ args:
with lib; let
helpers = import ./helpers.nix args; helpers = import ./helpers.nix args;
servers = [ servers = [
{ {
@ -243,7 +247,6 @@ let
cmd = cfg: ["haskell-language-server-wrapper"]; cmd = cfg: ["haskell-language-server-wrapper"];
} }
]; ];
in in {
{
imports = lib.lists.map (helpers.mkLsp) servers; imports = lib.lists.map (helpers.mkLsp) servers;
} }

View file

@ -1,10 +1,13 @@
{ config, pkgs, lib, ... }:
with lib;
let
cfg = config.plugins.lsp;
helpers = (import ../helpers.nix { inherit lib; });
in
{ {
config,
pkgs,
lib,
...
}:
with lib; let
cfg = config.plugins.lsp;
helpers = import ../helpers.nix {inherit lib;};
in {
imports = [ imports = [
./basic-servers.nix ./basic-servers.nix
]; ];
@ -14,7 +17,8 @@ in
enable = mkEnableOption "neovim's built-in LSP"; enable = mkEnableOption "neovim's built-in LSP";
enabledServers = mkOption { enabledServers = mkOption {
type = with types; listOf (oneOf [ type = with types;
listOf (oneOf [
str str
(submodule { (submodule {
options = { options = {
@ -60,10 +64,10 @@ in
}; };
}; };
config = config = let
let
runWrappers = wrappers: s: runWrappers = wrappers: s:
if wrappers == [ ] then s if wrappers == []
then s
else (head wrappers) (runWrappers (tail wrappers) s); else (head wrappers) (runWrappers (tail wrappers) s);
in in
mkIf cfg.enable { mkIf cfg.enable {

View file

@ -1,51 +1,65 @@
{ pkgs, config, lib, ... }:
{ {
mkLsp = pkgs,
{ name config,
, description ? "Enable ${name}." lib,
, serverName ? name ...
, package ? pkgs.${name} }: {
, extraPackages ? { } mkLsp = {
, cmd ? (cfg: null) name,
, settings ? (cfg: { }) description ? "Enable ${name}.",
, settingsOptions ? { } serverName ? name,
, ... package ? pkgs.${name},
extraPackages ? {},
cmd ? (cfg: null),
settings ? (cfg: {}),
settingsOptions ? {},
...
}: }:
# returns a module # returns a module
{ pkgs, config, lib, ... }: {
with lib; pkgs,
let config,
lib,
...
}:
with lib; let
cfg = config.plugins.lsp.servers.${name}; cfg = config.plugins.lsp.servers.${name};
packageOption = packageOption =
if package != null then { if package != null
then {
package = mkOption { package = mkOption {
default = package; default = package;
type = types.nullOr types.package; type = types.nullOr types.package;
}; };
} else { }; }
in else {};
{ in {
options = { options = {
plugins.lsp.servers.${name} = { plugins.lsp.servers.${name} =
{
enable = mkEnableOption description; enable = mkEnableOption description;
settings = settingsOptions; settings = settingsOptions;
} // packageOption; }
// packageOption;
}; };
config = mkIf cfg.enable config =
mkIf cfg.enable
{ {
extraPackages = (optional (package != null) cfg.package) ++ extraPackages =
(mapAttrsToList (name: _: cfg."${name}Package") extraPackages); (optional (package != null) cfg.package)
++ (mapAttrsToList (name: _: cfg."${name}Package") extraPackages);
plugins.lsp.enabledServers = [{ plugins.lsp.enabledServers = [
{
name = serverName; name = serverName;
extraOptions = { extraOptions = {
cmd = cmd cfg; cmd = cmd cfg;
settings = settings cfg.settings; settings = settings cfg.settings;
}; };
}]; }
];
}; };
}; };
} }

View file

@ -1,10 +1,13 @@
{ pkgs, lib, config, ... }: {
with lib; pkgs,
let lib,
config,
...
}:
with lib; let
cfg = config.plugins.lsp-lines; cfg = config.plugins.lsp-lines;
helpers = import ../helpers.nix {inherit lib;}; helpers = import ../helpers.nix {inherit lib;};
in in {
{
options = { options = {
plugins.lsp-lines = { plugins.lsp-lines = {
enable = mkEnableOption "lsp_lines.nvim"; enable = mkEnableOption "lsp_lines.nvim";
@ -19,14 +22,15 @@ in
}; };
}; };
config = config = let
let
diagnosticConfig = { diagnosticConfig = {
virtual_text = false; virtual_text = false;
virtual_lines = virtual_lines =
if cfg.currentLine then { if cfg.currentLine
then {
only_current_line = true; only_current_line = true;
} else true; }
else true;
}; };
in in
mkIf cfg.enable { mkIf cfg.enable {

View file

@ -1,10 +1,13 @@
{ pkgs, lib, config, ... }: {
with lib; pkgs,
let lib,
config,
...
}:
with lib; let
cfg = config.plugins.lspsaga; cfg = config.plugins.lspsaga;
helpers = import ../helpers.nix {inherit lib;}; helpers = import ../helpers.nix {inherit lib;};
in in {
{
options = { options = {
plugins.lspsaga = { plugins.lspsaga = {
enable = mkEnableOption "lspsaga.nvim"; enable = mkEnableOption "lspsaga.nvim";
@ -107,15 +110,14 @@ in
description = "Maximum finder preview lines"; description = "Maximum finder preview lines";
}; };
keys = keys = let
let defaultKeyOpt = desc:
defaultKeyOpt = desc: mkOption { mkOption {
description = desc; description = desc;
type = types.nullOr types.str; type = types.nullOr types.str;
default = null; default = null;
}; };
in in {
{
finderAction = { finderAction = {
open = defaultKeyOpt "Open from finder"; open = defaultKeyOpt "Open from finder";
vsplit = defaultKeyOpt "Vertical split in finder"; vsplit = defaultKeyOpt "Vertical split in finder";
@ -145,10 +147,15 @@ in
}; };
}; };
config = config = let
let notDefault = default: opt:
notDefault = default: opt: if (opt != default) then opt else null; if (opt != default)
notEmpty = opt: if ((filterAttrs (_: v: v != null) opt) != { }) then opt else null; then opt
else null;
notEmpty = opt:
if ((filterAttrs (_: v: v != null) opt) != {})
then opt
else null;
notNull = opt: opt; notNull = opt: opt;
lspsagaConfig = { lspsagaConfig = {
use_saga_diagnostic_sign = notDefault true cfg.signs.use; use_saga_diagnostic_sign = notDefault true cfg.signs.use;
@ -174,18 +181,19 @@ in
rename_prompt_prefix = notNull cfg.renamePromptPrefix; rename_prompt_prefix = notNull cfg.renamePromptPrefix;
border_style = border_style = let
let
borderStyle = borderStyle =
if cfg.borderStyle == "thin" then 1 if cfg.borderStyle == "thin"
else if cfg.borderStyle == "rounded" then 2 then 1
else if cfg.borderStyle == "thick" then 3 else if cfg.borderStyle == "rounded"
then 2
else if cfg.borderStyle == "thick"
then 3
else null; else null;
in in
borderStyle; borderStyle;
finder_action_keys = finder_action_keys = let
let
keys = { keys = {
open = notNull cfg.keys.finderAction.open; open = notNull cfg.keys.finderAction.open;
vsplit = notNull cfg.keys.finderAction.vsplit; vsplit = notNull cfg.keys.finderAction.vsplit;
@ -197,8 +205,7 @@ in
in in
notEmpty keys; notEmpty keys;
code_action_keys = code_action_keys = let
let
keys = { keys = {
quit = notNull cfg.keys.codeAction.quit; quit = notNull cfg.keys.codeAction.quit;
exec = notNull cfg.keys.codeAction.exec; exec = notNull cfg.keys.codeAction.exec;
@ -208,7 +215,6 @@ in
}; };
in in
mkIf cfg.enable { mkIf cfg.enable {
extraPlugins = [cfg.package]; extraPlugins = [cfg.package];
extraConfigLua = '' extraConfigLua = ''

View file

@ -1,9 +1,9 @@
{ pkgs {
, lib pkgs,
, config lib,
, ... config,
}: ...
let }: let
helpers = import ../helpers.nix {inherit lib;}; helpers = import ../helpers.nix {inherit lib;};
in in
with lib; { with lib; {
@ -63,8 +63,7 @@ with lib; {
}; };
}; };
config = config = let
let
cfg = config.plugins.nvim-lightbulb; cfg = config.plugins.nvim-lightbulb;
setupOptions = { setupOptions = {
inherit (cfg) ignore sign autocmd; inherit (cfg) ignore sign autocmd;

View file

@ -1,5 +1,6 @@
# THIS FILE IS AUTOGENERATED DO NOT EDIT # THIS FILE IS AUTOGENERATED DO NOT EDIT
lib: with lib; { lib:
with lib; {
"assist" = { "assist" = {
"expressionFillDefault" = mkOption { "expressionFillDefault" = mkOption {
type = types.nullOr (types.enum ["todo" "default"]); type = types.nullOr (types.enum ["todo" "default"]);

View file

@ -1,5 +1,9 @@
{ config, pkgs, lib, ... }: {
let config,
pkgs,
lib,
...
}: let
cfg = config.plugins.trouble; cfg = config.plugins.trouble;
helpers = import ../helpers.nix {inherit lib;}; helpers = import ../helpers.nix {inherit lib;};
in in

View file

@ -1,8 +1,7 @@
# This is for plugins not in nixpkgs # This is for plugins not in nixpkgs
# e.g. intellitab.nvim # e.g. intellitab.nvim
# Ideally, in the future, this would all be specified as a flake input! # Ideally, in the future, this would all be specified as a flake input!
{ pkgs, ... }: {pkgs, ...}: {
{
intellitab-nvim = pkgs.vimUtils.buildVimPlugin rec { intellitab-nvim = pkgs.vimUtils.buildVimPlugin rec {
pname = "intellitab-nvim"; pname = "intellitab-nvim";
version = "a6c1a505865f6131866d609c52440306e9914b16"; version = "a6c1a505865f6131866d609c52440306e9914b16";
@ -96,9 +95,8 @@
sha256 = "sha256-IaslJK1F2BxTvZzKGH9OKOl2RICi4d4rSgjliAIAqK4="; sha256 = "sha256-IaslJK1F2BxTvZzKGH9OKOl2RICi4d4rSgjliAIAqK4=";
}; };
passthru.python3Dependencies = ps:
with ps; [
passthru.python3Dependencies = ps: with ps; [
pynvim pynvim
jupyter-client jupyter-client
ueberzug ueberzug

View file

@ -1,10 +1,13 @@
{ pkgs, config, lib, ... }: {
with lib; pkgs,
let config,
lib,
...
}:
with lib; let
cfg = config.plugins.packer; cfg = config.plugins.packer;
helpers = import ../helpers.nix {inherit lib;}; helpers = import ../helpers.nix {inherit lib;};
in in {
{
options = { options = {
plugins.packer = { plugins.packer = {
enable = mkEnableOption "packer.nvim"; enable = mkEnableOption "packer.nvim";
@ -13,7 +16,8 @@ in
type = types.listOf (types.oneOf [ type = types.listOf (types.oneOf [
types.str types.str
(with types; let (with types; let
mkOpt = type: desc: mkOption { mkOpt = type: desc:
mkOption {
type = nullOr type; type = nullOr type;
default = null; default = null;
description = desc; description = desc;
@ -63,15 +67,26 @@ in
extraPlugins = [(pkgs.vimPlugins.packer-nvim.overrideAttrs (_: {pname = "packer.nvim";}))]; extraPlugins = [(pkgs.vimPlugins.packer-nvim.overrideAttrs (_: {pname = "packer.nvim";}))];
extraPackages = [pkgs.git]; extraPackages = [pkgs.git];
extraConfigLua = extraConfigLua = let
let plugins =
plugins = map map
(plugin: (plugin:
if isAttrs plugin then if isAttrs plugin
mapAttrs' (k: v: { name = if k == "name" then "@" else k; value = v; }) plugin then
mapAttrs' (k: v: {
name =
if k == "name"
then "@"
else k;
value = v;
})
plugin
else plugin) else plugin)
cfg.plugins; cfg.plugins;
packedPlugins = if length plugins == 1 then head plugins else plugins; packedPlugins =
if length plugins == 1
then head plugins
else plugins;
in in
mkIf (cfg.plugins != []) '' mkIf (cfg.plugins != []) ''
require('packer').startup(function() require('packer').startup(function()

View file

@ -1,10 +1,13 @@
{ pkgs, config, lib, ... }: {
with lib; pkgs,
let config,
lib,
...
}:
with lib; let
cfg = config.plugins.luasnip; cfg = config.plugins.luasnip;
helpers = import ../../helpers.nix {inherit lib;}; helpers = import ../../helpers.nix {inherit lib;};
in in {
{
options.plugins.luasnip = { options.plugins.luasnip = {
enable = mkEnableOption "Enable luasnip"; enable = mkEnableOption "Enable luasnip";
@ -38,7 +41,8 @@ in
# TODO: add option to also include the default runtimepath # TODO: add option to also include the default runtimepath
paths = mkOption { paths = mkOption {
default = null; default = null;
type = with types; nullOr (oneOf type = with types;
nullOr (oneOf
[ [
str str
path path
@ -75,15 +79,12 @@ in
# TODO: add support for lua # TODO: add support for lua
}; };
config = config = let
let fromVscodeLoaders =
lists.map
fromVscodeLoaders = lists.map (loader: let
(loader:
let
options = attrsets.getAttrs ["paths" "exclude" "include"] loader; options = attrsets.getAttrs ["paths" "exclude" "include"] loader;
in in ''
''
require("luasnip.loaders.from_vscode").${optionalString loader.lazyLoad "lazy_"}load(${helpers.toLuaObject options}) require("luasnip.loaders.from_vscode").${optionalString loader.lazyLoad "lazy_"}load(${helpers.toLuaObject options})
'') '')
cfg.fromVscode; cfg.fromVscode;

View file

@ -1,6 +1,10 @@
{ pkgs, config, lib, ... }: {
with lib; pkgs,
let config,
lib,
...
}:
with lib; let
cfg = config.plugins.airline; cfg = config.plugins.airline;
helpers = import ../helpers.nix {inherit lib;}; helpers = import ../helpers.nix {inherit lib;};
@ -10,8 +14,7 @@ let
type = sectionType; type = sectionType;
description = "Configuration for this section. Can be either a statusline-format string or a list of modules to be passed to airline#section#create_*."; description = "Configuration for this section. Can be either a statusline-format string or a list of modules to be passed to airline#section#create_*.";
}; };
in in {
{
options = { options = {
plugins.airline = { plugins.airline = {
enable = mkEnableOption "airline"; enable = mkEnableOption "airline";
@ -33,7 +36,8 @@ in
sections = mkOption { sections = mkOption {
description = "Statusbar sections"; description = "Statusbar sections";
default = null; default = null;
type = with types; nullOr (submodule { type = with types;
nullOr (submodule {
options = { options = {
a = sectionOption; a = sectionOption;
b = sectionOption; b = sectionOption;
@ -59,21 +63,24 @@ in
}; };
}; };
config = config = let
let
sections = {}; sections = {};
in in
mkIf cfg.enable { mkIf cfg.enable {
extraPlugins = with pkgs.vimPlugins; [ extraPlugins = with pkgs.vimPlugins;
[
cfg.package cfg.package
] ++ optional (!isNull cfg.theme) vim-airline-themes; ]
globals = { ++ optional (!isNull cfg.theme) vim-airline-themes;
globals =
{
airline.extensions = cfg.extensions; airline.extensions = cfg.extensions;
airline_statusline_ontop = mkIf cfg.onTop 1; airline_statusline_ontop = mkIf cfg.onTop 1;
airline_powerline_fonts = mkIf (cfg.powerline) 1; airline_powerline_fonts = mkIf (cfg.powerline) 1;
airline_theme = mkIf (!isNull cfg.theme) cfg.theme; airline_theme = mkIf (!isNull cfg.theme) cfg.theme;
} // sections; }
// sections;
}; };
} }

View file

@ -1,10 +1,13 @@
{ pkgs, config, lib, ... }: {
with lib; pkgs,
let config,
lib,
...
}:
with lib; let
cfg = config.plugins.lightline; cfg = config.plugins.lightline;
helpers = import ../helpers.nix {inherit lib;}; helpers = import ../helpers.nix {inherit lib;};
in in {
{
options = { options = {
plugins.lightline = { plugins.lightline = {
enable = mkEnableOption "lightline"; enable = mkEnableOption "lightline";
@ -51,11 +54,9 @@ in
active = mkOption { active = mkOption {
default = null; default = null;
type = types.nullOr (types.submodule { type = types.nullOr (types.submodule {
options = options = let
let
listType = with types; nullOr (listOf (listOf str)); listType = with types; nullOr (listOf (listOf str));
in in {
{
left = mkOption { left = mkOption {
type = listType; type = listType;
description = "List of components that will show up on the left side of the bar"; description = "List of components that will show up on the left side of the bar";
@ -79,8 +80,7 @@ in
}; };
}; };
config = config = let
let
configAttrs = filterAttrs (_: v: v != null) { configAttrs = filterAttrs (_: v: v != null) {
inherit (cfg) colorscheme active component componentFunction modeMap; inherit (cfg) colorscheme active component componentFunction modeMap;
}; };

View file

@ -1,6 +1,10 @@
{ pkgs, config, lib, ... }: {
with lib; pkgs,
let config,
lib,
...
}:
with lib; let
cfg = config.plugins.lualine; cfg = config.plugins.lualine;
helpers = import ../helpers.nix {inherit lib;}; helpers = import ../helpers.nix {inherit lib;};
separators = mkOption { separators = mkOption {
@ -52,8 +56,7 @@ let
])); ]));
default = null; default = null;
}; };
in in {
{
options = { options = {
plugins.lualine = { plugins.lualine = {
enable = mkEnableOption "lualine"; enable = mkEnableOption "lualine";
@ -79,8 +82,7 @@ in
alwaysDivideMiddle = mkOption { alwaysDivideMiddle = mkOption {
type = types.nullOr types.bool; type = types.nullOr types.bool;
default = null; default = null;
description = description = "When true, left_sections (a,b,c) can't take over entire statusline";
"When true, left_sections (a,b,c) can't take over entire statusline";
}; };
sections = mkOption { sections = mkOption {
@ -121,10 +123,22 @@ in
}; };
}; };
}; };
config = config = let
let processComponent = x:
processComponent = x: (if isAttrs x then processTableComponent else id) x; (
processTableComponent = { name, icons_enabled, icon, separator, extraConfig }: mergeAttrs if isAttrs x
then processTableComponent
else id
)
x;
processTableComponent = {
name,
icons_enabled,
icon,
separator,
extraConfig,
}:
mergeAttrs
{ {
"@" = name; "@" = name;
inherit icons_enabled icon separator; inherit icons_enabled icon separator;
@ -148,7 +162,6 @@ in
mkIf cfg.enable { mkIf cfg.enable {
extraPlugins = [cfg.package]; extraPlugins = [cfg.package];
extraPackages = [pkgs.git]; extraPackages = [pkgs.git];
extraConfigLua = extraConfigLua = ''require("lualine").setup(${helpers.toLuaObject setupOptions})'';
''require("lualine").setup(${helpers.toLuaObject setupOptions})'';
}; };
} }

View file

@ -1,14 +1,13 @@
{ pkgs {
, config pkgs,
, lib config,
, ... lib,
...
}: }:
with lib; with lib; let
let
cfg = config.plugins.telescope; cfg = config.plugins.telescope;
helpers = import ../helpers.nix {inherit lib;}; helpers = import ../helpers.nix {inherit lib;};
in in {
{
imports = [ imports = [
./frecency.nix ./frecency.nix
./fzf-native.nix ./fzf-native.nix
@ -68,14 +67,14 @@ in
let $BAT_THEME = '${cfg.highlightTheme}' let $BAT_THEME = '${cfg.highlightTheme}'
''; '';
extraConfigLua = extraConfigLua = let
let options =
options = { {
extensions = cfg.extensionConfig; extensions = cfg.extensionConfig;
defaults = cfg.defaults; defaults = cfg.defaults;
} // cfg.extraOptions; }
in // cfg.extraOptions;
'' in ''
do do
local __telescopeExtensions = ${helpers.toLuaObject cfg.enabledExtensions} local __telescopeExtensions = ${helpers.toLuaObject cfg.enabledExtensions}

View file

@ -1,10 +1,13 @@
{ pkgs, config, lib, ... }: {
with lib; pkgs,
let config,
lib,
...
}:
with lib; let
cfg = config.plugins.telescope.extensions.frecency; cfg = config.plugins.telescope.extensions.frecency;
helpers = import ../helpers.nix {inherit lib;}; helpers = import ../helpers.nix {inherit lib;};
in in {
{
options.plugins.telescope.extensions.frecency = { options.plugins.telescope.extensions.frecency = {
enable = mkEnableOption "frecency"; enable = mkEnableOption "frecency";
@ -47,8 +50,7 @@ in
}; };
}; };
config = config = let
let
configuration = { configuration = {
db_root = cfg.dbRoot; db_root = cfg.dbRoot;
default_workspace = cfg.defaultWorkspace; default_workspace = cfg.defaultWorkspace;

View file

@ -1,10 +1,13 @@
{ pkgs, config, lib, ... }: {
with lib; pkgs,
let config,
lib,
...
}:
with lib; let
cfg = config.plugins.telescope.extensions.fzf-native; cfg = config.plugins.telescope.extensions.fzf-native;
helpers = import ../helpers.nix {inherit lib;}; helpers = import ../helpers.nix {inherit lib;};
in in {
{
options.plugins.telescope.extensions.fzf-native = { options.plugins.telescope.extensions.fzf-native = {
enable = mkEnableOption "Enable fzf-native"; enable = mkEnableOption "Enable fzf-native";
@ -38,7 +41,8 @@ in
override_file_sorter = cfg.overrideFileSorter; override_file_sorter = cfg.overrideFileSorter;
case_mode = cfg.caseMode; case_mode = cfg.caseMode;
}; };
in mkIf cfg.enable { in
mkIf cfg.enable {
extraPlugins = [cfg.package]; extraPlugins = [cfg.package];
plugins.telescope.enabledExtensions = ["fzf"]; plugins.telescope.enabledExtensions = ["fzf"];

View file

@ -1,9 +1,12 @@
{ pkgs, config, lib, ...}:
with lib;
let
cfg = config.plugins.telescope.extensions.fzy-native;
in
{ {
pkgs,
config,
lib,
...
}:
with lib; let
cfg = config.plugins.telescope.extensions.fzy-native;
in {
options.plugins.telescope.extensions.fzy-native = { options.plugins.telescope.extensions.fzy-native = {
enable = mkEnableOption "Enable fzy-native"; enable = mkEnableOption "Enable fzy-native";
@ -24,7 +27,8 @@ in
override_generic_sorter = cfg.overrideGenericSorter; override_generic_sorter = cfg.overrideGenericSorter;
override_file_sorter = cfg.overrideFileSorter; override_file_sorter = cfg.overrideFileSorter;
}; };
in mkIf cfg.enable { in
mkIf cfg.enable {
extraPlugins = [pkgs.vimPlugins.telescope-fzy-native-nvim]; extraPlugins = [pkgs.vimPlugins.telescope-fzy-native-nvim];
plugins.telescope.enabledExtensions = ["fzy_native"]; plugins.telescope.enabledExtensions = ["fzy_native"];

View file

@ -1,10 +1,13 @@
{ pkgs, config, lib, ... }: {
with lib; pkgs,
let config,
lib,
...
}:
with lib; let
cfg = config.plugins.telescope.extensions.media_files; cfg = config.plugins.telescope.extensions.media_files;
helpers = import ../helpers.nix {inherit lib;}; helpers = import ../helpers.nix {inherit lib;};
in in {
{
options.plugins.telescope.extensions.media_files = { options.plugins.telescope.extensions.media_files = {
enable = mkEnableOption "Enable media_files extension for telescope"; enable = mkEnableOption "Enable media_files extension for telescope";

View file

@ -1,12 +1,14 @@
{ pkgs, config, lib, ... }:
with lib;
let
cfg = config.plugins.telescope.extensions.project-nvim;
in
{ {
pkgs,
config,
lib,
...
}:
with lib; let
cfg = config.plugins.telescope.extensions.project-nvim;
in {
options.plugins.telescope.extensions.project-nvim = { options.plugins.telescope.extensions.project-nvim = {
enable = mkEnableOption "project-nvim telescope extension"; enable = mkEnableOption "project-nvim telescope extension";
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {

View file

@ -1,10 +1,13 @@
{ config, pkgs, lib, ... }: {
with lib; config,
let pkgs,
lib,
...
}:
with lib; let
cfg = config.plugins.comment-nvim; cfg = config.plugins.comment-nvim;
helpers = import ../helpers.nix {inherit lib;}; helpers = import ../helpers.nix {inherit lib;};
in in {
{
options = { options = {
plugins.comment-nvim = { plugins.comment-nvim = {
enable = mkEnableOption "Enable comment-nvim"; enable = mkEnableOption "Enable comment-nvim";
@ -88,8 +91,7 @@ in
}; };
}; };
config = config = let
let
setupOptions = { setupOptions = {
padding = cfg.padding; padding = cfg.padding;
sticky = cfg.sticky; sticky = cfg.sticky;
@ -101,7 +103,6 @@ in
in in
mkIf cfg.enable { mkIf cfg.enable {
extraPlugins = [cfg.package]; extraPlugins = [cfg.package];
extraConfigLua = extraConfigLua = ''require("Comment").setup${helpers.toLuaObject setupOptions}'';
''require("Comment").setup${helpers.toLuaObject setupOptions}'';
}; };
} }

View file

@ -1,10 +1,13 @@
{ pkgs, config, lib, ... }: {
with lib; pkgs,
let config,
lib,
...
}:
with lib; let
cfg = config.plugins.commentary; cfg = config.plugins.commentary;
helpers = import ../helpers.nix {inherit lib;}; helpers = import ../helpers.nix {inherit lib;};
in in {
{
# TODO Add support for aditional filetypes. This requires autocommands! # TODO Add support for aditional filetypes. This requires autocommands!
options = { options = {

View file

@ -1,11 +1,14 @@
{ config, lib, pkgs, ... }: {
with lib; config,
let lib,
pkgs,
...
}:
with lib; let
cfg = config.plugins.dashboard; cfg = config.plugins.dashboard;
helpers = import ../helpers.nix {inherit lib;}; helpers = import ../helpers.nix {inherit lib;};
in in {
{
options = { options = {
plugins.dashboard = { plugins.dashboard = {
enable = mkEnableOption "dashboard"; enable = mkEnableOption "dashboard";
@ -107,8 +110,7 @@ in
}; };
}; };
config = config = let
let
options = { options = {
custom_header = cfg.header; custom_header = cfg.header;
custom_footer = cfg.footer; custom_footer = cfg.footer;
@ -132,8 +134,7 @@ in
extraConfigLua = '' extraConfigLua = ''
local dashboard = require("dashboard") local dashboard = require("dashboard")
${toString (mapAttrsToList (n: v: ${toString (mapAttrsToList (n: v: "dashboard.${n} = ${helpers.toLuaObject v}\n")
"dashboard.${n} = ${helpers.toLuaObject v}\n")
filteredOptions)} filteredOptions)}
''; '';
}; };

View file

@ -1,10 +1,13 @@
{ config, pkgs, lib, ... }: {
with lib; config,
let pkgs,
lib,
...
}:
with lib; let
cfg = config.plugins.easyescape; cfg = config.plugins.easyescape;
helpers = import ../helpers.nix {inherit lib;}; helpers = import ../helpers.nix {inherit lib;};
in in {
{
options = { options = {
plugins.easyescape = { plugins.easyescape = {
enable = mkEnableOption "Enable easyescape"; enable = mkEnableOption "Enable easyescape";

View file

@ -1,12 +1,17 @@
{ lib, pkgs, ... }@attrs: {
with lib; lib,
let pkgs,
...
} @ attrs:
with lib; let
helpers = import ../helpers.nix {inherit lib;}; helpers = import ../helpers.nix {inherit lib;};
eitherAttrsStrInt = with types; let eitherAttrsStrInt = with types; let
strInt = either str int; strInt = either str int;
in either strInt (attrsOf (either strInt (attrsOf strInt))); in
in with helpers; either strInt (attrsOf (either strInt (attrsOf strInt)));
in
with helpers;
mkPlugin attrs { mkPlugin attrs {
name = "emmet"; name = "emmet";
description = "Enable emmet"; description = "Enable emmet";

View file

@ -1,7 +1,12 @@
{ lib, pkgs, ... }@attrs: {
let lib,
pkgs,
...
} @ attrs: let
helpers = import ../helpers.nix {inherit lib;}; helpers = import ../helpers.nix {inherit lib;};
in with helpers; with lib; in
with helpers;
with lib;
mkPlugin attrs { mkPlugin attrs {
name = "endwise"; name = "endwise";
description = "Enable vim-endwise"; description = "Enable vim-endwise";

View file

@ -1,10 +1,13 @@
{ config, pkgs, lib, ... }: {
with lib; config,
let pkgs,
lib,
...
}:
with lib; let
cfg = config.plugins.floaterm; cfg = config.plugins.floaterm;
helpers = import ../helpers.nix {inherit lib;}; helpers = import ../helpers.nix {inherit lib;};
in in {
{
options = { options = {
plugins.floaterm = { plugins.floaterm = {
enable = mkEnableOption "floaterm"; enable = mkEnableOption "floaterm";

View file

@ -1,7 +1,12 @@
{ lib, pkgs, ... }@attrs: {
let lib,
pkgs,
...
} @ attrs: let
helpers = import ../helpers.nix {inherit lib;}; helpers = import ../helpers.nix {inherit lib;};
in with helpers; with lib; in
with helpers;
with lib;
mkPlugin attrs { mkPlugin attrs {
name = "goyo"; name = "goyo";
description = "Enable goyo.vim"; description = "Enable goyo.vim";

View file

@ -1,6 +1,10 @@
{ pkgs, config, lib, ... }: {
with lib; pkgs,
let config,
lib,
...
}:
with lib; let
cfg = config.plugins.harpoon; cfg = config.plugins.harpoon;
helpers = import ../helpers.nix {inherit lib;}; helpers = import ../helpers.nix {inherit lib;};
@ -15,8 +19,7 @@ let
''; '';
}; };
}; };
in in {
{
options.plugins.harpoon = { options.plugins.harpoon = {
enable = mkEnableOption "harpoon"; enable = mkEnableOption "harpoon";
@ -73,17 +76,16 @@ in
Menu window height Menu window height
''; '';
borderChars = helpers.defaultNullOpts.mkNullable (types.listOf types.str) borderChars =
helpers.defaultNullOpts.mkNullable (types.listOf types.str)
"[ \"\" \"\" \"\" \"\" \"\" \"\" \"\" \"\" ]" "[ \"\" \"\" \"\" \"\" \"\" \"\" \"\" \"\" ]"
"Border characters" "Border characters";
; };
}; };
}; config = let
projects =
config = builtins.mapAttrs
let
projects = builtins.mapAttrs
( (
name: value: { name: value: {
term.cmds = value.termCommands; term.cmds = value.termCommands;
@ -119,4 +121,3 @@ in
''; '';
}; };
} }

View file

@ -1,12 +1,12 @@
{ lib {
, pkgs lib,
, config pkgs,
, ... config,
...
} @ args: } @ args:
with lib; let with lib; let
helpers = import ../helpers.nix args; helpers = import ../helpers.nix args;
in in {
{
options.plugins.indent-blankline = { options.plugins.indent-blankline = {
enable = mkEnableOption "indent-blankline.nvim"; enable = mkEnableOption "indent-blankline.nvim";
@ -248,8 +248,7 @@ in
helpers.defaultNullOpts.mkBool false "Turns deprecation warning messages off."; helpers.defaultNullOpts.mkBool false "Turns deprecation warning messages off.";
}; };
config = config = let
let
cfg = config.plugins.indent-blankline; cfg = config.plugins.indent-blankline;
in in
mkIf cfg.enable { mkIf cfg.enable {

View file

@ -1,11 +1,14 @@
{ config, pkgs, lib, ... }: {
with lib; config,
let pkgs,
lib,
...
}:
with lib; let
cfg = config.plugins.intellitab; cfg = config.plugins.intellitab;
helpers = import ../helpers.nix {inherit lib;}; helpers = import ../helpers.nix {inherit lib;};
defs = import ../plugin-defs.nix {inherit pkgs;}; defs = import ../plugin-defs.nix {inherit pkgs;};
in in {
{
options = { options = {
plugins.intellitab = { plugins.intellitab = {
enable = mkEnableOption "intellitab.nvim"; enable = mkEnableOption "intellitab.nvim";

View file

@ -1,6 +1,10 @@
{ pkgs, lib, config, ... }: {
with lib; pkgs,
let lib,
config,
...
}:
with lib; let
cfg = config.plugins.magma-nvim; cfg = config.plugins.magma-nvim;
plugins = import ../plugin-defs.nix {inherit pkgs;}; plugins = import ../plugin-defs.nix {inherit pkgs;};
package = pkgs.fetchFromGitHub { package = pkgs.fetchFromGitHub {
@ -17,8 +21,7 @@ in {
type = types.enum ["none" "ueberzug" "kitty"]; type = types.enum ["none" "ueberzug" "kitty"];
default = "none"; default = "none";
example = "ueberzug"; example = "ueberzug";
description = description = " This configures how to display images. The following options are available:
" This configures how to display images. The following options are available:
none -- don't show imagesmagma_image_provider. none -- don't show imagesmagma_image_provider.
ueberzug -- use Ueberzug to display images. ueberzug -- use Ueberzug to display images.
kitty -- use the Kitty protocol to display images."; kitty -- use the Kitty protocol to display images.";
@ -27,8 +30,7 @@ in {
type = types.bool; type = types.bool;
default = true; default = true;
example = false; example = false;
description = description = " If this is true, then whenever you have an active cell its output window will be automatically shown.
" If this is true, then whenever you have an active cell its output window will be automatically shown.
If this is false, then the output window will only be automatically shown when you've just evaluated the code. So, if you take your cursor out of the cell, and then come back, the output window won't be opened (but the cell will be highlighted). This means that there will be nothing covering your code. You can then open the output window at will using :MagmaShowOutput."; If this is false, then the output window will only be automatically shown when you've just evaluated the code. So, if you take your cursor out of the cell, and then come back, the output window won't be opened (but the cell will be highlighted). This means that there will be nothing covering your code. You can then open the output window at will using :MagmaShowOutput.";
}; };
@ -36,60 +38,54 @@ in {
type = types.bool; type = types.bool;
default = true; default = true;
example = false; example = false;
description = description = " If this is true, then text output in the output window will be wrapped (akin to set wrap).";
" If this is true, then text output in the output window will be wrapped (akin to set wrap).";
}; };
output_window_borders = mkOption { output_window_borders = mkOption {
type = types.bool; type = types.bool;
default = true; default = true;
example = false; example = false;
description = description = " If this is true, then the output window will have rounded borders. If it is false, it will have no borders.";
" If this is true, then the output window will have rounded borders. If it is false, it will have no borders.";
}; };
cell_highlight_group = mkOption { cell_highlight_group = mkOption {
type = types.str; type = types.str;
default = "CursorLine"; default = "CursorLine";
# example = ""; # example = "";
description = description = " The highlight group to be used for highlighting cells.";
" The highlight group to be used for highlighting cells.";
}; };
save_path = mkOption { save_path = mkOption {
type = types.nullOr types.str; type = types.nullOr types.str;
default = null; default = null;
description = description = "Where to save/load with :MagmaSave and :MagmaLoad (with no parameters).
"Where to save/load with :MagmaSave and :MagmaLoad (with no parameters).
The generated file is placed in this directory, with the filename itself being the buffer's name, with % replaced by %% and / replaced by %, and postfixed with the extension .json."; The generated file is placed in this directory, with the filename itself being the buffer's name, with % replaced by %% and / replaced by %, and postfixed with the extension .json.";
}; };
show_mimetype_debug = mkOption { show_mimetype_debug = mkOption {
type = types.bool; type = types.bool;
default = false; default = false;
example = true; example = true;
description = description = " If this is true, then before any non-iostream output chunk, Magma shows the mimetypes it received for it.
" If this is true, then before any non-iostream output chunk, Magma shows the mimetypes it received for it.
This is meant for debugging and adding new mimetypes."; This is meant for debugging and adding new mimetypes.";
}; };
package = mkOption { package = mkOption {
type = types.nullOr types.package; type = types.nullOr types.package;
default = null; default = null;
example = example = "package = pkgs.fetchFromGitHub {
"package = pkgs.fetchFromGitHub {
owner = \"WhiteBlackGoose\"; owner = \"WhiteBlackGoose\";
repo = \"magma-nvim-goose\"; repo = \"magma-nvim-goose\";
rev = version; rev = version;
sha256 = \"sha256-IaslJK1F2BxTvZzKGH9OKOl2RICi4d4rSgjliAIAqK4=\";} "; sha256 = \"sha256-IaslJK1F2BxTvZzKGH9OKOl2RICi4d4rSgjliAIAqK4=\";} ";
}; };
}; };
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
extraPlugins = [ ( extraPlugins = [
if cfg.package != null then plugins.magma-nvim.override {src = cfg.package;} else plugins.magma-nvim (
)]; if cfg.package != null
then plugins.magma-nvim.override {src = cfg.package;}
else plugins.magma-nvim
)
];
globals = { globals = {
magma_image_provider = magma_image_provider =
@ -99,13 +95,11 @@ in {
magma_wrap_output = mkIf (!cfg.wrap_output) cfg.wrap_output; magma_wrap_output = mkIf (!cfg.wrap_output) cfg.wrap_output;
magma_output_window_borders = magma_output_window_borders =
mkIf (!cfg.output_window_borders) cfg.output_window_borders; mkIf (!cfg.output_window_borders) cfg.output_window_borders;
magma_highlight_group = mkIf (cfg.cell_highlight_group != "CursorLine") magma_highlight_group =
mkIf (cfg.cell_highlight_group != "CursorLine")
cfg.cell_highlight_group; cfg.cell_highlight_group;
magma_show_mimetype_debug = magma_show_mimetype_debug =
mkIf cfg.show_mimetype_debug cfg.show_mimetype_debug; mkIf cfg.show_mimetype_debug cfg.show_mimetype_debug;
}; };
}; };
} }

View file

@ -1,12 +1,14 @@
{ pkgs, config, lib, ... }: {
pkgs,
with lib; config,
let lib,
...
}:
with lib; let
cfg = config.plugins.mark-radar; cfg = config.plugins.mark-radar;
helpers = import ../helpers.nix {inherit lib;}; helpers = import ../helpers.nix {inherit lib;};
defs = import ../plugin-defs.nix {inherit pkgs;}; defs = import ../plugin-defs.nix {inherit pkgs;};
in in {
{
options.plugins.mark-radar = { options.plugins.mark-radar = {
enable = mkEnableOption "mark-radar"; enable = mkEnableOption "mark-radar";
@ -33,8 +35,7 @@ in
}; };
}; };
config = config = let
let
opts = helpers.toLuaObject { opts = helpers.toLuaObject {
inherit (cfg) highlight_group background_highlight_group; inherit (cfg) highlight_group background_highlight_group;
set_default_mappings = cfg.set_default_keybinds; set_default_mappings = cfg.set_default_keybinds;

View file

@ -1,14 +1,17 @@
{ pkgs, config, lib, ... }: {
with lib; pkgs,
let config,
lib,
...
}:
with lib; let
cfg = config.plugins.notify; cfg = config.plugins.notify;
helpers = import ../helpers.nix {inherit lib;}; helpers = import ../helpers.nix {inherit lib;};
icon = mkOption { icon = mkOption {
type = types.nullOr types.str; type = types.nullOr types.str;
default = null; default = null;
}; };
in in {
{
options.plugins.notify = { options.plugins.notify = {
enable = mkEnableOption "notify"; enable = mkEnableOption "notify";
@ -49,8 +52,7 @@ in
}; };
}; };
config = config = let
let
setupOptions = with cfg; { setupOptions = with cfg; {
stages = stages; stages = stages;
timeout = timeout; timeout = timeout;

View file

@ -1,10 +1,13 @@
{ pkgs, config, lib, ... }: {
with lib; pkgs,
let config,
lib,
...
}:
with lib; let
cfg = config.plugins.nvim-autopairs; cfg = config.plugins.nvim-autopairs;
helpers = import ../helpers.nix {inherit lib;}; helpers = import ../helpers.nix {inherit lib;};
in in {
{
options.plugins.nvim-autopairs = { options.plugins.nvim-autopairs = {
enable = mkEnableOption "nvim-autopairs"; enable = mkEnableOption "nvim-autopairs";
@ -41,8 +44,7 @@ in
}; };
}; };
config = config = let
let
options = { options = {
pairs_map = cfg.pairs; pairs_map = cfg.pairs;
disable_filetype = cfg.disabledFiletypes; disable_filetype = cfg.disabledFiletypes;

View file

@ -1,7 +1,10 @@
{ pkgs, config, lib, ... }: {
with lib; pkgs,
let config,
lib,
...
}:
with lib; let
cfg = config.plugins.nvim-colorizer; cfg = config.plugins.nvim-colorizer;
helpers = import ../helpers.nix {inherit lib;}; helpers = import ../helpers.nix {inherit lib;};
@ -84,12 +87,9 @@ let
default = null; default = null;
}; };
}; };
in {
in
{
options = { options = {
plugins.nvim-colorizer = { plugins.nvim-colorizer = {
enable = mkEnableOption "nvim-colorizer"; enable = mkEnableOption "nvim-colorizer";
package = helpers.mkPackageOption "nvim-colorizer" pkgs.vimPlugins.nvim-colorizer-lua; package = helpers.mkPackageOption "nvim-colorizer" pkgs.vimPlugins.nvim-colorizer-lua;
@ -100,11 +100,13 @@ in
types.listOf (types.oneOf [ types.listOf (types.oneOf [
types.str types.str
(types.submodule { (types.submodule {
options = { options =
{
language = mkOption { language = mkOption {
type = types.str; type = types.str;
}; };
} // colorizer-options; }
// colorizer-options;
}) })
]) ])
); );
@ -131,21 +133,23 @@ in
extraPlugins = [cfg.package]; extraPlugins = [cfg.package];
extraConfigLua = let extraConfigLua = let
filetypes =
filetypes = if (cfg.fileTypes != null) if (cfg.fileTypes != null)
then ( then
(
let let
list = map ( list =
v: if builtins.isAttrs v map (
v:
if builtins.isAttrs v
then v.language + " = " + helpers.toLuaObject (builtins.removeAttrs v ["language"]) then v.language + " = " + helpers.toLuaObject (builtins.removeAttrs v ["language"])
else "'${v}'" else "'${v}'"
) cfg.fileTypes;
in "{" + (concatStringsSep "," list) + "}"
) )
else cfg.fileTypes;
"nil" in
; "{" + (concatStringsSep "," list) + "}"
)
else "nil";
in '' in ''
require("colorizer").setup({ require("colorizer").setup({
filetypes = ${filetypes}, filetypes = ${filetypes},

View file

@ -1,12 +1,15 @@
{ pkgs, config, lib, ... }@args: {
with lib; pkgs,
let config,
lib,
...
} @ args:
with lib; let
cfg = config.plugins.nvim-tree; cfg = config.plugins.nvim-tree;
helpers = import ../helpers.nix {inherit lib;}; helpers = import ../helpers.nix {inherit lib;};
optionWarnings = import ../../lib/option-warnings.nix args; optionWarnings = import ../../lib/option-warnings.nix args;
basePluginPath = ["plugins" "nvim-tree"]; basePluginPath = ["plugins" "nvim-tree"];
in in {
{
imports = [ imports = [
(optionWarnings.mkRenamedOption { (optionWarnings.mkRenamedOption {
option = basePluginPath ++ ["updateCwd"]; option = basePluginPath ++ ["updateCwd"];
@ -102,15 +105,14 @@ in
description = "Enable diagnostics"; description = "Enable diagnostics";
}; };
icons = icons = let
let diagnosticOption = desc:
diagnosticOption = desc: mkOption { mkOption {
type = types.nullOr types.str; type = types.nullOr types.str;
default = null; default = null;
description = desc; description = desc;
}; };
in in {
{
hint = diagnosticOption "Hints"; hint = diagnosticOption "Hints";
info = diagnosticOption "Info"; info = diagnosticOption "Info";
warning = diagnosticOption "Warning"; warning = diagnosticOption "Warning";
@ -233,8 +235,7 @@ in
}; };
}; };
config = config = let
let
options = { options = {
disable_netrw = cfg.disableNetrw; disable_netrw = cfg.disableNetrw;
hijack_netrw = cfg.hijackNetrw; hijack_netrw = cfg.hijackNetrw;

View file

@ -1,11 +1,16 @@
{ pkgs, config, lib, ... }: {
with lib; pkgs,
let config,
lib,
...
}:
with lib; let
cfg = config.plugins.project-nvim; cfg = config.plugins.project-nvim;
helpers = import ../helpers.nix {inherit lib pkgs;}; helpers = import ../helpers.nix {inherit lib pkgs;};
in in {
{ options.plugins.project-nvim =
options.plugins.project-nvim = helpers.extraOptionsOptions // { helpers.extraOptionsOptions
// {
enable = mkEnableOption "project.nvim"; enable = mkEnableOption "project.nvim";
package = helpers.mkPackageOption "project-nvim" pkgs.vimPlugins.project-nvim; package = helpers.mkPackageOption "project-nvim" pkgs.vimPlugins.project-nvim;
@ -54,12 +59,11 @@ in
type = types.nullOr (types.either types.str helpers.rawType); type = types.nullOr (types.either types.str helpers.rawType);
default = null; default = null;
}; };
}; };
config = config = let
let options =
options = { {
manual_mode = cfg.manualMode; manual_mode = cfg.manualMode;
detection_methods = cfg.detectionMethods; detection_methods = cfg.detectionMethods;
patterns = cfg.patterns; patterns = cfg.patterns;
@ -69,7 +73,8 @@ in
silent_chdir = cfg.silentChdir; silent_chdir = cfg.silentChdir;
scope_schdir = cfg.scopeChdir; scope_schdir = cfg.scopeChdir;
data_path = cfg.dataPath; data_path = cfg.dataPath;
} // cfg.extraOptions; }
// cfg.extraOptions;
in in
mkIf cfg.enable { mkIf cfg.enable {
extraPlugins = [cfg.package]; extraPlugins = [cfg.package];

View file

@ -1,10 +1,13 @@
{ pkgs, config, lib, ... }: {
with lib; pkgs,
let config,
lib,
...
}:
with lib; let
cfg = config.plugins.specs; cfg = config.plugins.specs;
helpers = import ../helpers.nix {inherit lib;}; helpers = import ../helpers.nix {inherit lib;};
in in {
{
options.plugins.specs = { options.plugins.specs = {
enable = mkEnableOption "specs-nvim"; enable = mkEnableOption "specs-nvim";
@ -80,7 +83,8 @@ in
type = types.submodule { type = types.submodule {
options = { options = {
builtin = mkOption { builtin = mkOption {
type = types.nullOr type =
types.nullOr
(types.enum ["shrink_resizer" "slide_resizer" "empty_resizer"]); (types.enum ["shrink_resizer" "slide_resizer" "empty_resizer"]);
default = "shrink_resizer"; default = "shrink_resizer";
}; };
@ -110,31 +114,36 @@ in
type = with types; listOf string; type = with types; listOf string;
default = ["nofile"]; default = ["nofile"];
}; };
}; };
config = config = let
let
setup = helpers.toLuaObject { setup = helpers.toLuaObject {
inherit (cfg) show_jumps min_jump; inherit (cfg) show_jumps min_jump;
ignore_filetypes = attrsets.listToAttrs ignore_filetypes =
attrsets.listToAttrs
(lib.lists.map (x: attrsets.nameValuePair x true) (lib.lists.map (x: attrsets.nameValuePair x true)
cfg.ignored_filetypes); cfg.ignored_filetypes);
ignore_buftypes = attrsets.listToAttrs ignore_buftypes =
attrsets.listToAttrs
(lib.lists.map (x: attrsets.nameValuePair x true) (lib.lists.map (x: attrsets.nameValuePair x true)
cfg.ignored_buffertypes); cfg.ignored_buffertypes);
popup = { popup = {
inherit (cfg) blend width; inherit (cfg) blend width;
winhl = if (!isNull cfg.color) then "SpecsPopColor" else "PMenu"; winhl =
if (!isNull cfg.color)
then "SpecsPopColor"
else "PMenu";
delay_ms = cfg.delay; delay_ms = cfg.delay;
inc_ms = cfg.increment; inc_ms = cfg.increment;
fader = helpers.mkRaw (if cfg.fader.builtin == null then fader = helpers.mkRaw (
cfg.fader.custom if cfg.fader.builtin == null
else then cfg.fader.custom
''require("specs").${cfg.fader.builtin}''); else ''require("specs").${cfg.fader.builtin}''
resizer = helpers.mkRaw (if cfg.resizer.builtin == null then );
cfg.resizer.custom resizer = helpers.mkRaw (
else if cfg.resizer.builtin == null
''require("specs").${cfg.resizer.builtin}''); then cfg.resizer.custom
else ''require("specs").${cfg.resizer.builtin}''
);
}; };
}; };
in in

View file

@ -1,7 +1,12 @@
{ pkgs, lib, ... }@args: {
let pkgs,
lib,
...
} @ args: let
helpers = import ../helpers.nix {inherit lib;}; helpers = import ../helpers.nix {inherit lib;};
in with lib; with helpers; in
with lib;
with helpers;
mkPlugin args { mkPlugin args {
name = "startify"; name = "startify";
description = "Enable startify"; description = "Enable startify";
@ -17,7 +22,8 @@ mkPlugin args {
lists = mkDefaultOpt { lists = mkDefaultOpt {
description = "Startify display lists. If it's a string, it'll be interpreted as literal lua code"; description = "Startify display lists. If it's a string, it'll be interpreted as literal lua code";
global = "startify_lists"; global = "startify_lists";
type = types.listOf (types.oneOf [(types.submodule { type = types.listOf (types.oneOf [
(types.submodule {
options = { options = {
type = mkOption { type = mkOption {
type = types.str; type = types.str;
@ -35,11 +41,18 @@ mkPlugin args {
default = null; default = null;
}; };
}; };
}) types.str]); })
types.str
]);
value = val: let value = val: let
list = map (v: if builtins.isAttrs v then toLuaObject v else v) val; list = map (v:
in "{" + (concatStringsSep "," list) + "}"; if builtins.isAttrs v
then toLuaObject v
else v)
val;
in
"{" + (concatStringsSep "," list) + "}";
}; };
bookmarks = mkDefaultOpt { bookmarks = mkDefaultOpt {

View file

@ -1,7 +1,12 @@
{ lib, pkgs, ... }@attrs: {
let lib,
pkgs,
...
} @ attrs: let
helpers = import ../helpers.nix {inherit lib;}; helpers = import ../helpers.nix {inherit lib;};
in with helpers; with lib; in
with helpers;
with lib;
mkPlugin attrs { mkPlugin attrs {
name = "surround"; name = "surround";
description = "Enable surround.vim"; description = "Enable surround.vim";

View file

@ -1,10 +1,13 @@
{ pkgs, config, lib, ... }: {
with lib; pkgs,
let config,
lib,
...
}:
with lib; let
cfg = config.plugins.undotree; cfg = config.plugins.undotree;
helpers = import ../helpers.nix {inherit lib;}; helpers = import ../helpers.nix {inherit lib;};
in in {
{
options = { options = {
plugins.undotree = { plugins.undotree = {
enable = mkEnableOption "Enable undotree"; enable = mkEnableOption "Enable undotree";

View file

@ -14,16 +14,24 @@
inputs.nixpkgs.follows = "nixpkgs-stable"; inputs.nixpkgs.follows = "nixpkgs-stable";
}; };
outputs = { self, nixvim, nixvim-stable, nixpkgs, flake-utils, nixpkgs-stable, build-ts, gleam, ... }: outputs = {
self,
nixvim,
nixvim-stable,
nixpkgs,
flake-utils,
nixpkgs-stable,
build-ts,
gleam,
...
}:
(flake-utils.lib.eachDefaultSystem (flake-utils.lib.eachDefaultSystem
(system: (system: let
let
pkgs = import nixpkgs {inherit system;}; pkgs = import nixpkgs {inherit system;};
pkgs-stable = import nixpkgs-stable {inherit system;}; pkgs-stable = import nixpkgs-stable {inherit system;};
build = nixvim.legacyPackages.${system}.makeNixvim; build = nixvim.legacyPackages.${system}.makeNixvim;
build-stable = nixvim-stable.legacyPackages.${system}.makeNixvim; build-stable = nixvim-stable.legacyPackages.${system}.makeNixvim;
in in rec {
rec {
# A plain nixvim configuration # A plain nixvim configuration
packages = { packages = {
plain = build {}; plain = build {};
@ -118,7 +126,6 @@
rnix-lsp.enable = true; rnix-lsp.enable = true;
}; };
}; };
}; };
options = { options = {
@ -206,7 +213,6 @@
{name = "path";} {name = "path";}
{name = "buffer";} {name = "buffer";}
]; ];
}; };
barbar.enable = true; barbar.enable = true;
}; };
@ -275,7 +281,8 @@
}; };
}; };
}; };
})) // { }))
// {
nixosConfigurations.nixvim-machine = nixpkgs.lib.nixosSystem { nixosConfigurations.nixvim-machine = nixpkgs.lib.nixosSystem {
system = "x86_64-linux"; system = "x86_64-linux";
modules = [ modules = [
@ -288,8 +295,7 @@
}; };
nixosConfigurations.container = nixpkgs.lib.nixosSystem { nixosConfigurations.container = nixpkgs.lib.nixosSystem {
system = "x86_64-linux"; system = "x86_64-linux";
modules = modules = [
[
({pkgs, ...}: { ({pkgs, ...}: {
boot.isContainer = true; boot.isContainer = true;

View file

@ -1,9 +1,10 @@
{ lib, pkgs, ... }:
let
inherit (lib) mkEnableOption mkOption mkOptionType mkForce mkMerge mkIf types;
in
{ {
lib,
pkgs,
...
}: let
inherit (lib) mkEnableOption mkOption mkOptionType mkForce mkMerge mkIf types;
in {
helpers = mkOption { helpers = mkOption {
type = mkOptionType { type = mkOptionType {
name = "helpers"; name = "helpers";

View file

@ -1,18 +1,22 @@
modules: modules: {
{ pkgs, config, lib, ... }@args: pkgs,
config,
let lib,
...
} @ args: let
inherit (lib) mkEnableOption mkOption mkOptionType mkForce mkMerge mkIf types; inherit (lib) mkEnableOption mkOption mkOptionType mkForce mkMerge mkIf types;
shared = import ./_shared.nix args; shared = import ./_shared.nix args;
cfg = config.programs.nixvim; cfg = config.programs.nixvim;
in in {
{
options = { options = {
programs.nixvim = mkOption { programs.nixvim = mkOption {
type = types.submodule ((modules pkgs) ++ [{ type = types.submodule ((modules pkgs)
++ [
{
options.enable = mkEnableOption "nixvim"; options.enable = mkEnableOption "nixvim";
config.wrapRc = mkForce true; config.wrapRc = mkForce true;
}]); }
]);
}; };
nixvim.helpers = shared.helpers; nixvim.helpers = shared.helpers;
}; };

View file

@ -1,30 +1,35 @@
modules: modules: {
{ pkgs, config, lib, ... }@args: pkgs,
config,
let lib,
...
} @ args: let
inherit (lib) mkEnableOption mkOption mkOptionType mkMerge mkIf types; inherit (lib) mkEnableOption mkOption mkOptionType mkMerge mkIf types;
shared = import ./_shared.nix args; shared = import ./_shared.nix args;
cfg = config.programs.nixvim; cfg = config.programs.nixvim;
in in {
{
options = { options = {
programs.nixvim = mkOption { programs.nixvim = mkOption {
type = types.submodule ((modules pkgs) ++ [{ type = types.submodule ((modules pkgs)
++ [
{
options.enable = mkEnableOption "nixvim"; options.enable = mkEnableOption "nixvim";
}]); }
]);
}; };
nixvim.helpers = shared.helpers; nixvim.helpers = shared.helpers;
}; };
config = mkIf cfg.enable config =
mkIf cfg.enable
(mkMerge [ (mkMerge [
{home.packages = [cfg.finalPackage];} {home.packages = [cfg.finalPackage];}
(mkIf (!cfg.wrapRc) { (mkIf (!cfg.wrapRc) {
xdg.configFile."nvim/init.lua".text = cfg.initContent; xdg.configFile."nvim/init.lua".text = cfg.initContent;
}) })
({ {
warnings = cfg.warnings; warnings = cfg.warnings;
assertions = cfg.assertions; assertions = cfg.assertions;
}) }
]); ]);
} }

View file

@ -1,31 +1,36 @@
modules: modules: {
{ pkgs, config, lib, ... }@args: pkgs,
config,
let lib,
...
} @ args: let
inherit (lib) mkEnableOption mkOption mkOptionType mkMerge mkIf types; inherit (lib) mkEnableOption mkOption mkOptionType mkMerge mkIf types;
shared = import ./_shared.nix args; shared = import ./_shared.nix args;
cfg = config.programs.nixvim; cfg = config.programs.nixvim;
in in {
{
options = { options = {
programs.nixvim = mkOption { programs.nixvim = mkOption {
type = types.submodule ((modules pkgs) ++ [{ type = types.submodule ((modules pkgs)
++ [
{
options.enable = mkEnableOption "nixvim"; options.enable = mkEnableOption "nixvim";
}]); }
]);
}; };
nixvim.helpers = shared.helpers; nixvim.helpers = shared.helpers;
}; };
config = mkIf cfg.enable config =
mkIf cfg.enable
(mkMerge [ (mkMerge [
{environment.systemPackages = [cfg.finalPackage];} {environment.systemPackages = [cfg.finalPackage];}
(mkIf (!cfg.wrapRc) { (mkIf (!cfg.wrapRc) {
environment.etc."nvim/sysinit.lua".text = cfg.initContent; environment.etc."nvim/sysinit.lua".text = cfg.initContent;
environment.variables."VIM" = "/etc/nvim"; environment.variables."VIM" = "/etc/nvim";
}) })
({ {
warnings = cfg.warnings; warnings = cfg.warnings;
assertions = cfg.assertions; assertions = cfg.assertions;
}) }
]); ]);
} }

View file

@ -1,7 +1,7 @@
default_pkgs: modules: {pkgs ? default_pkgs, module}: default_pkgs: modules: {
pkgs ? default_pkgs,
let module,
}: let
inherit (pkgs) lib; inherit (pkgs) lib;
wrap = {wrapRc = true;}; wrap = {wrapRc = true;};
@ -9,5 +9,5 @@ let
eval = lib.evalModules { eval = lib.evalModules {
modules = (modules pkgs) ++ [module wrap]; modules = (modules pkgs) ++ [module wrap];
}; };
in
in eval.config.finalPackage eval.config.finalPackage