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 (
fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/c75e76f80c57784a6734356315b306140646ee84.tar.gz";
sha256 = "071aal00zp2m9knnhddgr2wqzlx6i6qa1263lv1y7bdn2w20h10h"; }
) {
src = ./.;
}).defaultNix
fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/c75e76f80c57784a6734356315b306140646ee84.tar.gz";
sha256 = "071aal00zp2m9knnhddgr2wqzlx6i6qa1263lv1y7bdn2w20h10h";
}
) {
src = ./.;
})
.defaultNix

View file

@ -1,8 +1,12 @@
{ pkgs, lib, modules, ... }:
let
{
pkgs,
lib,
modules,
...
}: let
options = lib.evalModules {
modules = modules;
specialArgs = { inherit pkgs lib; };
specialArgs = {inherit pkgs lib;};
};
docs = pkgs.nixosOptionsDoc {
# If we don't do this, we end up with _module.args on the generated options, which we do not want
@ -11,25 +15,25 @@ let
};
asciidoc = docs.optionsAsciiDoc;
in
pkgs.stdenv.mkDerivation {
name = "nixvim-docs";
pkgs.stdenv.mkDerivation {
name = "nixvim-docs";
src = asciidoc;
buildInputs = [
pkgs.asciidoctor
];
src = asciidoc;
buildInputs = [
pkgs.asciidoctor
];
phases = [ "buildPhase" ];
phases = ["buildPhase"];
buildPhase = ''
mkdir -p $out/share/doc
cat <<EOF > header.adoc
= NixVim options
This lists all the options available for NixVim.
:toc:
buildPhase = ''
mkdir -p $out/share/doc
cat <<EOF > header.adoc
= NixVim options
This lists all the options available for NixVim.
:toc:
EOF
cat header.adoc $src > tmp.adoc
asciidoctor tmp.adoc -o $out/share/doc/index.html
'';
}
EOF
cat header.adoc $src > tmp.adoc
asciidoctor tmp.adoc -o $out/share/doc/index.html
'';
}

View file

@ -1,5 +1,4 @@
{ pkgs, ... }:
{
{pkgs, ...}: {
programs.nixvim = {
# This just enables NixVim.
# 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
active = {
left = [
[ "mode" "paste" ]
[ "redaonly" "filename" "modified" "helloworld" ]
["mode" "paste"]
["redaonly" "filename" "modified" "helloworld"]
];
};
@ -73,7 +72,7 @@
# What about plugins not available as a module?
# Use extraPlugins:
extraPlugins = with pkgs.vimPlugins; [ vim-toml ];
extraPlugins = with pkgs.vimPlugins; [vim-toml];
};
};
}

154
flake.nix
View file

@ -6,92 +6,108 @@
inputs.beautysh.url = "github:lovesegfault/beautysh";
inputs.beautysh.inputs.nixpkgs.follows = "nixpkgs";
outputs = { self, nixpkgs, flake-utils, ... }@inputs:
outputs = {
self,
nixpkgs,
flake-utils,
...
} @ inputs:
with nixpkgs.lib;
with builtins;
let
with builtins; let
# TODO: Support nesting
nixvimModules = map (f: ./modules + "/${f}") (attrNames (builtins.readDir ./modules));
modules = pkgs: nixvimModules ++ [
(rec {
_file = ./flake.nix;
key = _file;
config = {
_module.args = {
pkgs = mkForce pkgs;
inherit (pkgs) lib;
helpers = import ./plugins/helpers.nix { inherit (pkgs) lib; };
inputs = inputs;
modules = pkgs:
nixvimModules
++ [
rec {
_file = ./flake.nix;
key = _file;
config = {
_module.args = {
pkgs = mkForce pkgs;
inherit (pkgs) lib;
helpers = import ./plugins/helpers.nix {inherit (pkgs) lib;};
inputs = inputs;
};
};
};
})
}
# ./plugins/default.nix
];
# ./plugins/default.nix
];
flakeOutput =
flake-utils.lib.eachDefaultSystem
(system:
let
pkgs = import nixpkgs { inherit system; };
extractRustAnalyzer = { stdenv, pkgs }: stdenv.mkDerivation {
pname = "extract_rust_analyzer";
version = "master";
(system: let
pkgs = import nixpkgs {inherit system;};
extractRustAnalyzer = {
stdenv,
pkgs,
}:
stdenv.mkDerivation {
pname = "extract_rust_analyzer";
version = "master";
dontUnpack = true;
dontBuild = true;
dontUnpack = true;
dontBuild = true;
buildInputs = [ pkgs.python3 ];
buildInputs = [pkgs.python3];
installPhase = ''
ls -la
mkdir -p $out/bin
cp ${./helpers/extract_rust_analyzer.py} $out/bin/extract_rust_analyzer.py
'';
};
extractRustAnalyzerPkg = pkgs.callPackage extractRustAnalyzer { };
in
{
packages = {
docs = pkgs.callPackage (import ./docs.nix) {
modules = nixvimModules;
};
runUpdates = pkgs.callPackage
({ pkgs, stdenv }: stdenv.mkDerivation {
pname = "run-updates";
version = pkgs.rust-analyzer.version;
installPhase = ''
ls -la
mkdir -p $out/bin
cp ${./helpers/extract_rust_analyzer.py} $out/bin/extract_rust_analyzer.py
'';
};
extractRustAnalyzerPkg = pkgs.callPackage extractRustAnalyzer {};
in {
packages = {
docs = pkgs.callPackage (import ./docs.nix) {
modules = nixvimModules;
};
runUpdates =
pkgs.callPackage
({
pkgs,
stdenv,
}:
stdenv.mkDerivation {
pname = "run-updates";
version = pkgs.rust-analyzer.version;
src = pkgs.rust-analyzer.src;
src = pkgs.rust-analyzer.src;
nativeBuildInputs = with pkgs; [extractRustAnalyzerPkg alejandra nixpkgs-fmt];
nativeBuildInputs = with pkgs; [extractRustAnalyzerPkg alejandra nixpkgs-fmt];
buildPhase = ''
extract_rust_analyzer.py editors/code/package.json |
alejandra --quiet |
nixpkgs-fmt > rust-analyzer-config.nix
'';
buildPhase = ''
extract_rust_analyzer.py editors/code/package.json |
alejandra --quiet |
nixpkgs-fmt > rust-analyzer-config.nix
'';
installPhase = ''
mkdir -p $out/share
cp rust-analyzer-config.nix $out/share
'';
})
{ };
};
legacyPackages = rec {
makeNixvimWithModule = import ./wrappers/standalone.nix pkgs modules;
makeNixvim = configuration: makeNixvimWithModule {
module = {
config = configuration;
};
installPhase = ''
mkdir -p $out/share
cp rust-analyzer-config.nix $out/share
'';
})
{};
};
legacyPackages = rec {
makeNixvimWithModule = import ./wrappers/standalone.nix pkgs modules;
makeNixvim = configuration:
makeNixvimWithModule {
module = {
config = configuration;
};
};
});
};
formatter = pkgs.alejandra;
});
in
flakeOutput // {
nixosModules.nixvim = import ./wrappers/nixos.nix modules;
homeManagerModules.nixvim = import ./wrappers/hm.nix modules;
nixDarwinModules.nixvim = import ./wrappers/darwin.nix modules;
};
flakeOutput
// {
nixosModules.nixvim = import ./wrappers/nixos.nix modules;
homeManagerModules.nixvim = import ./wrappers/hm.nix modules;
nixDarwinModules.nixvim = import ./wrappers/darwin.nix modules;
};
}

View file

