From 8b15271f6364286e11aa6c1f9fda8e02c3ec581b Mon Sep 17 00:00:00 2001 From: raf Date: Sat, 20 Jul 2024 13:01:40 +0000 Subject: [PATCH] modules: add helper scripts (#346) * modules: add helpers to display init.lua and its store path * docs: update 0.7 release notes * modules: use writeDashBin for helpers --- docs/release-notes/rl-0.7.md | 8 ++++++++ modules/default.nix | 24 ++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md index c1b05bc..e35549e 100644 --- a/docs/release-notes/rl-0.7.md +++ b/docs/release-notes/rl-0.7.md @@ -141,3 +141,11 @@ configuration formats. - Add [neo-tree.nvim] as an alternative file-tree plugin. It will be available under `vim.filetree.neo-tree`, similar to nvimtree. + +- Add `print-nvf-config` & `print-nvf-config-path` helper scripts to Neovim + closure. Both of those scripts have been automatically added to your PATH upon + using neovimConfig or `programs.nvf.enable`. + - `print-nvf-config` will display your `init.lua`, in full. + - `print-nvf-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 + identical clone. diff --git a/modules/default.nix b/modules/default.nix index fbcdb70..2099749 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -105,10 +105,30 @@ inputs: { inherit (vimOptions) viAlias vimAlias withRuby withNodeJs withPython3; inherit extraLuaPackages extraPython3Packages; }; + + # Additional helper scripts for printing and displaying nvf configuration + # in your commandline. + printConfig = pkgs.writers.writeDashBin "print-nvf-config" '' + cat << EOF + ${vimOptions.builtLuaConfigRC} + EOF + ''; + + printConfigPath = pkgs.writers.writeDashBin "print-nvf-config-path" '' + realpath ${pkgs.writeTextFile { + name = "nvf-init.lua"; + text = vimOptions.builtLuaConfigRC; + }} + ''; in { inherit (module) options config; inherit (module._module.args) pkgs; - # expose wrapped neovim-package - neovim = neovim-wrapped; + # 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"; + }; }