mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2024-12-19 07:29:49 +01:00
21fcace3ed
* flake: add lz.n and lzn-auto-require * lazy: init module * lzn-auto-require: add init lua code * wrapper: fix opt plugin format * lib.binds: add lz.n variant of bind functions * telescope: lazy load * nvim-tree: lazy load * dapui: lazy load * trouble: lazy load * toggleterm: lazy load * cheatsheet: lazy load * diffview: lazy load * icon-picker: lazy load * leap: lazy load * fidget: lazy load * docs: add section on lazy plugins * lazy: support lazy.enable=false * comment-nvim: lazy load * surround-nvim: lazy load * neo-tree: lazy load * fixup! lazy: init module * dap: appease the nix gods (fix statix lint) * flake.lock: fix merge mistake * doc: update release note * fixup! doc: update release note * neo-tree: fix duplicate neo-tree install * lazy: use attrsOf for lazy.plugins * treewide: update lazy.plugins syntax * docs: update lazy.plugins syntax * lazy: cleanup * Update docs/manual/hacking/additional-plugins.md Co-authored-by: diniamo <55629891+diniamo@users.noreply.github.com> * formatting nitpick Co-authored-by: diniamo <55629891+diniamo@users.noreply.github.com> * typo tee hee :3 Co-authored-by: diniamo <55629891+diniamo@users.noreply.github.com> * typo tee hee :4 Co-authored-by: diniamo <55629891+diniamo@users.noreply.github.com> * flake: update lz.n * lazy: update lz.n plugin spec * lazy: allow lines in place of str for lua code * copilot: lazy load * cmp: lazy load this moves cmp itself to lazy.plugins but other plugins that call cmp are not yet lazy so cmp is technically not yet lazy * luasnip: lazy load * flake: add rtp.nvim * cmp: actually lazy load source * fixup! cmp: actually lazy load source * format * docs: fix broken link * cmp-nvim-lsp: lazy load * lazy: allow key mode of str type * cmp: install sourcess via cmp.sourcePlugins * Update docs/manual/hacking/additional-plugins.md Co-authored-by: diniamo <55629891+diniamo@users.noreply.github.com> * lazy: refactor common var * nvim-dap-ui: add setupOpts * refactor: re-order plugin and lz.n configs lazy: make lzn-auto-require togglable * docs: update dag-entries * trouble: remove redundant import * lazy: remove unused module arg * toggleterm: make lazygit keybind optional * toggleterm: use toLuaObject for clarity * surround: rework keymap config * remove stale FIXME * lsp: use cmp_nvim_lsp capabilities * cmp: deduplicate attr key * theme: ensure themes load before lazy plugins * doc: update description of `theme` dag entry * lsp: avoid loading cmp on startup * doc: update configuration docs on custom plugins * cmp: skip trigger_load if lazy disabled * treesitter: remove redundant code * lsp: mark hack as HACK * comment: remove redundant plugin * Squash merge v0.7 into feature/lzn --------- Co-authored-by: raf <raf@notashelf.dev> Co-authored-by: diniamo <55629891+diniamo@users.noreply.github.com>
131 lines
4.2 KiB
Nix
131 lines
4.2 KiB
Nix
{
|
|
inputs,
|
|
lib,
|
|
}: {
|
|
pkgs,
|
|
extraSpecialArgs ? {},
|
|
modules ? [],
|
|
# deprecated
|
|
extraModules ? [],
|
|
configuration ? {},
|
|
}: let
|
|
inherit (pkgs) vimPlugins;
|
|
inherit (lib.strings) isString toString;
|
|
inherit (lib.lists) filter map concatLists;
|
|
|
|
# import modules.nix with `check`, `pkgs` and `lib` as arguments
|
|
# check can be disabled while calling this file is called
|
|
# to avoid checking in all modules
|
|
nvimModules = import ./modules.nix {inherit pkgs lib;};
|
|
|
|
# evaluate the extended library with the modules
|
|
# optionally with any additional modules passed by the user
|
|
module = lib.evalModules {
|
|
specialArgs = extraSpecialArgs // {modulesPath = toString ./.;};
|
|
modules = concatLists [
|
|
nvimModules
|
|
modules
|
|
(lib.optional (configuration != {}) (lib.warn ''
|
|
nvf: passing 'configuration' to lib.neovimConfiguration is deprecated.
|
|
''
|
|
configuration))
|
|
|
|
(lib.optionals (extraModules != []) (lib.warn ''
|
|
nvf: passing 'extraModules' to lib.neovimConfiguration is deprecated, use 'modules' instead.
|
|
''
|
|
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];
|
|
};
|
|
};
|
|
|
|
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 {
|
|
inherit (module) options config;
|
|
inherit (module._module.args) pkgs;
|
|
|
|
# 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";
|
|
|
|
meta = {
|
|
description = "Wrapped version of Neovim with additional helper scripts";
|
|
mainProgram = "nvim";
|
|
};
|
|
};
|
|
}
|