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,8 +1,12 @@
{ 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;};
}; };
docs = pkgs.nixosOptionsDoc { docs = pkgs.nixosOptionsDoc {
# If we don't do this, we end up with _module.args on the generated options, which we do not want # If we don't do this, we end up with _module.args on the generated options, which we do not want
@ -11,7 +15,7 @@ let
}; };
asciidoc = docs.optionsAsciiDoc; asciidoc = docs.optionsAsciiDoc;
in in
pkgs.stdenv.mkDerivation { pkgs.stdenv.mkDerivation {
name = "nixvim-docs"; name = "nixvim-docs";
src = asciidoc; src = asciidoc;
@ -19,7 +23,7 @@ pkgs.stdenv.mkDerivation {
pkgs.asciidoctor pkgs.asciidoctor
]; ];
phases = [ "buildPhase" ]; phases = ["buildPhase"];
buildPhase = '' buildPhase = ''
mkdir -p $out/share/doc mkdir -p $out/share/doc
@ -32,4 +36,4 @@ pkgs.stdenv.mkDerivation {
cat header.adoc $src > tmp.adoc cat header.adoc $src > tmp.adoc
asciidoctor tmp.adoc -o $out/share/doc/index.html asciidoctor tmp.adoc -o $out/share/doc/index.html
''; '';
} }

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
@ -53,8 +52,8 @@
# This is one of lightline's example configurations # This is one of lightline's example configurations
active = { active = {
left = [ left = [
[ "mode" "paste" ] ["mode" "paste"]
[ "redaonly" "filename" "modified" "helloworld" ] ["redaonly" "filename" "modified" "helloworld"]
]; ];
}; };
@ -73,7 +72,7 @@
# What about plugins not available as a module? # What about plugins not available as a module?
# Use extraPlugins: # Use extraPlugins:
extraPlugins = with pkgs.vimPlugins; [ vim-toml ]; extraPlugins = with pkgs.vimPlugins; [vim-toml];
}; };
}; };
} }

View file