@ -1,146 +1,185 @@
{ lib, ... }:
with lib;
rec {
{lib, ...}:
with lib; rec {
# vim dictionaries are, in theory, compatible with JSON
toVimDict = args: toJSON
toVimDict = args:
toJSON
(lib.filterAttrs (n: v: !isNull v) args);
# Black functional magic that converts a bunch of different Nix types to their
# lua equivalents!
toLuaObject = args:
if builtins.isAttrs args then
if hasAttr "__raw" args then
args.__raw
if builtins.isAttrs args
then
if hasAttr "__raw" args
then args.__raw
else
"{" + (concatStringsSep ","
"{"
+ (concatStringsSep ","
(mapAttrsToList
(n: v:
if head (stringToCharacters n) == "@" then
toLuaObject v
if head (stringToCharacters n) == "@"
then toLuaObject v
else "[${toLuaObject n}] = " + (toLuaObject v))
(filterAttrs (n: v: !isNull v && toLuaObject v != "{}") args))) + "}"
else if builtins.isList args then
"{" + concatMapStringsSep "," toLuaObject args + "}"
else if builtins.isString args then
# This should be enough!
(filterAttrs (n: v: !isNull v && toLuaObject v != "{}") args)))
+ "}"
else if builtins.isList args
then "{" + concatMapStringsSep "," toLuaObject args + "}"
else if builtins.isString args
then
# This should be enough!
builtins.toJSON args
else if builtins.isPath args then
builtins.toJSON (toString args)
else if builtins.isBool args then
"${ boolToString args }"
else if builtins.isFloat args then
"${ toString args }"
else if builtins.isInt args then
"${ toString args }"
else if isNull args then
"nil"
else if builtins.isPath args
then builtins.toJSON (toString args)
else if builtins.isBool args
then "${boolToString args}"
else if builtins.isFloat args
then "${toString args}"
else if builtins.isInt args
then "${toString args}"
else if isNull args
then "nil"
else "";
# Generates maps for a lua config
genMaps = mode: maps:
let
normalized = builtins.mapAttrs
(key: action:
if builtins.isString action then
{
silent = false;
expr = false;
unique = false;
noremap = true;
script = false;
nowait = false;
action = action;
}
else action)
maps;
in
builtins.attrValues (builtins.mapAttrs
genMaps = mode: maps: let
normalized =
builtins.mapAttrs
(key: action:
{
action = action.action;
config = lib.filterAttrs (_: v: v) {
inherit (action) silent expr unique noremap script nowait;
};
key = key;
mode = mode;
})
if builtins.isString action
then {
silent = false;
expr = false;
unique = false;
noremap = true;
script = false;
nowait = false;
action = action;
}
else action)
maps;
in
builtins.attrValues (builtins.mapAttrs
(key: action: {
action = action.action;
config = lib.filterAttrs (_: v: v) {
inherit (action) silent expr unique noremap script nowait;
};
key = key;
mode = mode;
})
normalized);
# Creates an option with a nullable type that defaults to null.
mkNullOrOption = type: desc: lib.mkOption {
type = lib.types.nullOr type;
default = null;
description = desc;
};
mkNullOrOption = type: desc:
lib.mkOption {
type = lib.types.nullOr type;
default = null;
description = desc;
};
mkIfNonNull = c: mkIf (!isNull c) c;
defaultNullOpts = rec {
mkNullable = type: default: desc: mkNullOrOption type (
let
defaultDesc = "default: `${default}`";
in
if desc == "" then defaultDesc else ''
${desc}
mkNullable = type: default: desc:
mkNullOrOption type (
let
defaultDesc = "default: `${default}`";
in
if desc == ""
then defaultDesc
else ''
${desc}
${defaultDesc}
''
);
${defaultDesc}
''
);
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}'';
mkEnum = enum: default: mkNullable (lib.types.enum enum) ''"${default}"'';
mkEnumFirstDefault = enum: mkEnum enum (head enum);
};
mkPackageOption = name: default: mkOption {
type = types.package;
inherit default;
description = "Plugin to use for ${name}";
};
mkPlugin = { config, lib, ... }: { name
, description
, package ? null
, extraPlugins ? [ ]
, extraPackages ? [ ]
, options ? { }
, ...
}:
let
cfg = config.plugins.${name};
# TODO support nested options!
pluginOptions = mapAttrs (k: v: v.option) options;
globals = mapAttrs'
(name: opt: {
name = opt.global;
value = if cfg.${name} != null then opt.value cfg.${name} else null;
})
options;
# does this evaluate package?
packageOption = if package == null then { } else {
package = mkPackageOption name package;
};
in
{
options.plugins.${name} = {
enable = mkEnableOption description;
} // packageOption // pluginOptions;
config = mkIf cfg.enable {
inherit extraPackages globals;
# does this evaluate package? it would not be desired to evaluate pacakge if we use another package.
extraPlugins = extraPlugins ++ optional (package != null) cfg.package;
};
mkPackageOption = name: default:
mkOption {
type = types.package;
inherit default;
description = "Plugin to use for ${name}";
};
mkPlugin = {
config,
lib,
...
}: {
name,
description,
package ? null,
extraPlugins ? [],
extraPackages ? [],
options ? {},
...
}: let
cfg = config.plugins.${name};
# TODO support nested options!
pluginOptions = mapAttrs (k: v: v.option) options;
globals =
mapAttrs'
(name: opt: {
name = opt.global;
value =
if cfg.${name} != null
then opt.value cfg.${name}
else null;
})
options;
# does this evaluate package?
packageOption =
if package == null
then {}
else {
package = mkPackageOption name package;
};
in {
options.plugins.${name} =
{
enable = mkEnableOption description;
}
// packageOption
// pluginOptions;
config = mkIf cfg.enable {
inherit extraPackages globals;
# does this evaluate package? it would not be desired to evaluate pacakge if we use another package.
extraPlugins = extraPlugins ++ optional (package != null) cfg.package;
};
};
globalVal = val:
if builtins.isBool val then
(if val == false then 0 else 1)
if builtins.isBool val
then
(
if val == false
then 0
else 1
)
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 {
type = types.nullOr type;
default = default;
@ -153,7 +192,7 @@ rec {
extraOptionsOptions = {
extraOptions = mkOption {
default = { };
default = {};
type = types.attrs;
description = ''
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: ''
do

View file

@ -1,73 +1,74 @@
{ lib, ... }:
with lib;
rec {
{lib, ...}:
with lib; rec {
# 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
mkDeprecatedOption =
{ option # an array of the path to the option
, alternative ? null
, message ? null
, visible ? false
}:
{ options, config, ... }:
let
fromOpt = getAttrFromPath option options;
fromValue = getAttrFromPath option config;
fullMessage = "The option `${showOption option}` has been deprecated, but might still work." +
(optionalString (alternative != null) " You may want to use `${showOption alternative}` instead.") +
(optionalString (message != null) " Message: ${message}");
in
{
config = mkIf (fromOpt.isDefined && fromValue != fromOpt.default) {
warnings = [
("Nixvim: ${fullMessage}")
];
};
};
mkRenamedOption =
{ option
, newOption
, visible ? false
, warn ? true
, overrideDescription ? null
}:
{ options, ... }:
let
fromOpt = getAttrFromPath option options;
# toOf = attrByPath newOption
# (abort "Renaming error: option `${showOption newOption}` does not exist.");
toType = let opt = attrByPath newOption { } options; 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
{
inherit visible;
description =
if overrideDescription == null
then message
else overrideDescription;
} // optionalAttrs (toType != null) {
type = toType;
});
config = mkMerge [
{
warnings = mkIf (warn && fromOpt.isDefined) [ "Nixvim: ${message}" ];
}
(mkAliasAndWrapDefinitions (setAttrByPath newOption) fromOpt)
mkDeprecatedOption = {
option, # an array of the path to the option
alternative ? null,
message ? null,
visible ? false,
}: {
options,
config,
...
}: let
fromOpt = getAttrFromPath option options;
fromValue = getAttrFromPath option config;
fullMessage =
"The option `${showOption option}` has been deprecated, but might still work."
+ (optionalString (alternative != null) " You may want to use `${showOption alternative}` instead.")
+ (optionalString (message != null) " Message: ${message}");
in {
config = mkIf (fromOpt.isDefined && fromValue != fromOpt.default) {
warnings = [
"Nixvim: ${fullMessage}"
];
};
mkAliasOption = option: newOption: mkRenamedOption {
inherit option newOption;
visible = true;
warn = false;
overrideDescription = "Alias of ${showOption newOption}";
};
mkRenamedOption = {
option,
newOption,
visible ? false,
warn ? true,
overrideDescription ? null,
}: {options, ...}: let
fromOpt = getAttrFromPath option options;
# toOf = attrByPath newOption
# (abort "Renaming error: option `${showOption newOption}` does not exist.");
toType = let
opt = attrByPath newOption {} options;
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
{
inherit visible;
description =
if overrideDescription == null
then message
else overrideDescription;
}
// optionalAttrs (toType != null) {
type = toType;
});
config = mkMerge [
{
warnings = mkIf (warn && fromOpt.isDefined) ["Nixvim: ${message}"];
}
(mkAliasAndWrapDefinitions (setAttrByPath newOption) fromOpt)
];
};
mkAliasOption = option: newOption:
mkRenamedOption {
inherit option newOption;
visible = true;
warn = false;
overrideDescription = "Alias of ${showOption newOption}";
};
# TODO:
# mkRemovedOption =
# { option

View file

@ -1,7 +1,10 @@
{ config, lib, ... }:
with lib;
let
helpers = import ../lib/helpers.nix { inherit lib; };
{
config,
lib,
...
}:
with lib; let
helpers = import ../lib/helpers.nix {inherit lib;};
autoGroupOption = types.submodule {
options = {
@ -47,13 +50,11 @@ let
nested = helpers.defaultNullOpts.mkBool false "Run nested autocommands.";
};
};
in
{
in {
options = {
autoGroups = mkOption {
type = types.attrsOf autoGroupOption;
default = { };
default = {};
description = "augroup definitions";
example = ''
autoGroups = {
@ -66,7 +67,7 @@ in
autoCmd = mkOption {
type = types.listOf autoCmdOption;
default = [ ];
default = [];
description = "autocmd definitions";
example = ''
autoCmd = [
@ -80,40 +81,41 @@ in
};
};
config = mkIf (config.autoGroups != { } || config.autoCmd != { }) {
extraConfigLuaPost = (optionalString (config.autoGroups != { }) ''
-- Set up autogroups {{
do
local __nixvim_autogroups = ${helpers.toLuaObject config.autoGroups}
config = mkIf (config.autoGroups != {} || config.autoCmd != {}) {
extraConfigLuaPost =
(optionalString (config.autoGroups != {}) ''
-- Set up autogroups {{
do
local __nixvim_autogroups = ${helpers.toLuaObject config.autoGroups}
for group_name, options in pairs(__nixvim_autogroups) do
vim.api.nvim_create_augroup(group_name, options)
for group_name, options in pairs(__nixvim_autogroups) do
vim.api.nvim_create_augroup(group_name, options)
end
end
end
-- }}
'') +
(optionalString (config.autoCmd != [ ]) ''
-- Set up autocommands {{
do
local __nixvim_autocommands = ${helpers.toLuaObject config.autoCmd}
-- }}
'')
+ (optionalString (config.autoCmd != []) ''
-- Set up autocommands {{
do
local __nixvim_autocommands = ${helpers.toLuaObject config.autoCmd}
for _, autocmd in ipairs(__nixvim_autocommands) do
vim.api.nvim_create_autocmd(
autocmd.event,
{
group = autocmd.group,
pattern = autocmd.pattern,
buffer = autocmd.buffer,
desc = autocmd.desc,
callback = autocmd.callback,
command = autocmd.command,
once = autocmd.once,
nested = autocmd.nested
}
)
for _, autocmd in ipairs(__nixvim_autocommands) do
vim.api.nvim_create_autocmd(
autocmd.event,
{
group = autocmd.group,
pattern = autocmd.pattern,
buffer = autocmd.buffer,
desc = autocmd.desc,
callback = autocmd.callback,
command = autocmd.command,
once = autocmd.once,
nested = autocmd.nested
}
)
end
end
end
-- }}
'');
-- }}
'');
};
}

View file

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

View file

@ -1,56 +1,58 @@
{ config, lib, ... }:
let
helpers = import ../lib/helpers.nix { inherit lib; };
in
with lib;
{
options = {
highlight = mkOption {
type = types.attrsOf types.anything;
default = { };
description = "Define highlight groups";
example = ''
highlight = {
Comment.fg = '#ff0000';
};
'';
config,
lib,
...
}: let
helpers = import ../lib/helpers.nix {inherit lib;};
in
with lib; {
options = {
highlight = mkOption {
type = types.attrsOf types.anything;
default = {};
description = "Define highlight groups";
example = ''
highlight = {
Comment.fg = '#ff0000';
};
'';
};
match = mkOption {
type = types.attrsOf types.str;
default = {};
description = "Define match groups";
example = ''
match = {
ExtraWhitespace = '\\s\\+$';
};
'';
};
};
match = mkOption {
type = types.attrsOf types.str;
default = { };
description = "Define match groups";
example = ''
match = {
ExtraWhitespace = '\\s\\+$';
};
'';
};
};
config = mkIf (config.highlight != {} || config.match != {}) {
extraConfigLuaPost =
(optionalString (config.highlight != {}) ''
-- Highlight groups {{
do
local highlights = ${helpers.toLuaObject config.highlight}
config = mkIf (config.highlight != { } || config.match != { }) {
extraConfigLuaPost = (optionalString (config.highlight != { }) ''
-- Highlight groups {{
do
local highlights = ${helpers.toLuaObject config.highlight}
for k,v in pairs(highlights) do
vim.api.nvim_set_hl(0, k, v)
end
end
-- }}
'') +
(optionalString (config.match != { }) ''
-- Match groups {{
do
local match = ${helpers.toLuaObject config.match}
for k,v in pairs(match) do
vim.fn.matchadd(k, v)
for k,v in pairs(highlights) do
vim.api.nvim_set_hl(0, k, v)
end
end
end
-- }}
'');
};
}
-- }}
'')
+ (optionalString (config.match != {}) ''
-- Match groups {{
do
local match = ${helpers.toLuaObject config.match}
for k,v in pairs(match) do
vim.fn.matchadd(k, v)
end
end
-- }}
'');
};
}

View file

@ -1,7 +1,10 @@
{ config, lib, ... }:
with lib;
let
helpers = import ../lib/helpers.nix { inherit lib; };
{
config,
lib,
...
}:
with lib; let
helpers = import ../lib/helpers.nix {inherit lib;};
mapOption = types.oneOf [
types.str
@ -57,13 +60,13 @@ let
})
];
mapOptions = mode: mkOption {
description = "Mappings for ${mode} mode";
type = types.attrsOf mapOption;
default = { };
};
in
{
mapOptions = mode:
mkOption {
description = "Mappings for ${mode} mode";
type = types.attrsOf mapOption;
default = {};
};
in {
options = {
maps = mkOption {
type = types.submodule {
@ -82,7 +85,7 @@ in
command = mapOptions "command-line";
};
};
default = { };
default = {};
description = ''
Custom keybindings for any mode.
@ -101,32 +104,30 @@ in
};
};
config =
let
mappings =
(helpers.genMaps "" config.maps.normalVisualOp) ++
(helpers.genMaps "n" config.maps.normal) ++
(helpers.genMaps "i" config.maps.insert) ++
(helpers.genMaps "v" config.maps.visual) ++
(helpers.genMaps "x" config.maps.visualOnly) ++
(helpers.genMaps "s" config.maps.select) ++
(helpers.genMaps "t" config.maps.terminal) ++
(helpers.genMaps "o" config.maps.operator) ++
(helpers.genMaps "l" config.maps.lang) ++
(helpers.genMaps "!" config.maps.insertCommand) ++
(helpers.genMaps "c" config.maps.command);
in
{
extraConfigLua = optionalString (mappings != [ ]) ''
-- Set up keybinds {{{
do
local __nixvim_binds = ${helpers.toLuaObject mappings}
config = let
mappings =
(helpers.genMaps "" config.maps.normalVisualOp)
++ (helpers.genMaps "n" config.maps.normal)
++ (helpers.genMaps "i" config.maps.insert)
++ (helpers.genMaps "v" config.maps.visual)
++ (helpers.genMaps "x" config.maps.visualOnly)
++ (helpers.genMaps "s" config.maps.select)
++ (helpers.genMaps "t" config.maps.terminal)
++ (helpers.genMaps "o" config.maps.operator)
++ (helpers.genMaps "l" config.maps.lang)
++ (helpers.genMaps "!" config.maps.insertCommand)
++ (helpers.genMaps "c" config.maps.command);
in {
extraConfigLua = optionalString (mappings != []) ''
-- Set up keybinds {{{
do
local __nixvim_binds = ${helpers.toLuaObject mappings}
for i, map in ipairs(__nixvim_binds) do
vim.keymap.set(map.mode, map.key, map.action, map.config)
end
for i, map in ipairs(__nixvim_binds) do
vim.keymap.set(map.mode, map.key, map.action, map.config)
end
-- }}}
'';
};
end
-- }}}
'';
};
}

View file

@ -1,44 +1,48 @@
{ 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 = mkOption {
type = types.attrsOf types.anything;
default = { };
default = {};
description = "The configuration options, e.g. line numbers";
};
globals = mkOption {
type = types.attrsOf types.anything;
default = { };
default = {};
description = "Global variables";
};
};
config = {
extraConfigLuaPre = optionalString (config.globals != { }) ''
-- Set up globals {{{
do
local nixvim_globals = ${helpers.toLuaObject config.globals}
extraConfigLuaPre =
optionalString (config.globals != {}) ''
-- Set up globals {{{
do
local nixvim_globals = ${helpers.toLuaObject config.globals}
for k,v in pairs(nixvim_globals) do
vim.g[k] = v
for k,v in pairs(nixvim_globals) do
vim.g[k] = v
end
end
end
-- }}}
'' + optionalString (config.options != { }) ''
-- Set up options {{{
do
local nixvim_options = ${helpers.toLuaObject config.options}
-- }}}
''
+ optionalString (config.options != {}) ''
-- Set up options {{{
do
local nixvim_options = ${helpers.toLuaObject config.options}
for k,v in pairs(nixvim_options) do
vim.opt[k] = v
for k,v in pairs(nixvim_options) do
vim.opt[k] = v
end
end
end
-- }}}
'';
-- }}}
'';
};
}

View file

@ -1,6 +1,10 @@
{ pkgs, config, lib, ... }:
with lib;
let
{
pkgs,
config,
lib,
...
}:
with lib; let
pluginWithConfigType = types.submodule {
options = {
config = mkOption {
@ -9,9 +13,11 @@ let
default = "";
};
optional = mkEnableOption "optional" // {
description = "Don't load by default (load with :packadd)";
};
optional =
mkEnableOption "optional"
// {
description = "Don't load by default (load with :packadd)";
};
plugin = mkOption {
type = types.package;
@ -19,8 +25,7 @@ let
};
};
};
in
{
in {
options = {
viAlias = mkOption {
type = types.bool;
@ -46,13 +51,13 @@ in
extraPlugins = mkOption {
type = with types; listOf (either package pluginWithConfigType);
default = [ ];
default = [];
description = "List of vim plugins to install";
};
extraPackages = mkOption {
type = types.listOf types.package;
default = [ ];
default = [];
description = "Extra packages to be made available to neovim";
};
@ -74,7 +79,6 @@ in
description = "Extra contents for init.lua after everything else";
};
extraConfigVim = mkOption {
type = types.lines;
default = "";
@ -101,18 +105,23 @@ in
};
};
config =
let
config = let
defaultPlugin = {
plugin = null;
config = "";
optional = false;
};
defaultPlugin = {
plugin = null;
config = "";
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 customRC;
plugins = normalizedPlugins;
@ -121,44 +130,47 @@ in
# or more generally before the commit:
# cda1f8ae468 - neovim: pass packpath via the wrapper
// optionalAttrs (functionArgs pkgs.neovimUtils.makeNeovimConfig ? configure) {
configure.packages =
{ nixvim = { start = map (x: x.plugin) normalizedPlugins; opt = [ ]; }; };
configure.packages = {
nixvim = {
start = map (x: x.plugin) normalizedPlugins;
opt = [];
};
};
});
customRC =
''
vim.cmd([[
${neovimConfig.neovimRcContent}
]])
'' +
(optionalString (config.extraConfigLuaPre != "") ''
${config.extraConfigLuaPre}
'') +
(optionalString (config.extraConfigVim != "") ''
vim.cmd([[
${config.extraConfigVim}
]])
'') +
(optionalString (config.extraConfigLua != "" || config.extraConfigLuaPost != "") ''
${config.extraConfigLua}
${config.extraConfigLuaPost}
'');
customRC =
''
vim.cmd([[
${neovimConfig.neovimRcContent}
]])
''
+ (optionalString (config.extraConfigLuaPre != "") ''
${config.extraConfigLuaPre}
'')
+ (optionalString (config.extraConfigVim != "") ''
vim.cmd([[
${config.extraConfigVim}
]])
'')
+ (optionalString (config.extraConfigLua != "" || config.extraConfigLuaPost != "") ''
${config.extraConfigLua}
${config.extraConfigLuaPost}
'');
extraWrapperArgs = builtins.concatStringsSep " " (
(optional (config.extraPackages != [ ])
''--prefix PATH : "${makeBinPath config.extraPackages}"'')
++
(optional (config.wrapRc)
''--add-flags -u --add-flags "${pkgs.writeText "init.lua" customRC}"'')
);
extraWrapperArgs = builtins.concatStringsSep " " (
(optional (config.extraPackages != [])
''--prefix PATH : "${makeBinPath config.extraPackages}"'')
++ (optional (config.wrapRc)
''--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;
wrapRc = false;
});
in
{
finalPackage = wrappedNeovim;
initContent = customRC;
};
in {
finalPackage = wrappedNeovim;
initContent = customRC;
};
}

View file

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

View file

@ -1,7 +1,5 @@
{ lib, ... }:
with lib;
{
{lib, ...}:
with lib; {
options = {
warnings = mkOption {
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 = {
enable = mkEnableOption "barbar.nvim";
@ -65,24 +68,25 @@ in
highlightVisible = helpers.defaultNullOpts.mkBool true "Highlight visible buffers";
icons = {
enable = helpers.defaultNullOpts.mkNullable
(with types; (either bool (enum [ "numbers" "both" ])))
enable =
helpers.defaultNullOpts.mkNullable
(with types; (either bool (enum ["numbers" "both"])))
"true"
''
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
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
'';
customColors = helpers.defaultNullOpts.mkNullable
customColors =
helpers.defaultNullOpts.mkNullable
(types.either types.bool types.str)
"false"
''
If set, the icon color will follow its corresponding buffer
highlight group. By default, the Buffer*Icon group is linked to the
Buffer* group (see Highlighting below). Otherwise, it will take its
default value as defined by devicons.
If set, the icon color will follow its corresponding buffer
highlight group. By default, the Buffer*Icon group is linked to the
Buffer* group (see Highlighting below). Otherwise, it will take its
default value as defined by devicons.
'';
separatorActive = helpers.defaultNullOpts.mkStr "" "Icon for the active tab separator";
@ -122,7 +126,6 @@ in
But only a static string is accepted here.
'';
# Keybinds concept:
# keys = {
# previousBuffer = mkBindDef "normal" "Previous buffer" { action = ":BufferPrevious<CR>"; silent = true; } "<A-,>";
@ -182,16 +185,16 @@ in
tabpages = cfg.tabpages;
};
in
mkIf cfg.enable {
extraPlugins = with pkgs.vimPlugins; [
cfg.package
nvim-web-devicons
];
mkIf cfg.enable {
extraPlugins = with pkgs.vimPlugins; [
cfg.package
nvim-web-devicons
];
extraConfigLua = ''
require('bufferline').setup(${helpers.toLuaObject setupOptions})
'';
extraConfigLua = ''
require('bufferline').setup(${helpers.toLuaObject setupOptions})
'';
# maps = genMaps cfg.keys;
};
# maps = genMaps cfg.keys;
};
}

View file

@ -1,12 +1,16 @@
{ config, pkgs, lib, ... }@args:
with lib;
let
{
config,
pkgs,
lib,
...
} @ args:
with lib; let
cfg = config.plugins.bufferline;
optionWarnings = import ../../lib/option-warnings.nix args;
helpers = import ../helpers.nix args;
highlight = mkOption {
type = types.nullOr (types.submodule ({ ... }: {
type = types.nullOr (types.submodule ({...}: {
options = {
guifg = mkOption {
type = types.nullOr types.str;
@ -20,14 +24,13 @@ let
};
};
}));
default = { };
default = {};
};
in
{
in {
imports = [
(optionWarnings.mkDeprecatedOption {
option = [ "plugins" "bufferline" "indicatorIcon" ];
alternative = [ "plugins" "bufferline" "indicator" "icon" ];
option = ["plugins" "bufferline" "indicatorIcon"];
alternative = ["plugins" "bufferline" "indicator" "icon"];
})
];
@ -111,7 +114,7 @@ in
default = null;
};
diagnostics = mkOption {
type = types.nullOr (types.enum [ false "nvim_lsp" "coc" ]);
type = types.nullOr (types.enum [false "nvim_lsp" "coc"]);
default = null;
};
diagnosticsUpdateInInsert = mkOption {
@ -147,7 +150,7 @@ in
default = null;
};
separatorStyle = mkOption {
type = types.nullOr (types.enum [ "slant" "thick" "thin" ]);
type = types.nullOr (types.enum ["slant" "thick" "thin"]);
default = null;
};
enforceRegularTabs = mkOption {
@ -159,27 +162,27 @@ in
default = null;
};
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;
};
indicator = mkOption {
default = { };
type = types.nullOr (types.submodule ({ ... }: {
default = {};
type = types.nullOr (types.submodule ({...}: {
options = {
icon = mkOption {
type = types.nullOr types.str;
default = null;
};
style = mkOption {
type = types.nullOr (types.enum [ "icon" "underline" "none" ]);
type = types.nullOr (types.enum ["icon" "underline" "none"]);
default = null;
};
};
}));
};
highlights = mkOption {
default = { };
type = types.nullOr (types.submodule ({ ... }: {
default = {};
type = types.nullOr (types.submodule ({...}: {
options = {
fill = highlight;
background = highlight;
@ -246,16 +249,16 @@ in
extraOptions = mkOption {
type = types.attrs;
default = { };
default = {};
description = "Extra options, will override others if defined";
};
};
};
config =
let
setupOptions = {
options = {
config = let
setupOptions = {
options =
{
numbers = cfg.numbers;
close_command = cfg.closeCommand;
right_mouse_command = cfg.rightMouseCommand;
@ -264,10 +267,13 @@ in
# deprecated, but might still work
indicator_icon = cfg.indicatorIcon;
indicator =
if cfg.indicator != null then with cfg.indicator; {
icon = icon;
style = style;
} else null;
if cfg.indicator != null
then
with cfg.indicator; {
icon = icon;
style = style;
}
else null;
buffer_close_icon = cfg.bufferCloseIcon;
modified_icon = cfg.modifiedIcon;
close_icon = cfg.closeIcon;
@ -290,70 +296,74 @@ in
enforce_regular_tabs = cfg.enforceRegularTabs;
always_show_bufferline = cfg.alwaysShowBufferline;
sort_by = cfg.sortBy;
} // cfg.extraOptions;
highlights = if builtins.isNull cfg.highlights then null else with cfg.highlights; {
fill = fill;
background = background;
}
// cfg.extraOptions;
highlights =
if builtins.isNull cfg.highlights
then null
else
with cfg.highlights; {
fill = fill;
background = background;
tab = tab;
tab_selected = tabSelected;
tab_close = tabClose;
close_button = closeButton;
close_button_visible = closeButtonVisible;
close_button_selected = closeButtonSelected;
tab = tab;
tab_selected = tabSelected;
tab_close = tabClose;
close_button = closeButton;
close_button_visible = closeButtonVisible;
close_button_selected = closeButtonSelected;
buffer_visible = bufferVisible;
buffer_selected = bufferSelected;
buffer_visible = bufferVisible;
buffer_selected = bufferSelected;
diagnostic = diagnostic;
diagnostic_visible = diagnosticVisible;
diagnostic_selected = diagnosticSelected;
diagnostic = diagnostic;
diagnostic_visible = diagnosticVisible;
diagnostic_selected = diagnosticSelected;
info = info;
info_visible = infoVisible;
info_selected = infoSelected;
info = info;
info_visible = infoVisible;
info_selected = infoSelected;
info_diagnostic = infoDiagnostic;
info_diagnostic_visible = infoDiagnosticVisible;
info_diagnostic_selected = infoDiagnosticSelected;
info_diagnostic = infoDiagnostic;
info_diagnostic_visible = infoDiagnosticVisible;
info_diagnostic_selected = infoDiagnosticSelected;
warning = warning;
warning_visible = warningVisible;
warning_selected = warningSelected;
warning = warning;
warning_visible = warningVisible;
warning_selected = warningSelected;
warning_diagnostic = warningDiagnostic;
warning_diagnostic_visible = warningDiagnosticVisible;
warning_diagnostic_selected = warningDiagnosticSelected;
warning_diagnostic = warningDiagnostic;
warning_diagnostic_visible = warningDiagnosticVisible;
warning_diagnostic_selected = warningDiagnosticSelected;
error = error;
error_visible = errorVisible;
error_selected = errorSelected;
error = error;
error_visible = errorVisible;
error_selected = errorSelected;
error_dagnostic = errorDiagnostic;
error_diagnostic_visible = errorDiagnosticVisible;
error_diagnostic_selected = errorDiagnosticSelected;
error_dagnostic = errorDiagnostic;
error_diagnostic_visible = errorDiagnosticVisible;
error_diagnostic_selected = errorDiagnosticSelected;
modified = modified;
modified_visible = modifiedVisible;
modified_selected = modifiedSelected;
modified = modified;
modified_visible = modifiedVisible;
modified_selected = modifiedSelected;
duplicate = duplicate;
duplicate_visible = duplicateVisible;
duplicate_selected = duplicateSelected;
duplicate = duplicate;
duplicate_visible = duplicateVisible;
duplicate_selected = duplicateSelected;
separator = separator;
separator_visible = separatorVisible;
separator_selected = separatorSelected;
separator = separator;
separator_visible = separatorVisible;
separator_selected = separatorSelected;
indicator_selected = indicatorSelected;
indicator_selected = indicatorSelected;
pick = pick;
pick_visible = pickVisible;
pick_selected = pickSelected;
};
};
in
pick = pick;
pick_visible = pickVisible;
pick_selected = pickSelected;
};
};
in
mkIf cfg.enable {
extraPlugins = with pkgs.vimPlugins; [
cfg.package

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 = {
colorschemes.base16 = {
enable = mkEnableOption "base16";
@ -34,7 +37,7 @@ in
config = mkIf cfg.enable {
colorscheme = "base16-${cfg.colorscheme}";
extraPlugins = [ cfg.package ];
extraPlugins = [cfg.package];
plugins.airline.theme = mkIf (cfg.setUpBar) "base16";
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 = {
colorschemes.gruvbox = {
enable = mkEnableOption "gruvbox";
@ -18,13 +21,13 @@ in
undercurl = mkEnableOption "undercurled text";
contrastDark = mkOption {
type = types.nullOr (types.enum [ "soft" "medium" "hard" ]);
type = types.nullOr (types.enum ["soft" "medium" "hard"]);
default = null;
description = "Contrast for the dark mode";
};
contrastLight = mkOption {
type = types.nullOr (types.enum [ "soft" "medium" "hard" ]);
type = types.nullOr (types.enum ["soft" "medium" "hard"]);
default = null;
description = "Contrast for the light mode";
};
@ -110,13 +113,12 @@ in
transparentBg = mkEnableOption "transparent background";
trueColor = mkEnableOption "true color support";
};
};
config = mkIf cfg.enable {
colorscheme = "gruvbox";
extraPlugins = [ cfg.package ];
extraPlugins = [cfg.package];
globals = {
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 = {
colorschemes.nord = {
enable = mkEnableOption "nord";
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";
borders = mkEnableOption
borders =
mkEnableOption
"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";
cursorline_transparent = mkEnableOption
cursorline_transparent =
mkEnableOption
"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";
italic = mkOption {
@ -36,7 +44,7 @@ in
config = mkIf cfg.enable {
colorscheme = "nord";
extraPlugins = [ cfg.package ];
extraPlugins = [cfg.package];
globals = {
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 = {
colorschemes.one = {
enable = mkEnableOption "vim-one";
@ -15,7 +18,7 @@ in
config = mkIf cfg.enable {
colorscheme = "one";
extraPlugins = [ cfg.package ];
extraPlugins = [cfg.package];
options = {
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 = {
colorschemes.onedark = {
enable = mkEnableOption "onedark";
@ -15,7 +18,7 @@ in
config = mkIf cfg.enable {
colorscheme = "onedark";
extraPlugins = [ cfg.package ];
extraPlugins = [cfg.package];
options = {
termguicolors = true;

View file

@ -1,76 +1,72 @@
{ pkgs
, config
, lib
, ...
}@args:
{
pkgs,
config,
lib,
...
} @ args:
with lib; let
cfg = config.colorschemes.tokyonight;
helpers = import ../helpers.nix args;
in
{
in {
options = {
colorschemes.tokyonight = {
enable = mkEnableOption "tokyonight";
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 =
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";
styles =
let
mkBackgroundStyle = name:
helpers.defaultNullOpts.mkEnumFirstDefault [ "dark" "transparent" "normal" ]
"Background style for ${name}";
in
{
comments =
helpers.defaultNullOpts.mkNullable (types.attrsOf types.anything) "{italic = true;}"
"Define comments highlight properties";
keywords =
helpers.defaultNullOpts.mkNullable (types.attrsOf types.anything) "{italic = true;}"
"Define keywords highlight properties";
functions =
helpers.defaultNullOpts.mkNullable (types.attrsOf types.anything) "{}"
"Define functions highlight properties";
variables =
helpers.defaultNullOpts.mkNullable (types.attrsOf types.anything) "{}"
"Define variables highlight properties";
sidebars = mkBackgroundStyle "sidebars";
floats = mkBackgroundStyle "floats";
};
styles = let
mkBackgroundStyle = name:
helpers.defaultNullOpts.mkEnumFirstDefault ["dark" "transparent" "normal"]
"Background style for ${name}";
in {
comments =
helpers.defaultNullOpts.mkNullable (types.attrsOf types.anything) "{italic = true;}"
"Define comments highlight properties";
keywords =
helpers.defaultNullOpts.mkNullable (types.attrsOf types.anything) "{italic = true;}"
"Define keywords highlight properties";
functions =
helpers.defaultNullOpts.mkNullable (types.attrsOf types.anything) "{}"
"Define functions highlight properties";
variables =
helpers.defaultNullOpts.mkNullable (types.attrsOf types.anything) "{}"
"Define variables highlight properties";
sidebars = mkBackgroundStyle "sidebars";
floats = mkBackgroundStyle "floats";
};
sidebars =
helpers.defaultNullOpts.mkNullable (types.listOf types.str) ''["qf" "help"]''
"Set a darker background on sidebar-like windows";
"Set a darker background on sidebar-like windows";
dayBrightness =
helpers.defaultNullOpts.mkNullable (types.numbers.between 0.0 1.0) "0.3"
"Adjusts the brightness of the colors of the **Day** style";
"Adjusts the brightness of the colors of the **Day** style";
hideInactiveStatusline =
helpers.defaultNullOpts.mkBool false
"Enabling this option will hide inactive statuslines and replace them with a thin border";
"Enabling this option will hide inactive statuslines and replace them with a thin border";
dimInactive = helpers.defaultNullOpts.mkBool false "dims inactive windows";
lualineBold =
helpers.defaultNullOpts.mkBool false
"When true, section headers in the lualine theme will be bold";
"When true, section headers in the lualine theme will be bold";
};
};
config = mkIf cfg.enable {
colorscheme = "tokyonight";
extraPlugins = [ cfg.package ];
options = { termguicolors = true; };
extraConfigLuaPre =
let
setupOptions = with cfg; {
inherit (cfg) style transparent styles sidebars;
terminal_colors = terminalColors;
hide_inactive_statusline = hideInactiveStatusline;
dim_inactive = dimInactive;
lualine_bold = lualineBold;
day_brightness = dayBrightness;
};
in
''
require("tokyonight").setup(${helpers.toLuaObject setupOptions})
'';
extraPlugins = [cfg.package];
options = {termguicolors = true;};
extraConfigLuaPre = let
setupOptions = with cfg; {
inherit (cfg) style transparent styles sidebars;
terminal_colors = terminalColors;
hide_inactive_statusline = hideInactiveStatusline;
dim_inactive = dimInactive;
lualine_bold = lualineBold;
day_brightness = dayBrightness;
};
in ''
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 = {
plugins.copilot = {
enable = mkEnableOption "copilot";
@ -12,11 +15,11 @@ in
filetypes = mkOption {
type = types.attrsOf types.bool;
description = "A dictionary mapping file types to their enabled status";
default = { };
example = literalExpression ''{
"*": false,
python: true
}'';
default = {};
example = literalExpression '' {
"*": false,
python: true
}'';
};
proxy = mkOption {
type = types.nullOr types.str;
@ -27,12 +30,17 @@ in
};
};
config =
mkIf cfg.enable {
extraPlugins = [ cfg.package ];
globals = {
config = mkIf cfg.enable {
extraPlugins = [cfg.package];
globals =
{
copilot_node_command = "${pkgs.nodejs-16_x}/bin/node";
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 = {
plugins.coq-nvim = {
enable = mkEnableOption "coq-nvim";
@ -16,7 +18,7 @@ in
installArtifacts = mkEnableOption "Install coq-artifacts";
autoStart = mkOption {
type = with types; nullOr (oneOf [ bool (enum [ "shut-up" ]) ]);
type = with types; nullOr (oneOf [bool (enum ["shut-up"])]);
default = null;
description = "Auto-start or shut up";
};
@ -28,23 +30,24 @@ in
};
};
};
config =
let
settings = {
auto_start = cfg.autoStart;
"keymap.recommended" = cfg.recommendedKeymaps;
};
in
config = let
settings = {
auto_start = cfg.autoStart;
"keymap.recommended" = cfg.recommendedKeymaps;
};
in
mkIf cfg.enable {
extraPlugins = [
cfg.package
] ++ optional cfg.installArtifacts plugins.coq-artifacts;
extraPlugins =
[
cfg.package
]
++ optional cfg.installArtifacts plugins.coq-artifacts;
plugins.lsp = {
preConfig = ''
vim.g.coq_settings = ${helpers.toLuaObject settings}
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 = {
enable = mkEnableOption "lspkind.nvim";
package = helpers.mkPackageOption "lspkind" pkgs.vimPlugins.lspkind-nvim;
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;
description = "Defines how annotations are shown";
};
preset = mkOption {
type = with types; nullOr (enum [ "default" "codicons" ]);
type = with types; nullOr (enum ["default" "codicons"]);
default = null;
description = "Default symbol map";
};
@ -61,34 +64,41 @@ in
};
};
config =
let
doCmp = cfg.cmp.enable && config.plugins.nvim-cmp.enable;
options = {
config = let
doCmp = cfg.cmp.enable && config.plugins.nvim-cmp.enable;
options =
{
mode = cfg.mode;
preset = cfg.preset;
symbol_map = cfg.symbolMap;
} // (if doCmp then {
maxwidth = cfg.cmp.maxWidth;
ellipsis_char = cfg.cmp.ellipsisChar;
menu = cfg.cmp.menu;
} else { });
in
}
// (
if doCmp
then {
maxwidth = cfg.cmp.maxWidth;
ellipsis_char = cfg.cmp.ellipsisChar;
menu = cfg.cmp.menu;
}
else {}
);
in
mkIf cfg.enable {
extraPlugins = [ cfg.package ];
extraPlugins = [cfg.package];
extraConfigLua = optionalString (!doCmp) ''
require('lspkind').init(${helpers.toLuaObject options})
'';
plugins.nvim-cmp.formatting.format =
if cfg.cmp.after != null then ''
if cfg.cmp.after != null
then ''
function(entry, vim_item)
local kind = require('lspkind').cmp_format(${helpers.toLuaObject options})(entry, vim_item)
return (${cfg.cmp.after})(entry, vim_after, kind)
end
'' else ''
''
else ''
require('lspkind').cmp_format(${helpers.toLuaObject options})
'';
};

View file

@ -1,54 +1,64 @@
{ lib, pkgs, ... }@attrs:
let
helpers = import ../../helpers.nix { inherit lib; };
in with helpers; with lib;
{
mkCmpSourcePlugin = { name, extraPlugins ? [], useDefaultPackage ? true, ... }: mkPlugin attrs {
inherit name;
extraPlugins = extraPlugins ++ (lists.optional useDefaultPackage pkgs.vimPlugins.${name});
description = "Enable ${name}";
};
lib,
pkgs,
...
} @ attrs: let
helpers = import ../../helpers.nix {inherit lib;};
in
with helpers;
with lib; {
mkCmpSourcePlugin = {
name,
extraPlugins ? [],
useDefaultPackage ? true,
...
}:
mkPlugin attrs {
inherit name;
extraPlugins = extraPlugins ++ (lists.optional useDefaultPackage pkgs.vimPlugins.${name});
description = "Enable ${name}";
};
pluginAndSourceNames = {
"luasnip" = "cmp_luasnip";
"snippy" = "cmp-snippy";
"ultisnips" = "cmp-nvim-ultisnips";
"vsnip" = "cmp-vsnip";
"buffer" = "cmp-buffer";
"calc" = "cmp-calc";
"dictionary" = "cmp-dictionary";
"digraphs" = "cmp-digraphs";
"omni" = "cmp-omni";
"spell" = "cmp-spell";
"nvim_lsp" = "cmp-nvim-lsp";
"nvim_lsp_document_symbol" = "cmp-nvim-lsp-document-symbol";
"nvim_lsp_signature_help" = "cmp-nvim-lsp-signature-help";
"vim_lsp" = "cmp-vim-lsp";
"path" = "cmp-path";
"git" = "cmp-git";
"conventionalcommits" = "cmp-conventionalcommits";
"cmdline" = "cmp-cmdline";
"cmp-cmdline-history" = "cmp-cmdline-history";
"fuzzy_buffer" = "cmp-fuzzy-buffer";
"fuzzy_path" = "cmp-fuzzy-path";
"rg" = "cmp-rg";
"fish" = "cmp-fish";
"tmux" = "cmp-tmux";
"zsh" = "cmp-zsh";
"crates" = "crates-nvim";
"npm" = "cmp-npm";
"cmp-clippy" = "cmp-clippy";
"cmp_tabnine" = "cmp-tabnine";
"copilot" = "cmp-copilot";
"dap" = "cmp-dap";
"emoji" = "cmp-emoji";
"greek" = "cmp-greek";
"latex_symbols" = "cmp-latex-symbols";
"look" = "cmp-look";
"nvim_lua" = "cmp-nvim-lua";
"pandoc_references" = "cmp-pandoc-references";
"cmp_pandoc" = "cmp-pandoc-nvim";
"treesitter" = "cmp-treesitter";
"vimwiki-tags" = "cmp-vimwiki-tags";
};
}
pluginAndSourceNames = {
"luasnip" = "cmp_luasnip";
"snippy" = "cmp-snippy";
"ultisnips" = "cmp-nvim-ultisnips";
"vsnip" = "cmp-vsnip";
"buffer" = "cmp-buffer";
"calc" = "cmp-calc";
"dictionary" = "cmp-dictionary";
"digraphs" = "cmp-digraphs";
"omni" = "cmp-omni";
"spell" = "cmp-spell";
"nvim_lsp" = "cmp-nvim-lsp";
"nvim_lsp_document_symbol" = "cmp-nvim-lsp-document-symbol";
"nvim_lsp_signature_help" = "cmp-nvim-lsp-signature-help";
"vim_lsp" = "cmp-vim-lsp";
"path" = "cmp-path";
"git" = "cmp-git";
"conventionalcommits" = "cmp-conventionalcommits";
"cmdline" = "cmp-cmdline";
"cmp-cmdline-history" = "cmp-cmdline-history";
"fuzzy_buffer" = "cmp-fuzzy-buffer";
"fuzzy_path" = "cmp-fuzzy-path";
"rg" = "cmp-rg";
"fish" = "cmp-fish";
"tmux" = "cmp-tmux";
"zsh" = "cmp-zsh";
"crates" = "crates-nvim";
"npm" = "cmp-npm";
"cmp-clippy" = "cmp-clippy";
"cmp_tabnine" = "cmp-tabnine";
"copilot" = "cmp-copilot";
"dap" = "cmp-dap";
"emoji" = "cmp-emoji";
"greek" = "cmp-greek";
"latex_symbols" = "cmp-latex-symbols";
"look" = "cmp-look";
"nvim_lua" = "cmp-nvim-lua";
"pandoc_references" = "cmp-pandoc-references";
"cmp_pandoc" = "cmp-pandoc-nvim";
"treesitter" = "cmp-treesitter";
"vimwiki-tags" = "cmp-vimwiki-tags";
};
}

View file

@ -1,19 +1,20 @@
{ pkgs, config, lib, ... }@args:
with lib;
let
{
pkgs,
config,
lib,
...
} @ args:
with lib; let
cfg = config.plugins.nvim-cmp;
helpers = import ../../helpers.nix { inherit lib; };
helpers = import ../../helpers.nix {inherit lib;};
mkNullOrOption = helpers.mkNullOrOption;
cmpLib = import ./cmp-helpers.nix args;
# functionName should be a string
# parameters should be a list of strings
wrapWithFunction = functionName: parameters:
let
parameterString = strings.concatStringsSep "," parameters;
in
''${functionName}(${parameterString})'';
in
{
wrapWithFunction = functionName: parameters: let
parameterString = strings.concatStringsSep "," parameters;
in ''${functionName}(${parameterString})'';
in {
options.plugins.nvim-cmp = {
enable = mkEnableOption "nvim-cmp";
@ -21,7 +22,7 @@ in
performance = mkOption {
default = null;
type = types.nullOr (types.submodule ({ ... }: {
type = types.nullOr (types.submodule ({...}: {
options = {
debounce = mkOption {
type = types.nullOr types.int;
@ -36,14 +37,14 @@ in
};
preselect = mkOption {
type = types.nullOr (types.enum [ "Item" "None" ]);
type = types.nullOr (types.enum ["Item" "None"]);
default = null;
example = ''"Item"'';
};
snippet = mkOption {
default = null;
type = types.nullOr (types.submodule ({ ... }: {
type = types.nullOr (types.submodule ({...}: {
options = {
expand = mkOption {
type = types.nullOr types.str;
@ -61,7 +62,7 @@ in
};
mappingPresets = mkOption {
default = [ ];
default = [];
type = types.listOf (types.enum [
"insert"
"cmdline"
@ -75,7 +76,7 @@ in
mapping = mkOption {
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 = {
action = mkOption {
type = types.nonEmptyStr;
@ -116,7 +117,7 @@ in
completion = mkOption {
default = null;
type = types.nullOr (types.submodule ({ ... }: {
type = types.nullOr (types.submodule ({...}: {
options = {
keyword_length = mkOption {
default = null;
@ -145,7 +146,7 @@ in
confirmation = mkOption {
default = null;
type = types.nullOr (types.submodule ({ ... }: {
type = types.nullOr (types.submodule ({...}: {
options = {
get_commit_characters = mkOption {
default = null;
@ -158,7 +159,7 @@ in
formatting = mkOption {
default = null;
type = types.nullOr (types.submodule ({ ... }: {
type = types.nullOr (types.submodule ({...}: {
options = {
fields = mkOption {
default = null;
@ -176,7 +177,7 @@ in
matching = mkOption {
default = null;
type = types.nullOr (types.submodule ({ ... }: {
type = types.nullOr (types.submodule ({...}: {
options = {
disallow_fuzzy_matching = mkOption {
default = null;
@ -196,7 +197,7 @@ in
sorting = mkOption {
default = null;
type = types.nullOr (types.submodule ({ ... }: {
type = types.nullOr (types.submodule ({...}: {
options = {
priority_weight = mkOption {
default = null;
@ -218,54 +219,53 @@ in
'';
};
sources =
let
source_config = types.submodule ({ ... }: {
options = {
name = mkOption {
type = types.str;
description = "The name of the source.";
example = ''"buffer"'';
};
option = mkOption {
default = null;
type = with types; nullOr (attrsOf anything);
description = "If direct lua code is needed use helpers.mkRaw";
};
keyword_length = mkOption {
default = null;
type = types.nullOr types.int;
};
keyword_pattern = mkOption {
default = null;
type = types.nullOr types.int;
};
trigger_characters = mkOption {
default = null;
type = with types; nullOr (listOf str);
};
priority = mkOption {
default = null;
type = types.nullOr types.int;
};
max_item_count = mkOption {
default = null;
type = types.nullOr types.int;
};
group_index = mkOption {
default = null;
type = types.nullOr types.int;
};
sources = let
source_config = types.submodule ({...}: {
options = {
name = mkOption {
type = types.str;
description = "The name of the source.";
example = ''"buffer"'';
};
});
in
option = mkOption {
default = null;
type = with types; nullOr (attrsOf anything);
description = "If direct lua code is needed use helpers.mkRaw";
};
keyword_length = mkOption {
default = null;
type = types.nullOr types.int;
};
keyword_pattern = mkOption {
default = null;
type = types.nullOr types.int;
};
trigger_characters = mkOption {
default = null;
type = with types; nullOr (listOf str);
};
priority = mkOption {
default = null;
type = types.nullOr types.int;
};
max_item_count = mkOption {
default = null;
type = types.nullOr types.int;
};
group_index = mkOption {
default = null;
type = types.nullOr types.int;
};
};
});
in
mkOption {
default = null;
type = with types; nullOr (either (listOf source_config) (listOf (listOf source_config)));
@ -286,7 +286,7 @@ in
view = mkOption {
default = null;
type = types.nullOr (types.submodule ({ ... }: {
type = types.nullOr (types.submodule ({...}: {
options = {
entries = mkOption {
default = null;
@ -296,20 +296,19 @@ in
}));
};
window =
let
# Reusable options
border = with types; mkNullOrOption (either str (listOf str)) null;
winhighlight = mkNullOrOption types.str null;
zindex = mkNullOrOption types.int null;
in
window = let
# Reusable options
border = with types; mkNullOrOption (either str (listOf str)) null;
winhighlight = mkNullOrOption types.str null;
zindex = mkNullOrOption types.int null;
in
mkOption {
default = null;
type = types.nullOr (types.submodule ({ ... }: {
type = types.nullOr (types.submodule ({...}: {
options = {
completion = mkOption {
default = null;
type = types.nullOr (types.submodule ({ ... }: {
type = types.nullOr (types.submodule ({...}: {
options = {
inherit border winhighlight zindex;
col_offset = mkNullOrOption types.int "Offsets the completion window relative to the cursor";
@ -320,7 +319,7 @@ in
documentation = mkOption {
default = null;
type = types.nullOr (types.submodule ({ ... }: {
type = types.nullOr (types.submodule ({...}: {
options = {
inherit border winhighlight zindex;
max_width = mkNullOrOption types.int "Window's max width";
@ -336,68 +335,99 @@ in
experimental = mkNullOrOption types.attrs "Experimental features";
};
config =
let
options = {
enabled = cfg.enable;
performance = cfg.performance;
preselect = if (isNull cfg.preselect) then null else helpers.mkRaw "cmp.PreselectMode.${cfg.preselect}";
config = let
options = {
enabled = cfg.enable;
performance = cfg.performance;
preselect =
if (isNull cfg.preselect)
then null
else helpers.mkRaw "cmp.PreselectMode.${cfg.preselect}";
# Not very readable sorry
# If null then null
# 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.
mapping =
let
mappings =
if (isNull cfg.mapping) then null
else
mapAttrs
(bind: mapping: 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;
luaMappings = (helpers.toLuaObject mappings);
wrapped = lists.fold (presetName: prevString: ''cmp.mapping.preset.${presetName}(${prevString})'') luaMappings cfg.mappingPresets;
in
helpers.mkRaw wrapped;
# Not very readable sorry
# If null then null
# 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.
mapping = let
mappings =
if (isNull cfg.mapping)
then null
else
mapAttrs
(bind: mapping:
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;
luaMappings = helpers.toLuaObject mappings;
wrapped = lists.fold (presetName: prevString: ''cmp.mapping.preset.${presetName}(${prevString})'') luaMappings cfg.mappingPresets;
in
helpers.mkRaw wrapped;
snippet = {
expand = if (isNull cfg.snippet || isNull cfg.snippet.expand) then null else helpers.mkRaw cfg.snippet.expand;
};
snippet = {
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_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;
};
confirmation = if (isNull cfg.confirmation) then null else {
confirmation =
if (isNull cfg.confirmation)
then null
else {
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;
};
formatting = if (isNull cfg.formatting) then null else {
formatting =
if (isNull cfg.formatting)
then null
else {
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;
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;
view = cfg.view;
window = cfg.window;
experimental = cfg.experimental;
};
in
sources = cfg.sources;
view = cfg.view;
window = cfg.window;
experimental = cfg.experimental;
};
in
mkIf cfg.enable {
extraPlugins = [ cfg.package ];
extraPlugins = [cfg.package];
extraConfigLua = helpers.wrapDo ''
local cmp = require('cmp')
@ -406,21 +436,23 @@ in
# If auto_enable_sources is set to true, figure out which are provided by the user
# and enable the corresponding plugins.
plugins =
let
flattened_sources = if (isNull cfg.sources) then [ ] else flatten cfg.sources;
# Take only the names from the sources provided by the user
found_sources = lists.unique (lists.map (source: source.name) flattened_sources);
# A list of known source names
known_source_names = attrNames cmpLib.pluginAndSourceNames;
plugins = let
flattened_sources =
if (isNull cfg.sources)
then []
else flatten cfg.sources;
# Take only the names from the sources provided by the user
found_sources = lists.unique (lists.map (source: source.name) flattened_sources);
# A list of known source names
known_source_names = attrNames cmpLib.pluginAndSourceNames;
attrs_enabled = listToAttrs (map
(name: {
name = cmpLib.pluginAndSourceNames.${name};
value.enable = mkIf (elem name found_sources) true;
})
known_source_names);
in
attrs_enabled = listToAttrs (map
(name: {
name = cmpLib.pluginAndSourceNames.${name};
value.enable = mkIf (elem name found_sources) true;
})
known_source_names);
in
mkIf cfg.auto_enable_sources attrs_enabled;
};
}

View file

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

View file

@ -1,13 +1,18 @@
{ lib, pkgs, ... }@attrs:
let
helpers = import ../helpers.nix { inherit lib; };
in with helpers; with lib;
mkPlugin attrs {
name = "fugitive";
description = "Enable vim-fugitive";
package = pkgs.vimPlugins.vim-fugitive;
extraPackages = [ pkgs.git ];
{
lib,
pkgs,
...
} @ attrs: let
helpers = import ../helpers.nix {inherit lib;};
in
with helpers;
with lib;
mkPlugin attrs {
name = "fugitive";
description = "Enable vim-fugitive";
package = pkgs.vimPlugins.vim-fugitive;
extraPackages = [pkgs.git];
# In typical tpope fashin, this plugin has no config options
options = {};
}
# In typical tpope fashin, this plugin has no config 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 = {
plugins.gitgutter = {
enable = mkEnableOption "gitgutter";
@ -54,14 +57,14 @@ in
};
signs = mkOption {
type =
let
signOption = desc: mkOption {
type = let
signOption = desc:
mkOption {
type = types.nullOr types.str;
default = null;
description = "Sign for ${desc}";
};
in
in
types.submodule {
options = {
added = signOption "added lines";
@ -73,7 +76,7 @@ in
modifiedRemoved = signOption "modified and removed lines";
};
};
default = { };
default = {};
description = "Custom signs for the sign column";
};
@ -166,20 +169,25 @@ in
};
};
config =
let
grepPackage = if builtins.isAttrs cfg.grep then [ cfg.grep.package ] else [ ];
grepCommand = if builtins.isAttrs cfg.grep then cfg.grep.command else cfg.grep;
in
config = let
grepPackage =
if builtins.isAttrs cfg.grep
then [cfg.grep.package]
else [];
grepCommand =
if builtins.isAttrs cfg.grep
then cfg.grep.command
else cfg.grep;
in
mkIf cfg.enable {
extraPlugins = [ cfg.package ];
extraPlugins = [cfg.package];
options = mkIf cfg.recommendedSettings {
updatetime = 100;
foldtext = "gitgutter#fold#foldtext";
};
extraPackages = [ pkgs.git ] ++ grepPackage;
extraPackages = [pkgs.git] ++ grepPackage;
globals = {
gitgutter_max_signs = mkIf (!isNull cfg.maxSigns) cfg.maxSigns;

View file

@ -1,12 +1,12 @@
{ pkgs
, lib
, config
, ...
{
pkgs,
lib,
config,
...
} @ args:
with lib; let
helpers = import ../helpers.nix args;
in
{
in {
options.plugins.gitmessenger = {
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
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
showing up. "current" includes diff hunks of only current file in the commit. "all" includes
all diff hunks in the commit.
@ -26,10 +26,10 @@ in
'';
gitCommand =
helpers.defaultNullOpts.mkStr "git"
"git command to retrieve commit messages.";
"git command to retrieve commit messages.";
noDefaultMappings =
helpers.defaultNullOpts.mkBool false
"When this value is set, it does not define any key mappings";
"When this value is set, it does not define any key mappings";
intoPopupAfterShow = helpers.defaultNullOpts.mkBool true ''
When this value is set to v:false, running :GitMessenger or <plug>(git-messenger) again after
showing a popup does not move the cursor in the window.
@ -91,12 +91,11 @@ in
'';
};
config =
let
cfg = config.plugins.gitmessenger;
in
config = let
cfg = config.plugins.gitmessenger;
in
mkIf cfg.enable {
extraPlugins = [ cfg.package ];
extraPlugins = [cfg.package];
globals = {
git_messenger_close_on_cursor_moved = cfg.closeOnCursorMoved;
git_messenger_include_diff = cfg.includeDiff;

View file

@ -1,26 +1,27 @@
{ config
, lib
, pkgs
, ...
{
config,
lib,
pkgs,
...
} @ args:
with lib; let
helpers = import ../helpers.nix args;
signOptions = defaults: {
hl =
helpers.defaultNullOpts.mkStr defaults.hl
"Specifies the highlight group to use for the sign";
"Specifies the highlight group to use for the sign";
text =
helpers.defaultNullOpts.mkStr defaults.text
"Specifies the character to use for the sign";
"Specifies the character to use for the sign";
numhl =
helpers.defaultNullOpts.mkStr defaults.numhl
"Specifies the highlight group to use for the number column";
"Specifies the highlight group to use for the number column";
linehl =
helpers.defaultNullOpts.mkStr defaults.linehl
"Specifies the highlight group to use for the line";
"Specifies the highlight group to use for the line";
showCount =
helpers.defaultNullOpts.mkBool false
"showing count of hunk, e.g. number of deleted lines";
"showing count of hunk, e.g. number of deleted lines";
};
signSetupOptions = values: {
inherit (values) hl text numhl linehl;
@ -33,8 +34,7 @@ with lib; let
description = "Lua function definition";
};
};
in
{
in {
options.plugins.gitsigns = {
enable = mkEnableOption "Enable gitsigns plugin";
package = helpers.mkPackageOption "gitsigns" pkgs.vimPlugins.gitsigns-nvim;
@ -76,19 +76,18 @@ in
linehl = "GitSignsAddLn";
};
};
worktrees =
let
worktreeModule = {
options = {
toplevel = mkOption {
type = types.str;
};
gitdir = mkOption {
type = types.str;
};
worktrees = let
worktreeModule = {
options = {
toplevel = mkOption {
type = types.str;
};
gitdir = mkOption {
type = types.str;
};
};
in
};
in
mkOption {
type = types.nullOr (types.listOf (types.submodule worktreeModule));
default = null;
@ -126,25 +125,25 @@ in
watchGitDir = {
enable =
helpers.defaultNullOpts.mkBool true
"Whether the watcher is enabled";
"Whether the watcher is enabled";
interval =
helpers.defaultNullOpts.mkInt 1000
"Interval the watcher waits between polls of the gitdir in milliseconds";
"Interval the watcher waits between polls of the gitdir in milliseconds";
followFiles =
helpers.defaultNullOpts.mkBool true
"If a file is moved with `git mv`, switch the buffer to the new location";
"If a file is moved with `git mv`, switch the buffer to the new location";
};
signPriority =
helpers.defaultNullOpts.mkInt 6
"Priority to use for signs";
"Priority to use for signs";
signcolumn =
helpers.defaultNullOpts.mkBool true
''
Enable/disable symbols in the sign column.
''
Enable/disable symbols in the sign column.
When enabled the highlights defined in `signs.*.hl` and symbols defined
in `signs.*.text` are used.
'';
When enabled the highlights defined in `signs.*.hl` and symbols defined
in `signs.*.text` are used.
'';
numhl = helpers.defaultNullOpts.mkBool false ''
line number highlights.
@ -164,33 +163,32 @@ in
Note: Virtual lines currently use the highlight `GitSignsDeleteVirtLn`.
'';
diffOpts =
let
diffOptModule = {
options = {
algorithm =
helpers.defaultNullOpts.mkEnumFirstDefault [ "myers" "minimal" "patience" "histogram" ]
"Diff algorithm to use";
internal =
helpers.defaultNullOpts.mkBool false
"Use Neovim's built in xdiff library for running diffs";
indentHeuristic =
helpers.defaultNullOpts.mkBool false
"Use the indent heuristic for the internal diff library.";
vertical =
helpers.defaultNullOpts.mkBool true
"Start diff mode with vertical splits";
linematch = mkOption {
type = types.nullOr types.int;
default = null;
description = ''
Enable second-stage diff on hunks to align lines.
Requires `internal=true`.
'';
};
diffOpts = let
diffOptModule = {
options = {
algorithm =
helpers.defaultNullOpts.mkEnumFirstDefault ["myers" "minimal" "patience" "histogram"]
"Diff algorithm to use";
internal =
helpers.defaultNullOpts.mkBool false
"Use Neovim's built in xdiff library for running diffs";
indentHeuristic =
helpers.defaultNullOpts.mkBool false
"Use the indent heuristic for the internal diff library.";
vertical =
helpers.defaultNullOpts.mkBool true
"Start diff mode with vertical splits";
linematch = mkOption {
type = types.nullOr types.int;
default = null;
description = ''
Enable second-stage diff on hunks to align lines.
Requires `internal=true`.
'';
};
};
in
};
in
mkOption {
type = types.nullOr (types.submodule diffOptModule);
default = null;
@ -240,7 +238,7 @@ in
'' "Function used to format `b:gitsigns_status`";
maxFileLength =
helpers.defaultNullOpts.mkInt 40000
"Max file length (in lines) to attach to";
"Max file length (in lines) to attach to";
previewConfig =
helpers.defaultNullOpts.mkNullable (types.attrsOf types.anything) ''
{
@ -256,34 +254,34 @@ in
'';
attachToUntracked =
helpers.defaultNullOpts.mkBool true
"Attach to untracked files.";
"Attach to untracked files.";
updateDebounce =
helpers.defaultNullOpts.mkInt 100
"Debounce time for updates (in milliseconds).";
"Debounce time for updates (in milliseconds).";
currentLineBlame = helpers.defaultNullOpts.mkBool false ''
Adds an unobtrusive and customisable blame annotation at the end of the current line.
'';
currentLineBlameOpts = {
virtText =
helpers.defaultNullOpts.mkBool true
"Whether to show a virtual text blame annotation";
"Whether to show a virtual text blame annotation";
virtTextPos =
helpers.defaultNullOpts.mkEnumFirstDefault [ "eol" "overlay" "right_align" ]
"Blame annotation position";
helpers.defaultNullOpts.mkEnumFirstDefault ["eol" "overlay" "right_align"]
"Blame annotation position";
delay =
helpers.defaultNullOpts.mkInt 1000
"Sets the delay (in milliseconds) before blame virtual text is displayed";
"Sets the delay (in milliseconds) before blame virtual text is displayed";
ignoreWhitespace =
helpers.defaultNullOpts.mkBool false
"Ignore whitespace when running blame";
"Ignore whitespace when running blame";
virtTextPriority =
helpers.defaultNullOpts.mkInt 100
"Priority of virtual text";
"Priority of virtual text";
};
currentLineBlameFormatter = {
normal =
helpers.defaultNullOpts.mkNullable (types.either types.str luaFunction)
''" <author>, <author_time> - <summary>"'' ''
''" <author>, <author_time> - <summary>"'' ''
String or function used to format the virtual text of
|gitsigns-config-current_line_blame|.
@ -292,7 +290,7 @@ in
nonCommitted =
helpers.defaultNullOpts.mkNullable (types.either types.str luaFunction)
''" <author>"'' ''
''" <author>"'' ''
String or function used to format the virtual text of
|gitsigns-config-current_line_blame| for lines that aren't committed.
'';
@ -316,89 +314,83 @@ in
'';
};
config =
let
cfg = config.plugins.gitsigns;
in
config = let
cfg = config.plugins.gitsigns;
in
mkIf cfg.enable {
extraPlugins = [ cfg.package ];
extraConfigLua =
let
luaFnOrStrToObj = val:
if val == null
then null
else if builtins.isString val
then val
else { __raw = val.function; };
setupOptions = {
inherit (cfg) worktrees signcolumn numhl linehl trouble yadm;
signs = mapAttrs (_: signSetupOptions) cfg.signs;
on_attach =
if cfg.onAttach != null
then { __raw = cfg.onAttach.function; }
else null;
watch_gitdir = {
inherit (cfg.watchGitDir) enable interval;
follow_files = cfg.watchGitDir.followFiles;
};
sign_priority = cfg.signPriority;
show_deleted = cfg.showDeleted;
diff_opts =
if cfg.diffOpts == null
then null
else {
inherit (cfg.diffOpts) algorithm internal vertical linematch;
indent_heuristic = cfg.diffOpts.indentHeuristic;
};
count_chars =
let
isStrInt = s: (builtins.match "[0-9]+" s) != null;
in
if cfg.countChars != null
then {
__raw =
"{"
+ (concatStringsSep "," (
lib.mapAttrsToList
(
name: value:
if isStrInt name
then "[${name}] = ${helpers.toLuaObject value}"
else "[${helpers.toLuaObject name}] = ${helpers.toLuaObject value}"
)
cfg.countChars
))
+ "}";
}
else null;
status_formatter =
if cfg.statusFormatter != null
then { __raw = cfg.statusFormatter.function; }
else null;
max_file_length = cfg.maxFileLength;
preview_config = cfg.previewConfig;
attach_to_untracked = cfg.attachToUntracked;
update_debounce = cfg.updateDebounce;
current_line_blame = cfg.currentLineBlame;
current_line_blame_opts =
let
cfgCl = cfg.currentLineBlameOpts;
in
{
inherit (cfgCl) delay;
virt_text = cfgCl.virtText;
virt_text_pos = cfgCl.virtTextPos;
ignore_whitespace = cfgCl.ignoreWhitespace;
virt_text_priority = cfgCl.virtTextPriority;
};
current_line_blame_formatter = luaFnOrStrToObj cfg.currentLineBlameFormatter.normal;
current_line_blame_formatter_nc = luaFnOrStrToObj cfg.currentLineBlameFormatter.nonCommitted;
word_diff = cfg.wordDiff;
debug_mode = cfg.debugMode;
extraPlugins = [cfg.package];
extraConfigLua = let
luaFnOrStrToObj = val:
if val == null
then null
else if builtins.isString val
then val
else {__raw = val.function;};
setupOptions = {
inherit (cfg) worktrees signcolumn numhl linehl trouble yadm;
signs = mapAttrs (_: signSetupOptions) cfg.signs;
on_attach =
if cfg.onAttach != null
then {__raw = cfg.onAttach.function;}
else null;
watch_gitdir = {
inherit (cfg.watchGitDir) enable interval;
follow_files = cfg.watchGitDir.followFiles;
};
in
''
require('gitsigns').setup(${helpers.toLuaObject setupOptions})
'';
sign_priority = cfg.signPriority;
show_deleted = cfg.showDeleted;
diff_opts =
if cfg.diffOpts == null
then null
else {
inherit (cfg.diffOpts) algorithm internal vertical linematch;
indent_heuristic = cfg.diffOpts.indentHeuristic;
};
count_chars = let
isStrInt = s: (builtins.match "[0-9]+" s) != null;
in
if cfg.countChars != null
then {
__raw =
"{"
+ (concatStringsSep "," (
lib.mapAttrsToList
(
name: value:
if isStrInt name
then "[${name}] = ${helpers.toLuaObject value}"
else "[${helpers.toLuaObject name}] = ${helpers.toLuaObject value}"
)
cfg.countChars
))
+ "}";
}
else null;
status_formatter =
if cfg.statusFormatter != null
then {__raw = cfg.statusFormatter.function;}
else null;
max_file_length = cfg.maxFileLength;
preview_config = cfg.previewConfig;
attach_to_untracked = cfg.attachToUntracked;
update_debounce = cfg.updateDebounce;
current_line_blame = cfg.currentLineBlame;
current_line_blame_opts = let
cfgCl = cfg.currentLineBlameOpts;
in {
inherit (cfgCl) delay;
virt_text = cfgCl.virtText;
virt_text_pos = cfgCl.virtTextPos;
ignore_whitespace = cfgCl.ignoreWhitespace;
virt_text_priority = cfgCl.virtTextPriority;
};
current_line_blame_formatter = luaFnOrStrToObj cfg.currentLineBlameFormatter.normal;
current_line_blame_formatter_nc = luaFnOrStrToObj cfg.currentLineBlameFormatter.nonCommitted;
word_diff = cfg.wordDiff;
debug_mode = cfg.debugMode;
};
in ''
require('gitsigns').setup(${helpers.toLuaObject setupOptions})
'';
};
}

View file

@ -1,8 +1,12 @@
{ config, lib, pkgs, ... }:
with lib;
let
{
config,
lib,
pkgs,
...
}:
with lib; let
cfg = config.plugins.neogit;
helpers = import ../helpers.nix { inherit lib; };
helpers = import ../helpers.nix {inherit lib;};
sectionDefaultsModule = types.submodule {
options = {
@ -12,8 +16,7 @@ let
};
};
};
in
{
in {
options = {
plugins.neogit = {
enable = mkEnableOption "neogit";
@ -72,7 +75,7 @@ in
};
};
};
default = { };
default = {};
};
kind = mkOption {
@ -104,7 +107,7 @@ in
};
};
};
default = { };
default = {};
};
integrations = mkOption {
@ -118,7 +121,7 @@ in
};
};
};
default = { };
default = {};
};
sections = mkOption {
@ -162,7 +165,7 @@ in
};
};
};
default = { };
default = {};
};
mappings = mkOption {
@ -198,14 +201,14 @@ in
};
};
};
default = { };
default = {};
};
};
};
config =
let
setupOptions = with cfg; helpers.toLuaObject {
config = let
setupOptions = with cfg;
helpers.toLuaObject {
inherit kind integrations signs sections mappings;
disable_signs = disableSigns;
disable_hint = disableHint;
@ -216,14 +219,16 @@ in
use_magit_keybindings = useMagitKeybindings;
commit_popup = commitPopup;
};
in
in
mkIf cfg.enable {
extraPlugins = with pkgs.vimPlugins; [
cfg.package
plenary-nvim
] ++ optional cfg.integrations.diffview diffview-nvim;
extraPlugins = with pkgs.vimPlugins;
[
cfg.package
plenary-nvim
]
++ optional cfg.integrations.diffview diffview-nvim;
extraPackages = [ pkgs.git ];
extraPackages = [pkgs.git];
extraConfigLua = ''
require('neogit').setup(${setupOptions})

View file

@ -17,7 +17,7 @@ in
options.plugins.clangd-extensions = {
enable = mkEnableOption "clangd_extensions, plugin implementing clangd LSP extensions";
package =
package =
helpers.mkPackageOption "clangd_extensions.nvim" pkgs.vimPlugins.clangd_extensions-nvim;
enableOffsetEncodingWorkaround = mkEnableOption ''

View file

@ -1,33 +1,38 @@
{ pkgs, lib, ... }@args:
with lib; with import ../helpers.nix { inherit lib; };
mkPlugin args {
name = "ledger";
description = "Enable ledger language features";
package = pkgs.vimPlugins.vim-ledger;
{
pkgs,
lib,
...
} @ args:
with lib;
with import ../helpers.nix {inherit lib;};
mkPlugin args {
name = "ledger";
description = "Enable ledger language features";
package = pkgs.vimPlugins.vim-ledger;
options = {
maxWidth = mkDefaultOpt {
global = "ledger_maxwidth";
description = "Number of columns to display foldtext";
type = types.int;
};
options = {
maxWidth = mkDefaultOpt {
global = "ledger_maxwidth";
description = "Number of columns to display foldtext";
type = types.int;
};
fillString = mkDefaultOpt {
global = "ledger_fillstring";
description = "String used to fill the space between account name and amount in the foldtext";
type = types.int;
};
fillString = mkDefaultOpt {
global = "ledger_fillstring";
description = "String used to fill the space between account name and amount in the foldtext";
type = types.int;
};
detailedFirst = mkDefaultOpt {
global = "ledger_detailed_first";
description = "Account completion sorted by depth instead of alphabetically";
type = types.bool;
};
detailedFirst = mkDefaultOpt {
global = "ledger_detailed_first";
description = "Account completion sorted by depth instead of alphabetically";
type = types.bool;
};
foldBlanks = mkDefaultOpt {
global = "ledger_fold_blanks";
description = "Hide blank lines following a transaction on a fold";
type = types.bool;
foldBlanks = mkDefaultOpt {
global = "ledger_fold_blanks";
description = "Hide blank lines following a transaction on a fold";
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 = {
plugins.markdown-preview = {
enable = mkEnableOption "markdown-preview";
@ -54,7 +57,7 @@ in
uml = helpers.defaultNullOpts.mkNullable (types.listOf types.str) "[]" "markdown-it-plantuml options";
maid = helpers.defaultNullOpts.mkNullable (types.listOf types.str) "[]" "mermaid options";
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:
- "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.
@ -86,18 +89,17 @@ in
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.
'';
};
};
config =
let
previewOptions = mapAttrs (name: value: cfg.previewOptions.${name}) cfg.previewOptions;
in
config = let
previewOptions = mapAttrs (name: value: cfg.previewOptions.${name}) cfg.previewOptions;
in
mkIf cfg.enable {
extraPlugins = [ cfg.package ];
extraPlugins = [cfg.package];
globals = {
mkdp_auto_start = mkIf (!isNull cfg.autoStart) cfg.autoStart;
@ -109,7 +111,7 @@ in
mkdp_browser = mkIf (!isNull cfg.browser) cfg.browser;
mkdp_echo_preview_url = mkIf (!isNull cfg.echoPreviewUrl) cfg.echoPreviewUrl;
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_highlight_css = mkIf (!isNull cfg.highlightCss) cfg.highlightCss;
mkdp_port = mkIf (!isNull cfg.port) cfg.port;

View file

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

View file

@ -1,11 +1,11 @@
{ pkgs
, lib
, config
, ...
{
pkgs,
lib,
config,
...
}:
with lib;
let
helpers = import ../helpers.nix { inherit lib; };
with lib; let
helpers = import ../helpers.nix {inherit lib;};
in {
options.plugins.plantuml-syntax = {
enable = mkEnableOption "plantuml syntax support";
@ -24,12 +24,11 @@ in {
};
};
config =
let
cfg = config.plugins.plantuml-syntax;
in
config = let
cfg = config.plugins.plantuml-syntax;
in
mkIf cfg.enable {
extraPlugins = [ cfg.package ];
extraPlugins = [cfg.package];
globals = {
plantuml_set_makeprg = cfg.setMakeprg;

View file

@ -1,233 +1,221 @@
{ pkgs
, config
, lib
, ...
{
pkgs,
config,
lib,
...
}:
with lib;
let
helpers = import ../helpers.nix { inherit lib; };
with lib; let
helpers = import ../helpers.nix {inherit lib;};
in {
options.plugins.rust-tools =
let
mkNullableOptionWithDefault =
{ type
, description
, default
,
}:
mkOption {
type = types.nullOr type;
default = null;
description = ''
${description}
default: `${default}`
'';
};
mkNullableBoolDefault = default: description:
mkNullableOptionWithDefault {
inherit description;
type = types.bool;
default = toString default;
};
mkNullableStrDefault = default: description:
mkNullableOptionWithDefault {
inherit description;
type = types.str;
default = ''"${default}"'';
};
mkNullableIntDefault = default: description:
mkNullableOptionWithDefault {
inherit description;
type = types.int;
default = toString default;
};
in
{
enable = mkEnableOption "rust tools plugins";
package = helpers.mkPackageOption "rust-tools" pkgs.vimPlugins.rust-tools-nvim;
serverPackage = mkOption {
type = types.package;
default = pkgs.rust-analyzer;
description = "Package to use for rust-analyzer";
};
executor = mkNullableOptionWithDefault {
type = types.enum [ "termopen" "quickfix" ];
default = ''"termopen"'';
description = "how to execute terminal commands";
};
onIntialized = mkOption {
type = types.nullOr types.str;
options.plugins.rust-tools = let
mkNullableOptionWithDefault = {
type,
description,
default,
}:
mkOption {
type = types.nullOr type;
default = null;
description = ''
Callback to execute once rust-analyzer is done initializing the workspace
The callback receives one parameter indicating the `health` of the server:
"ok" | "warning" | "error"
${description}
default: `${default}`
'';
};
reloadWorkspaceFromCargoToml = mkNullableBoolDefault true ''
Automatically call RustReloadWorkspace when writing to a Cargo.toml file.
mkNullableBoolDefault = default: description:
mkNullableOptionWithDefault {
inherit description;
type = types.bool;
default = toString default;
};
mkNullableStrDefault = default: description:
mkNullableOptionWithDefault {
inherit description;
type = types.str;
default = ''"${default}"'';
};
mkNullableIntDefault = default: description:
mkNullableOptionWithDefault {
inherit description;
type = types.int;
default = toString default;
};
in {
enable = mkEnableOption "rust tools plugins";
package = helpers.mkPackageOption "rust-tools" pkgs.vimPlugins.rust-tools-nvim;
serverPackage = mkOption {
type = types.package;
default = pkgs.rust-analyzer;
description = "Package to use for rust-analyzer";
};
executor = mkNullableOptionWithDefault {
type = types.enum ["termopen" "quickfix"];
default = ''"termopen"'';
description = "how to execute terminal commands";
};
onIntialized = mkOption {
type = types.nullOr types.str;
default = null;
description = ''
Callback to execute once rust-analyzer is done initializing the workspace
The callback receives one parameter indicating the `health` of the server:
"ok" | "warning" | "error"
'';
};
reloadWorkspaceFromCargoToml = mkNullableBoolDefault true ''
Automatically call RustReloadWorkspace when writing to a Cargo.toml file.
'';
inlayHints = {
auto = mkNullableBoolDefault true "automatically set inlay hints (type hints)";
onlyCurrentLine = mkNullableBoolDefault false "Only show for current line";
showParameterHints =
mkNullableBoolDefault true
"whether to show parameter hints with the inlay hints or not";
parameterHintsPrefix = mkNullableStrDefault "<- " "prefix for parameter hints";
otherHintsPrefix = mkNullableStrDefault "=> " "prefix for all the other hints (type, chaining)";
maxLenAlign =
mkNullableBoolDefault false
"whether to align to the length of the longest line in the file";
maxLenAlignPadding = mkNullableIntDefault 1 "padding from the left if max_len_align is true";
rightAlign = mkNullableBoolDefault false "whether to align to the extreme right or not";
rightAlignPadding = mkNullableIntDefault 7 "padding from the right if right_align is true";
highlight = mkNullableStrDefault "Comment" "The color of the hints";
};
hoverActions = {
border = mkOption {
type = types.nullOr types.anything;
default = null;
description = ''
the border that is used for the hover window. see vim.api.nvim_open_win()
'';
};
maxWidth = mkOption {
type = types.nullOr types.int;
default = null;
description = "Maximal width of the hover window. Nil means no max.";
};
maxHeight = mkOption {
type = types.nullOr types.int;
default = null;
description = "Maximal height of the hover window. Nil means no max.";
};
autoFocus = mkNullableBoolDefault false "whether the hover action window gets automatically focused";
};
crateGraph = {
backend = mkNullableStrDefault "x11" ''
Backend used for displaying the graph
see: https://graphviz.org/docs/outputs/
'';
inlayHints = {
auto = mkNullableBoolDefault true "automatically set inlay hints (type hints)";
onlyCurrentLine = mkNullableBoolDefault false "Only show for current line";
showParameterHints =
mkNullableBoolDefault true
"whether to show parameter hints with the inlay hints or not";
parameterHintsPrefix = mkNullableStrDefault "<- " "prefix for parameter hints";
otherHintsPrefix = mkNullableStrDefault "=> " "prefix for all the other hints (type, chaining)";
maxLenAlign =
mkNullableBoolDefault false
"whether to align to the length of the longest line in the file";
maxLenAlignPadding = mkNullableIntDefault 1 "padding from the left if max_len_align is true";
rightAlign = mkNullableBoolDefault false "whether to align to the extreme right or not";
rightAlignPadding = mkNullableIntDefault 7 "padding from the right if right_align is true";
highlight = mkNullableStrDefault "Comment" "The color of the hints";
output = mkOption {
type = types.nullOr types.str;
default = null;
description = "where to store the output, nil for no output stored";
};
hoverActions = {
border = mkOption {
type = types.nullOr types.anything;
default = null;
description = ''
the border that is used for the hover window. see vim.api.nvim_open_win()
'';
};
full = mkNullableBoolDefault true ''
true for all crates.io and external crates, false only the local crates
'';
maxWidth = mkOption {
type = types.nullOr types.int;
default = null;
description = "Maximal width of the hover window. Nil means no max.";
};
maxHeight = mkOption {
type = types.nullOr types.int;
default = null;
description = "Maximal height of the hover window. Nil means no max.";
};
autoFocus = mkNullableBoolDefault false "whether the hover action window gets automatically focused";
};
crateGraph = {
backend = mkNullableStrDefault "x11" ''
Backend used for displaying the graph
see: https://graphviz.org/docs/outputs/
enabledGraphvizBackends = mkOption {
type = types.nullOr (types.listOf types.str);
default = null;
description = ''
List of backends found on: https://graphviz.org/docs/outputs/
Is used for input validation and autocompletion
'';
output = mkOption {
type = types.nullOr types.str;
default = null;
description = "where to store the output, nil for no output stored";
};
full = mkNullableBoolDefault true ''
true for all crates.io and external crates, false only the local crates
'';
enabledGraphvizBackends = mkOption {
type = types.nullOr (types.listOf types.str);
default = null;
description = ''
List of backends found on: https://graphviz.org/docs/outputs/
Is used for input validation and autocompletion
'';
};
};
server =
{
standalone = mkNullableBoolDefault true ''
standalone file support
setting it to false may improve startup time
'';
}
// (import ../nvim-lsp/rust-analyzer-config.nix lib);
};
config =
let
cfg = config.plugins.rust-tools;
in
server =
{
standalone = mkNullableBoolDefault true ''
standalone file support
setting it to false may improve startup time
'';
}
// (import ../nvim-lsp/rust-analyzer-config.nix lib);
};
config = let
cfg = config.plugins.rust-tools;
in
mkIf cfg.enable {
extraPlugins = with pkgs.vimPlugins; [ nvim-lspconfig cfg.package ];
extraPackages = [ cfg.serverPackage ];
extraPlugins = with pkgs.vimPlugins; [nvim-lspconfig cfg.package];
extraPackages = [cfg.serverPackage];
plugins.lsp.postConfig =
let
setupOptions = {
tools = {
executor =
if cfg.executor != null
then { __raw = ''require("rust-tools.executors").${cfg.executor}''; }
else null;
plugins.lsp.postConfig = let
setupOptions = {
tools = {
executor =
if cfg.executor != null
then {__raw = ''require("rust-tools.executors").${cfg.executor}'';}
else null;
on_initialized =
if cfg.onIntialized != null
then { __raw = cfg.onIntialized; }
else null;
on_initialized =
if cfg.onIntialized != null
then {__raw = cfg.onIntialized;}
else null;
reload_workspace_from_cargo_toml = cfg.reloadWorkspaceFromCargoToml;
inlay_hints =
let
cfgIH = cfg.inlayHints;
in
{
auto = cfgIH.auto;
only_current_line = cfgIH.onlyCurrentLine;
show_parameter_hints = cfgIH.showParameterHints;
parameter_hints_prefix = cfgIH.parameterHintsPrefix;
other_hints_prefix = cfgIH.otherHintsPrefix;
max_len_align = cfgIH.maxLenAlign;
max_len_align_padding = cfgIH.maxLenAlignPadding;
right_align = cfgIH.rightAlign;
right_align_padding = cfgIH.rightAlignPadding;
highlight = cfgIH.highlight;
};
hover_actions =
let
cfgHA = cfg.hoverActions;
in
{
border = cfgHA.border;
max_width = cfgHA.maxWidth;
max_height = cfgHA.maxHeight;
auto_focus = cfgHA.autoFocus;
};
crate_graph =
let
cfgCG = cfg.crateGraph;
in
{
backend = cfgCG.backend;
output = cfgCG.output;
full = cfgCG.full;
enabled_graphviz_backends = cfgCG.enabledGraphvizBackends;
};
reload_workspace_from_cargo_toml = cfg.reloadWorkspaceFromCargoToml;
inlay_hints = let
cfgIH = cfg.inlayHints;
in {
auto = cfgIH.auto;
only_current_line = cfgIH.onlyCurrentLine;
show_parameter_hints = cfgIH.showParameterHints;
parameter_hints_prefix = cfgIH.parameterHintsPrefix;
other_hints_prefix = cfgIH.otherHintsPrefix;
max_len_align = cfgIH.maxLenAlign;
max_len_align_padding = cfgIH.maxLenAlignPadding;
right_align = cfgIH.rightAlign;
right_align_padding = cfgIH.rightAlignPadding;
highlight = cfgIH.highlight;
};
server = {
standalone = cfg.server.standalone;
settings.rust-analyzer = lib.filterAttrs (n: v: n != "standalone") cfg.server;
on_attach = { __raw = "__lspOnAttach"; };
hover_actions = let
cfgHA = cfg.hoverActions;
in {
border = cfgHA.border;
max_width = cfgHA.maxWidth;
max_height = cfgHA.maxHeight;
auto_focus = cfgHA.autoFocus;
};
crate_graph = let
cfgCG = cfg.crateGraph;
in {
backend = cfgCG.backend;
output = cfgCG.output;
full = cfgCG.full;
enabled_graphviz_backends = cfgCG.enabledGraphvizBackends;
};
};
in
''
require('rust-tools').setup(${helpers.toLuaObject setupOptions})
'';
server = {
standalone = cfg.server.standalone;
settings.rust-analyzer = lib.filterAttrs (n: v: n != "standalone") cfg.server;
on_attach = {__raw = "__lspOnAttach";};
};
};
in ''
require('rust-tools').setup(${helpers.toLuaObject setupOptions})
'';
};
}

View file

@ -1,35 +1,32 @@
{ pkgs
, lib
, config
, ...
}:
let
cfg = config.plugins.tagbar;
helpers = import ../helpers.nix { inherit lib; };
in
with lib;
{
options.plugins.tagbar = {
pkgs,
lib,
config,
...
}: let
cfg = config.plugins.tagbar;
helpers = import ../helpers.nix {inherit lib;};
in
with lib; {
options.plugins.tagbar = {
enable = mkEnableOption "tagbar";
enable = mkEnableOption "tagbar";
package = helpers.mkPackageOption "tagbar" pkgs.vimPlugins.tagbar;
package = helpers.mkPackageOption "tagbar" pkgs.vimPlugins.tagbar;
extraConfig = helpers.mkNullOrOption types.attrs ''
The configuration options for tagbar without the 'tagbar_' prefix.
Example: To set 'tagbar_show_tag_count' to 1, write
extraConfig = {
show_tag_count= true;
};
'';
};
extraConfig = helpers.mkNullOrOption types.attrs ''
The configuration options for tagbar without the 'tagbar_' prefix.
Example: To set 'tagbar_show_tag_count' to 1, write
extraConfig = {
show_tag_count= true;
};
'';
};
config = mkIf cfg.enable {
extraPlugins = [cfg.package];
config = mkIf cfg.enable {
extraPackages = [pkgs.ctags];
extraPlugins = [ cfg.package ];
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
, config
, ...
{
pkgs,
lib,
config,
...
}:
with lib;
let
helpers = import ../helpers.nix { inherit lib; };
with lib; let
helpers = import ../helpers.nix {inherit lib;};
in {
options.plugins.treesitter-context = {
enable = mkEnableOption "nvim-treesitter-context";
@ -19,7 +19,7 @@ in {
};
trimScope = mkOption {
type = types.enum [ "outer" "inner" ];
type = types.enum ["outer" "inner"];
default = "outer";
description = "Which context lines to discard if `max_lines` is exceeded";
};
@ -32,7 +32,7 @@ in {
patterns = mkOption {
type = types.attrsOf (types.listOf types.str);
default = { };
default = {};
description = ''
Patterns to use for context delimitation. The 'default' key matches all filetypes
'';
@ -40,17 +40,16 @@ in {
exactPatterns = mkOption {
type = types.attrsOf types.bool;
default = { };
default = {};
description = "Treat the coresponding entry in patterns as an exact match";
};
};
config =
let
cfg = config.plugins.treesitter-context;
in
config = let
cfg = config.plugins.treesitter-context;
in
mkIf cfg.enable {
extraPlugins = [ cfg.package ];
extraPlugins = [cfg.package];
plugins.treesitter.moduleConfig.context = {
max_lines = cfg.maxLines;

View file

@ -1,114 +1,110 @@
{ pkgs
, config
, lib
, ...
}:
with lib;
let
helpers = import ../helpers.nix { inherit lib; };
in
{
options.plugins.treesitter-refactor =
let
disable = mkOption {
type = types.listOf types.str;
default = [ ];
description = "List of languages to disable the module on";
};
in
{
pkgs,
config,
lib,
...
}:
with lib; let
helpers = import ../helpers.nix {inherit lib;};
in {
options.plugins.treesitter-refactor = let
disable = mkOption {
type = types.listOf types.str;
default = [];
description = "List of languages to disable the module on";
};
in {
enable =
mkEnableOption
"treesitter-refactor (requires plugins.treesitter.enable to be true)";
package = helpers.mkPackageOption "treesitter-refactor" pkgs.vimPlugins.nvim-treesitter-refactor;
highlightDefinitions = {
inherit disable;
enable =
mkEnableOption
"treesitter-refactor (requires plugins.treesitter.enable to be true)";
package = helpers.mkPackageOption "treesitter-refactor" pkgs.vimPlugins.nvim-treesitter-refactor;
highlightDefinitions = {
inherit disable;
enable =
mkEnableOption
"Highlights definition and usages of the current symbol under the cursor.";
clearOnCursorMove = mkOption {
type = types.bool;
default = true;
description = ''
Controls if highlights should be cleared when the cursor is moved. If your 'updatetime'
is around `100` you can set this to false to have a less laggy experience.
'';
};
};
highlightCurrentScope = {
inherit disable;
enable = mkEnableOption "highlights the block from the current scope where the cursor is.";
};
smartRename = {
inherit disable;
enable =
mkEnableOption
"Renames the symbol under the cursor within the current scope (and current file).";
keymaps = {
smartRename = mkOption {
type = types.nullOr types.str;
default = "grr";
description = "rename symbol under the cursor";
};
};
};
navigation = {
inherit disable;
enable = mkEnableOption ''
Provides "go to definition" for the symbol under the cursor,
and lists the definitions from the current file.
"Highlights definition and usages of the current symbol under the cursor.";
clearOnCursorMove = mkOption {
type = types.bool;
default = true;
description = ''
Controls if highlights should be cleared when the cursor is moved. If your 'updatetime'
is around `100` you can set this to false to have a less laggy experience.
'';
keymaps = {
gotoDefinition = mkOption {
type = types.nullOr types.str;
default = "gnd";
description = "go to the definition of the symbol under the cursor";
};
gotoDefinitionLspFallback = mkOption {
type = types.nullOr types.str;
default = null;
description = ''
go to the definition of the symbol under the cursor or use vim.lsp.buf.definition if
the symbol can not be resolved. You can use your own fallback function if create a
mapping fo `lua require'nvim-treesitter.refactor.navigation(nil, fallback_function)<cr>`.
'';
};
listDefinitons = mkOption {
type = types.nullOr types.str;
default = "gnD";
description = "list all definitions from the current file";
};
listDefinitonsToc = mkOption {
type = types.nullOr types.str;
default = "gO";
description = ''
list all definitions from the current file like a table of contents (similar to the one
you see when pressing |gO| in help files).
'';
};
gotoNextUsage = mkOption {
type = types.nullOr types.str;
default = "<a-*>";
description = "go to next usage of identifier under the cursor";
};
gotoPreviousUsage = mkOption {
type = types.nullOr types.str;
default = "<a-#>";
description = "go to previous usage of identifier";
};
};
};
highlightCurrentScope = {
inherit disable;
enable = mkEnableOption "highlights the block from the current scope where the cursor is.";
};
smartRename = {
inherit disable;
enable =
mkEnableOption
"Renames the symbol under the cursor within the current scope (and current file).";
keymaps = {
smartRename = mkOption {
type = types.nullOr types.str;
default = "grr";
description = "rename symbol under the cursor";
};
};
};
navigation = {
inherit disable;
enable = mkEnableOption ''
Provides "go to definition" for the symbol under the cursor,
and lists the definitions from the current file.
'';
config =
let
cfg = config.plugins.treesitter-refactor;
in
keymaps = {
gotoDefinition = mkOption {
type = types.nullOr types.str;
default = "gnd";
description = "go to the definition of the symbol under the cursor";
};
gotoDefinitionLspFallback = mkOption {
type = types.nullOr types.str;
default = null;
description = ''
go to the definition of the symbol under the cursor or use vim.lsp.buf.definition if
the symbol can not be resolved. You can use your own fallback function if create a
mapping fo `lua require'nvim-treesitter.refactor.navigation(nil, fallback_function)<cr>`.
'';
};
listDefinitons = mkOption {
type = types.nullOr types.str;
default = "gnD";
description = "list all definitions from the current file";
};
listDefinitonsToc = mkOption {
type = types.nullOr types.str;
default = "gO";
description = ''
list all definitions from the current file like a table of contents (similar to the one
you see when pressing |gO| in help files).
'';
};
gotoNextUsage = mkOption {
type = types.nullOr types.str;
default = "<a-*>";
description = "go to next usage of identifier under the cursor";
};
gotoPreviousUsage = mkOption {
type = types.nullOr types.str;
default = "<a-#>";
description = "go to previous usage of identifier";
};
};
};
};
config = let
cfg = config.plugins.treesitter-refactor;
in
mkIf cfg.enable {
extraPlugins = [ cfg.package ];
extraPlugins = [cfg.package];
plugins.treesitter.moduleConfig.refactor = {
highlight_definitions = {
@ -118,22 +114,20 @@ in
highlight_current_scope = cfg.highlightCurrentScope;
smart_rename = {
inherit (cfg.smartRename) enable disable;
keymaps = { smart_rename = cfg.smartRename.keymaps.smartRename; };
keymaps = {smart_rename = cfg.smartRename.keymaps.smartRename;};
};
navigation = {
inherit (cfg.navigation) enable disable;
keymaps =
let
cfgK = cfg.navigation.keymaps;
in
{
goto_definition = cfgK.gotoDefinition;
goto_definition_lsp_fallback = cfgK.gotoDefinitionLspFallback;
list_definitions = cfgK.listDefinitons;
list_definitions_toc = cfgK.listDefinitonsToc;
goto_next_usage = cfgK.gotoNextUsage;
goto_previous_usage = cfgK.gotoPreviousUsage;
};
keymaps = let
cfgK = cfg.navigation.keymaps;
in {
goto_definition = cfgK.gotoDefinition;
goto_definition_lsp_fallback = cfgK.gotoDefinitionLspFallback;
list_definitions = cfgK.listDefinitons;
list_definitions_toc = cfgK.listDefinitonsToc;
goto_next_usage = cfgK.gotoNextUsage;
goto_previous_usage = cfgK.gotoPreviousUsage;
};
};
};
};

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 = {
plugins.treesitter = {
enable = mkEnableOption "tree-sitter syntax highlighting";
@ -22,7 +25,7 @@ in
};
ensureInstalled = mkOption {
type = with types; oneOf [ (enum [ "all" ]) (listOf str) ];
type = with types; oneOf [(enum ["all"]) (listOf str)];
default = "all";
description = "Either \"all\" or a list of languages";
};
@ -32,8 +35,7 @@ in
default =
if cfg.nixGrammars
then null
else "$XDG_DATA_HOME/nvim/treesitter"
;
else "$XDG_DATA_HOME/nvim/treesitter";
description = ''
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!
@ -42,38 +44,37 @@ in
ignoreInstall = mkOption {
type = types.listOf types.str;
default = [ ];
default = [];
description = "List of parsers to ignore installing (for \"all\")";
};
disabledLanguages = mkOption {
type = types.listOf types.str;
default = [ ];
default = [];
description = "A list of languages to disable";
};
customCaptures = mkOption {
type = types.attrsOf types.str;
default = { };
default = {};
description = "Custom capture group highlighting";
};
incrementalSelection =
let
keymap = default: mkOption {
incrementalSelection = let
keymap = default:
mkOption {
type = types.str;
inherit default;
};
in
{
enable = mkEnableOption "incremental selection based on the named nodes from the grammar";
keymaps = {
initSelection = keymap "gnn";
nodeIncremental = keymap "grn";
scopeIncremental = keymap "grc";
nodeDecremental = keymap "grm";
};
in {
enable = mkEnableOption "incremental selection based on the named nodes from the grammar";
keymaps = {
initSelection = keymap "gnn";
nodeIncremental = keymap "grn";
scopeIncremental = keymap "grc";
nodeDecremental = keymap "grm";
};
};
indent = mkEnableOption "tree-sitter based indentation";
@ -87,24 +88,31 @@ in
moduleConfig = mkOption {
type = types.attrsOf types.anything;
default = { };
default = {};
description = "This is the configuration for extra modules. It should not be used directly";
};
};
};
config =
let
tsOptions = {
config = let
tsOptions =
{
highlight = {
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 =
if cfg.incrementalSelection.enable then {
if cfg.incrementalSelection.enable
then {
enable = true;
keymaps = {
init_selection = cfg.incrementalSelection.keymaps.initSelection;
@ -112,29 +120,39 @@ in
scope_incremental = cfg.incrementalSelection.keymaps.scopeIncremental;
node_decremental = cfg.incrementalSelection.keymaps.nodeDecremental;
};
} else null;
}
else null;
indent =
if cfg.indent then {
if cfg.indent
then {
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;
parser_install_dir = cfg.parserInstallDir;
} // cfg.moduleConfig;
in
}
// cfg.moduleConfig;
in
mkIf cfg.enable {
extraConfigLua = (optionalString (cfg.parserInstallDir != null) ''
vim.opt.runtimepath:append("${cfg.parserInstallDir}")
'') + ''
require('nvim-treesitter.configs').setup(${helpers.toLuaObject tsOptions})
'';
extraConfigLua =
(optionalString (cfg.parserInstallDir != null) ''
vim.opt.runtimepath:append("${cfg.parserInstallDir}")
'')
+ ''
require('nvim-treesitter.configs').setup(${helpers.toLuaObject tsOptions})
'';
extraPlugins = with pkgs; if cfg.nixGrammars then
[ (cfg.package.withPlugins (_: cfg.grammarPackages)) ]
else [ cfg.package ];
extraPackages = [ pkgs.tree-sitter pkgs.nodejs ];
extraPlugins = with pkgs;
if cfg.nixGrammars
then [(cfg.package.withPlugins (_: cfg.grammarPackages))]
else [cfg.package];
extraPackages = [pkgs.tree-sitter pkgs.nodejs];
options = mkIf cfg.folding {
foldmethod = "expr";
@ -142,4 +160,3 @@ in
};
};
}

View file

@ -1,42 +1,40 @@
{ pkgs
, lib
, config
, ...
}:
let
cfg = config.plugins.vimtex;
helpers = import ../helpers.nix { inherit lib; };
in
with lib;
{
options.plugins.vimtex = {
pkgs,
lib,
config,
...
}: let
cfg = config.plugins.vimtex;
helpers = import ../helpers.nix {inherit lib;};
in
with lib; {
options.plugins.vimtex = {
enable = mkEnableOption "vimtex";
enable = mkEnableOption "vimtex";
package = helpers.mkPackageOption "vimtex" pkgs.vimPlugins.vimtex;
package = helpers.mkPackageOption "vimtex" pkgs.vimPlugins.vimtex;
extraConfig = helpers.mkNullOrOption types.attrs ''
The configuration options for vimtex without the 'vimtex_' prefix.
Example: To set 'vimtex_compiler_enabled' to 1, write
extraConfig = {
compiler_enabled = true;
};
'';
};
config =
let
globals = {
enabled = cfg.enable;
} // cfg.extraConfig;
in
mkIf cfg.enable {
extraPlugins = [ cfg.package ];
# Usefull for inverse search
extraPackages = with pkgs; [ pstree xdotool ];
globals = mapAttrs' (name: value: nameValuePair ("vimtex_" + name) value) globals;
extraConfig = helpers.mkNullOrOption types.attrs ''
The configuration options for vimtex without the 'vimtex_' prefix.
Example: To set 'vimtex_compiler_enabled' to 1, write
extraConfig = {
compiler_enabled = true;
};
'';
};
}
config = let
globals =
{
enabled = cfg.enable;
}
// cfg.extraConfig;
in
mkIf cfg.enable {
extraPlugins = [cfg.package];
# Usefull for inverse search
extraPackages = with pkgs; [pstree xdotool];
globals = mapAttrs' (name: value: nameValuePair ("vimtex_" + name) value) globals;
};
}

View file

@ -1,18 +1,23 @@
{ lib, pkgs, ... }@attrs:
let
helpers = import ../helpers.nix { inherit lib; };
in with helpers; with lib;
mkPlugin attrs {
name = "zig";
description = "Enable zig";
package = pkgs.vimPlugins.zig-vim;
{
lib,
pkgs,
...
} @ attrs: let
helpers = import ../helpers.nix {inherit lib;};
in
with helpers;
with lib;
mkPlugin attrs {
name = "zig";
description = "Enable zig";
package = pkgs.vimPlugins.zig-vim;
# Possibly add option to disable Treesitter highlighting if this is installed
options = {
formatOnSave = mkDefaultOpt {
type = types.bool;
global = "zig_fmt_autosave";
description = "Run zig fmt on save";
};
};
}
# Possibly add option to disable Treesitter highlighting if this is installed
options = {
formatOnSave = mkDefaultOpt {
type = types.bool;
global = "zig_fmt_autosave";
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 = [
./servers.nix
];
@ -36,15 +39,14 @@ in
# };
};
config =
let
options = {
debug = cfg.debug;
sources = cfg.sourcesItems;
};
in
config = let
options = {
debug = cfg.debug;
sources = cfg.sourcesItems;
};
in
mkIf cfg.enable {
extraPlugins = [ cfg.package ];
extraPlugins = [cfg.package];
extraConfigLua = ''
require("null-ls").setup(${helpers.toLuaObject options})

View file

@ -1,30 +1,41 @@
{ pkgs, config, lib, ... }:
{
mkServer =
{ name
, sourceType
, description ? "${name} source, for null-ls."
, package ? null
, extraPackages ? [ ]
, ...
}:
# returns a module
{ pkgs, config, lib, ... }@args:
with lib;
let
helpers = import ../helpers.nix args;
cfg = config.plugins.null-ls.sources.${sourceType}.${name};
# does this evaluate package?
packageOption = if package == null then { } else {
pkgs,
config,
lib,
...
}: {
mkServer = {
name,
sourceType,
description ? "${name} source, for null-ls.",
package ? null,
extraPackages ? [],
...
}:
# returns a module
{
pkgs,
config,
lib,
...
} @ args:
with lib; let
helpers = import ../helpers.nix args;
cfg = config.plugins.null-ls.sources.${sourceType}.${name};
# does this evaluate package?
packageOption =
if package == null
then {}
else {
package = mkOption {
type = types.package;
default = package;
description = "Package to use for ${name} by null-ls";
};
};
in
{
options.plugins.null-ls.sources.${sourceType}.${name} = {
in {
options.plugins.null-ls.sources.${sourceType}.${name} =
{
enable = mkEnableOption description;
# 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" } }'\'
# '';
};
} // packageOption;
}
// packageOption;
config = mkIf cfg.enable {
# Does this evaluate package?
extraPackages = extraPackages ++ optional (package != null) cfg.package;
config = mkIf cfg.enable {
# Does this evaluate package?
extraPackages = extraPackages ++ optional (package != null) cfg.package;
# Add source to list of sources
plugins.null-ls.sourcesItems =
let
sourceItem = "${sourceType}.${name}";
withArgs = if (isNull cfg.withArgs) then sourceItem else "${sourceItem}.with ${cfg.withArgs}";
finalString = ''require("null-ls").builtins.${withArgs}'';
in
[ (helpers.mkRaw finalString) ];
};
# Add source to list of sources
plugins.null-ls.sourcesItems = let
sourceItem = "${sourceType}.${name}";
withArgs =
if (isNull cfg.withArgs)
then sourceItem
else "${sourceItem}.with ${cfg.withArgs}";
finalString = ''require("null-ls").builtins.${withArgs}'';
in [(helpers.mkRaw finalString)];
};
};
}

View file

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

View file

@ -1,13 +1,17 @@
{ pkgs, config, lib, ... }@args:
with lib;
let
{
pkgs,
config,
lib,
...
} @ args:
with lib; let
helpers = import ./helpers.nix args;
servers = [
{
name = "astro";
description = "Enable astrols, for Astro";
package = pkgs.nodePackages."@astrojs/language-server";
cmd = cfg: [ "${cfg.package}/bin/astro-ls" "--stdio" ];
cmd = cfg: ["${cfg.package}/bin/astro-ls" "--stdio"];
}
{
name = "bashls";
@ -23,7 +27,7 @@ let
name = "cssls";
description = "Enable cssls, for CSS";
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";
@ -70,7 +74,7 @@ let
'';
};
renameFilesWithClasses = mkOption {
type = types.nullOr (types.enum [ "always" "prompt" ]);
type = types.nullOr (types.enum ["always" "prompt"]);
default = null;
description = ''
When set to "always", will include edits to rename files when classes are renamed if the
@ -98,7 +102,7 @@ let
'';
};
documentation = mkOption {
type = types.nullOr (types.enum [ "none" "summary" "full" ]);
type = types.nullOr (types.enum ["none" "summary" "full"]);
default = null;
description = ''
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";
@ -125,13 +129,13 @@ let
name = "eslint";
description = "Enable eslint";
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";
description = "Enable elixirls";
package = pkgs.elixir_ls;
cmd = cfg: [ "${cfg.package}/bin/elixir-ls" ];
cmd = cfg: ["${cfg.package}/bin/elixir-ls"];
}
{
name = "gdscript";
@ -146,13 +150,13 @@ let
name = "html";
description = "Enable html, for HTML";
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";
description = "Enable jsonls, for JSON";
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";
@ -170,7 +174,7 @@ let
diagnostics = {
ignored = mkOption {
type = types.listOf types.str;
default = [ ];
default = [];
description = ''
Ignored diagnostic kinds.
The kind identifier is a snake_cased_string usually shown together
@ -179,7 +183,7 @@ let
};
excludedFiles = mkOption {
type = types.listOf types.str;
default = [ ];
default = [];
description = ''
Files to exclude from showing diagnostics. Useful for generated files.
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";
@ -205,7 +209,7 @@ let
serverName = "rust_analyzer";
settingsOptions = import ./rust-analyzer-config.nix lib;
settings = cfg: { rust-analyzer = cfg; };
settings = cfg: {rust-analyzer = cfg;};
}
{
name = "sumneko-lua";
@ -240,10 +244,9 @@ let
name = "hls";
description = "Enable 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;
}

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 = [
./basic-servers.nix
];
@ -14,24 +17,25 @@ in
enable = mkEnableOption "neovim's built-in LSP";
enabledServers = mkOption {
type = with types; listOf (oneOf [
str
(submodule {
options = {
name = mkOption {
type = str;
description = "The server's name";
};
type = with types;
listOf (oneOf [
str
(submodule {
options = {
name = mkOption {
type = str;
description = "The server's name";
};
extraOptions = mkOption {
type = attrs;
description = "Extra options for the server";
extraOptions = mkOption {
type = attrs;
description = "Extra options for the server";
};
};
};
})
]);
})
]);
description = "A list of enabled LSP servers. Don't use this directly.";
default = [ ];
default = [];
};
onAttach = mkOption {
@ -43,7 +47,7 @@ in
setupWrappers = mkOption {
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.";
default = [ ];
default = [];
};
preConfig = mkOption {
@ -60,14 +64,14 @@ in
};
};
config =
let
runWrappers = wrappers: s:
if wrappers == [ ] then s
else (head wrappers) (runWrappers (tail wrappers) s);
in
config = let
runWrappers = wrappers: s:
if wrappers == []
then s
else (head wrappers) (runWrappers (tail wrappers) s);
in
mkIf cfg.enable {
extraPlugins = [ pkgs.vimPlugins.nvim-lspconfig ];
extraPlugins = [pkgs.vimPlugins.nvim-lspconfig];
# Enable all LSP servers
extraConfigLua = ''

View file

@ -1,51 +1,65 @@
{ pkgs, config, lib, ... }:
{
mkLsp =
{ name
, description ? "Enable ${name}."
, serverName ? name
, package ? pkgs.${name}
, extraPackages ? { }
, cmd ? (cfg: null)
, settings ? (cfg: { })
, settingsOptions ? { }
, ...
}:
# returns a module
{ pkgs, config, lib, ... }:
with lib;
let
cfg = config.plugins.lsp.servers.${name};
pkgs,
config,
lib,
...
}: {
mkLsp = {
name,
description ? "Enable ${name}.",
serverName ? name,
package ? pkgs.${name},
extraPackages ? {},
cmd ? (cfg: null),
settings ? (cfg: {}),
settingsOptions ? {},
...
}:
# returns a module
{
pkgs,
config,
lib,
...
}:
with lib; let
cfg = config.plugins.lsp.servers.${name};
packageOption =
if package != null then {
package = mkOption {
default = package;
type = types.nullOr types.package;
};
} else { };
in
{
options = {
plugins.lsp.servers.${name} = {
packageOption =
if package != null
then {
package = mkOption {
default = package;
type = types.nullOr types.package;
};
}
else {};
in {
options = {
plugins.lsp.servers.${name} =
{
enable = mkEnableOption description;
settings = settingsOptions;
} // packageOption;
};
}
// packageOption;
};
config = mkIf cfg.enable
{
extraPackages = (optional (package != null) cfg.package) ++
(mapAttrsToList (name: _: cfg."${name}Package") extraPackages);
config =
mkIf cfg.enable
{
extraPackages =
(optional (package != null) cfg.package)
++ (mapAttrsToList (name: _: cfg."${name}Package") extraPackages);
plugins.lsp.enabledServers = [{
plugins.lsp.enabledServers = [
{
name = serverName;
extraOptions = {
cmd = cmd cfg;
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 = {
plugins.lsp-lines = {
enable = mkEnableOption "lsp_lines.nvim";
@ -19,24 +22,25 @@ in
};
};
config =
let
diagnosticConfig = {
virtual_text = false;
virtual_lines =
if cfg.currentLine then {
only_current_line = true;
} else true;
};
in
config = let
diagnosticConfig = {
virtual_text = false;
virtual_lines =
if cfg.currentLine
then {
only_current_line = true;
}
else true;
};
in
mkIf cfg.enable {
extraPlugins = [ cfg.package ];
extraPlugins = [cfg.package];
extraConfigLua = ''
do
require("lsp_lines").setup()
vim.diagnostic.config(${ helpers.toLuaObject diagnosticConfig })
vim.diagnostic.config(${helpers.toLuaObject diagnosticConfig})
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 = {
plugins.lspsaga = {
enable = mkEnableOption "lspsaga.nvim";
@ -107,32 +110,31 @@ in
description = "Maximum finder preview lines";
};
keys =
let
defaultKeyOpt = desc: mkOption {
keys = let
defaultKeyOpt = desc:
mkOption {
description = desc;
type = types.nullOr types.str;
default = null;
};
in
{
finderAction = {
open = defaultKeyOpt "Open from finder";
vsplit = defaultKeyOpt "Vertical split in finder";
split = defaultKeyOpt "Horizontal split in finder";
quit = defaultKeyOpt "Quit finder";
scrollDown = defaultKeyOpt "Scroll down finder";
scrollUp = defaultKeyOpt "Scroll up finder";
};
codeAction = {
quit = defaultKeyOpt "Quit code actions menu";
exec = defaultKeyOpt "Execute code action";
};
in {
finderAction = {
open = defaultKeyOpt "Open from finder";
vsplit = defaultKeyOpt "Vertical split in finder";
split = defaultKeyOpt "Horizontal split in finder";
quit = defaultKeyOpt "Quit finder";
scrollDown = defaultKeyOpt "Scroll down finder";
scrollUp = defaultKeyOpt "Scroll up finder";
};
codeAction = {
quit = defaultKeyOpt "Quit code actions menu";
exec = defaultKeyOpt "Execute code action";
};
};
borderStyle = mkOption {
type = types.nullOr (types.enum [ "thin" "rounded" "thick" ]);
type = types.nullOr (types.enum ["thin" "rounded" "thick"]);
default = null;
description = "Border style";
};
@ -145,71 +147,75 @@ in
};
};
config =
let
notDefault = default: opt: if (opt != default) then opt else null;
notEmpty = opt: if ((filterAttrs (_: v: v != null) opt) != { }) then opt else null;
notNull = opt: opt;
lspsagaConfig = {
use_saga_diagnostic_sign = notDefault true cfg.signs.use;
error_sign = notNull cfg.signs.error;
warn_sign = notNull cfg.signs.warning;
hint_sign = notNull cfg.signs.hint;
infor_sign = notNull cfg.signs.info;
config = let
notDefault = default: opt:
if (opt != default)
then opt
else null;
notEmpty = opt:
if ((filterAttrs (_: v: v != null) opt) != {})
then opt
else null;
notNull = opt: opt;
lspsagaConfig = {
use_saga_diagnostic_sign = notDefault true cfg.signs.use;
error_sign = notNull cfg.signs.error;
warn_sign = notNull cfg.signs.warning;
hint_sign = notNull cfg.signs.hint;
infor_sign = notNull cfg.signs.info;
# TODO Fix this!
# error_header = notNull cfg.headers.error;
# warn_header = notNull cfg.headers.warning;
# hint_header = notNull cfg.headers.hint;
# infor_header = notNull cfg.headers.info;
# TODO Fix this!
# error_header = notNull cfg.headers.error;
# warn_header = notNull cfg.headers.warning;
# hint_header = notNull cfg.headers.hint;
# infor_header = notNull cfg.headers.info;
max_diag_msg_width = notNull cfg.maxDialogWidth;
max_diag_msg_width = notNull cfg.maxDialogWidth;
code_action_icon = notNull cfg.icons.codeAction;
finder_definition_icon = notNull cfg.icons.findDefinition;
finder_reference_icon = notNull cfg.icons.findReference;
definition_preview_icon = notNull cfg.icons.definitionPreview;
code_action_icon = notNull cfg.icons.codeAction;
finder_definition_icon = notNull cfg.icons.findDefinition;
finder_reference_icon = notNull cfg.icons.findReference;
definition_preview_icon = notNull cfg.icons.definitionPreview;
max_finder_preview_lines = notNull cfg.maxFinderPreviewLines;
max_finder_preview_lines = notNull cfg.maxFinderPreviewLines;
rename_prompt_prefix = notNull cfg.renamePromptPrefix;
rename_prompt_prefix = notNull cfg.renamePromptPrefix;
border_style =
let
borderStyle =
if cfg.borderStyle == "thin" then 1
else if cfg.borderStyle == "rounded" then 2
else if cfg.borderStyle == "thick" then 3
else null;
in
borderStyle;
border_style = let
borderStyle =
if cfg.borderStyle == "thin"
then 1
else if cfg.borderStyle == "rounded"
then 2
else if cfg.borderStyle == "thick"
then 3
else null;
in
borderStyle;
finder_action_keys =
let
keys = {
open = notNull cfg.keys.finderAction.open;
vsplit = notNull cfg.keys.finderAction.vsplit;
split = notNull cfg.keys.finderAction.split;
quit = notNull cfg.keys.finderAction.quit;
scroll_down = notNull cfg.keys.finderAction.scrollDown;
scroll_up = notNull cfg.keys.finderAction.scrollUp;
};
in
notEmpty keys;
finder_action_keys = let
keys = {
open = notNull cfg.keys.finderAction.open;
vsplit = notNull cfg.keys.finderAction.vsplit;
split = notNull cfg.keys.finderAction.split;
quit = notNull cfg.keys.finderAction.quit;
scroll_down = notNull cfg.keys.finderAction.scrollDown;
scroll_up = notNull cfg.keys.finderAction.scrollUp;
};
in
notEmpty keys;
code_action_keys =
let
keys = {
quit = notNull cfg.keys.codeAction.quit;
exec = notNull cfg.keys.codeAction.exec;
};
in
notEmpty keys;
};
in
code_action_keys = let
keys = {
quit = notNull cfg.keys.codeAction.quit;
exec = notNull cfg.keys.codeAction.exec;
};
in
notEmpty keys;
};
in
mkIf cfg.enable {
extraPlugins = [ cfg.package ];
extraPlugins = [cfg.package];
extraConfigLua = ''
local saga = require 'lspsaga'

View file

@ -1,70 +1,69 @@
{ pkgs
, lib
, config
, ...
}:
let
helpers = import ../helpers.nix { inherit lib; };
{
pkgs,
lib,
config,
...
}: let
helpers = import ../helpers.nix {inherit lib;};
in
with lib; {
options.plugins.nvim-lightbulb = {
enable = mkEnableOption "nvim-lightbulb, showing available code actions";
with lib; {
options.plugins.nvim-lightbulb = {
enable = mkEnableOption "nvim-lightbulb, showing available code actions";
package = helpers.mkPackageOption "nvim-lightbulb" pkgs.vimPlugins.nvim-lightbulb;
package = helpers.mkPackageOption "nvim-lightbulb" pkgs.vimPlugins.nvim-lightbulb;
ignore = helpers.defaultNullOpts.mkNullable (types.listOf types.str) "[]" ''
LSP client names to ignore
'';
sign = {
enabled = helpers.defaultNullOpts.mkBool true "";
priority = helpers.defaultNullOpts.mkInt 10 "";
};
float = {
enabled = helpers.defaultNullOpts.mkBool false "";
text = helpers.defaultNullOpts.mkStr "💡" "Text to show in the popup float";
winOpts = helpers.defaultNullOpts.mkNullable (types.attrsOf types.anything) "{}" ''
Options for the floating window (see |vim.lsp.util.open_floating_preview| for more information)
ignore = helpers.defaultNullOpts.mkNullable (types.listOf types.str) "[]" ''
LSP client names to ignore
'';
};
virtualText = {
enabled = helpers.defaultNullOpts.mkBool false "";
sign = {
enabled = helpers.defaultNullOpts.mkBool true "";
priority = helpers.defaultNullOpts.mkInt 10 "";
};
text = helpers.defaultNullOpts.mkStr "💡" "Text to show at virtual text";
float = {
enabled = helpers.defaultNullOpts.mkBool false "";
hlMode = helpers.defaultNullOpts.mkStr "replace" ''
highlight mode to use for virtual text (replace, combine, blend), see
:help nvim_buf_set_extmark() for reference
'';
};
text = helpers.defaultNullOpts.mkStr "💡" "Text to show in the popup float";
statusText = {
enabled = helpers.defaultNullOpts.mkBool false "";
winOpts = helpers.defaultNullOpts.mkNullable (types.attrsOf types.anything) "{}" ''
Options for the floating window (see |vim.lsp.util.open_floating_preview| for more information)
'';
};
text = helpers.defaultNullOpts.mkStr "💡" "Text to provide when code actions are available";
virtualText = {
enabled = helpers.defaultNullOpts.mkBool false "";
textUnavailable = helpers.defaultNullOpts.mkStr "" ''
Text to provide when no actions are available
'';
};
text = helpers.defaultNullOpts.mkStr "💡" "Text to show at virtual text";
autocmd = {
enabled = helpers.defaultNullOpts.mkBool false "";
hlMode = helpers.defaultNullOpts.mkStr "replace" ''
highlight mode to use for virtual text (replace, combine, blend), see
:help nvim_buf_set_extmark() for reference
'';
};
pattern = helpers.defaultNullOpts.mkNullable (types.listOf types.str) ''["*"]'' "";
statusText = {
enabled = helpers.defaultNullOpts.mkBool false "";
events =
helpers.defaultNullOpts.mkNullable (types.listOf types.str)
text = helpers.defaultNullOpts.mkStr "💡" "Text to provide when code actions are available";
textUnavailable = helpers.defaultNullOpts.mkStr "" ''
Text to provide when no actions are available
'';
};
autocmd = {
enabled = helpers.defaultNullOpts.mkBool false "";
pattern = helpers.defaultNullOpts.mkNullable (types.listOf types.str) ''["*"]'' "";
events =
helpers.defaultNullOpts.mkNullable (types.listOf types.str)
''["CursorHold" "CursorHoldI"]'' "";
};
};
};
config =
let
config = let
cfg = config.plugins.nvim-lightbulb;
setupOptions = {
inherit (cfg) ignore sign autocmd;
@ -82,10 +81,10 @@ with lib; {
};
};
in
mkIf cfg.enable {
extraPlugins = [ cfg.package ];
extraConfigLua = ''
require("nvim-lightbulb").setup(${helpers.toLuaObject setupOptions})
'';
};
}
mkIf cfg.enable {
extraPlugins = [cfg.package];
extraConfigLua = ''
require("nvim-lightbulb").setup(${helpers.toLuaObject setupOptions})
'';
};
}

View file

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

View file

@ -1,26 +1,30 @@
{ config, pkgs, lib, ... }:
let
cfg = config.plugins.trouble;
helpers = import ../helpers.nix { inherit lib; };
in
with lib;
# with helpers;
{
options.plugins.trouble = {
enable = mkEnableOption "trouble.nvim";
config,
pkgs,
lib,
...
}: let
cfg = config.plugins.trouble;
helpers = import ../helpers.nix {inherit lib;};
in
with lib;
# with helpers;
{
options.plugins.trouble = {
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";
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";
icons = helpers.mkNullOrOption types.bool "Use devicons for filenames";
};
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";
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";
};
config = mkIf cfg.enable {
extraPlugins = with pkgs.vimPlugins; [
cfg.package
nvim-web-devicons
];
};
}
config = mkIf cfg.enable {
extraPlugins = with pkgs.vimPlugins; [
cfg.package
nvim-web-devicons
];
};
}

View file

@ -1,8 +1,7 @@
# This is for plugins not in nixpkgs
# e.g. intellitab.nvim
# Ideally, in the future, this would all be specified as a flake input!
{ pkgs, ... }:
{
{pkgs, ...}: {
intellitab-nvim = pkgs.vimUtils.buildVimPlugin rec {
pname = "intellitab-nvim";
version = "a6c1a505865f6131866d609c52440306e9914b16";
@ -47,7 +46,7 @@
sha256 = "sha256-/m4Paw6AvDzTMWWCWpPnrdI4gsjIDSJPvGCMV7ufbEA=";
};
propagatedBuildInputs = [ pkgs.python3Packages.pynvim ];
propagatedBuildInputs = [pkgs.python3Packages.pynvim];
})
(ps.buildPythonPackage rec {
pname = "std2";
@ -96,30 +95,29 @@
sha256 = "sha256-IaslJK1F2BxTvZzKGH9OKOl2RICi4d4rSgjliAIAqK4=";
};
passthru.python3Dependencies = ps: with ps; [
pynvim
jupyter-client
ueberzug
pillow
cairosvg
plotly
ipykernel
pyperclip
(ps.buildPythonPackage rec {
pname = "pnglatex";
version = "1.1";
src = fetchPypi {
inherit pname version;
hash = "sha256-CZUGDUkmttO0BzFYbGFSNMPkWzFC/BW4NmAeOwz4Y9M=";
};
doCheck = false;
meta = with lib; {
homepage = "https://github.com/MaT1g3R/pnglatex";
description = "a small program that converts LaTeX snippets to png";
};
})
];
passthru.python3Dependencies = ps:
with ps; [
pynvim
jupyter-client
ueberzug
pillow
cairosvg
plotly
ipykernel
pyperclip
(ps.buildPythonPackage rec {
pname = "pnglatex";
version = "1.1";
src = fetchPypi {
inherit pname version;
hash = "sha256-CZUGDUkmttO0BzFYbGFSNMPkWzFC/BW4NmAeOwz4Y9M=";
};
doCheck = false;
meta = with lib; {
homepage = "https://github.com/MaT1g3R/pnglatex";
description = "a small program that converts LaTeX snippets to png";
};
})
];
};
}

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 = {
plugins.packer = {
enable = mkEnableOption "packer.nvim";
@ -13,67 +16,79 @@ in
type = types.listOf (types.oneOf [
types.str
(with types; let
mkOpt = type: desc: mkOption {
type = nullOr type;
default = null;
description = desc;
};
mkOpt = type: desc:
mkOption {
type = nullOr type;
default = null;
description = desc;
};
function = attrsOf str;
in
types.submodule {
options = {
name = mkOption {
type = str;
description = "Name of the plugin to install";
};
types.submodule {
options = {
name = mkOption {
type = str;
description = "Name of the plugin to install";
};
disable = mkOpt bool "Mark plugin as inactive";
as = mkOpt bool "Specifies an alias under which to install the plugin";
installer = mkOpt function "A custom installer";
updater = mkOpt function "A custom updater";
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";
opt = mkOpt str "Marks a plugin as optional";
branch = mkOpt str "Git branch to use";
tag = mkOpt str "Git tag to use";
commit = mkOpt str "Git commit to use";
lock = mkOpt bool "Skip this plugin in updates";
run = mkOpt (oneOf [ str function ]) "Post-install hook";
requires = mkOpt (oneOf [ str (listOf any) ]) "Plugin dependencies";
rocks = mkOpt (oneOf [ str (listOf any) ]) "Luarocks dependencies";
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";
cmd = mkOpt (oneOf [ str (listOf str) ]) "Commands 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";
event = mkOpt (oneOf [ str (listOf str) ]) "Autocommand events 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";
module = mkOpt (oneOf [ str (listOf str) ]) "Patterns of module names which load this plugin";
};
})
disable = mkOpt bool "Mark plugin as inactive";
as = mkOpt bool "Specifies an alias under which to install the plugin";
installer = mkOpt function "A custom installer";
updater = mkOpt function "A custom updater";
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";
opt = mkOpt str "Marks a plugin as optional";
branch = mkOpt str "Git branch to use";
tag = mkOpt str "Git tag to use";
commit = mkOpt str "Git commit to use";
lock = mkOpt bool "Skip this plugin in updates";
run = mkOpt (oneOf [str function]) "Post-install hook";
requires = mkOpt (oneOf [str (listOf any)]) "Plugin dependencies";
rocks = mkOpt (oneOf [str (listOf any)]) "Luarocks dependencies";
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";
cmd = mkOpt (oneOf [str (listOf str)]) "Commands 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";
event = mkOpt (oneOf [str (listOf str)]) "Autocommand events 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";
module = mkOpt (oneOf [str (listOf str)]) "Patterns of module names which load this plugin";
};
})
]);
default = [ ];
default = [];
description = "List of plugins";
};
};
};
config = mkIf cfg.enable {
extraPlugins = [ (pkgs.vimPlugins.packer-nvim.overrideAttrs (_: { pname = "packer.nvim"; })) ];
extraPackages = [ pkgs.git ];
extraPlugins = [(pkgs.vimPlugins.packer-nvim.overrideAttrs (_: {pname = "packer.nvim";}))];
extraPackages = [pkgs.git];
extraConfigLua =
let
plugins = map
(plugin:
if isAttrs plugin then
mapAttrs' (k: v: { name = if k == "name" then "@" else k; value = v; }) plugin
else plugin)
cfg.plugins;
packedPlugins = if length plugins == 1 then head plugins else plugins;
in
mkIf (cfg.plugins != [ ]) ''
extraConfigLua = let
plugins =
map
(plugin:
if isAttrs plugin
then
mapAttrs' (k: v: {
name =
if k == "name"
then "@"
else k;
value = v;
})
plugin
else plugin)
cfg.plugins;
packedPlugins =
if length plugins == 1
then head plugins
else plugins;
in
mkIf (cfg.plugins != []) ''
require('packer').startup(function()
use ${helpers.toLuaObject packedPlugins}
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 = {
enable = mkEnableOption "Enable luasnip";
package = helpers.mkPackageOption "luasnip" pkgs.vimPlugins.luasnip;
fromVscode = mkOption {
default = [ ];
default = [];
example = ''
[
{}
@ -38,18 +41,19 @@ in
# TODO: add option to also include the default runtimepath
paths = mkOption {
default = null;
type = with types; nullOr (oneOf
[
str
path
helpers.rawType
(listOf (oneOf
[
str
path
helpers.rawType
]))
]);
type = with types;
nullOr (oneOf
[
str
path
helpers.rawType
(listOf (oneOf
[
str
path
helpers.rawType
]))
]);
};
exclude = mkOption {
@ -75,21 +79,18 @@ in
# TODO: add support for lua
};
config =
let
fromVscodeLoaders = lists.map
(loader:
let
options = attrsets.getAttrs [ "paths" "exclude" "include" ] loader;
in
''
require("luasnip.loaders.from_vscode").${optionalString loader.lazyLoad "lazy_"}load(${helpers.toLuaObject options})
'')
cfg.fromVscode;
in
config = let
fromVscodeLoaders =
lists.map
(loader: let
options = attrsets.getAttrs ["paths" "exclude" "include"] loader;
in ''
require("luasnip.loaders.from_vscode").${optionalString loader.lazyLoad "lazy_"}load(${helpers.toLuaObject options})
'')
cfg.fromVscode;
in
mkIf cfg.enable {
extraPlugins = [ cfg.package ];
extraPlugins = [cfg.package];
extraConfigLua = concatStringsSep "\n" fromVscodeLoaders;
};
}

View file

@ -1,17 +1,20 @@
{ pkgs, config, lib, ... }:
with lib;
let
{
pkgs,
config,
lib,
...
}:
with lib; let
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 {
default = null;
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_*.";
};
in
{
in {
options = {
plugins.airline = {
enable = mkEnableOption "airline";
@ -33,16 +36,17 @@ in
sections = mkOption {
description = "Statusbar sections";
default = null;
type = with types; nullOr (submodule {
options = {
a = sectionOption;
b = sectionOption;
c = sectionOption;
x = sectionOption;
y = sectionOption;
z = sectionOption;
};
});
type = with types;
nullOr (submodule {
options = {
a = sectionOption;
b = sectionOption;
c = sectionOption;
x = sectionOption;
y = sectionOption;
z = sectionOption;
};
});
};
powerline = mkOption {
@ -59,21 +63,24 @@ in
};
};
config =
let
sections = { };
in
config = let
sections = {};
in
mkIf cfg.enable {
extraPlugins = with pkgs.vimPlugins; [
cfg.package
] ++ optional (!isNull cfg.theme) vim-airline-themes;
globals = {
airline.extensions = cfg.extensions;
extraPlugins = with pkgs.vimPlugins;
[
cfg.package
]
++ optional (!isNull cfg.theme) vim-airline-themes;
globals =
{
airline.extensions = cfg.extensions;
airline_statusline_ontop = mkIf cfg.onTop 1;
airline_powerline_fonts = mkIf (cfg.powerline) 1;
airline_statusline_ontop = mkIf cfg.onTop 1;
airline_powerline_fonts = mkIf (cfg.powerline) 1;
airline_theme = mkIf (!isNull cfg.theme) cfg.theme;
} // sections;
airline_theme = mkIf (!isNull cfg.theme) cfg.theme;
}
// 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 = {
plugins.lightline = {
enable = mkEnableOption "lightline";
@ -51,23 +54,21 @@ in
active = mkOption {
default = null;
type = types.nullOr (types.submodule {
options =
let
listType = with types; nullOr (listOf (listOf str));
in
{
left = mkOption {
type = listType;
description = "List of components that will show up on the left side of the bar";
default = null;
};
right = mkOption {
type = listType;
description = "List of components that will show up on the right side of the bar";
default = null;
};
options = let
listType = with types; nullOr (listOf (listOf str));
in {
left = mkOption {
type = listType;
description = "List of components that will show up on the left side of the bar";
default = null;
};
right = mkOption {
type = listType;
description = "List of components that will show up on the right side of the bar";
default = null;
};
};
});
};
@ -79,14 +80,13 @@ in
};
};
config =
let
configAttrs = filterAttrs (_: v: v != null) {
inherit (cfg) colorscheme active component componentFunction modeMap;
};
in
config = let
configAttrs = filterAttrs (_: v: v != null) {
inherit (cfg) colorscheme active component componentFunction modeMap;
};
in
mkIf cfg.enable {
extraPlugins = [ cfg.package ];
globals.lightline = mkIf (configAttrs != { }) configAttrs;
extraPlugins = [cfg.package];
globals.lightline = mkIf (configAttrs != {}) configAttrs;
};
}

View file

@ -1,8 +1,12 @@
{ pkgs, config, lib, ... }:
with lib;
let
{
pkgs,
config,
lib,
...
}:
with lib; let
cfg = config.plugins.lualine;
helpers = import ../helpers.nix { inherit lib; };
helpers = import ../helpers.nix {inherit lib;};
separators = mkOption {
type = types.nullOr (types.submodule {
options = {
@ -32,7 +36,7 @@ let
default = defaultName;
};
icons_enabled = mkOption {
type = types.enum [ "True" "False" ];
type = types.enum ["True" "False"];
default = "True";
description = "displays icons in alongside component";
};
@ -44,7 +48,7 @@ let
separator = separators;
extraConfig = mkOption {
type = types.attrs;
default = { };
default = {};
description = "extra options for the component";
};
};
@ -52,8 +56,7 @@ let
]));
default = null;
};
in
{
in {
options = {
plugins.lualine = {
enable = mkEnableOption "lualine";
@ -79,12 +82,11 @@ in
alwaysDivideMiddle = mkOption {
type = types.nullOr types.bool;
default = null;
description =
"When true, left_sections (a,b,c) can't take over entire statusline";
description = "When true, left_sections (a,b,c) can't take over entire statusline";
};
sections = mkOption {
type = types.nullOr (types.submodule ({ ... }: {
type = types.nullOr (types.submodule ({...}: {
options = {
lualine_a = component_options "mode";
lualine_b = component_options "branch";
@ -100,7 +102,7 @@ in
};
tabline = mkOption {
type = types.nullOr (types.submodule ({ ... }: {
type = types.nullOr (types.submodule ({...}: {
options = {
lualine_a = component_options "";
lualine_b = component_options "";
@ -121,34 +123,45 @@ in
};
};
};
config =
let
processComponent = x: (if isAttrs x then processTableComponent else id) x;
processTableComponent = { name, icons_enabled, icon, separator, extraConfig }: mergeAttrs
{
"@" = name;
inherit icons_enabled icon separator;
}
extraConfig;
processSections = sections: mapAttrs (_: mapNullable (map processComponent)) sections;
setupOptions = {
options = {
theme = cfg.theme;
section_separators = cfg.sectionSeparators;
component_separators = cfg.componentSeparators;
disabled_filetypes = cfg.disabledFiletypes;
always_divide_middle = cfg.alwaysDivideMiddle;
};
sections = mapNullable processSections cfg.sections;
tabline = mapNullable processSections cfg.tabline;
extensions = cfg.extensions;
config = let
processComponent = x:
(
if isAttrs x
then processTableComponent
else id
)
x;
processTableComponent = {
name,
icons_enabled,
icon,
separator,
extraConfig,
}:
mergeAttrs
{
"@" = name;
inherit icons_enabled icon separator;
}
extraConfig;
processSections = sections: mapAttrs (_: mapNullable (map processComponent)) sections;
setupOptions = {
options = {
theme = cfg.theme;
section_separators = cfg.sectionSeparators;
component_separators = cfg.componentSeparators;
disabled_filetypes = cfg.disabledFiletypes;
always_divide_middle = cfg.alwaysDivideMiddle;
};
in
sections = mapNullable processSections cfg.sections;
tabline = mapNullable processSections cfg.tabline;
extensions = cfg.extensions;
};
in
mkIf cfg.enable {
extraPlugins = [ cfg.package ];
extraPackages = [ pkgs.git ];
extraConfigLua =
''require("lualine").setup(${helpers.toLuaObject setupOptions})'';
extraPlugins = [cfg.package];
extraPackages = [pkgs.git];
extraConfigLua = ''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 = [
./frecency.nix
./fzf-native.nix
@ -33,13 +32,13 @@ in
enabledExtensions = mkOption {
type = types.listOf types.str;
description = "A list of enabled extensions. Don't use this directly";
default = [ ];
default = [];
};
extensionConfig = mkOption {
type = types.attrsOf types.anything;
description = "Configuration for the extensions. Don't use this directly";
default = { };
default = {};
};
defaults = mkOption {
@ -50,13 +49,13 @@ in
extraOptions = mkOption {
type = types.attrs;
default = { };
default = {};
description = "An attribute set, that lets you set extra options or override options set by nixvim";
};
};
config = mkIf cfg.enable {
extraPackages = [ pkgs.bat ];
extraPackages = [pkgs.bat];
extraPlugins = with pkgs.vimPlugins; [
cfg.package
@ -68,23 +67,23 @@ in
let $BAT_THEME = '${cfg.highlightTheme}'
'';
extraConfigLua =
let
options = {
extraConfigLua = let
options =
{
extensions = cfg.extensionConfig;
defaults = cfg.defaults;
} // cfg.extraOptions;
in
''
do
local __telescopeExtensions = ${helpers.toLuaObject cfg.enabledExtensions}
}
// cfg.extraOptions;
in ''
do
local __telescopeExtensions = ${helpers.toLuaObject cfg.enabledExtensions}
require('telescope').setup(${helpers.toLuaObject options})
require('telescope').setup(${helpers.toLuaObject options})
for i, extension in ipairs(__telescopeExtensions) do
require('telescope').load_extension(extension)
end
for i, extension in ipairs(__telescopeExtensions) do
require('telescope').load_extension(extension)
end
'';
end
'';
};
}

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 = {
enable = mkEnableOption "frecency";
@ -47,26 +50,25 @@ in
};
};
config =
let
configuration = {
db_root = cfg.dbRoot;
default_workspace = cfg.defaultWorkspace;
ignore_patterns = cfg.ignorePatterns;
show_scores = cfg.showScores;
workspaces = cfg.workspaces;
show_unindexed = cfg.showUnindexed;
devicons_disabled = cfg.deviconsDisabled;
};
in
config = let
configuration = {
db_root = cfg.dbRoot;
default_workspace = cfg.defaultWorkspace;
ignore_patterns = cfg.ignorePatterns;
show_scores = cfg.showScores;
workspaces = cfg.workspaces;
show_unindexed = cfg.showUnindexed;
devicons_disabled = cfg.deviconsDisabled;
};
in
mkIf cfg.enable {
extraPackages = [ pkgs.sqlite ];
extraPackages = [pkgs.sqlite];
extraPlugins = with pkgs.vimPlugins; [
cfg.package
sqlite-lua
];
plugins.telescope.enabledExtensions = [ "frecency" ];
plugins.telescope.enabledExtensions = ["frecency"];
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 = {
enable = mkEnableOption "Enable fzf-native";
@ -26,7 +29,7 @@ in
default = null;
};
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;
};
};
@ -38,10 +41,11 @@ in
override_file_sorter = cfg.overrideFileSorter;
case_mode = cfg.caseMode;
};
in mkIf cfg.enable {
extraPlugins = [ cfg.package ];
in
mkIf cfg.enable {
extraPlugins = [cfg.package];
plugins.telescope.enabledExtensions = [ "fzf" ];
plugins.telescope.extensionConfig."fzf" = configuration;
};
plugins.telescope.enabledExtensions = ["fzf"];
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 = {
enable = mkEnableOption "Enable fzy-native";
@ -24,10 +27,11 @@ in
override_generic_sorter = cfg.overrideGenericSorter;
override_file_sorter = cfg.overrideFileSorter;
};
in mkIf cfg.enable {
extraPlugins = [ pkgs.vimPlugins.telescope-fzy-native-nvim ];
in
mkIf cfg.enable {
extraPlugins = [pkgs.vimPlugins.telescope-fzy-native-nvim];
plugins.telescope.enabledExtensions = [ "fzy_native" ];
plugins.telescope.extensionConfig."fzy_native" = configuration;
};
plugins.telescope.enabledExtensions = ["fzy_native"];
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 = {
enable = mkEnableOption "Enable media_files extension for telescope";
@ -23,7 +26,7 @@ in
};
config = mkIf cfg.enable {
plugins.telescope.enabledExtensions = [ "media_files" ];
plugins.telescope.enabledExtensions = ["media_files"];
extraPlugins = with pkgs.vimPlugins; [
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 = {
enable = mkEnableOption "project-nvim telescope extension";
};
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 = {
plugins.comment-nvim = {
enable = mkEnableOption "Enable comment-nvim";
@ -27,7 +30,7 @@ in
default = null;
};
toggler = mkOption {
type = types.nullOr (types.submodule ({ ... }: {
type = types.nullOr (types.submodule ({...}: {
options = {
line = mkOption {
type = types.str;
@ -45,7 +48,7 @@ in
default = null;
};
opleader = mkOption {
type = types.nullOr (types.submodule ({ ... }: {
type = types.nullOr (types.submodule ({...}: {
options = {
line = mkOption {
type = types.str;
@ -63,7 +66,7 @@ in
default = null;
};
mappings = mkOption {
type = types.nullOr (types.submodule ({ ... }: {
type = types.nullOr (types.submodule ({...}: {
options = {
basic = mkOption {
type = types.bool;
@ -88,20 +91,18 @@ in
};
};
config =
let
setupOptions = {
padding = cfg.padding;
sticky = cfg.sticky;
ignore = cfg.ignore;
toggler = cfg.toggler;
opleader = cfg.opleader;
mappings = cfg.mappings;
};
in
config = let
setupOptions = {
padding = cfg.padding;
sticky = cfg.sticky;
ignore = cfg.ignore;
toggler = cfg.toggler;
opleader = cfg.opleader;
mappings = cfg.mappings;
};
in
mkIf cfg.enable {
extraPlugins = [ cfg.package ];
extraConfigLua =
''require("Comment").setup${helpers.toLuaObject setupOptions}'';
extraPlugins = [cfg.package];
extraConfigLua = ''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!
options = {
@ -16,6 +19,6 @@ in
};
config = mkIf cfg.enable {
extraPlugins = [ cfg.package ];
extraPlugins = [cfg.package];
};
}

View file

@ -1,11 +1,14 @@
{ config, lib, pkgs, ... }:
with lib;
let
{
config,
lib,
pkgs,
...
}:
with lib; let
cfg = config.plugins.dashboard;
helpers = import ../helpers.nix { inherit lib; };
in
{
helpers = import ../helpers.nix {inherit lib;};
in {
options = {
plugins.dashboard = {
enable = mkEnableOption "dashboard";
@ -90,7 +93,7 @@ in
};
};
};
default = { };
default = {};
};
hideStatusline = mkOption {
@ -107,34 +110,32 @@ in
};
};
config =
let
options = {
custom_header = cfg.header;
custom_footer = cfg.footer;
custom_center = cfg.center;
config = let
options = {
custom_header = cfg.header;
custom_footer = cfg.footer;
custom_center = cfg.center;
preview_file_path = cfg.preview.file;
preview_file_height = cfg.preview.height;
preview_file_width = cfg.preview.width;
preview_command = cfg.preview.command;
preview_file_path = cfg.preview.file;
preview_file_height = cfg.preview.height;
preview_file_width = cfg.preview.width;
preview_command = cfg.preview.command;
hide_statusline = cfg.hideStatusline;
hide_tabline = cfg.hideTabline;
hide_statusline = cfg.hideStatusline;
hide_tabline = cfg.hideTabline;
session_directory = cfg.sessionDirectory;
};
session_directory = cfg.sessionDirectory;
};
filteredOptions = filterAttrs (_: v: !isNull v) options;
in
filteredOptions = filterAttrs (_: v: !isNull v) options;
in
mkIf cfg.enable {
extraPlugins = [ cfg.package ];
extraPlugins = [cfg.package];
extraConfigLua = ''
local dashboard = require("dashboard")
${toString (mapAttrsToList (n: v:
"dashboard.${n} = ${helpers.toLuaObject v}\n")
filteredOptions)}
${toString (mapAttrsToList (n: v: "dashboard.${n} = ${helpers.toLuaObject v}\n")
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 = {
plugins.easyescape = {
enable = mkEnableOption "Enable easyescape";

View file

@ -1,34 +1,39 @@
{ lib, pkgs, ... }@attrs:
with lib;
let
helpers = import ../helpers.nix { inherit lib; };
{
lib,
pkgs,
...
} @ attrs:
with lib; let
helpers = import ../helpers.nix {inherit lib;};
eitherAttrsStrInt = with types; let
strInt = either str int;
in either strInt (attrsOf (either strInt (attrsOf strInt)));
in with helpers;
mkPlugin attrs {
name = "emmet";
description = "Enable emmet";
package = pkgs.vimPlugins.emmet-vim;
in
either strInt (attrsOf (either strInt (attrsOf strInt)));
in
with helpers;
mkPlugin attrs {
name = "emmet";
description = "Enable emmet";
package = pkgs.vimPlugins.emmet-vim;
options = {
mode = mkDefaultOpt {
type = types.enum [ "i" "n" "v" "a" ];
global = "user_emmet_mode";
description = "Mode where emmet will enable";
};
options = {
mode = mkDefaultOpt {
type = types.enum ["i" "n" "v" "a"];
global = "user_emmet_mode";
description = "Mode where emmet will enable";
};
leader = mkDefaultOpt {
type = types.str;
global = "user_emmet_leader_key";
description = "Set leader key";
};
leader = mkDefaultOpt {
type = types.str;
global = "user_emmet_leader_key";
description = "Set leader key";
};
settings = mkDefaultOpt {
type = types.attrsOf (types.attrsOf eitherAttrsStrInt);
global = "user_emmet_settings";
description = "Emmet settings";
};
};
}
settings = mkDefaultOpt {
type = types.attrsOf (types.attrsOf eitherAttrsStrInt);
global = "user_emmet_settings";
description = "Emmet settings";
};
};
}

View file

@ -1,12 +1,17 @@
{ lib, pkgs, ... }@attrs:
let
helpers = import ../helpers.nix { inherit lib; };
in with helpers; with lib;
mkPlugin attrs {
name = "endwise";
description = "Enable vim-endwise";
package = pkgs.vimPlugins.vim-endwise;
{
lib,
pkgs,
...
} @ attrs: let
helpers = import ../helpers.nix {inherit lib;};
in
with helpers;
with lib;
mkPlugin attrs {
name = "endwise";
description = "Enable vim-endwise";
package = pkgs.vimPlugins.vim-endwise;
# Yes it's really not configurable
options = {};
}
# Yes it's really not configurable
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 = {
plugins.floaterm = {
enable = mkEnableOption "floaterm";
@ -21,7 +24,7 @@ in
default = null;
};
winType = mkOption {
type = types.nullOr (types.enum [ "float" "split" "vsplit" ]);
type = types.nullOr (types.enum ["float" "split" "vsplit"]);
default = null;
};
winWidth = mkOption {
@ -45,17 +48,17 @@ in
default = null;
};
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";
default = null;
};
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.";
default = null;
};
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.";
default = null;
};

View file

@ -1,29 +1,34 @@
{ lib, pkgs, ... }@attrs:
let
helpers = import ../helpers.nix { inherit lib; };
in with helpers; with lib;
mkPlugin attrs {
name = "goyo";
description = "Enable goyo.vim";
package = pkgs.vimPlugins.goyo-vim;
{
lib,
pkgs,
...
} @ attrs: let
helpers = import ../helpers.nix {inherit lib;};
in
with helpers;
with lib;
mkPlugin attrs {
name = "goyo";
description = "Enable goyo.vim";
package = pkgs.vimPlugins.goyo-vim;
options = {
width = mkDefaultOpt {
description = "Width";
global = "goyo_width";
type = types.int;
};
options = {
width = mkDefaultOpt {
description = "Width";
global = "goyo_width";
type = types.int;
};
height = mkDefaultOpt {
description = "Height";
global = "goyo_height";
type = types.int;
};
height = mkDefaultOpt {
description = "Height";
global = "goyo_height";
type = types.int;
};
showLineNumbers = mkDefaultOpt {
description = "Show line numbers when in Goyo mode";
global = "goyo_linenr";
type = types.bool;
};
};
}
showLineNumbers = mkDefaultOpt {
description = "Show line numbers when in Goyo mode";
global = "goyo_linenr";
type = types.bool;
};
};
}

View file

@ -1,8 +1,12 @@
{ pkgs, config, lib, ... }:
with lib;
let
{
pkgs,
config,
lib,
...
}:
with lib; let
cfg = config.plugins.harpoon;
helpers = import ../helpers.nix { inherit lib; };
helpers = import ../helpers.nix {inherit lib;};
projectConfigModule = types.submodule {
options = {
@ -15,8 +19,7 @@ let
'';
};
};
in
{
in {
options.plugins.harpoon = {
enable = mkEnableOption "harpoon";
@ -47,7 +50,7 @@ in
'';
projects = mkOption {
default = { };
default = {};
description = ''
Predefined projetcs. The keys of this attrs should be the path to the project.
$HOME is working.
@ -73,50 +76,48 @@ in
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 = builtins.mapAttrs
(
name: value: {
term.cmds = value.termCommands;
mark.marks = map (mark: { filename = mark; }) value.marks;
}
)
cfg.projects;
config = let
projects =
builtins.mapAttrs
(
name: value: {
term.cmds = value.termCommands;
mark.marks = map (mark: {filename = mark;}) value.marks;
}
)
cfg.projects;
options = {
global_settings = {
save_on_toggle = cfg.saveOnToggle;
save_on_change = cfg.saveOnChange;
enter_on_sendcmd = cfg.enterOnSendcmd;
tmux_autoclose_windows = cfg.tmuxAutocloseWindows;
excluded_filetypes = cfg.excludedFiletypes;
mark_branch = cfg.markBranch;
};
projects = projects;
menu = {
width = cfg.menu.width;
height = cfg.menu.height;
borderchars = cfg.menu.borderChars;
};
options = {
global_settings = {
save_on_toggle = cfg.saveOnToggle;
save_on_change = cfg.saveOnChange;
enter_on_sendcmd = cfg.enterOnSendcmd;
tmux_autoclose_windows = cfg.tmuxAutocloseWindows;
excluded_filetypes = cfg.excludedFiletypes;
mark_branch = cfg.markBranch;
};
in
projects = projects;
menu = {
width = cfg.menu.width;
height = cfg.menu.height;
borderchars = cfg.menu.borderChars;
};
};
in
mkIf cfg.enable {
extraPlugins = [ cfg.package ];
extraPlugins = [cfg.package];
extraConfigLua = ''
require('harpoon').setup(${helpers.toLuaObject options})
'';
};
}

View file

@ -1,12 +1,12 @@
{ lib
, pkgs
, config
, ...
{
lib,
pkgs,
config,
...
} @ args:
with lib; let
helpers = import ../helpers.nix args;
in
{
in {
options.plugins.indent-blankline = {
enable = mkEnableOption "indent-blankline.nvim";
@ -62,7 +62,7 @@ in
useTreesitter =
helpers.defaultNullOpts.mkBool false
"Use treesitter to calculate indentation when possible.";
"Use treesitter to calculate indentation when possible.";
indentLevel = helpers.defaultNullOpts.mkInt 10 "Specifies the maximum indent level to display.";
@ -107,14 +107,14 @@ in
filetypeExclude =
helpers.defaultNullOpts.mkNullable (types.listOf types.str)
''["lspinfo" "packer" "checkhealth" "help" "man" ""]'' ''
''["lspinfo" "packer" "checkhealth" "help" "man" ""]'' ''
Specifies a list of |filetype| values for which this plugin is not enabled.
Ignored if the value is an empty list.
'';
buftypeExclude =
helpers.defaultNullOpts.mkNullable (types.listOf types.str)
''["terminal" "nofile" "quickfix" "prompt"]'' ''
''["terminal" "nofile" "quickfix" "prompt"]'' ''
Specifies a list of |buftype| values for which this plugin is not enabled.
Ignored if the value is an empty list.
'';
@ -197,7 +197,7 @@ in
contextStartPriority =
helpers.defaultNullOpts.mkInt 10000
"Specifies the |extmarks| priority for the context start.";
"Specifies the |extmarks| priority for the context start.";
contextPatterns = helpers.defaultNullOpts.mkNullable (types.listOf types.str) ''
[
@ -248,12 +248,11 @@ in
helpers.defaultNullOpts.mkBool false "Turns deprecation warning messages off.";
};
config =
let
cfg = config.plugins.indent-blankline;
in
config = let
cfg = config.plugins.indent-blankline;
in
mkIf cfg.enable {
extraPlugins = [ cfg.package ];
extraPlugins = [cfg.package];
globals = {
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 = {
plugins.intellitab = {
enable = mkEnableOption "intellitab.nvim";
@ -15,7 +18,7 @@ in
};
config = mkIf cfg.enable {
extraPlugins = [ cfg.package ];
extraPlugins = [cfg.package];
maps.insert."<Tab>" = "<CMD>lua require([[intellitab]]).indent()<CR>";
plugins.treesitter = {

View file

@ -1,24 +1,27 @@
{ pkgs, lib, config, ... }:
with lib;
let
{
pkgs,
lib,
config,
...
}:
with lib; let
cfg = config.plugins.magma-nvim;
plugins = import ../plugin-defs.nix { inherit pkgs; };
plugins = import ../plugin-defs.nix {inherit pkgs;};
package = pkgs.fetchFromGitHub {
owner = "dccsillag";
repo = "magma-nvim";
rev = version;
sha256 = "sha256-IaslJK1F2BxTvZzKGH9OKOl2RICi4d4rSgjliAIAqK4=";
};
owner = "dccsillag";
repo = "magma-nvim";
rev = version;
sha256 = "sha256-IaslJK1F2BxTvZzKGH9OKOl2RICi4d4rSgjliAIAqK4=";
};
in {
options = {
plugins.magma-nvim = {
enable = mkEnableOption "Enable magma-nvim?";
image_provider = mkOption {
type = types.enum [ "none" "ueberzug" "kitty" ];
type = types.enum ["none" "ueberzug" "kitty"];
default = "none";
example = "ueberzug";
description =
" This configures how to display images. The following options are available:
description = " This configures how to display images. The following options are available:
none -- don't show imagesmagma_image_provider.
ueberzug -- use Ueberzug to display images.
kitty -- use the Kitty protocol to display images.";
@ -27,8 +30,7 @@ in {
type = types.bool;
default = true;
example = false;
description =
" If this is true, then whenever you have an active cell its output window will be automatically shown.
description = " 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.";
};
@ -36,60 +38,54 @@ in {
type = types.bool;
default = true;
example = false;
description =
" If this is true, then text output in the output window will be wrapped (akin to set wrap).";
description = " If this is true, then text output in the output window will be wrapped (akin to set wrap).";
};
output_window_borders = mkOption {
type = types.bool;
default = true;
example = false;
description =
" If this is true, then the output window will have rounded borders. If it is false, it will have no borders.";
description = " 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 {
type = types.str;
default = "CursorLine";
# example = "";
description =
" The highlight group to be used for highlighting cells.";
description = " The highlight group to be used for highlighting cells.";
};
save_path = mkOption {
type = types.nullOr types.str;
default = null;
description =
"Where to save/load with :MagmaSave and :MagmaLoad (with no parameters).
description = "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.";
};
show_mimetype_debug = mkOption {
type = types.bool;
default = false;
example = true;
description =
" If this is true, then before any non-iostream output chunk, Magma shows the mimetypes it received for it.
description = " 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.";
};
package = mkOption {
type = types.nullOr types.package;
default = null;
example =
"package = pkgs.fetchFromGitHub {
example = "package = pkgs.fetchFromGitHub {
owner = \"WhiteBlackGoose\";
repo = \"magma-nvim-goose\";
rev = version;
sha256 = \"sha256-IaslJK1F2BxTvZzKGH9OKOl2RICi4d4rSgjliAIAqK4=\";} ";
};
};
};
config = mkIf cfg.enable {
extraPlugins = [ (
if cfg.package != null then plugins.magma-nvim.override {src = cfg.package;} else plugins.magma-nvim
)];
extraPlugins = [
(
if cfg.package != null
then plugins.magma-nvim.override {src = cfg.package;}
else plugins.magma-nvim
)
];
globals = {
magma_image_provider =
@ -99,13 +95,11 @@ in {
magma_wrap_output = mkIf (!cfg.wrap_output) cfg.wrap_output;
magma_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;
magma_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 = {
enable = mkEnableOption "mark-radar";
@ -33,16 +35,15 @@ in
};
};
config =
let
opts = helpers.toLuaObject {
inherit (cfg) highlight_group background_highlight_group;
set_default_mappings = cfg.set_default_keybinds;
background_highlight = cfg.highlight_background;
};
in
config = let
opts = helpers.toLuaObject {
inherit (cfg) highlight_group background_highlight_group;
set_default_mappings = cfg.set_default_keybinds;
background_highlight = cfg.highlight_background;
};
in
mkIf cfg.enable {
extraPlugins = [ cfg.package ];
extraPlugins = [cfg.package];
extraConfigLua = ''
require("mark-radar").setup(${opts})

View file

@ -1,21 +1,24 @@
{ pkgs, config, lib, ... }:
with lib;
let
{
pkgs,
config,
lib,
...
}:
with lib; let
cfg = config.plugins.notify;
helpers = import ../helpers.nix { inherit lib; };
helpers = import ../helpers.nix {inherit lib;};
icon = mkOption {
type = types.nullOr types.str;
default = null;
};
in
{
in {
options.plugins.notify = {
enable = mkEnableOption "notify";
package = helpers.mkPackageOption "notify" pkgs.vimPlugins.nvim-notify;
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";
default = null;
};
@ -45,28 +48,27 @@ in
};
});
description = "Icons for the different levels";
default = { };
default = {};
};
};
config =
let
setupOptions = with cfg; {
stages = stages;
timeout = timeout;
background_color = backgroundColor;
minimum_width = minimumWidth;
icons = with icons; {
ERROR = error;
WARN = warn;
INFO = info;
DEBUG = debug;
TRACE = trace;
};
config = let
setupOptions = with cfg; {
stages = stages;
timeout = timeout;
background_color = backgroundColor;
minimum_width = minimumWidth;
icons = with icons; {
ERROR = error;
WARN = warn;
INFO = info;
DEBUG = debug;
TRACE = trace;
};
in
};
in
mkIf cfg.enable {
extraPlugins = [ cfg.package ];
extraPlugins = [cfg.package];
extraConfigLua = ''
vim.notify = require('notify');
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 = {
enable = mkEnableOption "nvim-autopairs";
@ -41,18 +44,17 @@ in
};
};
config =
let
options = {
pairs_map = cfg.pairs;
disable_filetype = cfg.disabledFiletypes;
break_line_filetype = cfg.breakLineFiletypes;
html_break_line_filetype = cfg.htmlFiletypes;
ignored_next_char = cfg.ignoredNextChar;
};
in
config = let
options = {
pairs_map = cfg.pairs;
disable_filetype = cfg.disabledFiletypes;
break_line_filetype = cfg.breakLineFiletypes;
html_break_line_filetype = cfg.htmlFiletypes;
ignored_next_char = cfg.ignoredNextChar;
};
in
mkIf cfg.enable {
extraPlugins = [ cfg.package ];
extraPlugins = [cfg.package];
extraConfigLua = ''
require('nvim-autopairs').setup(${helpers.toLuaObject options})

View file

@ -1,9 +1,12 @@
{ pkgs, config, lib, ... }:
with lib;
let
{
pkgs,
config,
lib,
...
}:
with lib; let
cfg = config.plugins.nvim-colorizer;
helpers = import ../helpers.nix { inherit lib; };
helpers = import ../helpers.nix {inherit lib;};
colorizer-options = {
RGB = mkOption {
@ -53,7 +56,7 @@ let
};
mode = mkOption {
description = "Set the display mode";
type = types.nullOr (types.enum [ "foreground" "background" "virtualtext" ]);
type = types.nullOr (types.enum ["foreground" "background" "virtualtext"]);
default = null;
};
tailwind = mkOption {
@ -61,7 +64,7 @@ let
type = types.nullOr (
types.oneOf [
types.bool
(types.enum [ "normal" "lsp" "both" ])
(types.enum ["normal" "lsp" "both"])
]
);
default = null;
@ -84,12 +87,9 @@ let
default = null;
};
};
in
{
in {
options = {
plugins.nvim-colorizer = {
enable = mkEnableOption "nvim-colorizer";
package = helpers.mkPackageOption "nvim-colorizer" pkgs.vimPlugins.nvim-colorizer-lua;
@ -100,11 +100,13 @@ in
types.listOf (types.oneOf [
types.str
(types.submodule {
options = {
language = mkOption {
type = types.str;
};
} // colorizer-options;
options =
{
language = mkOption {
type = types.str;
};
}
// colorizer-options;
})
])
);
@ -128,24 +130,26 @@ in
};
config = mkIf cfg.enable {
extraPlugins = [ cfg.package ];
extraPlugins = [cfg.package];
extraConfigLua = let
filetypes = if (cfg.fileTypes != null)
then (
let
list = map (
v: if builtins.isAttrs v
then v.language + " = " + helpers.toLuaObject (builtins.removeAttrs v [ "language" ])
else "'${v}'"
) cfg.fileTypes;
in "{" + (concatStringsSep "," list) + "}"
)
else
"nil"
;
filetypes =
if (cfg.fileTypes != null)
then
(
let
list =
map (
v:
if builtins.isAttrs v
then v.language + " = " + helpers.toLuaObject (builtins.removeAttrs v ["language"])
else "'${v}'"
)
cfg.fileTypes;
in
"{" + (concatStringsSep "," list) + "}"
)
else "nil";
in ''
require("colorizer").setup({
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 = [
(optionWarnings.mkRenamedOption {
option = basePluginPath ++ [ "updateCwd" ];
newOption = basePluginPath ++ [ "syncRootWithCwd" ];
option = basePluginPath ++ ["updateCwd"];
newOption = basePluginPath ++ ["syncRootWithCwd"];
})
(optionWarnings.mkRenamedOption {
option = basePluginPath ++ [ "updateFocusedFile" "updateCwd" ];
newOption = basePluginPath ++ [ "updateFocusedFile" "updateRoot" ];
option = basePluginPath ++ ["updateFocusedFile" "updateCwd"];
newOption = basePluginPath ++ ["updateFocusedFile" "updateRoot"];
})
(optionWarnings.mkDeprecatedOption {
option = basePluginPath ++ [ "openOnSetup" ];
option = basePluginPath ++ ["openOnSetup"];
alternative = [];
})
(optionWarnings.mkDeprecatedOption {
option = basePluginPath ++ [ "ignoreFtOnSetup" ];
option = basePluginPath ++ ["ignoreFtOnSetup"];
alternative = [];
})
];
@ -102,20 +105,19 @@ in
description = "Enable diagnostics";
};
icons =
let
diagnosticOption = desc: mkOption {
icons = let
diagnosticOption = desc:
mkOption {
type = types.nullOr types.str;
default = null;
description = desc;
};
in
{
hint = diagnosticOption "Hints";
info = diagnosticOption "Info";
warning = diagnosticOption "Warning";
error = diagnosticOption "Error";
};
in {
hint = diagnosticOption "Hints";
info = diagnosticOption "Info";
warning = diagnosticOption "Warning";
error = diagnosticOption "Error";
};
};
updateFocusedFile = {
@ -233,50 +235,49 @@ in
};
};
config =
let
options = {
disable_netrw = cfg.disableNetrw;
hijack_netrw = cfg.hijackNetrw;
open_on_setup = cfg.openOnSetup;
ignore_ft_on_setup = cfg.ignoreFtOnSetup;
open_on_tab = cfg.openOnTab;
hijack_cursor = cfg.hijackCursor;
sync_root_with_cwd = cfg.syncRootWithCwd;
respect_buf_cwd = cfg.respectBufCwd;
update_to_buf_dir = {
enable = cfg.updateToBufDir.enable;
auto_open = cfg.updateToBufDir.autoOpen;
};
diagnostics = cfg.diagnostics;
update_focused_file = {
enable = cfg.updateFocusedFile.enable;
update_root = cfg.updateFocusedFile.updateRoot;
ignore_list = cfg.updateFocusedFile.ignoreList;
};
system_open = cfg.systemOpen;
filters = cfg.filters;
git = cfg.git;
view = {
width = cfg.view.width;
height = cfg.view.height;
hide_root_folder = cfg.view.hideRootFolder;
side = cfg.view.side;
auto_resize = cfg.view.autoResize;
mappings = {
custom_only = cfg.view.mappings.customOnly;
list = cfg.view.mappings.list;
};
number = cfg.view.number;
relativenumber = cfg.view.relativenumber;
signcolumn = cfg.view.signcolumn;
};
trash = {
cmd = cfg.trash.cmd;
require_confirm = cfg.trash.requireConfirm;
};
config = let
options = {
disable_netrw = cfg.disableNetrw;
hijack_netrw = cfg.hijackNetrw;
open_on_setup = cfg.openOnSetup;
ignore_ft_on_setup = cfg.ignoreFtOnSetup;
open_on_tab = cfg.openOnTab;
hijack_cursor = cfg.hijackCursor;
sync_root_with_cwd = cfg.syncRootWithCwd;
respect_buf_cwd = cfg.respectBufCwd;
update_to_buf_dir = {
enable = cfg.updateToBufDir.enable;
auto_open = cfg.updateToBufDir.autoOpen;
};
in
diagnostics = cfg.diagnostics;
update_focused_file = {
enable = cfg.updateFocusedFile.enable;
update_root = cfg.updateFocusedFile.updateRoot;
ignore_list = cfg.updateFocusedFile.ignoreList;
};
system_open = cfg.systemOpen;
filters = cfg.filters;
git = cfg.git;
view = {
width = cfg.view.width;
height = cfg.view.height;
hide_root_folder = cfg.view.hideRootFolder;
side = cfg.view.side;
auto_resize = cfg.view.autoResize;
mappings = {
custom_only = cfg.view.mappings.customOnly;
list = cfg.view.mappings.list;
};
number = cfg.view.number;
relativenumber = cfg.view.relativenumber;
signcolumn = cfg.view.signcolumn;
};
trash = {
cmd = cfg.trash.cmd;
require_confirm = cfg.trash.requireConfirm;
};
};
in
mkIf cfg.enable {
extraPlugins = with pkgs.vimPlugins; [
cfg.package
@ -294,6 +295,6 @@ in
extraConfigLua = ''
require('nvim-tree').setup(${helpers.toLuaObject options})
'';
extraPackages = [ pkgs.git ];
extraPackages = [pkgs.git];
};
}

View file

@ -1,65 +1,69 @@
{ 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";
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";
package = helpers.mkPackageOption "project-nvim" pkgs.vimPlugins.project-nvim;
package = helpers.mkPackageOption "project-nvim" pkgs.vimPlugins.project-nvim;
manualMode = mkOption {
type = types.nullOr types.bool;
default = null;
manualMode = mkOption {
type = types.nullOr types.bool;
default = null;
};
detectionMethods = mkOption {
type = types.nullOr (types.listOf types.str);
default = null;
};
patterns = mkOption {
type = types.nullOr (types.listOf types.str);
default = null;
};
ignoreLsp = mkOption {
type = types.nullOr (types.listOf types.str);
default = null;
};
excludeDirs = mkOption {
type = types.nullOr (types.listOf types.str);
default = null;
};
showHidden = mkOption {
type = types.nullOr types.bool;
default = null;
};
silentChdir = mkOption {
type = types.nullOr types.bool;
default = null;
};
scopeChdir = mkOption {
type = types.nullOr (types.enum ["global" "tab" "win"]);
default = null;
};
dataPath = mkOption {
type = types.nullOr (types.either types.str helpers.rawType);
default = null;
};
};
detectionMethods = mkOption {
type = types.nullOr (types.listOf types.str);
default = null;
};
patterns = mkOption {
type = types.nullOr (types.listOf types.str);
default = null;
};
ignoreLsp = mkOption {
type = types.nullOr (types.listOf types.str);
default = null;
};
excludeDirs = mkOption {
type = types.nullOr (types.listOf types.str);
default = null;
};
showHidden = mkOption {
type = types.nullOr types.bool;
default = null;
};
silentChdir = mkOption {
type = types.nullOr types.bool;
default = null;
};
scopeChdir = mkOption {
type = types.nullOr (types.enum [ "global" "tab" "win" ]);
default = null;
};
dataPath = mkOption {
type = types.nullOr (types.either types.str helpers.rawType);
default = null;
};
};
config =
let
options = {
config = let
options =
{
manual_mode = cfg.manualMode;
detection_methods = cfg.detectionMethods;
patterns = cfg.patterns;
@ -69,10 +73,11 @@ in
silent_chdir = cfg.silentChdir;
scope_schdir = cfg.scopeChdir;
data_path = cfg.dataPath;
} // cfg.extraOptions;
in
}
// cfg.extraOptions;
in
mkIf cfg.enable {
extraPlugins = [ cfg.package ];
extraPlugins = [cfg.package];
extraConfigLua = ''
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 = {
enable = mkEnableOption "specs-nvim";
@ -73,15 +76,16 @@ in
};
};
};
default = { builtin = "linear_fader"; };
default = {builtin = "linear_fader";};
};
resizer = mkOption {
type = types.submodule {
options = {
builtin = mkOption {
type = types.nullOr
(types.enum [ "shrink_resizer" "slide_resizer" "empty_resizer" ]);
type =
types.nullOr
(types.enum ["shrink_resizer" "slide_resizer" "empty_resizer"]);
default = "shrink_resizer";
};
@ -98,48 +102,53 @@ in
};
};
};
default = { builtin = "shrink_resizer"; };
default = {builtin = "shrink_resizer";};
};
ignored_filetypes = mkOption {
type = with types; listOf string;
default = [ ];
default = [];
};
ignored_buffertypes = mkOption {
type = with types; listOf string;
default = [ "nofile" ];
default = ["nofile"];
};
};
config =
let
setup = helpers.toLuaObject {
inherit (cfg) show_jumps min_jump;
ignore_filetypes = attrsets.listToAttrs
(lib.lists.map (x: attrsets.nameValuePair x true)
cfg.ignored_filetypes);
ignore_buftypes = attrsets.listToAttrs
(lib.lists.map (x: attrsets.nameValuePair x true)
cfg.ignored_buffertypes);
popup = {
inherit (cfg) blend width;
winhl = if (!isNull cfg.color) then "SpecsPopColor" else "PMenu";
delay_ms = cfg.delay;
inc_ms = cfg.increment;
fader = helpers.mkRaw (if cfg.fader.builtin == null then
cfg.fader.custom
else
''require("specs").${cfg.fader.builtin}'');
resizer = helpers.mkRaw (if cfg.resizer.builtin == null then
cfg.resizer.custom
else
''require("specs").${cfg.resizer.builtin}'');
};
config = let
setup = helpers.toLuaObject {
inherit (cfg) show_jumps min_jump;
ignore_filetypes =
attrsets.listToAttrs
(lib.lists.map (x: attrsets.nameValuePair x true)
cfg.ignored_filetypes);
ignore_buftypes =
attrsets.listToAttrs
(lib.lists.map (x: attrsets.nameValuePair x true)
cfg.ignored_buffertypes);
popup = {
inherit (cfg) blend width;
winhl =
if (!isNull cfg.color)
then "SpecsPopColor"
else "PMenu";
delay_ms = cfg.delay;
inc_ms = cfg.increment;
fader = helpers.mkRaw (
if cfg.fader.builtin == null
then cfg.fader.custom
else ''require("specs").${cfg.fader.builtin}''
);
resizer = helpers.mkRaw (
if cfg.resizer.builtin == null
then cfg.resizer.custom
else ''require("specs").${cfg.resizer.builtin}''
);
};
in
};
in
mkIf cfg.enable {
extraPlugins = [ cfg.package ];
extraPlugins = [cfg.package];
highlight.SpecsPopColor.bg = mkIf (!isNull cfg.color) cfg.color;

View file

@ -1,220 +1,233 @@
{ pkgs, lib, ... }@args:
let
helpers = import ../helpers.nix { inherit lib; };
in with lib; with helpers;
mkPlugin args {
name = "startify";
description = "Enable startify";
package = pkgs.vimPlugins.vim-startify;
{
pkgs,
lib,
...
} @ args: let
helpers = import ../helpers.nix {inherit lib;};
in
with lib;
with helpers;
mkPlugin args {
name = "startify";
description = "Enable startify";
package = pkgs.vimPlugins.vim-startify;
options = {
sessionDir = mkDefaultOpt {
description = "Directory to save/load session";
global = "startify_session_dir";
type = types.str;
};
lists = mkDefaultOpt {
description = "Startify display lists. If it's a string, it'll be interpreted as literal lua code";
global = "startify_lists";
type = types.listOf (types.oneOf [(types.submodule {
options = {
type = mkOption {
type = types.str;
description = "The type of the list";
};
# TODO the header should be a literal lua string!
header = mkOption {
type = types.nullOr (types.listOf types.str);
description = "Optional header. It's a list of strings";
default = null;
};
indices = mkOption {
type = types.nullOr (types.listOf types.str);
description = "Optional indices for the current list";
default = null;
};
options = {
sessionDir = mkDefaultOpt {
description = "Directory to save/load session";
global = "startify_session_dir";
type = types.str;
};
}) types.str]);
value = val: let
list = map (v: if builtins.isAttrs v then toLuaObject v else v) val;
in "{" + (concatStringsSep "," list) + "}";
};
lists = mkDefaultOpt {
description = "Startify display lists. If it's a string, it'll be interpreted as literal lua code";
global = "startify_lists";
type = types.listOf (types.oneOf [
(types.submodule {
options = {
type = mkOption {
type = types.str;
description = "The type of the list";
};
# TODO the header should be a literal lua string!
header = mkOption {
type = types.nullOr (types.listOf types.str);
description = "Optional header. It's a list of strings";
default = null;
};
indices = mkOption {
type = types.nullOr (types.listOf types.str);
description = "Optional indices for the current list";
default = null;
};
};
})
types.str
]);
bookmarks = mkDefaultOpt {
description = "A list of files or directories to bookmark.";
global = "startify_bookmarks";
type = with types; listOf (oneOf [str (attrsOf str)]);
};
value = val: let
list = map (v:
if builtins.isAttrs v
then toLuaObject v
else v)
val;
in
"{" + (concatStringsSep "," list) + "}";
};
commands = mkDefaultOpt {
description = "A list of commands to execute on selection";
global = "startify_commands";
type = with types; listOf (oneOf [ str (listOf str) attrs ]);
};
bookmarks = mkDefaultOpt {
description = "A list of files or directories to bookmark.";
global = "startify_bookmarks";
type = with types; listOf (oneOf [str (attrsOf str)]);
};
filesNumber = mkDefaultOpt {
description = "The number of files to list";
global = "startify_files_number";
type = types.int;
};
commands = mkDefaultOpt {
description = "A list of commands to execute on selection";
global = "startify_commands";
type = with types; listOf (oneOf [str (listOf str) attrs]);
};
updateOldFiles = mkDefaultOpt {
description = "Update v:oldfiles on-the-fly, so that :Startify is always up-to-date";
global = "startify_update_oldfiles";
type = types.bool;
};
filesNumber = mkDefaultOpt {
description = "The number of files to list";
global = "startify_files_number";
type = types.int;
};
sessionAutoload = mkDefaultOpt {
description = "Load Session.vim";
global = "startify_session_autoload";
type = types.bool;
};
updateOldFiles = mkDefaultOpt {
description = "Update v:oldfiles on-the-fly, so that :Startify is always up-to-date";
global = "startify_update_oldfiles";
type = types.bool;
};
sessionBeforeSave = mkDefaultOpt {
description = "Commands to be executed before saving a session";
global = "startify_session_before_save";
type = types.listOf types.str;
};
sessionAutoload = mkDefaultOpt {
description = "Load Session.vim";
global = "startify_session_autoload";
type = types.bool;
};
sessionPersistence = mkDefaultOpt {
description = "Automatically update sessions";
global = "startify_session_persistence";
type = types.bool;
};
sessionBeforeSave = mkDefaultOpt {
description = "Commands to be executed before saving a session";
global = "startify_session_before_save";
type = types.listOf types.str;
};
sessionDeleteBuffers = mkDefaultOpt {
description = "Delete all buffers when loading or closing a session";
global = "startify_session_delete_buffers";
type = types.bool;
};
sessionPersistence = mkDefaultOpt {
description = "Automatically update sessions";
global = "startify_session_persistence";
type = types.bool;
};
changeToDir = mkDefaultOpt {
description = "When opening a file or bookmark, change to its directory";
global = "startify_change_to_dir";
type = types.bool;
};
sessionDeleteBuffers = mkDefaultOpt {
description = "Delete all buffers when loading or closing a session";
global = "startify_session_delete_buffers";
type = types.bool;
};
changeToVcsRoot = mkDefaultOpt {
description = "When opening a file or bookmark, change to the root directory of the VCS";
global = "startify_change_to_vcs_root";
type = types.bool;
};
changeToDir = mkDefaultOpt {
description = "When opening a file or bookmark, change to its directory";
global = "startify_change_to_dir";
type = types.bool;
};
changeCmd = mkDefaultOpt {
description = "The default command for switching directories";
global = "startify_change_cmd";
type = types.enum [ "cd" "lcd" "tcd" ];
};
changeToVcsRoot = mkDefaultOpt {
description = "When opening a file or bookmark, change to the root directory of the VCS";
global = "startify_change_to_vcs_root";
type = types.bool;
};
skipList = mkDefaultOpt {
description = "A list of regexes that is used to filter recently used files";
global = "startify_skiplist";
type = types.listOf types.str;
};
changeCmd = mkDefaultOpt {
description = "The default command for switching directories";
global = "startify_change_cmd";
type = types.enum ["cd" "lcd" "tcd"];
};
useUnicode = mkDefaultOpt {
description = "Use unicode box drawing characters for the fortune header";
global = "startify_fortune_use_unicode";
type = types.bool;
};
skipList = mkDefaultOpt {
description = "A list of regexes that is used to filter recently used files";
global = "startify_skiplist";
type = types.listOf types.str;
};
paddingLeft = mkDefaultOpt {
description = "Number of spaces used for left padding";
global = "startify_padding_left";
type = types.int;
};
useUnicode = mkDefaultOpt {
description = "Use unicode box drawing characters for the fortune header";
global = "startify_fortune_use_unicode";
type = types.bool;
};
skipListServer = mkDefaultOpt {
description = "Do not create the startify buffer if this is a Vim server instance with a name contained in this list";
global = "startify_skiplist_server";
type = types.listOf types.str;
};
paddingLeft = mkDefaultOpt {
description = "Number of spaces used for left padding";
global = "startify_padding_left";
type = types.int;
};
enableSpecial = mkDefaultOpt {
description = "Show &lt;empty buffer&gt; and &lt;quit&gt;";
global = "startify_enable_special";
type = types.bool;
};
skipListServer = mkDefaultOpt {
description = "Do not create the startify buffer if this is a Vim server instance with a name contained in this list";
global = "startify_skiplist_server";
type = types.listOf types.str;
};
enableUnsafe = mkDefaultOpt {
description = "Improves start time but reduces accuracy of the file list";
global = "startify_enable_unsafe";
type = types.bool;
};
enableSpecial = mkDefaultOpt {
description = "Show &lt;empty buffer&gt; and &lt;quit&gt;";
global = "startify_enable_special";
type = types.bool;
};
sessionRemoveLines = mkDefaultOpt {
description = "Lines matching any of the patterns in this list will be removed from the session file";
global = "startify_session_remove_lines";
type = types.listOf types.str;
};
enableUnsafe = mkDefaultOpt {
description = "Improves start time but reduces accuracy of the file list";
global = "startify_enable_unsafe";
type = types.bool;
};
sessionSaveVars = mkDefaultOpt {
description = "List of variables for Startify to save into the session file";
global = "startify_session_savevars";
type = types.listOf types.str;
};
sessionRemoveLines = mkDefaultOpt {
description = "Lines matching any of the patterns in this list will be removed from the session file";
global = "startify_session_remove_lines";
type = types.listOf types.str;
};
sessionSaveCmds = mkDefaultOpt {
description = "List of cmdline commands to run when loading the session";
global = "startify_session_savecmds";
type = types.listOf types.str;
};
sessionSaveVars = mkDefaultOpt {
description = "List of variables for Startify to save into the session file";
global = "startify_session_savevars";
type = types.listOf types.str;
};
sessionNumber = mkDefaultOpt {
description = "Maximum number of sessions to display";
global = "startify_session_number";
type = types.listOf types.str;
};
sessionSaveCmds = mkDefaultOpt {
description = "List of cmdline commands to run when loading the session";
global = "startify_session_savecmds";
type = types.listOf types.str;
};
sessionSort = mkDefaultOpt {
description = "Sort sessions by modification time rather than alphabetically";
global = "startify_session_sort";
type = types.bool;
};
sessionNumber = mkDefaultOpt {
description = "Maximum number of sessions to display";
global = "startify_session_number";
type = types.listOf types.str;
};
customIndices = mkDefaultOpt {
description = "Use this list as indices instead of increasing numbers";
global = "startify_custom_indices";
type = types.listOf types.str;
};
sessionSort = mkDefaultOpt {
description = "Sort sessions by modification time rather than alphabetically";
global = "startify_session_sort";
type = types.bool;
};
customHeader = mkDefaultOpt {
description = "Define your own header";
global = "startify_custom_header";
type = types.oneOf [ types.str (types.listOf types.str) ];
};
customIndices = mkDefaultOpt {
description = "Use this list as indices instead of increasing numbers";
global = "startify_custom_indices";
type = types.listOf types.str;
};
customQuotes = mkDefaultOpt {
description = "Own quotes for the cowsay header";
global = "startify_custom_header_quotes";
# TODO this should also support funcrefs!
type = types.listOf (types.listOf types.str);
};
customHeader = mkDefaultOpt {
description = "Define your own header";
global = "startify_custom_header";
type = types.oneOf [types.str (types.listOf types.str)];
};
customFooter = mkDefaultOpt {
description = "Custom footer";
global = "startify_custom_footer";
type = types.str;
};
customQuotes = mkDefaultOpt {
description = "Own quotes for the cowsay header";
global = "startify_custom_header_quotes";
# TODO this should also support funcrefs!
type = types.listOf (types.listOf types.str);
};
disableAtVimEnter = mkDefaultOpt {
description = "Don't run Startify at Vim startup";
global = "startify_disable_at_vimenter";
type = types.bool;
};
customFooter = mkDefaultOpt {
description = "Custom footer";
global = "startify_custom_footer";
type = types.str;
};
relativePath = mkDefaultOpt {
description = "If the file is in or below the current working directory, use a relative path";
global = "startify_relative_path";
type = types.bool;
};
disableAtVimEnter = mkDefaultOpt {
description = "Don't run Startify at Vim startup";
global = "startify_disable_at_vimenter";
type = types.bool;
};
useEnv = mkDefaultOpt {
description = "Show environment variables in path, if their name is shorter than their value";
global = "startify_use_env";
type = types.bool;
};
};
}
relativePath = mkDefaultOpt {
description = "If the file is in or below the current working directory, use a relative path";
global = "startify_relative_path";
type = types.bool;
};
useEnv = mkDefaultOpt {
description = "Show environment variables in path, if their name is shorter than their value";
global = "startify_use_env";
type = types.bool;
};
};
}

View file

@ -1,11 +1,16 @@
{ lib, pkgs, ... }@attrs:
let
helpers = import ../helpers.nix { inherit lib; };
in with helpers; with lib;
mkPlugin attrs {
name = "surround";
description = "Enable surround.vim";
package = pkgs.vimPlugins.surround;
{
lib,
pkgs,
...
} @ attrs: let
helpers = import ../helpers.nix {inherit lib;};
in
with helpers;
with lib;
mkPlugin attrs {
name = "surround";
description = "Enable surround.vim";
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 = {
plugins.undotree = {
enable = mkEnableOption "Enable undotree";
@ -110,7 +113,7 @@ in
};
config = mkIf cfg.enable {
extraPlugins = [ cfg.package ];
extraPlugins = [cfg.package];
globals = {
undotree_WindowLayout = mkIf (cfg.windowLayout != null) cfg.windowLayout;

View file

@ -14,299 +14,305 @@
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
(system:
let
pkgs = import nixpkgs { inherit system; };
pkgs-stable = import nixpkgs-stable { inherit system; };
build = nixvim.legacyPackages.${system}.makeNixvim;
build-stable = nixvim-stable.legacyPackages.${system}.makeNixvim;
in
rec {
# A plain nixvim configuration
packages = {
plain = build { };
(system: let
pkgs = import nixpkgs {inherit system;};
pkgs-stable = import nixpkgs-stable {inherit system;};
build = nixvim.legacyPackages.${system}.makeNixvim;
build-stable = nixvim-stable.legacyPackages.${system}.makeNixvim;
in rec {
# A plain nixvim configuration
packages = {
plain = build {};
# Should print "Hello!" when starting up
hello = build {
extraConfigLua = "print(\"Hello!\")";
# Should print "Hello!" when starting up
hello = build {
extraConfigLua = "print(\"Hello!\")";
};
simple-plugin = build {
extraPlugins = [pkgs.vimPlugins.vim-surround];
};
gruvbox = build {
extraPlugins = [pkgs.vimPlugins.gruvbox];
colorscheme = "gruvbox";
};
gruvbox-module = build {
colorschemes.gruvbox.enable = true;
};
treesitter = build {
plugins.treesitter.enable = true;
};
treesitter-nonix = build {
plugins.treesitter = {
enable = true;
nixGrammars = false;
};
};
elixir-ls = build {
plugins.lsp.enable = true;
plugins.lsp.servers.elixirls.enable = true;
};
lsp-lines = build-stable {
plugins.lsp-lines.enable = true;
};
trouble = build {
plugins.lsp = {
enable = true;
servers.clangd.enable = true;
};
simple-plugin = build {
extraPlugins = [ pkgs.vimPlugins.vim-surround ];
};
plugins.trouble.enable = true;
};
gruvbox = build {
extraPlugins = [ pkgs.vimPlugins.gruvbox ];
colorscheme = "gruvbox";
beautysh = build {
plugins.null-ls = {
enable = true;
sources.formatting.beautysh.enable = true;
};
};
gruvbox-module = build {
colorschemes.gruvbox.enable = true;
};
keymaps = build {
maps.normal."," = "<cmd>echo \"test\"<cr>";
};
treesitter = build {
plugins.treesitter.enable = true;
};
issue-40 = build-stable {
plugins = {
nix.enable = true;
nvim-autopairs.enable = true;
treesitter-nonix = build {
plugins.treesitter = {
lualine = {
enable = true;
nixGrammars = false;
sectionSeparators = {
left = "";
right = "";
};
componentSeparators = {
left = "";
right = "";
};
theme = "auto";
};
goyo = {
enable = true;
showLineNumbers = false;
};
lsp = {
enable = true;
servers = {
rust-analyzer.enable = true;
rnix-lsp.enable = true;
};
};
};
elixir-ls = build {
plugins.lsp.enable = true;
plugins.lsp.servers.elixirls.enable = true;
options = {
# Indentation
autoindent = true;
tabstop = 4;
shiftwidth = 4;
expandtab = true;
backspace = "indent,eol,start";
# Text
showmatch = true;
mouse = "a";
number = true;
relativenumber = false;
ttyfast = true;
clipboard = "unnamedplus";
# Colors
background = "dark";
termguicolors = true;
};
};
issue-65 = build {
colorschemes.gruvbox = {
enable = true;
contrastLight = "hard";
contrastDark = "hard";
};
lsp-lines = build-stable {
plugins.lsp-lines.enable = true;
options = {
number = true;
shiftwidth = 2;
tabstop = 2;
guifont = "FiraCode\ Nerd\ Font\ Mono:h14";
};
trouble = build {
plugins.lsp = {
plugins = {
lsp = {
enable = true;
servers.rnix-lsp.enable = true;
servers.rust-analyzer.enable = true;
servers.jsonls.enable = true;
};
nvim-tree = {
enable = true;
openOnSetup = true;
openOnTab = true;
};
telescope = {
enable = true;
};
nvim-cmp = {
formatting = {
format = ''
require("lspkind").cmp_format({
mode="symbol",
maxwidth = 50,
ellipsis_char = "..."
})
'';
};
auto_enable_sources = true;
snippet = {
expand = ''
function(args)
require("luasnip").lsp_expand(args.body)
end
'';
};
enable = true;
sources = [
{name = "nvim_lsp";}
{
name = "luasnip";
option = {
show_autosnippets = true;
};
}
{name = "path";}
{name = "buffer";}
];
};
barbar.enable = true;
};
globals.mapleader = " ";
extraPlugins = with pkgs.vimPlugins; [
which-key-nvim
# leap-nvim
vim-flutter
plenary-nvim
fidget-nvim
luasnip
lspkind-nvim
];
# extraConfigLua = (builtins.readFile ./nvim-extra-lua.lua);
};
issue-71 = build {
maps.normal."<leader>hb" = "<cmd>lua require('gitsigns').blame_line{full=true}<cr>";
};
lspkind = build {
plugins = {
lsp = {
enable = true;
servers.clangd.enable = true;
};
plugins.trouble.enable = true;
};
beautysh = build {
plugins.null-ls = {
enable = true;
sources.formatting.beautysh.enable = true;
};
};
keymaps = build {
maps.normal."," = "<cmd>echo \"test\"<cr>";
};
issue-40 = build-stable {
plugins = {
nix.enable = true;
nvim-autopairs.enable = true;
lualine = {
enable = true;
sectionSeparators = {
left = "";
right = "";
};
componentSeparators = {
left = "";
right = "";
};
theme = "auto";
};
goyo = {
enable = true;
showLineNumbers = false;
};
lsp = {
enable = true;
servers = {
rust-analyzer.enable = true;
rnix-lsp.enable = true;
};
};
};
options = {
# Indentation
autoindent = true;
tabstop = 4;
shiftwidth = 4;
expandtab = true;
backspace = "indent,eol,start";
# Text
showmatch = true;
mouse = "a";
number = true;
relativenumber = false;
ttyfast = true;
clipboard = "unnamedplus";
# Colors
background = "dark";
termguicolors = true;
};
};
issue-65 = build {
colorschemes.gruvbox = {
enable = true;
contrastLight = "hard";
contrastDark = "hard";
};
options = {
number = true;
shiftwidth = 2;
tabstop = 2;
guifont = "FiraCode\ Nerd\ Font\ Mono:h14";
};
plugins = {
lsp = {
enable = true;
servers.rnix-lsp.enable = true;
servers.rust-analyzer.enable = true;
servers.jsonls.enable = true;
};
nvim-tree = {
enable = true;
openOnSetup = true;
openOnTab = true;
};
telescope = {
enable = true;
};
nvim-cmp = {
formatting = {
format = ''
require("lspkind").cmp_format({
mode="symbol",
maxwidth = 50,
ellipsis_char = "..."
})
'';
};
auto_enable_sources = true;
snippet = {
expand = ''
function(args)
require("luasnip").lsp_expand(args.body)
end
'';
};
enable = true;
sources = [
{ name = "nvim_lsp"; }
{
name = "luasnip";
option = {
show_autosnippets = true;
};
}
{ name = "path"; }
{ name = "buffer"; }
];
};
barbar.enable = true;
};
globals.mapleader = " ";
extraPlugins = with pkgs.vimPlugins; [
which-key-nvim
# leap-nvim
vim-flutter
plenary-nvim
fidget-nvim
luasnip
lspkind-nvim
];
# extraConfigLua = (builtins.readFile ./nvim-extra-lua.lua);
};
issue-71 = build {
maps.normal."<leader>hb" = "<cmd>lua require('gitsigns').blame_line{full=true}<cr>";
};
lspkind = build {
plugins = {
lsp = {
enable = true;
servers.clangd.enable = true;
};
nvim-cmp.enable = true;
lspkind.enable = true;
};
};
highlight = build {
options.termguicolors = true;
highlight = {
Normal.fg = "#ff0000";
};
};
autoCmd = build {
autoCmd = [
{
event = [ "BufEnter" "BufWinEnter" ];
pattern = [ "*.c" "*.h" ];
command = "echo 'Entering a C or C++ file'";
}
{
event = "InsertEnter";
command = "norm zz";
}
];
};
ts-custom = build {
plugins.treesitter = {
enable = true;
nixGrammars = true;
grammarPackages = [
(build-ts.lib.buildGrammar pkgs {
language = "gleam";
version = "0.25.0";
source = gleam;
})
];
};
nvim-cmp.enable = true;
lspkind.enable = true;
};
};
})) // {
highlight = build {
options.termguicolors = true;
highlight = {
Normal.fg = "#ff0000";
};
};
autoCmd = build {
autoCmd = [
{
event = ["BufEnter" "BufWinEnter"];
pattern = ["*.c" "*.h"];
command = "echo 'Entering a C or C++ file'";
}
{
event = "InsertEnter";
command = "norm zz";
}
];
};
ts-custom = build {
plugins.treesitter = {
enable = true;
nixGrammars = true;
grammarPackages = [
(build-ts.lib.buildGrammar pkgs {
language = "gleam";
version = "0.25.0";
source = gleam;
})
];
};
};
};
}))
// {
nixosConfigurations.nixvim-machine = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
({ pkgs, ... }: {
({pkgs, ...}: {
environment.systemPackages = [
(nixvim.build pkgs { colorschemes.gruvbox.enable = true; })
(nixvim.build pkgs {colorschemes.gruvbox.enable = true;})
];
})
];
};
nixosConfigurations.container = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules =
[
({ pkgs, ... }: {
boot.isContainer = true;
modules = [
({pkgs, ...}: {
boot.isContainer = true;
# Let 'nixos-version --json' know about the Git revision
# of this flake.
system.configurationRevision = nixpkgs.lib.mkIf (self ? rev) self.rev;
# Let 'nixos-version --json' know about the Git revision
# of this flake.
system.configurationRevision = nixpkgs.lib.mkIf (self ? rev) self.rev;
imports = [
nixvim.nixosModules.x86_64-linux.nixvim
];
imports = [
nixvim.nixosModules.x86_64-linux.nixvim
];
programs.nixvim = {
enable = true;
colorschemes.gruvbox.enable = true;
};
})
];
programs.nixvim = {
enable = true;
colorschemes.gruvbox.enable = true;
};
})
];
};
};
}

View file

@ -1,9 +1,10 @@
{ lib, pkgs, ... }:
let
inherit (lib) mkEnableOption mkOption mkOptionType mkForce mkMerge mkIf types;
in
{
lib,
pkgs,
...
}: let
inherit (lib) mkEnableOption mkOption mkOptionType mkForce mkMerge mkIf types;
in {
helpers = mkOption {
type = mkOptionType {
name = "helpers";
@ -11,6 +12,6 @@ in
check = builtins.isAttrs;
};
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:
{ pkgs, config, lib, ... }@args:
let
modules: {
pkgs,
config,
lib,
...
} @ args: let
inherit (lib) mkEnableOption mkOption mkOptionType mkForce mkMerge mkIf types;
shared = import ./_shared.nix args;
cfg = config.programs.nixvim;
in
{
in {
options = {
programs.nixvim = mkOption {
type = types.submodule ((modules pkgs) ++ [{
options.enable = mkEnableOption "nixvim";
config.wrapRc = mkForce true;
}]);
type = types.submodule ((modules pkgs)
++ [
{
options.enable = mkEnableOption "nixvim";
config.wrapRc = mkForce true;
}
]);
};
nixvim.helpers = shared.helpers;
};
config = mkIf cfg.enable mkMerge [
{
environment.systemPackages = [ cfg.finalPackage ];
environment.systemPackages = [cfg.finalPackage];
}
{
warnings = cfg.warnings;

View file

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

View file

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

View file

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