mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2025-01-10 00:49:48 +01:00
Compare commits
20 commits
7b21e10b88
...
72a4a6ee41
Author | SHA1 | Date | |
---|---|---|---|
|
72a4a6ee41 | ||
|
9be26f2ac3 | ||
|
c2185f25df | ||
|
fb91b1bbaa | ||
|
90cb9b7293 | ||
|
af67523642 | ||
|
a0d75f9182 | ||
|
57a6abc063 | ||
|
4fd2ded18a | ||
|
1f8b49bcef | ||
|
9f6f191e07 | ||
|
244a560922 | ||
|
ddabc26c33 | ||
|
63ea5bd71f | ||
|
e2de9a1e27 | ||
|
e280cdc8f3 | ||
|
8897e164ba | ||
|
6e3c9cbc1e | ||
|
cb136a9485 | ||
|
05e5f5e399 |
15 changed files with 346 additions and 366 deletions
|
@ -31,7 +31,7 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
homeManagerModules = {
|
homeManagerModules = {
|
||||||
nvf = import ./flake/modules/home-manager.nix {inherit lib self;};
|
nvf = import ./flake/modules/home-manager.nix self.packages lib;
|
||||||
default = self.homeManagerModules.nvf;
|
default = self.homeManagerModules.nvf;
|
||||||
neovim-flake =
|
neovim-flake =
|
||||||
lib.warn ''
|
lib.warn ''
|
||||||
|
@ -42,7 +42,7 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
nixosModules = {
|
nixosModules = {
|
||||||
nvf = import ./flake/modules/nixos.nix {inherit lib self;};
|
nvf = import ./flake/modules/nixos.nix self.packages lib;
|
||||||
default = self.nixosModules.nvf;
|
default = self.nixosModules.nvf;
|
||||||
neovim-flake =
|
neovim-flake =
|
||||||
lib.warn ''
|
lib.warn ''
|
||||||
|
|
|
@ -1,28 +1,22 @@
|
||||||
# Home Manager module
|
# Home Manager module
|
||||||
{
|
packages: lib: {
|
||||||
self,
|
|
||||||
lib,
|
|
||||||
}: {
|
|
||||||
config,
|
config,
|
||||||
pkgs,
|
pkgs,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (self) packages inputs;
|
|
||||||
inherit (lib) maintainers;
|
inherit (lib) maintainers;
|
||||||
inherit (lib.modules) mkIf mkAliasOptionModule;
|
inherit (lib.modules) mkIf mkAliasOptionModule;
|
||||||
inherit (lib.lists) optional;
|
inherit (lib.lists) optional;
|
||||||
inherit (lib.options) mkOption mkEnableOption literalExpression;
|
inherit (lib.options) mkOption mkEnableOption literalExpression;
|
||||||
inherit (lib.types) anything bool submoduleWith;
|
inherit (lib.types) attrsOf anything bool;
|
||||||
|
inherit (lib.nvim) neovimConfiguration;
|
||||||
|
inherit (lib.nvim.types) anythingConcatLists;
|
||||||
|
|
||||||
cfg = config.programs.nvf;
|
cfg = config.programs.nvf;
|
||||||
|
|
||||||
nvfModule = submoduleWith {
|
neovimConfigured = neovimConfiguration {
|
||||||
description = "Nvf module";
|
inherit pkgs;
|
||||||
class = "nvf";
|
modules = [cfg.settings];
|
||||||
specialArgs = {
|
|
||||||
inherit pkgs lib inputs;
|
|
||||||
};
|
|
||||||
modules = import ../../modules/modules.nix {inherit pkgs lib;};
|
|
||||||
};
|
};
|
||||||
in {
|
in {
|
||||||
imports = [
|
imports = [
|
||||||
|
@ -61,7 +55,7 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
settings = mkOption {
|
settings = mkOption {
|
||||||
type = nvfModule;
|
type = attrsOf anythingConcatLists;
|
||||||
default = {};
|
default = {};
|
||||||
description = "Attribute set of nvf preferences.";
|
description = "Attribute set of nvf preferences.";
|
||||||
example = literalExpression ''
|
example = literalExpression ''
|
||||||
|
@ -84,7 +78,7 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
programs.nvf.finalPackage = cfg.settings.vim.build.finalPackage;
|
programs.nvf.finalPackage = neovimConfigured.neovim;
|
||||||
|
|
||||||
home = {
|
home = {
|
||||||
sessionVariables = mkIf cfg.defaultEditor {EDITOR = "nvim";};
|
sessionVariables = mkIf cfg.defaultEditor {EDITOR = "nvim";};
|
||||||
|
|
|
@ -1,28 +1,22 @@
|
||||||
# NixOS module
|
# NixOS module
|
||||||
{
|
packages: lib: {
|
||||||
self,
|
|
||||||
lib,
|
|
||||||
}: {
|
|
||||||
config,
|
config,
|
||||||
pkgs,
|
pkgs,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (self) inputs packages;
|
|
||||||
inherit (lib) maintainers;
|
inherit (lib) maintainers;
|
||||||
inherit (lib.modules) mkIf mkOverride mkAliasOptionModule;
|
inherit (lib.modules) mkIf mkOverride mkAliasOptionModule;
|
||||||
inherit (lib.lists) optional;
|
inherit (lib.lists) optional;
|
||||||
inherit (lib.options) mkOption mkEnableOption literalExpression;
|
inherit (lib.options) mkOption mkEnableOption literalExpression;
|
||||||
inherit (lib.types) anything bool submoduleWith;
|
inherit (lib.types) attrsOf anything bool;
|
||||||
|
inherit (lib.nvim) neovimConfiguration;
|
||||||
|
inherit (lib.nvim.types) anythingConcatLists;
|
||||||
|
|
||||||
cfg = config.programs.nvf;
|
cfg = config.programs.nvf;
|
||||||
|
|
||||||
nvfModule = submoduleWith {
|
neovimConfigured = neovimConfiguration {
|
||||||
description = "Nvf module";
|
inherit pkgs;
|
||||||
class = "nvf";
|
modules = [cfg.settings];
|
||||||
specialArgs = {
|
|
||||||
inherit pkgs lib inputs;
|
|
||||||
};
|
|
||||||
modules = import ../../modules/modules.nix {inherit pkgs lib;};
|
|
||||||
};
|
};
|
||||||
in {
|
in {
|
||||||
imports = [
|
imports = [
|
||||||
|
@ -61,7 +55,7 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
settings = mkOption {
|
settings = mkOption {
|
||||||
type = nvfModule;
|
type = attrsOf anythingConcatLists;
|
||||||
default = {};
|
default = {};
|
||||||
description = "Attribute set of nvf preferences.";
|
description = "Attribute set of nvf preferences.";
|
||||||
example = literalExpression ''
|
example = literalExpression ''
|
||||||
|
@ -84,7 +78,7 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
programs.nvf.finalPackage = cfg.settings.vim.build.finalPackage;
|
programs.nvf.finalPackage = neovimConfigured.neovim;
|
||||||
|
|
||||||
environment = {
|
environment = {
|
||||||
variables.EDITOR = mkIf cfg.defaultEditor (mkOverride 900 "nvim");
|
variables.EDITOR = mkIf cfg.defaultEditor (mkOverride 900 "nvim");
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
docs = import ../docs {inherit pkgs inputs lib;};
|
docs = import ../docs {inherit pkgs inputs lib;};
|
||||||
pluginVersion = input: input.shortRev or input.shortDirtyRev or "dirty";
|
|
||||||
in {
|
in {
|
||||||
packages = {
|
packages = {
|
||||||
inherit (docs.manual) htmlOpenTool;
|
inherit (docs.manual) htmlOpenTool;
|
||||||
|
@ -67,12 +66,6 @@
|
||||||
Volumes = {"/home/neovim/demo" = {};};
|
Volumes = {"/home/neovim/demo" = {};};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
# Plugins that need a compile step
|
|
||||||
blink-cmp = pkgs.callPackage ./packages/blink-cmp.nix {
|
|
||||||
src = inputs.plugin-blink-cmp;
|
|
||||||
version = pluginVersion inputs.plugin-blink-cmp;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,38 +0,0 @@
|
||||||
{
|
|
||||||
rustPlatform,
|
|
||||||
hostPlatform,
|
|
||||||
src,
|
|
||||||
version,
|
|
||||||
vimUtils,
|
|
||||||
}: {
|
|
||||||
blink-cmp = let
|
|
||||||
inherit version src;
|
|
||||||
blink-fuzzy-lib = rustPlatform.buildRustPackage {
|
|
||||||
pname = "blink-fuzzy-lib";
|
|
||||||
inherit version src;
|
|
||||||
|
|
||||||
env = {
|
|
||||||
# TODO: remove this if plugin stops using nightly rust
|
|
||||||
RUSTC_BOOTSTRAP = true;
|
|
||||||
};
|
|
||||||
cargoLock = {
|
|
||||||
lockFile = "${src}/Cargo.lock";
|
|
||||||
outputHashes = {
|
|
||||||
"frizbee-0.1.0" = "sha256-pt6sMsRyjXrbrTK7t/YvWeen/n3nU8UUaiNYTY1LczE=";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
libExt =
|
|
||||||
if hostPlatform.isDarwin
|
|
||||||
then "dylib"
|
|
||||||
else "so";
|
|
||||||
in
|
|
||||||
vimUtils.buildVimPlugin {
|
|
||||||
pname = "blink-cmp";
|
|
||||||
inherit version src;
|
|
||||||
preInstall = ''
|
|
||||||
mkdir -p target/release
|
|
||||||
ln -s ${blink-fuzzy-lib}/lib/libblink_cmp_fuzzy.${libExt} target/release/libblink_cmp_fuzzy.${libExt}
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
}
|
|
|
@ -1,8 +1,57 @@
|
||||||
{lib}: let
|
{lib}: let
|
||||||
inherit (lib.options) mergeEqualOption;
|
inherit (lib.options) showOption showFiles getFiles mergeOneOption mergeEqualOption;
|
||||||
inherit (lib.strings) isString stringLength match;
|
inherit (lib.strings) isString isStringLike;
|
||||||
inherit (lib.types) listOf mkOptionType;
|
inherit (lib.types) anything attrsOf listOf mkOptionType;
|
||||||
|
inherit (lib.nvim.types) anythingConcatLists;
|
||||||
|
inherit (builtins) typeOf isAttrs any head concatLists stringLength match;
|
||||||
in {
|
in {
|
||||||
|
# HACK: Does this break anything in our case?
|
||||||
|
# A modified version of the nixpkgs anything type that concatenates lists
|
||||||
|
# This isn't the default because the order in which the lists are concatenated depends on the order in which the modules are imported,
|
||||||
|
# which makes it non-deterministic
|
||||||
|
anythingConcatLists =
|
||||||
|
anything
|
||||||
|
// {
|
||||||
|
merge = loc: defs: let
|
||||||
|
getType = value:
|
||||||
|
if isAttrs value && isStringLike value
|
||||||
|
then "stringCoercibleSet"
|
||||||
|
else typeOf value;
|
||||||
|
|
||||||
|
# Throw an error if not all defs have the same type
|
||||||
|
checkType = getType (head defs).value;
|
||||||
|
commonType =
|
||||||
|
if any (def: getType def.value != checkType) defs
|
||||||
|
then throw "The option `${showOption loc}' has conflicting option types in ${showFiles (getFiles defs)}"
|
||||||
|
else checkType;
|
||||||
|
|
||||||
|
mergeFunctions = {
|
||||||
|
# Recursively merge attribute sets
|
||||||
|
set = (attrsOf anythingConcatLists).merge;
|
||||||
|
|
||||||
|
# Overridden behavior for lists, that concatenates lists
|
||||||
|
list = _: defs: concatLists (map (e: e.value) defs);
|
||||||
|
|
||||||
|
# This means it's a package, only accept a single definition
|
||||||
|
stringCoercibleSet = mergeOneOption;
|
||||||
|
|
||||||
|
# This works by passing the argument to the functions,
|
||||||
|
# and merging their returns values instead
|
||||||
|
lambda = loc: defs: arg:
|
||||||
|
anythingConcatLists.merge
|
||||||
|
(loc ++ ["<function body>"])
|
||||||
|
(map (def: {
|
||||||
|
inherit (def) file;
|
||||||
|
value = def.value arg;
|
||||||
|
})
|
||||||
|
defs);
|
||||||
|
};
|
||||||
|
in
|
||||||
|
# Merge the defs with the correct function from above, if available
|
||||||
|
# otherwise only allow equal values
|
||||||
|
(mergeFunctions.${commonType} or mergeEqualOption) loc defs;
|
||||||
|
};
|
||||||
|
|
||||||
mergelessListOf = elemType: let
|
mergelessListOf = elemType: let
|
||||||
super = listOf elemType;
|
super = listOf elemType;
|
||||||
in
|
in
|
||||||
|
|
|
@ -11,5 +11,5 @@ in {
|
||||||
inherit (typesDag) dagOf;
|
inherit (typesDag) dagOf;
|
||||||
inherit (typesPlugin) pluginsOpt extraPluginType mkPluginSetupOption luaInline pluginType borderType;
|
inherit (typesPlugin) pluginsOpt extraPluginType mkPluginSetupOption luaInline pluginType borderType;
|
||||||
inherit (typesLanguage) diagnostics mkGrammarOption;
|
inherit (typesLanguage) diagnostics mkGrammarOption;
|
||||||
inherit (customTypes) char hexColor mergelessListOf;
|
inherit (customTypes) anythingConcatLists char hexColor mergelessListOf;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,8 +9,9 @@
|
||||||
extraModules ? [],
|
extraModules ? [],
|
||||||
configuration ? {},
|
configuration ? {},
|
||||||
}: let
|
}: let
|
||||||
inherit (lib.strings) toString;
|
inherit (pkgs) vimPlugins;
|
||||||
inherit (lib.lists) concatLists;
|
inherit (lib.strings) isString toString;
|
||||||
|
inherit (lib.lists) filter map concatLists;
|
||||||
|
|
||||||
# import modules.nix with `check`, `pkgs` and `lib` as arguments
|
# import modules.nix with `check`, `pkgs` and `lib` as arguments
|
||||||
# check can be disabled while calling this file is called
|
# check can be disabled while calling this file is called
|
||||||
|
@ -20,12 +21,7 @@
|
||||||
# evaluate the extended library with the modules
|
# evaluate the extended library with the modules
|
||||||
# optionally with any additional modules passed by the user
|
# optionally with any additional modules passed by the user
|
||||||
module = lib.evalModules {
|
module = lib.evalModules {
|
||||||
specialArgs =
|
specialArgs = extraSpecialArgs // {modulesPath = toString ./.;};
|
||||||
extraSpecialArgs
|
|
||||||
// {
|
|
||||||
inherit inputs;
|
|
||||||
modulesPath = toString ./.;
|
|
||||||
};
|
|
||||||
modules = concatLists [
|
modules = concatLists [
|
||||||
nvimModules
|
nvimModules
|
||||||
modules
|
modules
|
||||||
|
@ -40,11 +36,133 @@
|
||||||
extraModules))
|
extraModules))
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# alias to the internal configuration
|
||||||
|
vimOptions = module.config.vim;
|
||||||
|
|
||||||
|
noBuildPlug = {pname, ...} @ attrs: let
|
||||||
|
src = inputs."plugin-${attrs.pname}";
|
||||||
|
in
|
||||||
|
{
|
||||||
|
version = src.shortRev or src.shortDirtyRev or "dirty";
|
||||||
|
outPath = src;
|
||||||
|
passthru.vimPlugin = false;
|
||||||
|
}
|
||||||
|
// attrs;
|
||||||
|
|
||||||
|
# build a vim plugin with the given name and arguments
|
||||||
|
# if the plugin is nvim-treesitter, warn the user to use buildTreesitterPlug
|
||||||
|
# instead
|
||||||
|
buildPlug = attrs: let
|
||||||
|
src = inputs."plugin-${attrs.pname}";
|
||||||
|
in
|
||||||
|
pkgs.vimUtils.buildVimPlugin (
|
||||||
|
{
|
||||||
|
version = src.shortRev or src.shortDirtyRev or "dirty";
|
||||||
|
inherit src;
|
||||||
|
}
|
||||||
|
// attrs
|
||||||
|
);
|
||||||
|
|
||||||
|
buildTreesitterPlug = grammars: vimPlugins.nvim-treesitter.withPlugins (_: grammars);
|
||||||
|
|
||||||
|
pluginBuilders = {
|
||||||
|
nvim-treesitter = buildTreesitterPlug vimOptions.treesitter.grammars;
|
||||||
|
flutter-tools-patched = buildPlug {
|
||||||
|
pname = "flutter-tools";
|
||||||
|
patches = [../patches/flutter-tools.patch];
|
||||||
|
};
|
||||||
|
blink-cmp = let
|
||||||
|
version = inputs.plugin-blink-cmp.shortRev or inputs.plugin-blink-cmp.shortDirtyRev or "dirty";
|
||||||
|
src = inputs.plugin-blink-cmp;
|
||||||
|
blink-fuzzy-lib = pkgs.rustPlatform.buildRustPackage {
|
||||||
|
pname = "blink-fuzzy-lib";
|
||||||
|
inherit version src;
|
||||||
|
|
||||||
|
env = {
|
||||||
|
# TODO: remove this if plugin stops using nightly rust
|
||||||
|
RUSTC_BOOTSTRAP = true;
|
||||||
|
};
|
||||||
|
cargoLock = {
|
||||||
|
lockFile = "${src}/Cargo.lock";
|
||||||
|
outputHashes = {
|
||||||
|
"frizbee-0.1.0" = "sha256-pt6sMsRyjXrbrTK7t/YvWeen/n3nU8UUaiNYTY1LczE=";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
libExt =
|
||||||
|
if pkgs.hostPlatform.isDarwin
|
||||||
|
then "dylib"
|
||||||
|
else "so";
|
||||||
|
in
|
||||||
|
buildPlug {
|
||||||
|
pname = "blink-cmp";
|
||||||
|
inherit version src;
|
||||||
|
preInstall = ''
|
||||||
|
mkdir -p target/release
|
||||||
|
ln -s ${blink-fuzzy-lib}/lib/libblink_cmp_fuzzy.${libExt} target/release/libblink_cmp_fuzzy.${libExt}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
buildConfigPlugins = plugins:
|
||||||
|
map (
|
||||||
|
plug:
|
||||||
|
if (isString plug)
|
||||||
|
then pluginBuilders.${plug} or (noBuildPlug {pname = plug;})
|
||||||
|
else plug
|
||||||
|
) (filter (f: f != null) plugins);
|
||||||
|
|
||||||
|
# built (or "normalized") plugins that are modified
|
||||||
|
builtStartPlugins = buildConfigPlugins vimOptions.startPlugins;
|
||||||
|
builtOptPlugins = map (package: package // {optional = true;}) (buildConfigPlugins vimOptions.optPlugins);
|
||||||
|
|
||||||
|
# additional Lua and Python3 packages, mapped to their respective functions
|
||||||
|
# to conform to the format mnw expects. end user should
|
||||||
|
# only ever need to pass a list of packages, which are modified
|
||||||
|
# here
|
||||||
|
extraLuaPackages = ps: map (x: ps.${x}) vimOptions.luaPackages;
|
||||||
|
extraPython3Packages = ps: map (x: ps.${x}) vimOptions.python3Packages;
|
||||||
|
|
||||||
|
# Wrap the user's desired (unwrapped) Neovim package with arguments that'll be used to
|
||||||
|
# generate a wrapped Neovim package.
|
||||||
|
neovim-wrapped = inputs.mnw.lib.wrap pkgs {
|
||||||
|
neovim = vimOptions.package;
|
||||||
|
plugins = builtStartPlugins ++ builtOptPlugins;
|
||||||
|
appName = "nvf";
|
||||||
|
extraBinPath = vimOptions.extraPackages;
|
||||||
|
initLua = vimOptions.builtLuaConfigRC;
|
||||||
|
luaFiles = vimOptions.extraLuaFiles;
|
||||||
|
|
||||||
|
inherit (vimOptions) viAlias vimAlias withRuby withNodeJs withPython3;
|
||||||
|
inherit extraLuaPackages extraPython3Packages;
|
||||||
|
};
|
||||||
|
|
||||||
|
dummyInit = pkgs.writeText "nvf-init.lua" vimOptions.builtLuaConfigRC;
|
||||||
|
# Additional helper scripts for printing and displaying nvf configuration
|
||||||
|
# in your commandline.
|
||||||
|
printConfig = pkgs.writers.writeDashBin "nvf-print-config" "cat ${dummyInit}";
|
||||||
|
printConfigPath = pkgs.writers.writeDashBin "nvf-print-config-path" "echo -n ${dummyInit}";
|
||||||
in {
|
in {
|
||||||
inherit (module) options config;
|
inherit (module) options config;
|
||||||
inherit (module._module.args) pkgs;
|
inherit (module._module.args) pkgs;
|
||||||
|
|
||||||
# Expose wrapped neovim-package for userspace
|
# Expose wrapped neovim-package for userspace
|
||||||
# or module consumption.
|
# or module consumption.
|
||||||
neovim = module.config.vim.build.finalPackage;
|
neovim = pkgs.symlinkJoin {
|
||||||
|
name = "nvf-with-helpers";
|
||||||
|
paths = [neovim-wrapped printConfig printConfigPath];
|
||||||
|
postBuild = "echo Helpers added";
|
||||||
|
|
||||||
|
# Allow evaluating vimOptions, i.e., config.vim from the packages' passthru
|
||||||
|
# attribute. For example, packages.x86_64-linux.neovim.passthru.neovimConfig
|
||||||
|
# will return the configuration in full.
|
||||||
|
passthru.neovimConfig = vimOptions;
|
||||||
|
|
||||||
|
meta =
|
||||||
|
neovim-wrapped.meta
|
||||||
|
// {
|
||||||
|
description = "Wrapped Neovim package with helper scripts to print the config (path)";
|
||||||
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,6 @@
|
||||||
# using the configuration passed in `neovim` and `plugins` modules.
|
# using the configuration passed in `neovim` and `plugins` modules.
|
||||||
wrapper = map (p: ./wrapper + "/${p}") [
|
wrapper = map (p: ./wrapper + "/${p}") [
|
||||||
"build"
|
"build"
|
||||||
"environment"
|
|
||||||
"rc"
|
"rc"
|
||||||
"warnings"
|
"warnings"
|
||||||
"lazy"
|
"lazy"
|
||||||
|
|
|
@ -1,111 +1,13 @@
|
||||||
{
|
{
|
||||||
inputs,
|
|
||||||
lib,
|
|
||||||
config,
|
config,
|
||||||
pkgs,
|
lib,
|
||||||
...
|
...
|
||||||
}
|
}: let
|
||||||
: let
|
inherit (lib.attrsets) attrValues;
|
||||||
inherit (pkgs) vimPlugins;
|
|
||||||
inherit (lib.strings) isString;
|
|
||||||
inherit (lib.lists) filter map;
|
|
||||||
|
|
||||||
# alias to the internal configuration
|
cfg = config.vim;
|
||||||
vimOptions = config.vim;
|
|
||||||
|
|
||||||
noBuildPlug = {pname, ...} @ attrs: let
|
|
||||||
src = inputs."plugin-${attrs.pname}";
|
|
||||||
in
|
|
||||||
{
|
|
||||||
version = src.shortRev or src.shortDirtyRev or "dirty";
|
|
||||||
outPath = src;
|
|
||||||
passthru.vimPlugin = false;
|
|
||||||
}
|
|
||||||
// attrs;
|
|
||||||
|
|
||||||
# build a vim plugin with the given name and arguments
|
|
||||||
# if the plugin is nvim-treesitter, warn the user to use buildTreesitterPlug
|
|
||||||
# instead
|
|
||||||
buildPlug = attrs: let
|
|
||||||
src = inputs."plugin-${attrs.pname}";
|
|
||||||
in
|
|
||||||
pkgs.vimUtils.buildVimPlugin (
|
|
||||||
{
|
|
||||||
version = src.shortRev or src.shortDirtyRev or "dirty";
|
|
||||||
inherit src;
|
|
||||||
}
|
|
||||||
// attrs
|
|
||||||
);
|
|
||||||
|
|
||||||
buildTreesitterPlug = grammars: vimPlugins.nvim-treesitter.withPlugins (_: grammars);
|
|
||||||
|
|
||||||
pluginBuilders = {
|
|
||||||
nvim-treesitter = buildTreesitterPlug vimOptions.treesitter.grammars;
|
|
||||||
flutter-tools-patched = buildPlug {
|
|
||||||
pname = "flutter-tools";
|
|
||||||
patches = [../patches/flutter-tools.patch];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
buildConfigPlugins = plugins:
|
|
||||||
map (
|
|
||||||
plug:
|
|
||||||
if (isString plug)
|
|
||||||
then pluginBuilders.${plug} or (noBuildPlug {pname = plug;})
|
|
||||||
else plug
|
|
||||||
) (filter (f: f != null) plugins);
|
|
||||||
|
|
||||||
# built (or "normalized") plugins that are modified
|
|
||||||
builtStartPlugins = buildConfigPlugins vimOptions.startPlugins;
|
|
||||||
builtOptPlugins = map (package: package // {optional = true;}) (buildConfigPlugins vimOptions.optPlugins);
|
|
||||||
|
|
||||||
# additional Lua and Python3 packages, mapped to their respective functions
|
|
||||||
# to conform to the format mnw expects. end user should
|
|
||||||
# only ever need to pass a list of packages, which are modified
|
|
||||||
# here
|
|
||||||
extraLuaPackages = ps: map (x: ps.${x}) vimOptions.luaPackages;
|
|
||||||
extraPython3Packages = ps: map (x: ps.${x}) vimOptions.python3Packages;
|
|
||||||
|
|
||||||
# Wrap the user's desired (unwrapped) Neovim package with arguments that'll be used to
|
|
||||||
# generate a wrapped Neovim package.
|
|
||||||
neovim-wrapped = inputs.mnw.lib.wrap pkgs {
|
|
||||||
neovim = vimOptions.package;
|
|
||||||
plugins = builtStartPlugins ++ builtOptPlugins;
|
|
||||||
appName = "nvf";
|
|
||||||
extraBinPath = vimOptions.extraPackages;
|
|
||||||
initLua = vimOptions.builtLuaConfigRC;
|
|
||||||
luaFiles = vimOptions.extraLuaFiles;
|
|
||||||
|
|
||||||
inherit (vimOptions) viAlias vimAlias withRuby withNodeJs withPython3;
|
|
||||||
inherit extraLuaPackages extraPython3Packages;
|
|
||||||
};
|
|
||||||
|
|
||||||
dummyInit = pkgs.writeText "nvf-init.lua" vimOptions.builtLuaConfigRC;
|
|
||||||
# Additional helper scripts for printing and displaying nvf configuration
|
|
||||||
# in your commandline.
|
|
||||||
printConfig = pkgs.writers.writeDashBin "nvf-print-config" "cat ${dummyInit}";
|
|
||||||
printConfigPath = pkgs.writers.writeDashBin "nvf-print-config-path" "echo -n ${dummyInit}";
|
|
||||||
|
|
||||||
# Expose wrapped neovim-package for userspace
|
|
||||||
# or module consumption.
|
|
||||||
neovim = pkgs.symlinkJoin {
|
|
||||||
name = "nvf-with-helpers";
|
|
||||||
paths = [neovim-wrapped printConfig printConfigPath];
|
|
||||||
postBuild = "echo Helpers added";
|
|
||||||
|
|
||||||
# Allow evaluating vimOptions, i.e., config.vim from the packages' passthru
|
|
||||||
# attribute. For example, packages.x86_64-linux.neovim.passthru.neovimConfig
|
|
||||||
# will return the configuration in full.
|
|
||||||
passthru.neovimConfig = vimOptions;
|
|
||||||
|
|
||||||
meta =
|
|
||||||
neovim-wrapped.meta
|
|
||||||
// {
|
|
||||||
description = "Wrapped Neovim package with helper scripts to print the config (path)";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
in {
|
in {
|
||||||
config.vim.build = {
|
config = {
|
||||||
finalPackage = neovim;
|
vim.startPlugins = map (x: x.package) (attrValues cfg.extraPlugins);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
./options.nix
|
|
||||||
./config.nix
|
./config.nix
|
||||||
|
./options.nix
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,144 @@
|
||||||
{lib, ...}: let
|
{
|
||||||
inherit (lib.types) package;
|
pkgs,
|
||||||
inherit (lib.options) mkOption;
|
lib,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
inherit (lib.options) mkOption mkEnableOption literalMD;
|
||||||
|
inherit (lib.types) package bool str listOf attrsOf;
|
||||||
|
inherit (lib.nvim.types) pluginsOpt extraPluginType;
|
||||||
in {
|
in {
|
||||||
options.vim.build = {
|
options.vim = {
|
||||||
finalPackage = mkOption {
|
package = mkOption {
|
||||||
type = package;
|
type = package;
|
||||||
readOnly = true;
|
default = pkgs.neovim-unwrapped;
|
||||||
description = "final output package";
|
description = ''
|
||||||
|
The neovim package to use for the wrapper. This
|
||||||
|
corresponds to the package that will be wrapped
|
||||||
|
with your plugins and settings.
|
||||||
|
|
||||||
|
::: {.warning}
|
||||||
|
You will need to use an unwrapped package for this
|
||||||
|
option to work as intended. Using an already wrapped
|
||||||
|
package here may yield undesirable results.
|
||||||
|
:::
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
viAlias = mkOption {
|
||||||
|
type = bool;
|
||||||
|
default = true;
|
||||||
|
description = "Enable the `vi` alias for `nvim`";
|
||||||
|
};
|
||||||
|
|
||||||
|
vimAlias = mkOption {
|
||||||
|
type = bool;
|
||||||
|
default = true;
|
||||||
|
description = "Enable the `vim` alias for `nvim`";
|
||||||
|
};
|
||||||
|
|
||||||
|
startPlugins = pluginsOpt {
|
||||||
|
default = ["plenary-nvim"];
|
||||||
|
example = ''
|
||||||
|
[pkgs.vimPlugins.telescope-nvim]
|
||||||
|
'';
|
||||||
|
|
||||||
|
description = ''
|
||||||
|
List of plugins to load on startup. This is used
|
||||||
|
internally to add plugins to Neovim's runtime.
|
||||||
|
|
||||||
|
To add additional plugins to your configuration, consider
|
||||||
|
using the [{option}`vim.extraPlugins`](#opt-vim.extraPlugins)
|
||||||
|
option.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
optPlugins = pluginsOpt {
|
||||||
|
default = [];
|
||||||
|
example = ''
|
||||||
|
[pkgs.vimPlugins.vim-ghost]
|
||||||
|
'';
|
||||||
|
description = ''
|
||||||
|
List of plugins to optionally load on startup.
|
||||||
|
|
||||||
|
This option has the same type definition as {option}`vim.startPlugins`
|
||||||
|
and plugins in this list are appended to {option}`vim.startPlugins` by
|
||||||
|
the wrapper during the build process.
|
||||||
|
|
||||||
|
To avoid overriding packages and dependencies provided by startPlugins, you
|
||||||
|
are recommended to use this option or {option}`vim.extraPlugins` option.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
extraPlugins = mkOption {
|
||||||
|
type = attrsOf extraPluginType;
|
||||||
|
default = {};
|
||||||
|
description = ''
|
||||||
|
A list of plugins and their configurations that will be
|
||||||
|
set up after builtin plugins.
|
||||||
|
|
||||||
|
This option takes a special type that allows you to order
|
||||||
|
your custom plugins using nvf's modified DAG library.
|
||||||
|
'';
|
||||||
|
|
||||||
|
example = literalMD ''
|
||||||
|
```nix
|
||||||
|
with pkgs.vimPlugins; {
|
||||||
|
aerial = {
|
||||||
|
package = aerial-nvim;
|
||||||
|
setup = "require('aerial').setup {}";
|
||||||
|
};
|
||||||
|
|
||||||
|
harpoon = {
|
||||||
|
package = harpoon;
|
||||||
|
setup = "require('harpoon').setup {}";
|
||||||
|
after = ["aerial"]; # place harpoon configuration after aerial
|
||||||
|
};
|
||||||
|
}
|
||||||
|
```
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
extraPackages = mkOption {
|
||||||
|
type = listOf package;
|
||||||
|
default = [];
|
||||||
|
example = ''[pkgs.fzf pkgs.ripgrep]'';
|
||||||
|
description = ''
|
||||||
|
List of additional packages to make available to the Neovim
|
||||||
|
wrapper.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
# this defaults to `true` in the wrapper
|
||||||
|
# and since we pass this value to the wrapper
|
||||||
|
# with an inherit, it should be `true` here as well
|
||||||
|
withRuby =
|
||||||
|
mkEnableOption ''
|
||||||
|
Ruby support in the Neovim wrapper.
|
||||||
|
''
|
||||||
|
// {
|
||||||
|
default = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
withNodeJs = mkEnableOption ''
|
||||||
|
NodeJs support in the Neovim wrapper
|
||||||
|
'';
|
||||||
|
|
||||||
|
luaPackages = mkOption {
|
||||||
|
type = listOf str;
|
||||||
|
default = [];
|
||||||
|
example = ''["magick" "serpent"]'';
|
||||||
|
description = "List of lua packages to install";
|
||||||
|
};
|
||||||
|
|
||||||
|
withPython3 = mkEnableOption ''
|
||||||
|
Python3 support in the Neovim wrapper
|
||||||
|
'';
|
||||||
|
|
||||||
|
python3Packages = mkOption {
|
||||||
|
type = listOf str;
|
||||||
|
default = [];
|
||||||
|
example = ''["pynvim"]'';
|
||||||
|
description = "List of python packages to install";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
{
|
|
||||||
config,
|
|
||||||
lib,
|
|
||||||
...
|
|
||||||
}: let
|
|
||||||
inherit (lib.attrsets) attrValues;
|
|
||||||
|
|
||||||
cfg = config.vim;
|
|
||||||
in {
|
|
||||||
config = {
|
|
||||||
vim.startPlugins = map (x: x.package) (attrValues cfg.extraPlugins);
|
|
||||||
};
|
|
||||||
}
|
|
|
@ -1,6 +0,0 @@
|
||||||
{
|
|
||||||
imports = [
|
|
||||||
./config.nix
|
|
||||||
./options.nix
|
|
||||||
];
|
|
||||||
}
|
|
|
@ -1,144 +0,0 @@
|
||||||
{
|
|
||||||
pkgs,
|
|
||||||
lib,
|
|
||||||
...
|
|
||||||
}: let
|
|
||||||
inherit (lib.options) mkOption mkEnableOption literalMD;
|
|
||||||
inherit (lib.types) package bool str listOf attrsOf;
|
|
||||||
inherit (lib.nvim.types) pluginsOpt extraPluginType;
|
|
||||||
in {
|
|
||||||
options.vim = {
|
|
||||||
package = mkOption {
|
|
||||||
type = package;
|
|
||||||
default = pkgs.neovim-unwrapped;
|
|
||||||
description = ''
|
|
||||||
The neovim package to use for the wrapper. This
|
|
||||||
corresponds to the package that will be wrapped
|
|
||||||
with your plugins and settings.
|
|
||||||
|
|
||||||
::: {.warning}
|
|
||||||
You will need to use an unwrapped package for this
|
|
||||||
option to work as intended. Using an already wrapped
|
|
||||||
package here may yield undesirable results.
|
|
||||||
:::
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
viAlias = mkOption {
|
|
||||||
type = bool;
|
|
||||||
default = true;
|
|
||||||
description = "Enable the `vi` alias for `nvim`";
|
|
||||||
};
|
|
||||||
|
|
||||||
vimAlias = mkOption {
|
|
||||||
type = bool;
|
|
||||||
default = true;
|
|
||||||
description = "Enable the `vim` alias for `nvim`";
|
|
||||||
};
|
|
||||||
|
|
||||||
startPlugins = pluginsOpt {
|
|
||||||
default = ["plenary-nvim"];
|
|
||||||
example = ''
|
|
||||||
[pkgs.vimPlugins.telescope-nvim]
|
|
||||||
'';
|
|
||||||
|
|
||||||
description = ''
|
|
||||||
List of plugins to load on startup. This is used
|
|
||||||
internally to add plugins to Neovim's runtime.
|
|
||||||
|
|
||||||
To add additional plugins to your configuration, consider
|
|
||||||
using the [{option}`vim.extraPlugins`](#opt-vim.extraPlugins)
|
|
||||||
option.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
optPlugins = pluginsOpt {
|
|
||||||
default = [];
|
|
||||||
example = ''
|
|
||||||
[pkgs.vimPlugins.vim-ghost]
|
|
||||||
'';
|
|
||||||
description = ''
|
|
||||||
List of plugins to optionally load on startup.
|
|
||||||
|
|
||||||
This option has the same type definition as {option}`vim.startPlugins`
|
|
||||||
and plugins in this list are appended to {option}`vim.startPlugins` by
|
|
||||||
the wrapper during the build process.
|
|
||||||
|
|
||||||
To avoid overriding packages and dependencies provided by startPlugins, you
|
|
||||||
are recommended to use this option or {option}`vim.extraPlugins` option.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
extraPlugins = mkOption {
|
|
||||||
type = attrsOf extraPluginType;
|
|
||||||
default = {};
|
|
||||||
description = ''
|
|
||||||
A list of plugins and their configurations that will be
|
|
||||||
set up after builtin plugins.
|
|
||||||
|
|
||||||
This option takes a special type that allows you to order
|
|
||||||
your custom plugins using nvf's modified DAG library.
|
|
||||||
'';
|
|
||||||
|
|
||||||
example = literalMD ''
|
|
||||||
```nix
|
|
||||||
with pkgs.vimPlugins; {
|
|
||||||
aerial = {
|
|
||||||
package = aerial-nvim;
|
|
||||||
setup = "require('aerial').setup {}";
|
|
||||||
};
|
|
||||||
|
|
||||||
harpoon = {
|
|
||||||
package = harpoon;
|
|
||||||
setup = "require('harpoon').setup {}";
|
|
||||||
after = ["aerial"]; # place harpoon configuration after aerial
|
|
||||||
};
|
|
||||||
}
|
|
||||||
```
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
extraPackages = mkOption {
|
|
||||||
type = listOf package;
|
|
||||||
default = [];
|
|
||||||
example = ''[pkgs.fzf pkgs.ripgrep]'';
|
|
||||||
description = ''
|
|
||||||
List of additional packages to make available to the Neovim
|
|
||||||
wrapper.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
# this defaults to `true` in the wrapper
|
|
||||||
# and since we pass this value to the wrapper
|
|
||||||
# with an inherit, it should be `true` here as well
|
|
||||||
withRuby =
|
|
||||||
mkEnableOption ''
|
|
||||||
Ruby support in the Neovim wrapper.
|
|
||||||
''
|
|
||||||
// {
|
|
||||||
default = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
withNodeJs = mkEnableOption ''
|
|
||||||
NodeJs support in the Neovim wrapper
|
|
||||||
'';
|
|
||||||
|
|
||||||
luaPackages = mkOption {
|
|
||||||
type = listOf str;
|
|
||||||
default = [];
|
|
||||||
example = ''["magick" "serpent"]'';
|
|
||||||
description = "List of lua packages to install";
|
|
||||||
};
|
|
||||||
|
|
||||||
withPython3 = mkEnableOption ''
|
|
||||||
Python3 support in the Neovim wrapper
|
|
||||||
'';
|
|
||||||
|
|
||||||
python3Packages = mkOption {
|
|
||||||
type = listOf str;
|
|
||||||
default = [];
|
|
||||||
example = ''["pynvim"]'';
|
|
||||||
description = "List of python packages to install";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
Loading…
Reference in a new issue