mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2024-11-07 14:55:59 +01:00
style: improve modules/default.nix code, rename helper scripts (#351)
Co-authored-by: raf <raf@notashelf.dev>
This commit is contained in:
parent
fd65c83956
commit
de20ff2c51
2 changed files with 37 additions and 53 deletions
|
@ -143,10 +143,10 @@ configuration formats.
|
||||||
- Add [neo-tree.nvim] as an alternative file-tree plugin. It will be available
|
- Add [neo-tree.nvim] as an alternative file-tree plugin. It will be available
|
||||||
under `vim.filetree.neo-tree`, similar to nvimtree.
|
under `vim.filetree.neo-tree`, similar to nvimtree.
|
||||||
|
|
||||||
- Add `print-nvf-config` & `print-nvf-config-path` helper scripts to Neovim
|
- Add `nvf-print-config` & `nvf-print-config-path` helper scripts to Neovim
|
||||||
closure. Both of those scripts have been automatically added to your PATH upon
|
closure. Both of those scripts have been automatically added to your PATH upon
|
||||||
using neovimConfig or `programs.nvf.enable`.
|
using neovimConfig or `programs.nvf.enable`.
|
||||||
- `print-nvf-config` will display your `init.lua`, in full.
|
- `nvf-print-config` will display your `init.lua`, in full.
|
||||||
- `print-nvf-config-path` will display the path to _a clone_ of your
|
- `nvf-print-config-path` will display the path to _a clone_ of your
|
||||||
`init.lua`. This is not the path used by the Neovim wrapper, but an
|
`init.lua`. This is not the path used by the Neovim wrapper, but an
|
||||||
identical clone.
|
identical clone.
|
||||||
|
|
|
@ -7,11 +7,9 @@ inputs: {
|
||||||
extraModules ? [],
|
extraModules ? [],
|
||||||
}: let
|
}: let
|
||||||
inherit (pkgs) vimPlugins;
|
inherit (pkgs) vimPlugins;
|
||||||
inherit (pkgs.vimUtils) buildVimPlugin;
|
|
||||||
inherit (lib.strings) isString toString;
|
inherit (lib.strings) isString toString;
|
||||||
inherit (lib.lists) filter map concatLists;
|
inherit (lib.lists) filter map concatLists;
|
||||||
inherit (lib.attrsets) recursiveUpdate getAttr;
|
inherit (lib.attrsets) recursiveUpdate;
|
||||||
inherit (lib.asserts) assertMsg;
|
|
||||||
|
|
||||||
# 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
|
||||||
|
@ -33,12 +31,21 @@ inputs: {
|
||||||
# build a vim plugin with the given name and arguments
|
# build a vim plugin with the given name and arguments
|
||||||
# if the plugin is nvim-treesitter, warn the user to use buildTreesitterPlug
|
# if the plugin is nvim-treesitter, warn the user to use buildTreesitterPlug
|
||||||
# instead
|
# instead
|
||||||
buildPlug = {pname, ...} @ attrs: let
|
buildPlug = attrs: let
|
||||||
src = getAttr ("plugin-" + pname) inputs;
|
src = inputs."plugin-${attrs.pname}";
|
||||||
in
|
in
|
||||||
pkgs.stdenvNoCC.mkDerivation ({
|
pkgs.stdenvNoCC.mkDerivation ({
|
||||||
inherit src;
|
|
||||||
version = src.shortRev or src.shortDirtyRev or "dirty";
|
version = src.shortRev or src.shortDirtyRev or "dirty";
|
||||||
|
|
||||||
|
inherit src;
|
||||||
|
|
||||||
|
nativeBuildInputs = with pkgs.vimUtils; [
|
||||||
|
vimCommandCheckHook
|
||||||
|
vimGenDocHook
|
||||||
|
neovimRequireCheckHook
|
||||||
|
];
|
||||||
|
passthru.vimPlugin = true;
|
||||||
|
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
runHook preInstall
|
runHook preInstall
|
||||||
|
|
||||||
|
@ -50,41 +57,27 @@ inputs: {
|
||||||
}
|
}
|
||||||
// attrs);
|
// attrs);
|
||||||
|
|
||||||
noBuildPlug = {pname, ...} @ attrs: let
|
|
||||||
input = getAttr ("plugin-" + pname) inputs;
|
|
||||||
in
|
|
||||||
{
|
|
||||||
version = input.shortRev or input.shortDirtyRev or "dirty";
|
|
||||||
outPath = getAttr ("plugin-" + pname) inputs;
|
|
||||||
}
|
|
||||||
// attrs;
|
|
||||||
|
|
||||||
buildTreesitterPlug = grammars: vimPlugins.nvim-treesitter.withPlugins (_: grammars);
|
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:
|
buildConfigPlugins = plugins:
|
||||||
map
|
map
|
||||||
(plug: (
|
(
|
||||||
if (isString plug)
|
plug:
|
||||||
then
|
if (isString plug)
|
||||||
(
|
then pluginBuilders.${plug} or (buildPlug {pname = plug;})
|
||||||
if (plug == "nvim-treesitter")
|
else plug
|
||||||
then (buildTreesitterPlug vimOptions.treesitter.grammars)
|
)
|
||||||
else if (plug == "flutter-tools-patched")
|
(filter (f: f != null) plugins);
|
||||||
then
|
|
||||||
(
|
|
||||||
buildPlug
|
|
||||||
{
|
|
||||||
pname = "flutter-tools";
|
|
||||||
patches = [../patches/flutter-tools.patch];
|
|
||||||
}
|
|
||||||
)
|
|
||||||
else noBuildPlug {pname = plug;}
|
|
||||||
)
|
|
||||||
else plug
|
|
||||||
))
|
|
||||||
(filter
|
|
||||||
(f: f != null)
|
|
||||||
plugins);
|
|
||||||
|
|
||||||
# built (or "normalized") plugins that are modified
|
# built (or "normalized") plugins that are modified
|
||||||
builtStartPlugins = buildConfigPlugins vimOptions.startPlugins;
|
builtStartPlugins = buildConfigPlugins vimOptions.startPlugins;
|
||||||
|
@ -114,20 +107,11 @@ inputs: {
|
||||||
inherit extraLuaPackages extraPython3Packages;
|
inherit extraLuaPackages extraPython3Packages;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
dummyInit = pkgs.writeText "nvf-init.lua" vimOptions.builtLuaConfigRC;
|
||||||
# Additional helper scripts for printing and displaying nvf configuration
|
# Additional helper scripts for printing and displaying nvf configuration
|
||||||
# in your commandline.
|
# in your commandline.
|
||||||
printConfig = pkgs.writers.writeDashBin "print-nvf-config" ''
|
printConfig = pkgs.writers.writeDashBin "nvf-print-config" "cat ${dummyInit}";
|
||||||
cat << EOF
|
printConfigPath = pkgs.writers.writeDashBin "nvf-print-config-path" "echo -n ${dummyInit}";
|
||||||
${vimOptions.builtLuaConfigRC}
|
|
||||||
EOF
|
|
||||||
'';
|
|
||||||
|
|
||||||
printConfigPath = pkgs.writers.writeDashBin "print-nvf-config-path" ''
|
|
||||||
realpath ${pkgs.writeTextFile {
|
|
||||||
name = "nvf-init.lua";
|
|
||||||
text = vimOptions.builtLuaConfigRC;
|
|
||||||
}}
|
|
||||||
'';
|
|
||||||
in {
|
in {
|
||||||
inherit (module) options config;
|
inherit (module) options config;
|
||||||
inherit (module._module.args) pkgs;
|
inherit (module._module.args) pkgs;
|
||||||
|
@ -137,7 +121,7 @@ in {
|
||||||
neovim = pkgs.symlinkJoin {
|
neovim = pkgs.symlinkJoin {
|
||||||
name = "nvf-with-helpers";
|
name = "nvf-with-helpers";
|
||||||
paths = [neovim-wrapped printConfig printConfigPath];
|
paths = [neovim-wrapped printConfig printConfigPath];
|
||||||
postBuild = "echo helpers added";
|
postBuild = "echo Helpers added";
|
||||||
|
|
||||||
meta = {
|
meta = {
|
||||||
description = "Wrapped version of Neovim with additional helper scripts";
|
description = "Wrapped version of Neovim with additional helper scripts";
|
||||||
|
|
Loading…
Reference in a new issue