@ -6,43 +6,52 @@
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 = {
_module.args = { _module.args = {
pkgs = mkForce pkgs; pkgs = mkForce pkgs;
inherit (pkgs) lib; inherit (pkgs) lib;
helpers = import ./plugins/helpers.nix { inherit (pkgs) lib; }; helpers = import ./plugins/helpers.nix {inherit (pkgs) lib;};
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 = {
extractRustAnalyzer = { stdenv, pkgs }: stdenv.mkDerivation { stdenv,
pkgs,
}:
stdenv.mkDerivation {
pname = "extract_rust_analyzer"; pname = "extract_rust_analyzer";
version = "master"; version = "master";
dontUnpack = true; dontUnpack = true;
dontBuild = true; dontBuild = true;
buildInputs = [ pkgs.python3 ]; buildInputs = [pkgs.python3];
installPhase = '' installPhase = ''
ls -la ls -la
@ -50,15 +59,19 @@
cp ${./helpers/extract_rust_analyzer.py} $out/bin/extract_rust_analyzer.py cp ${./helpers/extract_rust_analyzer.py} $out/bin/extract_rust_analyzer.py
''; '';
}; };
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;
@ -77,19 +90,22 @@
cp rust-analyzer-config.nix $out/share cp rust-analyzer-config.nix $out/share
''; '';
}) })
{ }; {};
}; };
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;
@ -153,7 +192,7 @@ rec {
extraOptionsOptions = { extraOptionsOptions = {
extraOptions = mkOption { extraOptions = mkOption {
default = { }; default = {};
type = types.attrs; type = types.attrs;
description = '' description = ''
These attributes will be added to the table parameter for the setup function. These attributes will be added to the table parameter for the setup function.
@ -162,7 +201,7 @@ rec {
}; };
}; };
mkRaw = r: { __raw = r; }; mkRaw = r: {__raw = r;};
wrapDo = string: '' wrapDo = string: ''
do do

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.type or (types.submodule { }); opt = attrByPath newOption {} options;
message = "`${showOption option}` has been renamed to `${showOption newOption}`, but can still be used for compatibility";
in in
{ opt.type or (types.submodule {});
message = "`${showOption option}` has been renamed to `${showOption newOption}`, but can still be used for compatibility";
in {
options = setAttrByPath option (mkOption options = setAttrByPath option (mkOption
{ {
inherit visible; inherit visible;
@ -50,18 +49,20 @@ 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 [
{ {
warnings = mkIf (warn && fromOpt.isDefined) [ "Nixvim: ${message}" ]; warnings = mkIf (warn && fromOpt.isDefined) ["Nixvim: ${message}"];
} }
(mkAliasAndWrapDefinitions (setAttrByPath newOption) fromOpt) (mkAliasAndWrapDefinitions (setAttrByPath newOption) fromOpt)
]; ];
}; };
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,7 +1,10 @@
{ config, lib, ... }: {
with lib; config,
let lib,
helpers = import ../lib/helpers.nix { inherit lib; }; ...
}:
with lib; let
helpers = import ../lib/helpers.nix {inherit lib;};
autoGroupOption = types.submodule { autoGroupOption = types.submodule {
options = { options = {
@ -47,13 +50,11 @@ 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;
default = { }; default = {};
description = "augroup definitions"; description = "augroup definitions";
example = '' example = ''
autoGroups = { autoGroups = {
@ -66,7 +67,7 @@ in
autoCmd = mkOption { autoCmd = mkOption {
type = types.listOf autoCmdOption; type = types.listOf autoCmdOption;
default = [ ]; default = [];
description = "autocmd definitions"; description = "autocmd definitions";
example = '' example = ''
autoCmd = [ autoCmd = [
@ -80,8 +81,9 @@ 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,13 +1,15 @@
{ config, lib, ... }:
let
helpers = import ../lib/helpers.nix { inherit lib; };
in
with lib;
{ {
config,
lib,
...
}: let
helpers = import ../lib/helpers.nix {inherit lib;};
in
with lib; {
options = { options = {
highlight = mkOption { highlight = mkOption {
type = types.attrsOf types.anything; type = types.attrsOf types.anything;
default = { }; default = {};
description = "Define highlight groups"; description = "Define highlight groups";
example = '' example = ''
highlight = { highlight = {
@ -18,7 +20,7 @@ with lib;
match = mkOption { match = mkOption {
type = types.attrsOf types.str; type = types.attrsOf types.str;
default = { }; default = {};
description = "Define match groups"; description = "Define match groups";
example = '' example = ''
match = { match = {
@ -28,8 +30,9 @@ 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}
@ -52,5 +55,4 @@ with lib;
-- }} -- }}
''); '');
}; };
} }

View file

@ -1,7 +1,10 @@
{ config, lib, ... }: {
with lib; config,
let lib,
helpers = import ../lib/helpers.nix { inherit lib; }; ...
}:
with lib; let
helpers = import ../lib/helpers.nix {inherit lib;};
mapOption = types.oneOf [ mapOption = types.oneOf [
types.str types.str
@ -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 {
@ -82,7 +85,7 @@ in
command = mapOptions "command-line"; command = mapOptions "command-line";
}; };
}; };
default = { }; default = {};
description = '' description = ''
Custom keybindings for any mode. Custom keybindings for any mode.
@ -101,23 +104,21 @@ 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
local __nixvim_binds = ${helpers.toLuaObject mappings} local __nixvim_binds = ${helpers.toLuaObject mappings}

View file

@ -1,25 +1,28 @@
{ 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;
default = { }; default = {};
description = "The configuration options, e.g. line numbers"; description = "The configuration options, e.g. line numbers";
}; };
globals = mkOption { globals = mkOption {
type = types.attrsOf types.anything; type = types.attrsOf types.anything;
default = { }; default = {};
description = "Global variables"; description = "Global variables";
}; };
}; };
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;
@ -46,13 +51,13 @@ in
extraPlugins = mkOption { extraPlugins = mkOption {
type = with types; listOf (either package pluginWithConfigType); type = with types; listOf (either package pluginWithConfigType);
default = [ ]; default = [];
description = "List of vim plugins to install"; description = "List of vim plugins to install";
}; };
extraPackages = mkOption { extraPackages = mkOption {
type = types.listOf types.package; type = types.listOf types.package;
default = [ ]; default = [];
description = "Extra packages to be made available to neovim"; description = "Extra packages to be made available to neovim";
}; };
@ -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,34 +143,33 @@ 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}
''); '');
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;
let
cfg = config.plugins.barbar;
helpers = import ../helpers.nix { inherit lib; };
in
{ {
lib,
pkgs,
config,
...
}:
with lib; let
cfg = config.plugins.barbar;
helpers = import ../helpers.nix {inherit lib;};
in {
options.plugins.barbar = { options.plugins.barbar = {
enable = mkEnableOption "barbar.nvim"; enable = mkEnableOption "barbar.nvim";
@ -65,17 +68,18 @@ in
highlightVisible = helpers.defaultNullOpts.mkBool true "Highlight visible buffers"; highlightVisible = helpers.defaultNullOpts.mkBool true "Highlight visible buffers";
icons = { icons = {
enable = helpers.defaultNullOpts.mkNullable enable =
(with types; (either bool (enum [ "numbers" "both" ]))) helpers.defaultNullOpts.mkNullable
(with types; (either bool (enum ["numbers" "both"])))
"true" "true"
'' ''
Enable/disable icons if set to 'numbers', will show buffer index in the tabline if set to Enable/disable icons if set to 'numbers', will show buffer index in the tabline if set to
'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,12 +1,16 @@
{ 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;
highlight = mkOption { highlight = mkOption {
type = types.nullOr (types.submodule ({ ... }: { type = types.nullOr (types.submodule ({...}: {
options = { options = {
guifg = mkOption { guifg = mkOption {
type = types.nullOr types.str; type = types.nullOr types.str;
@ -20,14 +24,13 @@ let
}; };
}; };
})); }));
default = { }; default = {};
}; };
in in {
{
imports = [ imports = [
(optionWarnings.mkDeprecatedOption { (optionWarnings.mkDeprecatedOption {
option = [ "plugins" "bufferline" "indicatorIcon" ]; option = ["plugins" "bufferline" "indicatorIcon"];
alternative = [ "plugins" "bufferline" "indicator" "icon" ]; alternative = ["plugins" "bufferline" "indicator" "icon"];
}) })
]; ];
@ -111,7 +114,7 @@ in
default = null; default = null;
}; };
diagnostics = mkOption { diagnostics = mkOption {
type = types.nullOr (types.enum [ false "nvim_lsp" "coc" ]); type = types.nullOr (types.enum [false "nvim_lsp" "coc"]);
default = null; default = null;
}; };
diagnosticsUpdateInInsert = mkOption { diagnosticsUpdateInInsert = mkOption {
@ -147,7 +150,7 @@ in
default = null; default = null;
}; };
separatorStyle = mkOption { separatorStyle = mkOption {
type = types.nullOr (types.enum [ "slant" "thick" "thin" ]); type = types.nullOr (types.enum ["slant" "thick" "thin"]);
default = null; default = null;
}; };
enforceRegularTabs = mkOption { enforceRegularTabs = mkOption {
@ -159,27 +162,27 @@ in
default = null; default = null;
}; };
sortBy = mkOption { sortBy = mkOption {
type = types.nullOr (types.enum [ "id" "extension" "relative_directory" "directory" "tabs" ]); type = types.nullOr (types.enum ["id" "extension" "relative_directory" "directory" "tabs"]);
default = null; default = null;
}; };
indicator = mkOption { indicator = mkOption {
default = { }; default = {};
type = types.nullOr (types.submodule ({ ... }: { type = types.nullOr (types.submodule ({...}: {
options = { options = {
icon = mkOption { icon = mkOption {
type = types.nullOr types.str; type = types.nullOr types.str;
default = null; default = null;
}; };
style = mkOption { style = mkOption {
type = types.nullOr (types.enum [ "icon" "underline" "none" ]); type = types.nullOr (types.enum ["icon" "underline" "none"]);
default = null; default = null;
}; };
}; };
})); }));
}; };
highlights = mkOption { highlights = mkOption {
default = { }; default = {};
type = types.nullOr (types.submodule ({ ... }: { type = types.nullOr (types.submodule ({...}: {
options = { options = {
fill = highlight; fill = highlight;
background = highlight; background = highlight;
@ -246,16 +249,16 @@ in
extraOptions = mkOption { extraOptions = mkOption {
type = types.attrs; type = types.attrs;
default = { }; default = {};
description = "Extra options, will override others if defined"; description = "Extra options, will override others if defined";
}; };
}; };
}; };
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;
let
cfg = config.colorschemes.base16;
helpers = import ../helpers.nix { inherit lib; };
themes = import ./base16-list.nix;
in
{ {
pkgs,
config,
lib,
...
}:
with lib; let
cfg = config.colorschemes.base16;
helpers = import ../helpers.nix {inherit lib;};
themes = import ./base16-list.nix;
in {
options = { options = {
colorschemes.base16 = { colorschemes.base16 = {
enable = mkEnableOption "base16"; enable = mkEnableOption "base16";
@ -34,7 +37,7 @@ in
config = mkIf cfg.enable { config = mkIf cfg.enable {
colorscheme = "base16-${cfg.colorscheme}"; colorscheme = "base16-${cfg.colorscheme}";
extraPlugins = [ cfg.package ]; extraPlugins = [cfg.package];
plugins.airline.theme = mkIf (cfg.setUpBar) "base16"; plugins.airline.theme = mkIf (cfg.setUpBar) "base16";
plugins.lightline.colorscheme = null; plugins.lightline.colorscheme = null;

View file

@ -1,11 +1,14 @@
{ pkgs, config, lib, ... }:
with lib;
let
cfg = config.colorschemes.gruvbox;
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" ];
in
{ {
pkgs,
config,
lib,
...
}:
with lib; let
cfg = config.colorschemes.gruvbox;
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"];
in {
options = { options = {
colorschemes.gruvbox = { colorschemes.gruvbox = {
enable = mkEnableOption "gruvbox"; enable = mkEnableOption "gruvbox";
@ -18,13 +21,13 @@ in
undercurl = mkEnableOption "undercurled text"; undercurl = mkEnableOption "undercurled text";
contrastDark = mkOption { contrastDark = mkOption {
type = types.nullOr (types.enum [ "soft" "medium" "hard" ]); type = types.nullOr (types.enum ["soft" "medium" "hard"]);
default = null; default = null;
description = "Contrast for the dark mode"; description = "Contrast for the dark mode";
}; };
contrastLight = mkOption { contrastLight = mkOption {
type = types.nullOr (types.enum [ "soft" "medium" "hard" ]); type = types.nullOr (types.enum ["soft" "medium" "hard"]);
default = null; default = null;
description = "Contrast for the light mode"; description = "Contrast for the light mode";
}; };
@ -110,13 +113,12 @@ in
transparentBg = mkEnableOption "transparent background"; transparentBg = mkEnableOption "transparent background";
trueColor = mkEnableOption "true color support"; trueColor = mkEnableOption "true color support";
}; };
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
colorscheme = "gruvbox"; colorscheme = "gruvbox";
extraPlugins = [ cfg.package ]; extraPlugins = [cfg.package];
globals = { globals = {
gruvbox_bold = mkIf (!cfg.bold) 0; gruvbox_bold = mkIf (!cfg.bold) 0;

View file

@ -1,29 +1,37 @@
{ pkgs, config, lib, ... }:
with lib;
let
cfg = config.colorschemes.nord;
helpers = import ../helpers.nix { inherit lib; };
in
{ {
pkgs,
config,
lib,
...
}:
with lib; let
cfg = config.colorschemes.nord;
helpers = import ../helpers.nix {inherit lib;};
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 {
@ -36,7 +44,7 @@ in
config = mkIf cfg.enable { config = mkIf cfg.enable {
colorscheme = "nord"; colorscheme = "nord";
extraPlugins = [ cfg.package ]; extraPlugins = [cfg.package];
globals = { globals = {
nord_contrast = mkIf cfg.contrast 1; nord_contrast = mkIf cfg.contrast 1;

View file

@ -1,10 +1,13 @@
{ pkgs, config, lib, ... }:
with lib;
let
cfg = config.colorschemes.one;
helpers = import ../helpers.nix { inherit lib; };
in
{ {
pkgs,
config,
lib,
...
}:
with lib; let
cfg = config.colorschemes.one;
helpers = import ../helpers.nix {inherit lib;};
in {
options = { options = {
colorschemes.one = { colorschemes.one = {
enable = mkEnableOption "vim-one"; enable = mkEnableOption "vim-one";
@ -15,7 +18,7 @@ in
config = mkIf cfg.enable { config = mkIf cfg.enable {
colorscheme = "one"; colorscheme = "one";
extraPlugins = [ cfg.package ]; extraPlugins = [cfg.package];
options = { options = {
termguicolors = true; termguicolors = true;

View file

@ -1,10 +1,13 @@
{ pkgs, config, lib, ... }:
with lib;
let
cfg = config.colorschemes.onedark;
helpers = import ../helpers.nix { inherit lib; };
in
{ {
pkgs,
config,
lib,
...
}:
with lib; let
cfg = config.colorschemes.onedark;
helpers = import ../helpers.nix {inherit lib;};
in {
options = { options = {
colorschemes.onedark = { colorschemes.onedark = {
enable = mkEnableOption "onedark"; enable = mkEnableOption "onedark";
@ -15,7 +18,7 @@ in
config = mkIf cfg.enable { config = mkIf cfg.enable {
colorscheme = "onedark"; colorscheme = "onedark";
extraPlugins = [ cfg.package ]; extraPlugins = [cfg.package];
options = { options = {
termguicolors = true; termguicolors = true;

View file

@ -1,29 +1,27 @@
{ 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";
package = helpers.mkPackageOption "tokyonight" pkgs.vimPlugins.tokyonight-nvim; package = helpers.mkPackageOption "tokyonight" pkgs.vimPlugins.tokyonight-nvim;
style = helpers.defaultNullOpts.mkEnumFirstDefault [ "storm" "night" "day" ] "Theme style"; style = helpers.defaultNullOpts.mkEnumFirstDefault ["storm" "night" "day"] "Theme style";
terminalColors = terminalColors =
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";
@ -56,10 +54,9 @@ in
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
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;
let
cfg = config.plugins.copilot;
helpers = import ../helpers.nix { inherit lib; };
in
{ {
config,
pkgs,
lib,
...
}:
with lib; let
cfg = config.plugins.copilot;
helpers = import ../helpers.nix {inherit lib;};
in {
options = { options = {
plugins.copilot = { plugins.copilot = {
enable = mkEnableOption "copilot"; enable = mkEnableOption "copilot";
@ -12,8 +15,8 @@ in
filetypes = mkOption { filetypes = mkOption {
type = types.attrsOf types.bool; type = types.attrsOf types.bool;
description = "A dictionary mapping file types to their enabled status"; description = "A dictionary mapping file types to their enabled status";
default = { }; default = {};
example = literalExpression ''{ example = literalExpression '' {
"*": false, "*": false,
python: true python: true
}''; }'';
@ -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;
let
cfg = config.plugins.coq-nvim;
helpers = import ../helpers.nix { inherit lib; };
plugins = import ../plugin-defs.nix { inherit pkgs; };
in
{ {
pkgs,
lib,
config,
...
}:
with lib; let
cfg = config.plugins.coq-nvim;
helpers = import ../helpers.nix {inherit lib;};
plugins = import ../plugin-defs.nix {inherit pkgs;};
in {
options = { options = {
plugins.coq-nvim = { plugins.coq-nvim = {
enable = mkEnableOption "coq-nvim"; enable = mkEnableOption "coq-nvim";
@ -16,7 +18,7 @@ in
installArtifacts = mkEnableOption "Install coq-artifacts"; installArtifacts = mkEnableOption "Install coq-artifacts";
autoStart = mkOption { autoStart = mkOption {
type = with types; nullOr (oneOf [ bool (enum [ "shut-up" ]) ]); type = with types; nullOr (oneOf [bool (enum ["shut-up"])]);
default = null; default = null;
description = "Auto-start or shut up"; description = "Auto-start or shut up";
}; };
@ -28,23 +30,24 @@ 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}
local coq = require 'coq' local coq = require 'coq'
''; '';
setupWrappers = [ (s: ''coq.lsp_ensure_capabilities(${s})'') ]; setupWrappers = [(s: ''coq.lsp_ensure_capabilities(${s})'')];
}; };
}; };
} }

View file

@ -1,23 +1,26 @@
{ config, pkgs, lib, ... }:
with lib;
let
cfg = config.plugins.lspkind;
helpers = import ../helpers.nix { inherit lib; };
in
{ {
config,
pkgs,
lib,
...
}:
with lib; let
cfg = config.plugins.lspkind;
helpers = import ../helpers.nix {inherit lib;};
in {
options.plugins.lspkind = { options.plugins.lspkind = {
enable = mkEnableOption "lspkind.nvim"; enable = mkEnableOption "lspkind.nvim";
package = helpers.mkPackageOption "lspkind" pkgs.vimPlugins.lspkind-nvim; package = helpers.mkPackageOption "lspkind" pkgs.vimPlugins.lspkind-nvim;
mode = mkOption { mode = mkOption {
type = with types; nullOr (enum [ "text" "text_symbol" "symbol_text" "symbol" ]); type = with types; nullOr (enum ["text" "text_symbol" "symbol_text" "symbol"]);
default = null; default = null;
description = "Defines how annotations are shown"; description = "Defines how annotations are shown";
}; };
preset = mkOption { preset = mkOption {
type = with types; nullOr (enum [ "default" "codicons" ]); type = with types; nullOr (enum ["default" "codicons"]);
default = null; default = null;
description = "Default symbol map"; description = "Default symbol map";
}; };
@ -61,34 +64,41 @@ 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];
extraConfigLua = optionalString (!doCmp) '' extraConfigLua = optionalString (!doCmp) ''
require('lspkind').init(${helpers.toLuaObject options}) require('lspkind').init(${helpers.toLuaObject options})
''; '';
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}";
@ -51,4 +61,4 @@ in with helpers; with lib;
"treesitter" = "cmp-treesitter"; "treesitter" = "cmp-treesitter";
"vimwiki-tags" = "cmp-vimwiki-tags"; "vimwiki-tags" = "cmp-vimwiki-tags";
}; };
} }

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";
@ -21,7 +22,7 @@ in
performance = mkOption { performance = mkOption {
default = null; default = null;
type = types.nullOr (types.submodule ({ ... }: { type = types.nullOr (types.submodule ({...}: {
options = { options = {
debounce = mkOption { debounce = mkOption {
type = types.nullOr types.int; type = types.nullOr types.int;
@ -36,14 +37,14 @@ in
}; };
preselect = mkOption { preselect = mkOption {
type = types.nullOr (types.enum [ "Item" "None" ]); type = types.nullOr (types.enum ["Item" "None"]);
default = null; default = null;
example = ''"Item"''; example = ''"Item"'';
}; };
snippet = mkOption { snippet = mkOption {
default = null; default = null;
type = types.nullOr (types.submodule ({ ... }: { type = types.nullOr (types.submodule ({...}: {
options = { options = {
expand = mkOption { expand = mkOption {
type = types.nullOr types.str; type = types.nullOr types.str;
@ -61,7 +62,7 @@ in
}; };
mappingPresets = mkOption { mappingPresets = mkOption {
default = [ ]; default = [];
type = types.listOf (types.enum [ type = types.listOf (types.enum [
"insert" "insert"
"cmdline" "cmdline"
@ -75,7 +76,7 @@ in
mapping = mkOption { mapping = mkOption {
default = null; default = null;
type = types.nullOr (types.attrsOf (types.either types.str (types.submodule ({ ... }: { type = types.nullOr (types.attrsOf (types.either types.str (types.submodule ({...}: {
options = { options = {
action = mkOption { action = mkOption {
type = types.nonEmptyStr; type = types.nonEmptyStr;
@ -116,7 +117,7 @@ in
completion = mkOption { completion = mkOption {
default = null; default = null;
type = types.nullOr (types.submodule ({ ... }: { type = types.nullOr (types.submodule ({...}: {
options = { options = {
keyword_length = mkOption { keyword_length = mkOption {
default = null; default = null;
@ -145,7 +146,7 @@ in
confirmation = mkOption { confirmation = mkOption {
default = null; default = null;
type = types.nullOr (types.submodule ({ ... }: { type = types.nullOr (types.submodule ({...}: {
options = { options = {
get_commit_characters = mkOption { get_commit_characters = mkOption {
default = null; default = null;
@ -158,7 +159,7 @@ in
formatting = mkOption { formatting = mkOption {
default = null; default = null;
type = types.nullOr (types.submodule ({ ... }: { type = types.nullOr (types.submodule ({...}: {
options = { options = {
fields = mkOption { fields = mkOption {
default = null; default = null;
@ -176,7 +177,7 @@ in
matching = mkOption { matching = mkOption {
default = null; default = null;
type = types.nullOr (types.submodule ({ ... }: { type = types.nullOr (types.submodule ({...}: {
options = { options = {
disallow_fuzzy_matching = mkOption { disallow_fuzzy_matching = mkOption {
default = null; default = null;
@ -196,7 +197,7 @@ in
sorting = mkOption { sorting = mkOption {
default = null; default = null;
type = types.nullOr (types.submodule ({ ... }: { type = types.nullOr (types.submodule ({...}: {
options = { options = {
priority_weight = mkOption { priority_weight = mkOption {
default = null; default = null;
@ -218,9 +219,8 @@ in
''; '';
}; };
sources = sources = let
let source_config = types.submodule ({...}: {
source_config = types.submodule ({ ... }: {
options = { options = {
name = mkOption { name = mkOption {
type = types.str; type = types.str;
@ -286,7 +286,7 @@ in
view = mkOption { view = mkOption {
default = null; default = null;
type = types.nullOr (types.submodule ({ ... }: { type = types.nullOr (types.submodule ({...}: {
options = { options = {
entries = mkOption { entries = mkOption {
default = null; default = null;
@ -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;
@ -305,11 +304,11 @@ in
in in
mkOption { mkOption {
default = null; default = null;
type = types.nullOr (types.submodule ({ ... }: { type = types.nullOr (types.submodule ({...}: {
options = { options = {
completion = mkOption { completion = mkOption {
default = null; default = null;
type = types.nullOr (types.submodule ({ ... }: { type = types.nullOr (types.submodule ({...}: {
options = { options = {
inherit border winhighlight zindex; inherit border winhighlight zindex;
col_offset = mkNullOrOption types.int "Offsets the completion window relative to the cursor"; col_offset = mkNullOrOption types.int "Offsets the completion window relative to the cursor";
@ -320,7 +319,7 @@ in
documentation = mkOption { documentation = mkOption {
default = null; default = null;
type = types.nullOr (types.submodule ({ ... }: { type = types.nullOr (types.submodule ({...}: {
options = { options = {
inherit border winhighlight zindex; inherit border winhighlight zindex;
max_width = mkNullOrOption types.int "Window's max width"; max_width = mkNullOrOption types.int "Window's max width";
@ -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;
@ -397,7 +427,7 @@ in
}; };
in in
mkIf cfg.enable { mkIf cfg.enable {
extraPlugins = [ cfg.package ]; extraPlugins = [cfg.package];
extraConfigLua = helpers.wrapDo '' extraConfigLua = helpers.wrapDo ''
local cmp = require('cmp') local cmp = require('cmp')
@ -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,13 +1,18 @@
{ lib, pkgs, ... }@attrs: {
let lib,
helpers = import ../helpers.nix { inherit lib; }; pkgs,
in with helpers; with lib; ...
mkPlugin attrs { } @ attrs: let
helpers = import ../helpers.nix {inherit lib;};
in
with helpers;
with lib;
mkPlugin attrs {
name = "fugitive"; name = "fugitive";
description = "Enable vim-fugitive"; description = "Enable vim-fugitive";
package = pkgs.vimPlugins.vim-fugitive; package = pkgs.vimPlugins.vim-fugitive;
extraPackages = [ pkgs.git ]; extraPackages = [pkgs.git];
# In typical tpope fashin, this plugin has no config options # In typical tpope fashin, this plugin has no config options
options = {}; options = {};
} }

View file

@ -1,10 +1,13 @@
{ pkgs, config, lib, ... }:
with lib;
let
cfg = config.plugins.gitgutter;
helpers = import ../helpers.nix { inherit lib; };
in
{ {
pkgs,
config,
lib,
...
}:
with lib; let
cfg = config.plugins.gitgutter;
helpers = import ../helpers.nix {inherit lib;};
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}";
@ -73,7 +76,7 @@ in
modifiedRemoved = signOption "modified and removed lines"; modifiedRemoved = signOption "modified and removed lines";
}; };
}; };
default = { }; default = {};
description = "Custom signs for the sign column"; description = "Custom signs for the sign column";
}; };
@ -166,20 +169,25 @@ 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];
options = mkIf cfg.recommendedSettings { options = mkIf cfg.recommendedSettings {
updatetime = 100; updatetime = 100;
foldtext = "gitgutter#fold#foldtext"; foldtext = "gitgutter#fold#foldtext";
}; };
extraPackages = [ pkgs.git ] ++ grepPackage; extraPackages = [pkgs.git] ++ grepPackage;
globals = { globals = {
gitgutter_max_signs = mkIf (!isNull cfg.maxSigns) cfg.maxSigns; gitgutter_max_signs = mkIf (!isNull cfg.maxSigns) cfg.maxSigns;

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";
@ -16,7 +16,7 @@ in
A popup window is no longer closed automatically when moving a cursor after the window is A popup window is no longer closed automatically when moving a cursor after the window is
shown up. shown up.
''; '';
includeDiff = helpers.defaultNullOpts.mkEnumFirstDefault [ "none" "current" "all" ] '' includeDiff = helpers.defaultNullOpts.mkEnumFirstDefault ["none" "current" "all"] ''
When this value is not set to "none", a popup window includes diff hunks of the commit at When this value is not set to "none", a popup window includes diff hunks of the commit at
showing up. "current" includes diff hunks of only current file in the commit. "all" includes showing up. "current" includes diff hunks of only current file in the commit. "all" includes
all diff hunks in the commit. all diff hunks in the commit.
@ -91,12 +91,11 @@ in
''; '';
}; };
config = config = let
let
cfg = config.plugins.gitmessenger; cfg = config.plugins.gitmessenger;
in in
mkIf cfg.enable { mkIf cfg.enable {
extraPlugins = [ cfg.package ]; extraPlugins = [cfg.package];
globals = { globals = {
git_messenger_close_on_cursor_moved = cfg.closeOnCursorMoved; git_messenger_close_on_cursor_moved = cfg.closeOnCursorMoved;
git_messenger_include_diff = cfg.includeDiff; git_messenger_include_diff = cfg.includeDiff;

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,12 +163,11 @@ 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 =
helpers.defaultNullOpts.mkEnumFirstDefault [ "myers" "minimal" "patience" "histogram" ] helpers.defaultNullOpts.mkEnumFirstDefault ["myers" "minimal" "patience" "histogram"]
"Diff algorithm to use"; "Diff algorithm to use";
internal = internal =
helpers.defaultNullOpts.mkBool false helpers.defaultNullOpts.mkBool false
@ -268,7 +266,7 @@ in
helpers.defaultNullOpts.mkBool true helpers.defaultNullOpts.mkBool true
"Whether to show a virtual text blame annotation"; "Whether to show a virtual text blame annotation";
virtTextPos = virtTextPos =
helpers.defaultNullOpts.mkEnumFirstDefault [ "eol" "overlay" "right_align" ] helpers.defaultNullOpts.mkEnumFirstDefault ["eol" "overlay" "right_align"]
"Blame annotation position"; "Blame annotation position";
delay = delay =
helpers.defaultNullOpts.mkInt 1000 helpers.defaultNullOpts.mkInt 1000
@ -316,26 +314,24 @@ 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
else if builtins.isString val else if builtins.isString val
then val then val
else { __raw = val.function; }; else {__raw = val.function;};
setupOptions = { setupOptions = {
inherit (cfg) worktrees signcolumn numhl linehl trouble yadm; inherit (cfg) worktrees signcolumn numhl linehl trouble yadm;
signs = mapAttrs (_: signSetupOptions) cfg.signs; signs = mapAttrs (_: signSetupOptions) cfg.signs;
on_attach = on_attach =
if cfg.onAttach != null if cfg.onAttach != null
then { __raw = cfg.onAttach.function; } then {__raw = cfg.onAttach.function;}
else null; else null;
watch_gitdir = { watch_gitdir = {
inherit (cfg.watchGitDir) enable interval; inherit (cfg.watchGitDir) enable interval;
@ -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
@ -373,18 +368,16 @@ in
else null; else null;
status_formatter = status_formatter =
if cfg.statusFormatter != null if cfg.statusFormatter != null
then { __raw = cfg.statusFormatter.function; } then {__raw = cfg.statusFormatter.function;}
else null; else null;
max_file_length = cfg.maxFileLength; max_file_length = cfg.maxFileLength;
preview_config = cfg.previewConfig; preview_config = cfg.previewConfig;
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,8 +1,12 @@
{ 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;};
sectionDefaultsModule = types.submodule { sectionDefaultsModule = types.submodule {
options = { options = {
@ -12,8 +16,7 @@ let
}; };
}; };
}; };
in in {
{
options = { options = {
plugins.neogit = { plugins.neogit = {
enable = mkEnableOption "neogit"; enable = mkEnableOption "neogit";
@ -72,7 +75,7 @@ in
}; };
}; };
}; };
default = { }; default = {};
}; };
kind = mkOption { kind = mkOption {
@ -104,7 +107,7 @@ in
}; };
}; };
}; };
default = { }; default = {};
}; };
integrations = mkOption { integrations = mkOption {
@ -118,7 +121,7 @@ in
}; };
}; };
}; };
default = { }; default = {};
}; };
sections = mkOption { sections = mkOption {
@ -162,7 +165,7 @@ in
}; };
}; };
}; };
default = { }; default = {};
}; };
mappings = mkOption { mappings = mkOption {
@ -198,14 +201,14 @@ in
}; };
}; };
}; };
default = { }; default = {};
}; };
}; };
}; };
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,12 +221,14 @@ 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];
extraConfigLua = '' extraConfigLua = ''
require('neogit').setup(${setupOptions}) require('neogit').setup(${setupOptions})

View file

@ -1,6 +1,11 @@
{ pkgs, lib, ... }@args: {
with lib; with import ../helpers.nix { inherit lib; }; pkgs,
mkPlugin args { lib,
...
} @ args:
with lib;
with import ../helpers.nix {inherit lib;};
mkPlugin args {
name = "ledger"; name = "ledger";
description = "Enable ledger language features"; description = "Enable ledger language features";
package = pkgs.vimPlugins.vim-ledger; package = pkgs.vimPlugins.vim-ledger;
@ -30,4 +35,4 @@ mkPlugin args {
type = types.bool; type = types.bool;
}; };
}; };
} }

View file

@ -1,10 +1,13 @@
{ config, pkgs, lib, ... }:
with lib;
let
cfg = config.plugins.markdown-preview;
helpers = import ../helpers.nix { inherit lib; };
in
{ {
config,
pkgs,
lib,
...
}:
with lib; let
cfg = config.plugins.markdown-preview;
helpers = import ../helpers.nix {inherit lib;};
in {
options = { options = {
plugins.markdown-preview = { plugins.markdown-preview = {
enable = mkEnableOption "markdown-preview"; enable = mkEnableOption "markdown-preview";
@ -54,7 +57,7 @@ in
uml = helpers.defaultNullOpts.mkNullable (types.listOf types.str) "[]" "markdown-it-plantuml options"; uml = helpers.defaultNullOpts.mkNullable (types.listOf types.str) "[]" "markdown-it-plantuml options";
maid = helpers.defaultNullOpts.mkNullable (types.listOf types.str) "[]" "mermaid options"; maid = helpers.defaultNullOpts.mkNullable (types.listOf types.str) "[]" "mermaid options";
disable_sync_scroll = helpers.defaultNullOpts.mkBool false "Disable sync scroll"; disable_sync_scroll = helpers.defaultNullOpts.mkBool false "Disable sync scroll";
sync_scroll_type = helpers.defaultNullOpts.mkNullable (types.enum [ "middle" "top" "relative" ]) "middle" '' sync_scroll_type = helpers.defaultNullOpts.mkNullable (types.enum ["middle" "top" "relative"]) "middle" ''
Scroll type: Scroll type:
- "middle": The cursor position is always shown at the middle of the preview page. - "middle": The cursor position is always shown at the middle of the preview page.
- "top": The vim top viewport is always shown at the top of the preview page. - "top": The vim top viewport is always shown at the top of the preview page.
@ -86,18 +89,17 @@ in
Recognized filetypes. These filetypes will have MarkdownPreview... commands. Recognized filetypes. These filetypes will have MarkdownPreview... commands.
''; '';
theme = helpers.defaultNullOpts.mkNullable (types.enum [ "dark" "light" ]) "dark" '' theme = helpers.defaultNullOpts.mkNullable (types.enum ["dark" "light"]) "dark" ''
Default theme (dark or light). By default the theme is define according to the preferences of the system. Default theme (dark or light). By default the theme is define according to the preferences of the system.
''; '';
}; };
}; };
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 {
extraPlugins = [ cfg.package ]; extraPlugins = [cfg.package];
globals = { globals = {
mkdp_auto_start = mkIf (!isNull cfg.autoStart) cfg.autoStart; mkdp_auto_start = mkIf (!isNull cfg.autoStart) cfg.autoStart;
@ -109,7 +111,7 @@ in
mkdp_browser = mkIf (!isNull cfg.browser) cfg.browser; mkdp_browser = mkIf (!isNull cfg.browser) cfg.browser;
mkdp_echo_preview_url = mkIf (!isNull cfg.echoPreviewUrl) cfg.echoPreviewUrl; mkdp_echo_preview_url = mkIf (!isNull cfg.echoPreviewUrl) cfg.echoPreviewUrl;
mkdp_browserfunc = mkIf (!isNull cfg.browserFunc) cfg.browserFunc; mkdp_browserfunc = mkIf (!isNull cfg.browserFunc) cfg.browserFunc;
mkdp_preview_options = mkIf (cfg.previewOptions != { }) previewOptions; mkdp_preview_options = mkIf (cfg.previewOptions != {}) previewOptions;
mkdp_markdown_css = mkIf (!isNull cfg.markdownCss) cfg.markdownCss; mkdp_markdown_css = mkIf (!isNull cfg.markdownCss) cfg.markdownCss;
mkdp_highlight_css = mkIf (!isNull cfg.highlightCss) cfg.highlightCss; mkdp_highlight_css = mkIf (!isNull cfg.highlightCss) cfg.highlightCss;
mkdp_port = mkIf (!isNull cfg.port) cfg.port; mkdp_port = mkIf (!isNull cfg.port) cfg.port;

View file

@ -1,12 +1,17 @@
{ lib, pkgs, ... }@attrs: {
let lib,
helpers = import ../helpers.nix { inherit lib; }; pkgs,
in with helpers; with lib; ...
mkPlugin attrs { } @ attrs: let
helpers = import ../helpers.nix {inherit lib;};
in
with helpers;
with lib;
mkPlugin attrs {
name = "nix"; name = "nix";
description = "Enable nix"; description = "Enable nix";
package = pkgs.vimPlugins.vim-nix; package = pkgs.vimPlugins.vim-nix;
# Possibly add option to disable Treesitter highlighting if this is installed # Possibly add option to disable Treesitter highlighting if this is installed
options = {}; options = {};
} }

View file

@ -1,11 +1,11 @@
{ 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 = {
enable = mkEnableOption "plantuml syntax support"; enable = mkEnableOption "plantuml syntax support";
@ -24,12 +24,11 @@ in {
}; };
}; };
config = config = let
let
cfg = config.plugins.plantuml-syntax; cfg = config.plugins.plantuml-syntax;
in in
mkIf cfg.enable { mkIf cfg.enable {
extraPlugins = [ cfg.package ]; extraPlugins = [cfg.package];
globals = { globals = {
plantuml_set_makeprg = cfg.setMakeprg; plantuml_set_makeprg = cfg.setMakeprg;

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 {
@ -56,7 +53,7 @@ in {
}; };
executor = mkNullableOptionWithDefault { executor = mkNullableOptionWithDefault {
type = types.enum [ "termopen" "quickfix" ]; type = types.enum ["termopen" "quickfix"];
default = ''"termopen"''; default = ''"termopen"'';
description = "how to execute terminal commands"; description = "how to execute terminal commands";
}; };
@ -157,34 +154,30 @@ 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 =
if cfg.executor != null if cfg.executor != null
then { __raw = ''require("rust-tools.executors").${cfg.executor}''; } then {__raw = ''require("rust-tools.executors").${cfg.executor}'';}
else null; else null;
on_initialized = on_initialized =
if cfg.onIntialized != null if cfg.onIntialized != null
then { __raw = cfg.onIntialized; } then {__raw = cfg.onIntialized;}
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;
@ -222,11 +211,10 @@ in {
server = { server = {
standalone = cfg.server.standalone; standalone = cfg.server.standalone;
settings.rust-analyzer = lib.filterAttrs (n: v: n != "standalone") cfg.server; settings.rust-analyzer = lib.filterAttrs (n: v: n != "standalone") cfg.server;
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
, config
, ...
}:
let
cfg = config.plugins.tagbar;
helpers = import ../helpers.nix { inherit lib; };
in
with lib;
{ {
pkgs,
lib,
config,
...
}: let
cfg = config.plugins.tagbar;
helpers = import ../helpers.nix {inherit lib;};
in
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,11 +23,10 @@ with lib;
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
extraPlugins = [cfg.package];
extraPlugins = [ cfg.package ]; extraPackages = [pkgs.ctags];
extraPackages = [ pkgs.ctags ];
globals = mapAttrs' (name: value: nameValuePair ("tagbar_" + name) value) cfg.extraConfig; globals = mapAttrs' (name: value: nameValuePair ("tagbar_" + name) value) cfg.extraConfig;
}; };
} }

View file

@ -1,11 +1,11 @@
{ 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 = {
enable = mkEnableOption "nvim-treesitter-context"; enable = mkEnableOption "nvim-treesitter-context";
@ -19,7 +19,7 @@ in {
}; };
trimScope = mkOption { trimScope = mkOption {
type = types.enum [ "outer" "inner" ]; type = types.enum ["outer" "inner"];
default = "outer"; default = "outer";
description = "Which context lines to discard if `max_lines` is exceeded"; description = "Which context lines to discard if `max_lines` is exceeded";
}; };
@ -32,7 +32,7 @@ in {
patterns = mkOption { patterns = mkOption {
type = types.attrsOf (types.listOf types.str); type = types.attrsOf (types.listOf types.str);
default = { }; default = {};
description = '' description = ''
Patterns to use for context delimitation. The 'default' key matches all filetypes Patterns to use for context delimitation. The 'default' key matches all filetypes
''; '';
@ -40,17 +40,16 @@ in {
exactPatterns = mkOption { exactPatterns = mkOption {
type = types.attrsOf types.bool; type = types.attrsOf types.bool;
default = { }; default = {};
description = "Treat the coresponding entry in patterns as an exact match"; description = "Treat the coresponding entry in patterns as an exact match";
}; };
}; };
config = config = let
let
cfg = config.plugins.treesitter-context; cfg = config.plugins.treesitter-context;
in in
mkIf cfg.enable { mkIf cfg.enable {
extraPlugins = [ cfg.package ]; extraPlugins = [cfg.package];
plugins.treesitter.moduleConfig.context = { plugins.treesitter.moduleConfig.context = {
max_lines = cfg.maxLines; max_lines = cfg.maxLines;

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,12 +100,11 @@ in
}; };
}; };
config = config = let
let
cfg = config.plugins.treesitter-refactor; cfg = config.plugins.treesitter-refactor;
in in
mkIf cfg.enable { mkIf cfg.enable {
extraPlugins = [ cfg.package ]; extraPlugins = [cfg.package];
plugins.treesitter.moduleConfig.refactor = { plugins.treesitter.moduleConfig.refactor = {
highlight_definitions = { highlight_definitions = {
@ -118,15 +114,13 @@ in
highlight_current_scope = cfg.highlightCurrentScope; highlight_current_scope = cfg.highlightCurrentScope;
smart_rename = { smart_rename = {
inherit (cfg.smartRename) enable disable; inherit (cfg.smartRename) enable disable;
keymaps = { smart_rename = cfg.smartRename.keymaps.smartRename; }; keymaps = {smart_rename = cfg.smartRename.keymaps.smartRename;};
}; };
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;
let
cfg = config.plugins.treesitter;
helpers = import ../helpers.nix { inherit lib; };
in
{ {
pkgs,
lib,
config,
...
}:
with lib; let
cfg = config.plugins.treesitter;
helpers = import ../helpers.nix {inherit lib;};
in {
options = { options = {
plugins.treesitter = { plugins.treesitter = {
enable = mkEnableOption "tree-sitter syntax highlighting"; enable = mkEnableOption "tree-sitter syntax highlighting";
@ -22,7 +25,7 @@ in
}; };
ensureInstalled = mkOption { ensureInstalled = mkOption {
type = with types; oneOf [ (enum [ "all" ]) (listOf str) ]; type = with types; oneOf [(enum ["all"]) (listOf str)];
default = "all"; default = "all";
description = "Either \"all\" or a list of languages"; description = "Either \"all\" or a list of languages";
}; };
@ -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!
@ -42,30 +44,29 @@ in
ignoreInstall = mkOption { ignoreInstall = mkOption {
type = types.listOf types.str; type = types.listOf types.str;
default = [ ]; default = [];
description = "List of parsers to ignore installing (for \"all\")"; description = "List of parsers to ignore installing (for \"all\")";
}; };
disabledLanguages = mkOption { disabledLanguages = mkOption {
type = types.listOf types.str; type = types.listOf types.str;
default = [ ]; default = [];
description = "A list of languages to disable"; description = "A list of languages to disable";
}; };
customCaptures = mkOption { customCaptures = mkOption {
type = types.attrsOf types.str; type = types.attrsOf types.str;
default = { }; default = {};
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";
@ -87,24 +88,31 @@ in
moduleConfig = mkOption { moduleConfig = mkOption {
type = types.attrsOf types.anything; type = types.attrsOf types.anything;
default = { }; default = {};
description = "This is the configuration for extra modules. It should not be used directly"; description = "This is the configuration for extra modules. It should not be used directly";
}; };
}; };
}; };
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,29 +120,39 @@ 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
else [ cfg.package ]; then [(cfg.package.withPlugins (_: cfg.grammarPackages))]
extraPackages = [ pkgs.tree-sitter pkgs.nodejs ]; else [cfg.package];
extraPackages = [pkgs.tree-sitter pkgs.nodejs];
options = mkIf cfg.folding { options = mkIf cfg.folding {
foldmethod = "expr"; foldmethod = "expr";
@ -142,4 +160,3 @@ in
}; };
}; };
} }

View file

@ -1,16 +1,14 @@
{ pkgs
, lib
, config
, ...
}:
let
cfg = config.plugins.vimtex;
helpers = import ../helpers.nix { inherit lib; };
in
with lib;
{ {
pkgs,
lib,
config,
...
}: let
cfg = config.plugins.vimtex;
helpers = import ../helpers.nix {inherit lib;};
in
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,19 +22,19 @@ 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
extraPackages = with pkgs; [ pstree xdotool ]; extraPackages = with pkgs; [pstree xdotool];
globals = mapAttrs' (name: value: nameValuePair ("vimtex_" + name) value) globals; globals = mapAttrs' (name: value: nameValuePair ("vimtex_" + name) value) globals;
}; };
} }

View file

@ -1,8 +1,13 @@
{ lib, pkgs, ... }@attrs: {
let lib,
helpers = import ../helpers.nix { inherit lib; }; pkgs,
in with helpers; with lib; ...
mkPlugin attrs { } @ attrs: let
helpers = import ../helpers.nix {inherit lib;};
in
with helpers;
with lib;
mkPlugin attrs {
name = "zig"; name = "zig";
description = "Enable zig"; description = "Enable zig";
package = pkgs.vimPlugins.zig-vim; package = pkgs.vimPlugins.zig-vim;
@ -15,4 +20,4 @@ mkPlugin attrs {
description = "Run zig fmt on save"; description = "Run zig fmt on save";
}; };
}; };
} }

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,15 +39,14 @@ in
# }; # };
}; };
config = config = let
let
options = { options = {
debug = cfg.debug; debug = cfg.debug;
sources = cfg.sourcesItems; sources = cfg.sourcesItems;
}; };
in in
mkIf cfg.enable { mkIf cfg.enable {
extraPlugins = [ cfg.package ]; extraPlugins = [cfg.package];
extraConfigLua = '' extraConfigLua = ''
require("null-ls").setup(${helpers.toLuaObject options}) require("null-ls").setup(${helpers.toLuaObject options})

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,14 +1,18 @@
{ 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 = {
gitsigns = { }; gitsigns = {};
shellcheck = { shellcheck = {
package = pkgs.shellcheck; package = pkgs.shellcheck;
}; };
}; };
completion = { }; completion = {};
diagnostics = { diagnostics = {
flake8 = { flake8 = {
package = pkgs.python3Packages.flake8; package = pkgs.python3Packages.flake8;
@ -65,18 +69,18 @@ let
# sourceType = "formatting"; # sourceType = "formatting";
# packages = [...]; # packages = [...];
# }] # }]
serverDataFormatted = lib.mapAttrsToList serverDataFormatted =
(sourceType: sourceSet: lib.mapAttrsToList
lib.mapAttrsToList (name: attrs: attrs // { inherit sourceType name; }) sourceSet (
sourceType: 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,13 +1,17 @@
{ 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 = [
{ {
name = "astro"; name = "astro";
description = "Enable astrols, for Astro"; description = "Enable astrols, for Astro";
package = pkgs.nodePackages."@astrojs/language-server"; package = pkgs.nodePackages."@astrojs/language-server";
cmd = cfg: [ "${cfg.package}/bin/astro-ls" "--stdio" ]; cmd = cfg: ["${cfg.package}/bin/astro-ls" "--stdio"];
} }
{ {
name = "bashls"; name = "bashls";
@ -23,7 +27,7 @@ let
name = "cssls"; name = "cssls";
description = "Enable cssls, for CSS"; description = "Enable cssls, for CSS";
package = pkgs.nodePackages.vscode-langservers-extracted; package = pkgs.nodePackages.vscode-langservers-extracted;
cmd = cfg: [ "${cfg.package}/bin/vscode-css-language-server" "--stdio" ]; cmd = cfg: ["${cfg.package}/bin/vscode-css-language-server" "--stdio"];
} }
{ {
name = "dartls"; name = "dartls";
@ -70,7 +74,7 @@ let
''; '';
}; };
renameFilesWithClasses = mkOption { renameFilesWithClasses = mkOption {
type = types.nullOr (types.enum [ "always" "prompt" ]); type = types.nullOr (types.enum ["always" "prompt"]);
default = null; default = null;
description = '' description = ''
When set to "always", will include edits to rename files when classes are renamed if the When set to "always", will include edits to rename files when classes are renamed if the
@ -98,7 +102,7 @@ let
''; '';
}; };
documentation = mkOption { documentation = mkOption {
type = types.nullOr (types.enum [ "none" "summary" "full" ]); type = types.nullOr (types.enum ["none" "summary" "full"]);
default = null; default = null;
description = '' description = ''
The typekind of dartdocs to include in Hovers, Code Completion, Signature Help and other The typekind of dartdocs to include in Hovers, Code Completion, Signature Help and other
@ -114,7 +118,7 @@ let
''; '';
}; };
}; };
settings = cfg: { dart = cfg; }; settings = cfg: {dart = cfg;};
} }
{ {
name = "denols"; name = "denols";
@ -125,13 +129,13 @@ let
name = "eslint"; name = "eslint";
description = "Enable eslint"; description = "Enable eslint";
package = pkgs.nodePackages.vscode-langservers-extracted; package = pkgs.nodePackages.vscode-langservers-extracted;
cmd = cfg: [ "${cfg.package}/bin/vscode-eslint-language-server" "--stdio" ]; cmd = cfg: ["${cfg.package}/bin/vscode-eslint-language-server" "--stdio"];
} }
{ {
name = "elixirls"; name = "elixirls";
description = "Enable elixirls"; description = "Enable elixirls";
package = pkgs.elixir_ls; package = pkgs.elixir_ls;
cmd = cfg: [ "${cfg.package}/bin/elixir-ls" ]; cmd = cfg: ["${cfg.package}/bin/elixir-ls"];
} }
{ {
name = "gdscript"; name = "gdscript";
@ -146,13 +150,13 @@ let
name = "html"; name = "html";
description = "Enable html, for HTML"; description = "Enable html, for HTML";
package = pkgs.nodePackages.vscode-langservers-extracted; package = pkgs.nodePackages.vscode-langservers-extracted;
cmd = cfg: [ "${cfg.package}/bin/vscode-html-language-server" "--stdio" ]; cmd = cfg: ["${cfg.package}/bin/vscode-html-language-server" "--stdio"];
} }
{ {
name = "jsonls"; name = "jsonls";
description = "Enable jsonls, for JSON"; description = "Enable jsonls, for JSON";
package = pkgs.nodePackages.vscode-langservers-extracted; package = pkgs.nodePackages.vscode-langservers-extracted;
cmd = cfg: [ "${cfg.package}/bin/vscode-json-language-server" "--stdio" ]; cmd = cfg: ["${cfg.package}/bin/vscode-json-language-server" "--stdio"];
} }
{ {
name = "nil_ls"; name = "nil_ls";
@ -170,7 +174,7 @@ let
diagnostics = { diagnostics = {
ignored = mkOption { ignored = mkOption {
type = types.listOf types.str; type = types.listOf types.str;
default = [ ]; default = [];
description = '' description = ''
Ignored diagnostic kinds. Ignored diagnostic kinds.
The kind identifier is a snake_cased_string usually shown together The kind identifier is a snake_cased_string usually shown together
@ -179,7 +183,7 @@ let
}; };
excludedFiles = mkOption { excludedFiles = mkOption {
type = types.listOf types.str; type = types.listOf types.str;
default = [ ]; default = [];
description = '' description = ''
Files to exclude from showing diagnostics. Useful for generated files. Files to exclude from showing diagnostics. Useful for generated files.
It accepts an array of paths. Relative paths are joint to the workspace root. It accepts an array of paths. Relative paths are joint to the workspace root.
@ -188,7 +192,7 @@ let
}; };
}; };
}; };
settings = cfg: { nil = { inherit (cfg) formatting diagnostics; }; }; settings = cfg: {nil = {inherit (cfg) formatting diagnostics;};};
} }
{ {
name = "pyright"; name = "pyright";
@ -205,7 +209,7 @@ let
serverName = "rust_analyzer"; serverName = "rust_analyzer";
settingsOptions = import ./rust-analyzer-config.nix lib; settingsOptions = import ./rust-analyzer-config.nix lib;
settings = cfg: { rust-analyzer = cfg; }; settings = cfg: {rust-analyzer = cfg;};
} }
{ {
name = "sumneko-lua"; name = "sumneko-lua";
@ -240,10 +244,9 @@ let
name = "hls"; name = "hls";
description = "Enable haskell language server"; description = "Enable haskell language server";
package = pkgs.haskell-language-server; package = pkgs.haskell-language-server;
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 = {
@ -31,7 +35,7 @@ in
}) })
]); ]);
description = "A list of enabled LSP servers. Don't use this directly."; description = "A list of enabled LSP servers. Don't use this directly.";
default = [ ]; default = [];
}; };
onAttach = mkOption { onAttach = mkOption {
@ -43,7 +47,7 @@ in
setupWrappers = mkOption { setupWrappers = mkOption {
type = with types; listOf (functionTo str); type = with types; listOf (functionTo str);
description = "Code to be run to wrap the setup args. Takes in an argument containing the previous results, and returns a new string of code."; description = "Code to be run to wrap the setup args. Takes in an argument containing the previous results, and returns a new string of code.";
default = [ ]; default = [];
}; };
preConfig = mkOption { preConfig = mkOption {
@ -60,14 +64,14 @@ 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 {
extraPlugins = [ pkgs.vimPlugins.nvim-lspconfig ]; extraPlugins = [pkgs.vimPlugins.nvim-lspconfig];
# Enable all LSP servers # Enable all LSP servers
extraConfigLua = '' extraConfigLua = ''

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;
let
cfg = config.plugins.lsp-lines;
helpers = import ../helpers.nix { inherit lib; };
in
{ {
pkgs,
lib,
config,
...
}:
with lib; let
cfg = config.plugins.lsp-lines;
helpers = import ../helpers.nix {inherit lib;};
in {
options = { options = {
plugins.lsp-lines = { plugins.lsp-lines = {
enable = mkEnableOption "lsp_lines.nvim"; enable = mkEnableOption "lsp_lines.nvim";
@ -19,24 +22,25 @@ 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 {
extraPlugins = [ cfg.package ]; extraPlugins = [cfg.package];
extraConfigLua = '' extraConfigLua = ''
do do
require("lsp_lines").setup() require("lsp_lines").setup()
vim.diagnostic.config(${ helpers.toLuaObject diagnosticConfig }) vim.diagnostic.config(${helpers.toLuaObject diagnosticConfig})
end end
''; '';
}; };

View file

@ -1,10 +1,13 @@
{ pkgs, lib, config, ... }:
with lib;
let
cfg = config.plugins.lspsaga;
helpers = import ../helpers.nix { inherit lib; };
in
{ {
pkgs,
lib,
config,
...
}:
with lib; let
cfg = config.plugins.lspsaga;
helpers = import ../helpers.nix {inherit lib;};
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";
@ -132,7 +134,7 @@ in
}; };
borderStyle = mkOption { borderStyle = mkOption {
type = types.nullOr (types.enum [ "thin" "rounded" "thick" ]); type = types.nullOr (types.enum ["thin" "rounded" "thick"]);
default = null; default = null;
description = "Border style"; description = "Border style";
}; };
@ -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,8 +215,7 @@ in
}; };
in in
mkIf cfg.enable { mkIf cfg.enable {
extraPlugins = [cfg.package];
extraPlugins = [ cfg.package ];
extraConfigLua = '' extraConfigLua = ''
local saga = require 'lspsaga' local saga = require 'lspsaga'

View file

@ -1,12 +1,12 @@
{ 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; {
options.plugins.nvim-lightbulb = { options.plugins.nvim-lightbulb = {
enable = mkEnableOption "nvim-lightbulb, showing available code actions"; enable = mkEnableOption "nvim-lightbulb, showing available code actions";
@ -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;
@ -83,9 +82,9 @@ with lib; {
}; };
in in
mkIf cfg.enable { mkIf cfg.enable {
extraPlugins = [ cfg.package ]; extraPlugins = [cfg.package];
extraConfigLua = '' extraConfigLua = ''
require("nvim-lightbulb").setup(${helpers.toLuaObject setupOptions}) require("nvim-lightbulb").setup(${helpers.toLuaObject setupOptions})
''; '';
}; };
} }

View file

@ -1,8 +1,9 @@
# 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"]);
default = null; default = null;
description = '' description = ''
Placeholder expression to use for missing expressions in assists. Placeholder expression to use for missing expressions in assists.
@ -105,7 +106,7 @@ lib: with lib; {
}; };
}; };
"features" = mkOption { "features" = mkOption {
type = types.nullOr (types.oneOf [ (types.enum [ "all" ]) (types.listOf (types.str)) ]); type = types.nullOr (types.oneOf [(types.enum ["all"]) (types.listOf (types.str))]);
default = null; default = null;
description = '' description = ''
List of features to activate. List of features to activate.
@ -217,7 +218,7 @@ lib: with lib; {
''; '';
}; };
"features" = mkOption { "features" = mkOption {
type = types.nullOr (types.nullOr (types.oneOf [ (types.enum [ "all" ]) (types.listOf (types.str)) ])); type = types.nullOr (types.nullOr (types.oneOf [(types.enum ["all"]) (types.listOf (types.str))]));
default = null; default = null;
description = '' description = ''
List of features to activate. Defaults to List of features to activate. Defaults to
@ -320,7 +321,7 @@ lib: with lib; {
}; };
"callable" = { "callable" = {
"snippets" = mkOption { "snippets" = mkOption {
type = types.nullOr (types.enum [ "fill_arguments" "add_parentheses" "none" ]); type = types.nullOr (types.enum ["fill_arguments" "add_parentheses" "none"]);
default = null; default = null;
description = '' description = ''
Whether to add parenthesis and argument snippets when completing function. Whether to add parenthesis and argument snippets when completing function.
@ -508,7 +509,7 @@ lib: with lib; {
''; '';
}; };
"watcher" = mkOption { "watcher" = mkOption {
type = types.nullOr (types.enum [ "client" "server" ]); type = types.nullOr (types.enum ["client" "server"]);
default = null; default = null;
description = '' description = ''
Controls file watching implementation. Controls file watching implementation.
@ -727,7 +728,7 @@ lib: with lib; {
''; '';
}; };
"group" = mkOption { "group" = mkOption {
type = types.nullOr (types.enum [ "preserve" "crate" "module" "item" ]); type = types.nullOr (types.enum ["preserve" "crate" "module" "item"]);
default = null; default = null;
description = '' description = ''
How imports should be grouped into use statements. How imports should be grouped into use statements.
@ -768,7 +769,7 @@ lib: with lib; {
}; };
}; };
"prefix" = mkOption { "prefix" = mkOption {
type = types.nullOr (types.enum [ "plain" "self" "crate" ]); type = types.nullOr (types.enum ["plain" "self" "crate"]);
default = null; default = null;
description = '' description = ''
The path structure for newly inserted paths to use. The path structure for newly inserted paths to use.
@ -838,7 +839,7 @@ lib: with lib; {
}; };
"closureReturnTypeHints" = { "closureReturnTypeHints" = {
"enable" = mkOption { "enable" = mkOption {
type = types.nullOr (types.enum [ "always" "never" "with_block" ]); type = types.nullOr (types.enum ["always" "never" "with_block"]);
default = null; default = null;
description = '' description = ''
Whether to show inlay type hints for return types of closures. Whether to show inlay type hints for return types of closures.
@ -852,7 +853,7 @@ lib: with lib; {
}; };
"lifetimeElisionHints" = { "lifetimeElisionHints" = {
"enable" = mkOption { "enable" = mkOption {
type = types.nullOr (types.enum [ "always" "never" "skip_trivial" ]); type = types.nullOr (types.enum ["always" "never" "skip_trivial"]);
default = null; default = null;
description = '' description = ''
Whether to show inlay type hints for elided lifetimes in function signatures. Whether to show inlay type hints for elided lifetimes in function signatures.
@ -905,7 +906,7 @@ lib: with lib; {
}; };
"reborrowHints" = { "reborrowHints" = {
"enable" = mkOption { "enable" = mkOption {
type = types.nullOr (types.enum [ "always" "never" "mutable" ]); type = types.nullOr (types.enum ["always" "never" "mutable"]);
default = null; default = null;
description = '' description = ''
Whether to show inlay type hints for compiler inserted reborrows. Whether to show inlay type hints for compiler inserted reborrows.
@ -1154,7 +1155,7 @@ lib: with lib; {
}; };
}; };
"linkedProjects" = mkOption { "linkedProjects" = mkOption {
type = types.nullOr (types.listOf (types.oneOf [ (types.str) (types.attrsOf types.anything) ])); type = types.nullOr (types.listOf (types.oneOf [(types.str) (types.attrsOf types.anything)]));
default = null; default = null;
description = '' description = ''
Disable project auto-discovery in favor of explicitly specified set Disable project auto-discovery in favor of explicitly specified set
@ -1471,7 +1472,7 @@ lib: with lib; {
}; };
"signatureInfo" = { "signatureInfo" = {
"detail" = mkOption { "detail" = mkOption {
type = types.nullOr (types.enum [ "full" "parameters" ]); type = types.nullOr (types.enum ["full" "parameters"]);
default = null; default = null;
description = '' description = ''
Show full signature of the callable. Only shows parameters if disabled. Show full signature of the callable. Only shows parameters if disabled.
@ -1517,7 +1518,7 @@ lib: with lib; {
"symbol" = { "symbol" = {
"search" = { "search" = {
"kind" = mkOption { "kind" = mkOption {
type = types.nullOr (types.enum [ "only_types" "all_symbols" ]); type = types.nullOr (types.enum ["only_types" "all_symbols"]);
default = null; default = null;
description = '' description = ''
Workspace symbol search kind. Workspace symbol search kind.
@ -1543,7 +1544,7 @@ lib: with lib; {
''; '';
}; };
"scope" = mkOption { "scope" = mkOption {
type = types.nullOr (types.enum [ "workspace" "workspace_and_dependencies" ]); type = types.nullOr (types.enum ["workspace" "workspace_and_dependencies"]);
default = null; default = null;
description = '' description = ''
Workspace symbol search scope. Workspace symbol search scope.

View file

@ -1,17 +1,21 @@
{ config, pkgs, lib, ... }:
let
cfg = config.plugins.trouble;
helpers = import ../helpers.nix { inherit lib; };
in
with lib;
# with helpers;
{ {
config,
pkgs,
lib,
...
}: let
cfg = config.plugins.trouble;
helpers = import ../helpers.nix {inherit lib;};
in
with lib;
# with helpers;
{
options.plugins.trouble = { options.plugins.trouble = {
enable = mkEnableOption "trouble.nvim"; enable = mkEnableOption "trouble.nvim";
package = helpers.mkPackageOption "trouble-nvim" pkgs.vimPlugins.trouble-nvim; package = helpers.mkPackageOption "trouble-nvim" pkgs.vimPlugins.trouble-nvim;
position = helpers.mkNullOrOption (types.enum [ "top" "left" "right" "bottom" ]) "Position of the list"; position = helpers.mkNullOrOption (types.enum ["top" "left" "right" "bottom"]) "Position of the list";
height = helpers.mkNullOrOption types.int "Height of the trouble list when position is top or bottom"; height = helpers.mkNullOrOption types.int "Height of the trouble list when position is top or bottom";
width = helpers.mkNullOrOption types.int "Width of the trouble list when position is left or right"; width = helpers.mkNullOrOption types.int "Width of the trouble list when position is left or right";
icons = helpers.mkNullOrOption types.bool "Use devicons for filenames"; icons = helpers.mkNullOrOption types.bool "Use devicons for filenames";
@ -23,4 +27,4 @@ with lib;
nvim-web-devicons nvim-web-devicons
]; ];
}; };
} }

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";
@ -47,7 +46,7 @@
sha256 = "sha256-/m4Paw6AvDzTMWWCWpPnrdI4gsjIDSJPvGCMV7ufbEA="; sha256 = "sha256-/m4Paw6AvDzTMWWCWpPnrdI4gsjIDSJPvGCMV7ufbEA=";
}; };
propagatedBuildInputs = [ pkgs.python3Packages.pynvim ]; propagatedBuildInputs = [pkgs.python3Packages.pynvim];
}) })
(ps.buildPythonPackage rec { (ps.buildPythonPackage rec {
pname = "std2"; pname = "std2";
@ -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;
let
cfg = config.plugins.packer;
helpers = import ../helpers.nix { inherit lib; };
in
{ {
pkgs,
config,
lib,
...
}:
with lib; let
cfg = config.plugins.packer;
helpers = import ../helpers.nix {inherit lib;};
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;
@ -31,49 +35,60 @@ in
as = mkOpt bool "Specifies an alias under which to install the plugin"; as = mkOpt bool "Specifies an alias under which to install the plugin";
installer = mkOpt function "A custom installer"; installer = mkOpt function "A custom installer";
updater = mkOpt function "A custom updater"; updater = mkOpt function "A custom updater";
after = mkOpt (oneOf [ str (listOf any) ]) "Plugins to load after this plugin"; after = mkOpt (oneOf [str (listOf any)]) "Plugins to load after this plugin";
rtp = mkOpt str "Specifies a subdirectory of the plugin to add to runtimepath"; rtp = mkOpt str "Specifies a subdirectory of the plugin to add to runtimepath";
opt = mkOpt str "Marks a plugin as optional"; opt = mkOpt str "Marks a plugin as optional";
branch = mkOpt str "Git branch to use"; branch = mkOpt str "Git branch to use";
tag = mkOpt str "Git tag to use"; tag = mkOpt str "Git tag to use";
commit = mkOpt str "Git commit to use"; commit = mkOpt str "Git commit to use";
lock = mkOpt bool "Skip this plugin in updates"; lock = mkOpt bool "Skip this plugin in updates";
run = mkOpt (oneOf [ str function ]) "Post-install hook"; run = mkOpt (oneOf [str function]) "Post-install hook";
requires = mkOpt (oneOf [ str (listOf any) ]) "Plugin dependencies"; requires = mkOpt (oneOf [str (listOf any)]) "Plugin dependencies";
rocks = mkOpt (oneOf [ str (listOf any) ]) "Luarocks dependencies"; rocks = mkOpt (oneOf [str (listOf any)]) "Luarocks dependencies";
config = mkOpt (oneOf [ str function ]) "Code to run after this plugin is loaded"; config = mkOpt (oneOf [str function]) "Code to run after this plugin is loaded";
setup = mkOpt (oneOf [ str function ]) "Code to be run before this plugin is loaded"; setup = mkOpt (oneOf [str function]) "Code to be run before this plugin is loaded";
cmd = mkOpt (oneOf [ str (listOf str) ]) "Commands which load this plugin"; cmd = mkOpt (oneOf [str (listOf str)]) "Commands which load this plugin";
ft = mkOpt (oneOf [ str (listOf str) ]) "Filetypes which load this plugin"; ft = mkOpt (oneOf [str (listOf str)]) "Filetypes which load this plugin";
keys = mkOpt (oneOf [ str (listOf str) ]) "Keymaps which load this plugin"; keys = mkOpt (oneOf [str (listOf str)]) "Keymaps which load this plugin";
event = mkOpt (oneOf [ str (listOf str) ]) "Autocommand events which load this plugin"; event = mkOpt (oneOf [str (listOf str)]) "Autocommand events which load this plugin";
fn = mkOpt (oneOf [ str (listOf str) ]) "Functions which load this plugin"; fn = mkOpt (oneOf [str (listOf str)]) "Functions which load this plugin";
cond = mkOpt (oneOf [ str function (listOf (oneOf [ str function ])) ]) "Conditional test to load this plugin"; cond = mkOpt (oneOf [str function (listOf (oneOf [str function]))]) "Conditional test to load this plugin";
module = mkOpt (oneOf [ str (listOf str) ]) "Patterns of module names which load this plugin"; module = mkOpt (oneOf [str (listOf str)]) "Patterns of module names which load this plugin";
}; };
}) })
]); ]);
default = [ ]; default = [];
description = "List of plugins"; description = "List of plugins";
}; };
}; };
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
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()
use ${helpers.toLuaObject packedPlugins} use ${helpers.toLuaObject packedPlugins}
end) end)

View file

@ -1,17 +1,20 @@
{ pkgs, config, lib, ... }:
with lib;
let
cfg = config.plugins.luasnip;
helpers = import ../../helpers.nix { inherit lib; };
in
{ {
pkgs,
config,
lib,
...
}:
with lib; let
cfg = config.plugins.luasnip;
helpers = import ../../helpers.nix {inherit lib;};
in {
options.plugins.luasnip = { options.plugins.luasnip = {
enable = mkEnableOption "Enable luasnip"; enable = mkEnableOption "Enable luasnip";
package = helpers.mkPackageOption "luasnip" pkgs.vimPlugins.luasnip; package = helpers.mkPackageOption "luasnip" pkgs.vimPlugins.luasnip;
fromVscode = mkOption { fromVscode = mkOption {
default = [ ]; default = [];
example = '' example = ''
[ [
{} {}
@ -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,21 +79,18 @@ in
# TODO: add support for lua # TODO: add support for lua
}; };
config = config = let
let fromVscodeLoaders =
lists.map
fromVscodeLoaders = lists.map (loader: let
(loader: options = attrsets.getAttrs ["paths" "exclude" "include"] loader;
let in ''
options = attrsets.getAttrs [ "paths" "exclude" "include" ] loader;
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;
in in
mkIf cfg.enable { mkIf cfg.enable {
extraPlugins = [ cfg.package ]; extraPlugins = [cfg.package];
extraConfigLua = concatStringsSep "\n" fromVscodeLoaders; extraConfigLua = concatStringsSep "\n" fromVscodeLoaders;
}; };
} }

View file

@ -1,17 +1,20 @@
{ 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;};
sectionType = with types; nullOr (oneOf [ str (listOf str) ]); sectionType = with types; nullOr (oneOf [str (listOf str)]);
sectionOption = mkOption { sectionOption = mkOption {
default = null; default = null;
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;
let
cfg = config.plugins.lightline;
helpers = import ../helpers.nix { inherit lib; };
in
{ {
pkgs,
config,
lib,
...
}:
with lib; let
cfg = config.plugins.lightline;
helpers = import ../helpers.nix {inherit lib;};
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,14 +80,13 @@ 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;
}; };
in in
mkIf cfg.enable { mkIf cfg.enable {
extraPlugins = [ cfg.package ]; extraPlugins = [cfg.package];
globals.lightline = mkIf (configAttrs != { }) configAttrs; globals.lightline = mkIf (configAttrs != {}) configAttrs;
}; };
} }

View file

@ -1,8 +1,12 @@
{ 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 {
type = types.nullOr (types.submodule { type = types.nullOr (types.submodule {
options = { options = {
@ -32,7 +36,7 @@ let
default = defaultName; default = defaultName;
}; };
icons_enabled = mkOption { icons_enabled = mkOption {
type = types.enum [ "True" "False" ]; type = types.enum ["True" "False"];
default = "True"; default = "True";
description = "displays icons in alongside component"; description = "displays icons in alongside component";
}; };
@ -44,7 +48,7 @@ let
separator = separators; separator = separators;
extraConfig = mkOption { extraConfig = mkOption {
type = types.attrs; type = types.attrs;
default = { }; default = {};
description = "extra options for the component"; description = "extra options for the component";
}; };
}; };
@ -52,8 +56,7 @@ let
])); ]));
default = null; default = null;
}; };
in in {
{
options = { options = {
plugins.lualine = { plugins.lualine = {
enable = mkEnableOption "lualine"; enable = mkEnableOption "lualine";
@ -79,12 +82,11 @@ 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 {
type = types.nullOr (types.submodule ({ ... }: { type = types.nullOr (types.submodule ({...}: {
options = { options = {
lualine_a = component_options "mode"; lualine_a = component_options "mode";
lualine_b = component_options "branch"; lualine_b = component_options "branch";
@ -100,7 +102,7 @@ in
}; };
tabline = mkOption { tabline = mkOption {
type = types.nullOr (types.submodule ({ ... }: { type = types.nullOr (types.submodule ({...}: {
options = { options = {
lualine_a = component_options ""; lualine_a = component_options "";
lualine_b = component_options ""; lualine_b = component_options "";
@ -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;
@ -146,9 +160,8 @@ in
}; };
in 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
, lib
, ...
}:
with lib;
let
cfg = config.plugins.telescope;
helpers = import ../helpers.nix { inherit lib; };
in
{ {
pkgs,
config,
lib,
...
}:
with lib; let
cfg = config.plugins.telescope;
helpers = import ../helpers.nix {inherit lib;};
in {
imports = [ imports = [
./frecency.nix ./frecency.nix
./fzf-native.nix ./fzf-native.nix
@ -33,13 +32,13 @@ in
enabledExtensions = mkOption { enabledExtensions = mkOption {
type = types.listOf types.str; type = types.listOf types.str;
description = "A list of enabled extensions. Don't use this directly"; description = "A list of enabled extensions. Don't use this directly";
default = [ ]; default = [];
}; };
extensionConfig = mkOption { extensionConfig = mkOption {
type = types.attrsOf types.anything; type = types.attrsOf types.anything;
description = "Configuration for the extensions. Don't use this directly"; description = "Configuration for the extensions. Don't use this directly";
default = { }; default = {};
}; };
defaults = mkOption { defaults = mkOption {
@ -50,13 +49,13 @@ in
extraOptions = mkOption { extraOptions = mkOption {
type = types.attrs; type = types.attrs;
default = { }; default = {};
description = "An attribute set, that lets you set extra options or override options set by nixvim"; description = "An attribute set, that lets you set extra options or override options set by nixvim";
}; };
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
extraPackages = [ pkgs.bat ]; extraPackages = [pkgs.bat];
extraPlugins = with pkgs.vimPlugins; [ extraPlugins = with pkgs.vimPlugins; [
cfg.package cfg.package
@ -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;
let
cfg = config.plugins.telescope.extensions.frecency;
helpers = import ../helpers.nix { inherit lib; };
in
{ {
pkgs,
config,
lib,
...
}:
with lib; let
cfg = config.plugins.telescope.extensions.frecency;
helpers = import ../helpers.nix {inherit lib;};
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;
@ -60,13 +62,13 @@ in
}; };
in in
mkIf cfg.enable { mkIf cfg.enable {
extraPackages = [ pkgs.sqlite ]; extraPackages = [pkgs.sqlite];
extraPlugins = with pkgs.vimPlugins; [ extraPlugins = with pkgs.vimPlugins; [
cfg.package cfg.package
sqlite-lua sqlite-lua
]; ];
plugins.telescope.enabledExtensions = [ "frecency" ]; plugins.telescope.enabledExtensions = ["frecency"];
plugins.telescope.extensionConfig."frecency" = configuration; plugins.telescope.extensionConfig."frecency" = configuration;
}; };
} }

View file

@ -1,10 +1,13 @@
{ pkgs, config, lib, ... }:
with lib;
let
cfg = config.plugins.telescope.extensions.fzf-native;
helpers = import ../helpers.nix { inherit lib; };
in
{ {
pkgs,
config,
lib,
...
}:
with lib; let
cfg = config.plugins.telescope.extensions.fzf-native;
helpers = import ../helpers.nix {inherit lib;};
in {
options.plugins.telescope.extensions.fzf-native = { options.plugins.telescope.extensions.fzf-native = {
enable = mkEnableOption "Enable fzf-native"; enable = mkEnableOption "Enable fzf-native";
@ -26,7 +29,7 @@ in
default = null; default = null;
}; };
caseMode = mkOption { caseMode = mkOption {
type = types.nullOr (types.enum [ "smart_case" "ignore_case" "respect_case" ]); type = types.nullOr (types.enum ["smart_case" "ignore_case" "respect_case"]);
default = null; default = null;
}; };
}; };
@ -38,10 +41,11 @@ in
override_file_sorter = cfg.overrideFileSorter; override_file_sorter = cfg.overrideFileSorter;
case_mode = cfg.caseMode; case_mode = cfg.caseMode;
}; };
in mkIf cfg.enable { in
extraPlugins = [ cfg.package ]; mkIf cfg.enable {
extraPlugins = [cfg.package];
plugins.telescope.enabledExtensions = [ "fzf" ]; plugins.telescope.enabledExtensions = ["fzf"];
plugins.telescope.extensionConfig."fzf" = configuration; plugins.telescope.extensionConfig."fzf" = configuration;
}; };
} }

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,10 +27,11 @@ 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
extraPlugins = [ pkgs.vimPlugins.telescope-fzy-native-nvim ]; mkIf cfg.enable {
extraPlugins = [pkgs.vimPlugins.telescope-fzy-native-nvim];
plugins.telescope.enabledExtensions = [ "fzy_native" ]; plugins.telescope.enabledExtensions = ["fzy_native"];
plugins.telescope.extensionConfig."fzy_native" = configuration; plugins.telescope.extensionConfig."fzy_native" = configuration;
}; };
} }

View file

@ -1,10 +1,13 @@
{ pkgs, config, lib, ... }:
with lib;
let
cfg = config.plugins.telescope.extensions.media_files;
helpers = import ../helpers.nix { inherit lib; };
in
{ {
pkgs,
config,
lib,
...
}:
with lib; let
cfg = config.plugins.telescope.extensions.media_files;
helpers = import ../helpers.nix {inherit lib;};
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";
@ -23,7 +26,7 @@ in
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
plugins.telescope.enabledExtensions = [ "media_files" ]; plugins.telescope.enabledExtensions = ["media_files"];
extraPlugins = with pkgs.vimPlugins; [ extraPlugins = with pkgs.vimPlugins; [
popup-nvim popup-nvim

View file

@ -1,15 +1,17 @@
{ 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 {
plugins.telescope.enabledExtensions = [ "projects" ]; plugins.telescope.enabledExtensions = ["projects"];
}; };
} }

View file

@ -1,10 +1,13 @@
{ config, pkgs, lib, ... }:
with lib;
let
cfg = config.plugins.comment-nvim;
helpers = import ../helpers.nix { inherit lib; };
in
{ {
config,
pkgs,
lib,
...
}:
with lib; let
cfg = config.plugins.comment-nvim;
helpers = import ../helpers.nix {inherit lib;};
in {
options = { options = {
plugins.comment-nvim = { plugins.comment-nvim = {
enable = mkEnableOption "Enable comment-nvim"; enable = mkEnableOption "Enable comment-nvim";
@ -27,7 +30,7 @@ in
default = null; default = null;
}; };
toggler = mkOption { toggler = mkOption {
type = types.nullOr (types.submodule ({ ... }: { type = types.nullOr (types.submodule ({...}: {
options = { options = {
line = mkOption { line = mkOption {
type = types.str; type = types.str;
@ -45,7 +48,7 @@ in
default = null; default = null;
}; };
opleader = mkOption { opleader = mkOption {
type = types.nullOr (types.submodule ({ ... }: { type = types.nullOr (types.submodule ({...}: {
options = { options = {
line = mkOption { line = mkOption {
type = types.str; type = types.str;
@ -63,7 +66,7 @@ in
default = null; default = null;
}; };
mappings = mkOption { mappings = mkOption {
type = types.nullOr (types.submodule ({ ... }: { type = types.nullOr (types.submodule ({...}: {
options = { options = {
basic = mkOption { basic = mkOption {
type = types.bool; type = types.bool;
@ -88,8 +91,7 @@ in
}; };
}; };
config = config = let
let
setupOptions = { setupOptions = {
padding = cfg.padding; padding = cfg.padding;
sticky = cfg.sticky; sticky = cfg.sticky;
@ -100,8 +102,7 @@ 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;
let
cfg = config.plugins.commentary;
helpers = import ../helpers.nix { inherit lib; };
in
{ {
pkgs,
config,
lib,
...
}:
with lib; let
cfg = config.plugins.commentary;
helpers = import ../helpers.nix {inherit lib;};
in {
# TODO Add support for aditional filetypes. This requires autocommands! # TODO Add support for aditional filetypes. This requires autocommands!
options = { options = {
@ -16,6 +19,6 @@ in
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
extraPlugins = [ cfg.package ]; extraPlugins = [cfg.package];
}; };
} }

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";
@ -90,7 +93,7 @@ in
}; };
}; };
}; };
default = { }; default = {};
}; };
hideStatusline = mkOption { hideStatusline = mkOption {
@ -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;
@ -128,12 +130,11 @@ in
filteredOptions = filterAttrs (_: v: !isNull v) options; filteredOptions = filterAttrs (_: v: !isNull v) options;
in in
mkIf cfg.enable { mkIf cfg.enable {
extraPlugins = [ cfg.package ]; extraPlugins = [cfg.package];
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;
let
cfg = config.plugins.easyescape;
helpers = import ../helpers.nix { inherit lib; };
in
{ {
config,
pkgs,
lib,
...
}:
with lib; let
cfg = config.plugins.easyescape;
helpers = import ../helpers.nix {inherit lib;};
in {
options = { options = {
plugins.easyescape = { plugins.easyescape = {
enable = mkEnableOption "Enable easyescape"; enable = mkEnableOption "Enable easyescape";

View file

@ -1,20 +1,25 @@
{ lib, pkgs, ... }@attrs: {
with lib; lib,
let pkgs,
helpers = import ../helpers.nix { inherit lib; }; ...
} @ attrs:
with lib; let
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)));
mkPlugin attrs { in
with helpers;
mkPlugin attrs {
name = "emmet"; name = "emmet";
description = "Enable emmet"; description = "Enable emmet";
package = pkgs.vimPlugins.emmet-vim; package = pkgs.vimPlugins.emmet-vim;
options = { options = {
mode = mkDefaultOpt { mode = mkDefaultOpt {
type = types.enum [ "i" "n" "v" "a" ]; type = types.enum ["i" "n" "v" "a"];
global = "user_emmet_mode"; global = "user_emmet_mode";
description = "Mode where emmet will enable"; description = "Mode where emmet will enable";
}; };
@ -31,4 +36,4 @@ mkPlugin attrs {
description = "Emmet settings"; description = "Emmet settings";
}; };
}; };
} }

View file

@ -1,12 +1,17 @@
{ lib, pkgs, ... }@attrs: {
let lib,
helpers = import ../helpers.nix { inherit lib; }; pkgs,
in with helpers; with lib; ...
mkPlugin attrs { } @ attrs: let
helpers = import ../helpers.nix {inherit lib;};
in
with helpers;
with lib;
mkPlugin attrs {
name = "endwise"; name = "endwise";
description = "Enable vim-endwise"; description = "Enable vim-endwise";
package = pkgs.vimPlugins.vim-endwise; package = pkgs.vimPlugins.vim-endwise;
# Yes it's really not configurable # Yes it's really not configurable
options = {}; options = {};
} }

View file

@ -1,10 +1,13 @@
{ config, pkgs, lib, ... }:
with lib;
let
cfg = config.plugins.floaterm;
helpers = import ../helpers.nix { inherit lib; };
in
{ {
config,
pkgs,
lib,
...
}:
with lib; let
cfg = config.plugins.floaterm;
helpers = import ../helpers.nix {inherit lib;};
in {
options = { options = {
plugins.floaterm = { plugins.floaterm = {
enable = mkEnableOption "floaterm"; enable = mkEnableOption "floaterm";
@ -21,7 +24,7 @@ in
default = null; default = null;
}; };
winType = mkOption { winType = mkOption {
type = types.nullOr (types.enum [ "float" "split" "vsplit" ]); type = types.nullOr (types.enum ["float" "split" "vsplit"]);
default = null; default = null;
}; };
winWidth = mkOption { winWidth = mkOption {
@ -45,17 +48,17 @@ in
default = null; default = null;
}; };
opener = mkOption { opener = mkOption {
type = types.nullOr (types.enum [ "edit" "split" "vsplit" "tabe" "drop" ]); type = types.nullOr (types.enum ["edit" "split" "vsplit" "tabe" "drop"]);
description = "Command used for opening a file in the outside nvim from within :terminal"; description = "Command used for opening a file in the outside nvim from within :terminal";
default = null; default = null;
}; };
autoClose = mkOption { autoClose = mkOption {
type = types.nullOr (types.enum [ 0 1 2 ]); type = types.nullOr (types.enum [0 1 2]);
description = "Whether to close floaterm window once the job gets finished."; description = "Whether to close floaterm window once the job gets finished.";
default = null; default = null;
}; };
autoHide = mkOption { autoHide = mkOption {
type = types.nullOr (types.enum [ 0 1 2 ]); type = types.nullOr (types.enum [0 1 2]);
description = "Whether to hide previous floaterm before switching to or opening another one."; description = "Whether to hide previous floaterm before switching to or opening another one.";
default = null; default = null;
}; };

View file

@ -1,8 +1,13 @@
{ lib, pkgs, ... }@attrs: {
let lib,
helpers = import ../helpers.nix { inherit lib; }; pkgs,
in with helpers; with lib; ...
mkPlugin attrs { } @ attrs: let
helpers = import ../helpers.nix {inherit lib;};
in
with helpers;
with lib;
mkPlugin attrs {
name = "goyo"; name = "goyo";
description = "Enable goyo.vim"; description = "Enable goyo.vim";
package = pkgs.vimPlugins.goyo-vim; package = pkgs.vimPlugins.goyo-vim;
@ -26,4 +31,4 @@ mkPlugin attrs {
type = types.bool; type = types.bool;
}; };
}; };
} }

View file

@ -1,8 +1,12 @@
{ 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;};
projectConfigModule = types.submodule { projectConfigModule = types.submodule {
options = { options = {
@ -15,8 +19,7 @@ let
''; '';
}; };
}; };
in in {
{
options.plugins.harpoon = { options.plugins.harpoon = {
enable = mkEnableOption "harpoon"; enable = mkEnableOption "harpoon";
@ -47,7 +50,7 @@ in
''; '';
projects = mkOption { projects = mkOption {
default = { }; default = {};
description = '' description = ''
Predefined projetcs. The keys of this attrs should be the path to the project. Predefined projetcs. The keys of this attrs should be the path to the project.
$HOME is working. $HOME is working.
@ -73,21 +76,20 @@ 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;
mark.marks = map (mark: { filename = mark; }) value.marks; mark.marks = map (mark: {filename = mark;}) value.marks;
} }
) )
cfg.projects; cfg.projects;
@ -112,11 +114,10 @@ in
}; };
in in
mkIf cfg.enable { mkIf cfg.enable {
extraPlugins = [ cfg.package ]; extraPlugins = [cfg.package];
extraConfigLua = '' extraConfigLua = ''
require('harpoon').setup(${helpers.toLuaObject options}) require('harpoon').setup(${helpers.toLuaObject options})
''; '';
}; };
} }

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,12 +248,11 @@ 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 {
extraPlugins = [ cfg.package ]; extraPlugins = [cfg.package];
globals = { globals = {
indent_blankline_char = cfg.char; indent_blankline_char = cfg.char;

View file

@ -1,11 +1,14 @@
{ config, pkgs, lib, ... }:
with lib;
let
cfg = config.plugins.intellitab;
helpers = import ../helpers.nix { inherit lib; };
defs = import ../plugin-defs.nix { inherit pkgs; };
in
{ {
config,
pkgs,
lib,
...
}:
with lib; let
cfg = config.plugins.intellitab;
helpers = import ../helpers.nix {inherit lib;};
defs = import ../plugin-defs.nix {inherit pkgs;};
in {
options = { options = {
plugins.intellitab = { plugins.intellitab = {
enable = mkEnableOption "intellitab.nvim"; enable = mkEnableOption "intellitab.nvim";
@ -15,7 +18,7 @@ in
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
extraPlugins = [ cfg.package ]; extraPlugins = [cfg.package];
maps.insert."<Tab>" = "<CMD>lua require([[intellitab]]).indent()<CR>"; maps.insert."<Tab>" = "<CMD>lua require([[intellitab]]).indent()<CR>";
plugins.treesitter = { plugins.treesitter = {

View file

@ -1,8 +1,12 @@
{ 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 {
owner = "dccsillag"; owner = "dccsillag";
repo = "magma-nvim"; repo = "magma-nvim";
@ -14,11 +18,10 @@ in {
plugins.magma-nvim = { plugins.magma-nvim = {
enable = mkEnableOption "Enable magma-nvim?"; enable = mkEnableOption "Enable magma-nvim?";
image_provider = mkOption { image_provider = mkOption {
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, ... }:
with lib;
let
cfg = config.plugins.mark-radar;
helpers = import ../helpers.nix { inherit lib; };
defs = import ../plugin-defs.nix { inherit pkgs; };
in
{ {
pkgs,
config,
lib,
...
}:
with lib; let
cfg = config.plugins.mark-radar;
helpers = import ../helpers.nix {inherit lib;};
defs = import ../plugin-defs.nix {inherit pkgs;};
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;
@ -42,7 +43,7 @@ in
}; };
in in
mkIf cfg.enable { mkIf cfg.enable {
extraPlugins = [ cfg.package ]; extraPlugins = [cfg.package];
extraConfigLua = '' extraConfigLua = ''
require("mark-radar").setup(${opts}) require("mark-radar").setup(${opts})

View file

@ -1,21 +1,24 @@
{ 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";
package = helpers.mkPackageOption "notify" pkgs.vimPlugins.nvim-notify; package = helpers.mkPackageOption "notify" pkgs.vimPlugins.nvim-notify;
stages = mkOption { stages = mkOption {
type = types.nullOr (types.enum [ "fade_in_slide_out" "fade" "slide" "static" ]); type = types.nullOr (types.enum ["fade_in_slide_out" "fade" "slide" "static"]);
description = "Animation style"; description = "Animation style";
default = null; default = null;
}; };
@ -45,12 +48,11 @@ in
}; };
}); });
description = "Icons for the different levels"; description = "Icons for the different levels";
default = { }; default = {};
}; };
}; };
config = config = let
let
setupOptions = with cfg; { setupOptions = with cfg; {
stages = stages; stages = stages;
timeout = timeout; timeout = timeout;
@ -66,7 +68,7 @@ in
}; };
in in
mkIf cfg.enable { mkIf cfg.enable {
extraPlugins = [ cfg.package ]; extraPlugins = [cfg.package];
extraConfigLua = '' extraConfigLua = ''
vim.notify = require('notify'); vim.notify = require('notify');
require('notify').setup(${helpers.toLuaObject setupOptions}) require('notify').setup(${helpers.toLuaObject setupOptions})

View file

@ -1,10 +1,13 @@
{ pkgs, config, lib, ... }:
with lib;
let
cfg = config.plugins.nvim-autopairs;
helpers = import ../helpers.nix { inherit lib; };
in
{ {
pkgs,
config,
lib,
...
}:
with lib; let
cfg = config.plugins.nvim-autopairs;
helpers = import ../helpers.nix {inherit lib;};
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;
@ -52,7 +54,7 @@ in
}; };
in in
mkIf cfg.enable { mkIf cfg.enable {
extraPlugins = [ cfg.package ]; extraPlugins = [cfg.package];
extraConfigLua = '' extraConfigLua = ''
require('nvim-autopairs').setup(${helpers.toLuaObject options}) require('nvim-autopairs').setup(${helpers.toLuaObject options})

View file

@ -1,9 +1,12 @@
{ 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;};
colorizer-options = { colorizer-options = {
RGB = mkOption { RGB = mkOption {
@ -53,7 +56,7 @@ let
}; };
mode = mkOption { mode = mkOption {
description = "Set the display mode"; description = "Set the display mode";
type = types.nullOr (types.enum [ "foreground" "background" "virtualtext" ]); type = types.nullOr (types.enum ["foreground" "background" "virtualtext"]);
default = null; default = null;
}; };
tailwind = mkOption { tailwind = mkOption {
@ -61,7 +64,7 @@ let
type = types.nullOr ( type = types.nullOr (
types.oneOf [ types.oneOf [
types.bool types.bool
(types.enum [ "normal" "lsp" "both" ]) (types.enum ["normal" "lsp" "both"])
] ]
); );
default = null; default = null;
@ -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;
}) })
]) ])
); );
@ -128,24 +130,26 @@ in
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
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 (
then v.language + " = " + helpers.toLuaObject (builtins.removeAttrs v [ "language" ]) v:
if builtins.isAttrs v
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,27 +1,30 @@
{ pkgs, config, lib, ... }@args:
with lib;
let
cfg = config.plugins.nvim-tree;
helpers = import ../helpers.nix { inherit lib; };
optionWarnings = import ../../lib/option-warnings.nix args;
basePluginPath = [ "plugins" "nvim-tree" ];
in
{ {
pkgs,
config,
lib,
...
} @ args:
with lib; let
cfg = config.plugins.nvim-tree;
helpers = import ../helpers.nix {inherit lib;};
optionWarnings = import ../../lib/option-warnings.nix args;
basePluginPath = ["plugins" "nvim-tree"];
in {
imports = [ imports = [
(optionWarnings.mkRenamedOption { (optionWarnings.mkRenamedOption {
option = basePluginPath ++ [ "updateCwd" ]; option = basePluginPath ++ ["updateCwd"];
newOption = basePluginPath ++ [ "syncRootWithCwd" ]; newOption = basePluginPath ++ ["syncRootWithCwd"];
}) })
(optionWarnings.mkRenamedOption { (optionWarnings.mkRenamedOption {
option = basePluginPath ++ [ "updateFocusedFile" "updateCwd" ]; option = basePluginPath ++ ["updateFocusedFile" "updateCwd"];
newOption = basePluginPath ++ [ "updateFocusedFile" "updateRoot" ]; newOption = basePluginPath ++ ["updateFocusedFile" "updateRoot"];
}) })
(optionWarnings.mkDeprecatedOption { (optionWarnings.mkDeprecatedOption {
option = basePluginPath ++ [ "openOnSetup" ]; option = basePluginPath ++ ["openOnSetup"];
alternative = []; alternative = [];
}) })
(optionWarnings.mkDeprecatedOption { (optionWarnings.mkDeprecatedOption {
option = basePluginPath ++ [ "ignoreFtOnSetup" ]; option = basePluginPath ++ ["ignoreFtOnSetup"];
alternative = []; alternative = [];
}) })
]; ];
@ -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;
@ -294,6 +295,6 @@ in
extraConfigLua = '' extraConfigLua = ''
require('nvim-tree').setup(${helpers.toLuaObject options}) require('nvim-tree').setup(${helpers.toLuaObject options})
''; '';
extraPackages = [ pkgs.git ]; extraPackages = [pkgs.git];
}; };
} }

View file

@ -1,11 +1,16 @@
{ pkgs, config, lib, ... }:
with lib;
let
cfg = config.plugins.project-nvim;
helpers = import ../helpers.nix { inherit lib pkgs; };
in
{ {
options.plugins.project-nvim = helpers.extraOptionsOptions // { pkgs,
config,
lib,
...
}:
with lib; let
cfg = config.plugins.project-nvim;
helpers = import ../helpers.nix {inherit lib pkgs;};
in {
options.plugins.project-nvim =
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;
@ -46,7 +51,7 @@ in
}; };
scopeChdir = mkOption { scopeChdir = mkOption {
type = types.nullOr (types.enum [ "global" "tab" "win" ]); type = types.nullOr (types.enum ["global" "tab" "win"]);
default = null; default = null;
}; };
@ -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,10 +73,11 @@ 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];
extraConfigLua = '' extraConfigLua = ''
require('project_nvim').setup(${helpers.toLuaObject options}) require('project_nvim').setup(${helpers.toLuaObject options})

View file

@ -1,10 +1,13 @@
{ pkgs, config, lib, ... }:
with lib;
let
cfg = config.plugins.specs;
helpers = import ../helpers.nix { inherit lib; };
in
{ {
pkgs,
config,
lib,
...
}:
with lib; let
cfg = config.plugins.specs;
helpers = import ../helpers.nix {inherit lib;};
in {
options.plugins.specs = { options.plugins.specs = {
enable = mkEnableOption "specs-nvim"; enable = mkEnableOption "specs-nvim";
@ -73,15 +76,16 @@ in
}; };
}; };
}; };
default = { builtin = "linear_fader"; }; default = {builtin = "linear_fader";};
}; };
resizer = mkOption { resizer = mkOption {
type = types.submodule { type = types.submodule {
options = { options = {
builtin = mkOption { builtin = mkOption {
type = types.nullOr type =
(types.enum [ "shrink_resizer" "slide_resizer" "empty_resizer" ]); types.nullOr
(types.enum ["shrink_resizer" "slide_resizer" "empty_resizer"]);
default = "shrink_resizer"; default = "shrink_resizer";
}; };
@ -98,48 +102,53 @@ in
}; };
}; };
}; };
default = { builtin = "shrink_resizer"; }; default = {builtin = "shrink_resizer";};
}; };
ignored_filetypes = mkOption { ignored_filetypes = mkOption {
type = with types; listOf string; type = with types; listOf string;
default = [ ]; default = [];
}; };
ignored_buffertypes = mkOption { ignored_buffertypes = mkOption {
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
mkIf cfg.enable { mkIf cfg.enable {
extraPlugins = [ cfg.package ]; extraPlugins = [cfg.package];
highlight.SpecsPopColor.bg = mkIf (!isNull cfg.color) cfg.color; highlight.SpecsPopColor.bg = mkIf (!isNull cfg.color) cfg.color;

View file

@ -1,8 +1,13 @@
{ pkgs, lib, ... }@args: {
let pkgs,
helpers = import ../helpers.nix { inherit lib; }; lib,
in with lib; with helpers; ...
mkPlugin args { } @ args: let
helpers = import ../helpers.nix {inherit lib;};
in
with lib;
with helpers;
mkPlugin args {
name = "startify"; name = "startify";
description = "Enable startify"; description = "Enable startify";
package = pkgs.vimPlugins.vim-startify; package = pkgs.vimPlugins.vim-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 {
@ -51,7 +64,7 @@ mkPlugin args {
commands = mkDefaultOpt { commands = mkDefaultOpt {
description = "A list of commands to execute on selection"; description = "A list of commands to execute on selection";
global = "startify_commands"; global = "startify_commands";
type = with types; listOf (oneOf [ str (listOf str) attrs ]); type = with types; listOf (oneOf [str (listOf str) attrs]);
}; };
filesNumber = mkDefaultOpt { filesNumber = mkDefaultOpt {
@ -105,7 +118,7 @@ mkPlugin args {
changeCmd = mkDefaultOpt { changeCmd = mkDefaultOpt {
description = "The default command for switching directories"; description = "The default command for switching directories";
global = "startify_change_cmd"; global = "startify_change_cmd";
type = types.enum [ "cd" "lcd" "tcd" ]; type = types.enum ["cd" "lcd" "tcd"];
}; };
skipList = mkDefaultOpt { skipList = mkDefaultOpt {
@ -183,7 +196,7 @@ mkPlugin args {
customHeader = mkDefaultOpt { customHeader = mkDefaultOpt {
description = "Define your own header"; description = "Define your own header";
global = "startify_custom_header"; global = "startify_custom_header";
type = types.oneOf [ types.str (types.listOf types.str) ]; type = types.oneOf [types.str (types.listOf types.str)];
}; };
customQuotes = mkDefaultOpt { customQuotes = mkDefaultOpt {
@ -217,4 +230,4 @@ mkPlugin args {
type = types.bool; type = types.bool;
}; };
}; };
} }

View file

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

View file

@ -1,10 +1,13 @@
{ pkgs, config, lib, ... }:
with lib;
let
cfg = config.plugins.undotree;
helpers = import ../helpers.nix { inherit lib; };
in
{ {
pkgs,
config,
lib,
...
}:
with lib; let
cfg = config.plugins.undotree;
helpers = import ../helpers.nix {inherit lib;};
in {
options = { options = {
plugins.undotree = { plugins.undotree = {
enable = mkEnableOption "Enable undotree"; enable = mkEnableOption "Enable undotree";
@ -110,7 +113,7 @@ in
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
extraPlugins = [ cfg.package ]; extraPlugins = [cfg.package];
globals = { globals = {
undotree_WindowLayout = mkIf (cfg.windowLayout != null) cfg.windowLayout; undotree_WindowLayout = mkIf (cfg.windowLayout != null) cfg.windowLayout;

View file

@ -14,19 +14,27 @@
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 {};
# Should print "Hello!" when starting up # Should print "Hello!" when starting up
hello = build { hello = build {
@ -34,11 +42,11 @@
}; };
simple-plugin = build { simple-plugin = build {
extraPlugins = [ pkgs.vimPlugins.vim-surround ]; extraPlugins = [pkgs.vimPlugins.vim-surround];
}; };
gruvbox = build { gruvbox = build {
extraPlugins = [ pkgs.vimPlugins.gruvbox ]; extraPlugins = [pkgs.vimPlugins.gruvbox];
colorscheme = "gruvbox"; colorscheme = "gruvbox";
}; };
@ -118,7 +126,6 @@
rnix-lsp.enable = true; rnix-lsp.enable = true;
}; };
}; };
}; };
options = { options = {
@ -196,17 +203,16 @@
}; };
enable = true; enable = true;
sources = [ sources = [
{ name = "nvim_lsp"; } {name = "nvim_lsp";}
{ {
name = "luasnip"; name = "luasnip";
option = { option = {
show_autosnippets = true; show_autosnippets = true;
}; };
} }
{ name = "path"; } {name = "path";}
{ name = "buffer"; } {name = "buffer";}
]; ];
}; };
barbar.enable = true; barbar.enable = true;
}; };
@ -250,8 +256,8 @@
autoCmd = build { autoCmd = build {
autoCmd = [ autoCmd = [
{ {
event = [ "BufEnter" "BufWinEnter" ]; event = ["BufEnter" "BufWinEnter"];
pattern = [ "*.c" "*.h" ]; pattern = ["*.c" "*.h"];
command = "echo 'Entering a C or C++ file'"; command = "echo 'Entering a C or C++ file'";
} }
{ {
@ -275,22 +281,22 @@
}; };
}; };
}; };
})) // { }))
// {
nixosConfigurations.nixvim-machine = nixpkgs.lib.nixosSystem { nixosConfigurations.nixvim-machine = nixpkgs.lib.nixosSystem {
system = "x86_64-linux"; system = "x86_64-linux";
modules = [ modules = [
({ pkgs, ... }: { ({pkgs, ...}: {
environment.systemPackages = [ environment.systemPackages = [
(nixvim.build pkgs { colorschemes.gruvbox.enable = true; }) (nixvim.build pkgs {colorschemes.gruvbox.enable = true;})
]; ];
}) })
]; ];
}; };
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;
# Let 'nixos-version --json' know about the Git revision # Let 'nixos-version --json' know about the Git revision

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";
@ -11,6 +12,6 @@ in
check = builtins.isAttrs; check = builtins.isAttrs;
}; };
description = "Use this option to access the helpers"; description = "Use this option to access the helpers";
default = import ../plugins/helpers.nix { inherit (pkgs) lib; }; default = import ../plugins/helpers.nix {inherit (pkgs) lib;};
}; };
} }

View file

@ -1,25 +1,29 @@
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;
}; };
config = mkIf cfg.enable mkMerge [ config = mkIf cfg.enable mkMerge [
{ {
environment.systemPackages = [ cfg.finalPackage ]; environment.systemPackages = [cfg.finalPackage];
} }
{ {
warnings = cfg.warnings; warnings = cfg.warnings;

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,13 +1,13 @@
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;};
eval = lib.evalModules { eval = lib.evalModules {
modules = (modules pkgs) ++ [ module wrap ]; modules = (modules pkgs) ++ [module wrap];
}; };
in
in eval.config.finalPackage eval.config.finalPackage