From 21f4e5b9ab1ed44c75031cfa3e2e5cd45997bb0d Mon Sep 17 00:00:00 2001 From: Gerg-L <88247690+Gerg-L@users.noreply.github.com> Date: Sat, 27 Jul 2024 04:03:44 +0000 Subject: [PATCH 1/5] flake.lock: Update (#348) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Flake lock file updates: • Updated input 'mnw': 'github:Gerg-L/mnw/4ea225024677e7c3a96080af8624fd3aa5dfa1b6?narHash=sha256-PF/FbgCUZ6mQrKp28G2YoVDlSThBy8AxIT9d2Ju3kTY%3D' (2024-07-20) → 'github:Gerg-L/mnw/81e98e83d863d4fad506ed932d432570030cedd3?narHash=sha256-ejkSFN5qHf161CnFq73b2LZlnJzYidBwUEtdx5/hNiY%3D' (2024-07-26) --- flake.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flake.lock b/flake.lock index c5544f6..bb5248f 100644 --- a/flake.lock +++ b/flake.lock @@ -69,11 +69,11 @@ }, "mnw": { "locked": { - "lastModified": 1721440413, - "narHash": "sha256-PF/FbgCUZ6mQrKp28G2YoVDlSThBy8AxIT9d2Ju3kTY=", + "lastModified": 1722037780, + "narHash": "sha256-ejkSFN5qHf161CnFq73b2LZlnJzYidBwUEtdx5/hNiY=", "owner": "Gerg-L", "repo": "mnw", - "rev": "4ea225024677e7c3a96080af8624fd3aa5dfa1b6", + "rev": "81e98e83d863d4fad506ed932d432570030cedd3", "type": "github" }, "original": { From 0984e8444410e0f2ee88463764ba4e715e8306ee Mon Sep 17 00:00:00 2001 From: Ching Pei Yang <59727193+horriblename@users.noreply.github.com> Date: Mon, 29 Jul 2024 16:02:00 +0200 Subject: [PATCH 2/5] wrapper: fix additionalRuntimePaths lua script (#349) --- modules/wrapper/rc/options.nix | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/modules/wrapper/rc/options.nix b/modules/wrapper/rc/options.nix index 0594a48..4165da6 100644 --- a/modules/wrapper/rc/options.nix +++ b/modules/wrapper/rc/options.nix @@ -155,11 +155,7 @@ in { -- The following list is generated from `vim.additionalRuntimePaths` -- and is used to append additional runtime paths to the -- `runtimepath` option. - local additionalRuntimePaths = ${listToLuaTable cfg.additionalRuntimePaths}; - - for _, path in ipairs(additionalRuntimePaths) do - vim.opt.runtimepath:append(path) - end + vim.opt.runtimepath:append(${listToLuaTable cfg.additionalRuntimePaths}) ''} ${optionalString cfg.disableDefaultRuntimePaths '' From 773186d93df33160036fab5938a09fb6ee1afb87 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 29 Jul 2024 21:06:50 +0300 Subject: [PATCH 3/5] flake: update nixpkgs & mnw --- flake.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/flake.lock b/flake.lock index bb5248f..de29be3 100644 --- a/flake.lock +++ b/flake.lock @@ -69,11 +69,11 @@ }, "mnw": { "locked": { - "lastModified": 1722037780, - "narHash": "sha256-ejkSFN5qHf161CnFq73b2LZlnJzYidBwUEtdx5/hNiY=", + "lastModified": 1722191188, + "narHash": "sha256-YF//iMALbrd2Ni9aju7w8NniH16Qz6RFTRD6md5UkDc=", "owner": "Gerg-L", "repo": "mnw", - "rev": "81e98e83d863d4fad506ed932d432570030cedd3", + "rev": "c7b289f3f5a31b6e744be37d83fc231816621231", "type": "github" }, "original": { @@ -129,11 +129,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1721016451, - "narHash": "sha256-Cypl9ORr5UjtBsbjXMTJRepTe362yNVrPrntUvHiTaw=", + "lastModified": 1722141560, + "narHash": "sha256-Ul3rIdesWaiW56PS/Ak3UlJdkwBrD4UcagCmXZR9Z7Y=", "owner": "nixos", "repo": "nixpkgs", - "rev": "a14c5d651cee9ed70f9cd9e83f323f1e531002db", + "rev": "038fb464fcfa79b4f08131b07f2d8c9a6bcc4160", "type": "github" }, "original": { From fd65c8395681f4778e36c7c5a9c25ed8b5c0748d Mon Sep 17 00:00:00 2001 From: poz Date: Thu, 8 Aug 2024 20:45:33 +0200 Subject: [PATCH 4/5] plugins/new-file-template: init module (#350) * plugins/new-file-template: init module * docs: add release note entry about new-file-template.nvim * docs: update jacekpoz's link * plugins/new-file-template: remove _: in default.nix * plugins/new-file-template: add example for disableSpecific * plugins/new-file-template: add docs on how to add custom templates * plugins/new-file-template: fix disableSpecific example * plugins/new-file-template: improve documentation * plugins/new-file-template: remove redundant example * plugins/new-file-template: more compact docs * plugins/new-file-template: more doc improvements * plugins/new-file-template: fix formatting issue --- docs/release-notes/rl-0.5.md | 2 +- docs/release-notes/rl-0.6.md | 2 +- docs/release-notes/rl-0.7.md | 5 +- flake.nix | 8 ++- modules/plugins/utility/default.nix | 1 + .../utility/new-file-template/config.nix | 23 ++++++++ .../utility/new-file-template/default.nix | 6 +++ .../new-file-template/new-file-template.nix | 54 +++++++++++++++++++ 8 files changed, 97 insertions(+), 4 deletions(-) create mode 100644 modules/plugins/utility/new-file-template/config.nix create mode 100644 modules/plugins/utility/new-file-template/default.nix create mode 100644 modules/plugins/utility/new-file-template/new-file-template.nix diff --git a/docs/release-notes/rl-0.5.md b/docs/release-notes/rl-0.5.md index 083d9d5..8e8ac6a 100644 --- a/docs/release-notes/rl-0.5.md +++ b/docs/release-notes/rl-0.5.md @@ -83,7 +83,7 @@ Release notes for release 0.5 - Updated indent-blankine.nvim to v3 - this comes with a few option changes, which will be migrated with `renamedOptionModule` -[jacekpoz](https://github.com/jacekpoz): +[jacekpoz](https://jacekpoz.pl): - Fixed scrollOffset not being used diff --git a/docs/release-notes/rl-0.6.md b/docs/release-notes/rl-0.6.md index 437c916..a04e717 100644 --- a/docs/release-notes/rl-0.6.md +++ b/docs/release-notes/rl-0.6.md @@ -62,7 +62,7 @@ vim.api.nvim_set_keymap('n', 'a', ':lua camelToSnake()', { noremap = - Added rose-pine theme. -[jacekpoz](https://github.com/jacekpoz): +[jacekpoz](https://jacekpoz.pl): - Added `vim.autocomplete.alwaysComplete`. Allows users to have the autocomplete window popup only when manually activated. diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md index 87bd3b6..21edbdd 100644 --- a/docs/release-notes/rl-0.7.md +++ b/docs/release-notes/rl-0.7.md @@ -62,14 +62,17 @@ configuration formats. recommended to go through rustacean.nvim's README to take a closer look at its features and usage -[jacekpoz](https://github.com/jacekpoz): +[jacekpoz](https://jacekpoz.pl): [ocaml-lsp]: https://github.com/ocaml/ocaml-lsp +[new-file-template.nvim]: https://github.com/otavioschwanck/new-file-template.nvim - Add [ocaml-lsp] support - Fix "Emac" typo +- Add [new-file-template.nvim] to automatically fill new file contents using templates. + [diniamo](https://github.com/diniamo): - Move the `theme` dag entry to before `luaScript`. diff --git a/flake.nix b/flake.nix index 0290638..c00e9b8 100644 --- a/flake.nix +++ b/flake.nix @@ -628,9 +628,15 @@ }; plugin-nvim-nio = { - # (required nvim-dap-ui) + # (required by nvim-dap-ui) url = "github:nvim-neotest/nvim-nio"; flake = false; }; + + plugin-new-file-template-nvim = { + # (required by new-file-template.nvim) + url = "github:otavioschwanck/new-file-template.nvim"; + flake = false; + }; }; } diff --git a/modules/plugins/utility/default.nix b/modules/plugins/utility/default.nix index a5a8892..835ebf6 100644 --- a/modules/plugins/utility/default.nix +++ b/modules/plugins/utility/default.nix @@ -4,6 +4,7 @@ ./ccc ./gestures ./motion + ./new-file-template ./telescope ./icon-picker ./images diff --git a/modules/plugins/utility/new-file-template/config.nix b/modules/plugins/utility/new-file-template/config.nix new file mode 100644 index 0000000..8f23973 --- /dev/null +++ b/modules/plugins/utility/new-file-template/config.nix @@ -0,0 +1,23 @@ +{ + config, + lib, + ... +}: let + inherit (lib.modules) mkIf; + inherit (lib.nvim.dag) entryAnywhere; + inherit (lib.nvim.lua) toLuaObject; + + cfg = config.vim.utility.new-file-template; +in { + config = mkIf cfg.enable { + vim = { + startPlugins = [ + "new-file-template-nvim" + ]; + + pluginRC.new-file-template = entryAnywhere '' + require('new-file-template').setup(${toLuaObject cfg.setupOpts}) + ''; + }; + }; +} diff --git a/modules/plugins/utility/new-file-template/default.nix b/modules/plugins/utility/new-file-template/default.nix new file mode 100644 index 0000000..c698759 --- /dev/null +++ b/modules/plugins/utility/new-file-template/default.nix @@ -0,0 +1,6 @@ +{ + imports = [ + ./config.nix + ./new-file-template.nix + ]; +} diff --git a/modules/plugins/utility/new-file-template/new-file-template.nix b/modules/plugins/utility/new-file-template/new-file-template.nix new file mode 100644 index 0000000..167d2b0 --- /dev/null +++ b/modules/plugins/utility/new-file-template/new-file-template.nix @@ -0,0 +1,54 @@ +{lib, ...}: let + inherit (lib.options) mkOption; + inherit (lib.types) attrsOf bool listOf str; + inherit (lib.nvim.types) mkPluginSetupOption; +in { + options.vim.utility.new-file-template = { + enable = mkOption { + type = bool; + default = false; + description = '' + new-file-template.nvim: Automatically insert a template on new files in neovim. + ::: {.note} + For custom templates add a directory containing `lua/templates/*.lua` + to `vim.additionalRuntimePaths`. + ::: + [custom-template-docs]: https://github.com/otavioschwanck/new-file-template.nvim?tab=readme-ov-file#creating-new-templates + More documentation on the templates available at [custom-template-docs] + ''; + }; + + setupOpts = mkPluginSetupOption "nvim-file-template.nvim" { + disableInsert = mkOption { + type = bool; + default = false; + description = "Enter insert mode after inserting the template"; + }; + + disableAutocmd = mkOption { + type = bool; + default = false; + description = "Disable the autocmd that creates the template"; + }; + + disableFiletype = mkOption { + type = listOf str; + default = []; + description = "Disable default templates for specific filetypes"; + }; + + disableSpecific = mkOption { + type = attrsOf (listOf str); + default = {}; + description = "Disable specific regexp for the default templates."; + example = "{ ruby = [\".*\"]; }"; + }; + + suffixAsFiletype = mkOption { + type = bool; + default = false; + description = "Use suffix of filename rather than `vim.bo.filetype` as filetype"; + }; + }; + }; +} From de20ff2c5176bf4b27ab436c091983b4a34eb1a2 Mon Sep 17 00:00:00 2001 From: diniamo <55629891+diniamo@users.noreply.github.com> Date: Sun, 11 Aug 2024 21:10:55 +0000 Subject: [PATCH 5/5] style: improve modules/default.nix code, rename helper scripts (#351) Co-authored-by: raf --- docs/release-notes/rl-0.7.md | 6 +-- modules/default.nix | 84 +++++++++++++++--------------------- 2 files changed, 37 insertions(+), 53 deletions(-) diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md index 21edbdd..0d607f9 100644 --- a/docs/release-notes/rl-0.7.md +++ b/docs/release-notes/rl-0.7.md @@ -143,10 +143,10 @@ 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 +- 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 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 + - `nvf-print-config` will display your `init.lua`, in full. + - `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 identical clone. diff --git a/modules/default.nix b/modules/default.nix index 227cf20..9cf9b70 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -7,11 +7,9 @@ inputs: { extraModules ? [], }: let inherit (pkgs) vimPlugins; - inherit (pkgs.vimUtils) buildVimPlugin; inherit (lib.strings) isString toString; inherit (lib.lists) filter map concatLists; - inherit (lib.attrsets) recursiveUpdate getAttr; - inherit (lib.asserts) assertMsg; + inherit (lib.attrsets) recursiveUpdate; # import modules.nix with `check`, `pkgs` and `lib` as arguments # 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 # if the plugin is nvim-treesitter, warn the user to use buildTreesitterPlug # instead - buildPlug = {pname, ...} @ attrs: let - src = getAttr ("plugin-" + pname) inputs; + buildPlug = attrs: let + src = inputs."plugin-${attrs.pname}"; in pkgs.stdenvNoCC.mkDerivation ({ - inherit src; version = src.shortRev or src.shortDirtyRev or "dirty"; + + inherit src; + + nativeBuildInputs = with pkgs.vimUtils; [ + vimCommandCheckHook + vimGenDocHook + neovimRequireCheckHook + ]; + passthru.vimPlugin = true; + installPhase = '' runHook preInstall @@ -50,41 +57,27 @@ inputs: { } // 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); + 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 - ( - if (plug == "nvim-treesitter") - then (buildTreesitterPlug vimOptions.treesitter.grammars) - else if (plug == "flutter-tools-patched") - then - ( - buildPlug - { - pname = "flutter-tools"; - patches = [../patches/flutter-tools.patch]; - } - ) - else noBuildPlug {pname = plug;} - ) - else plug - )) - (filter - (f: f != null) - plugins); + ( + plug: + if (isString plug) + then pluginBuilders.${plug} or (buildPlug {pname = plug;}) + else plug + ) + (filter (f: f != null) plugins); # built (or "normalized") plugins that are modified builtStartPlugins = buildConfigPlugins vimOptions.startPlugins; @@ -114,20 +107,11 @@ inputs: { 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 "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; - }} - ''; + 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; @@ -137,7 +121,7 @@ in { neovim = pkgs.symlinkJoin { name = "nvf-with-helpers"; paths = [neovim-wrapped printConfig printConfigPath]; - postBuild = "echo helpers added"; + postBuild = "echo Helpers added"; meta = { description = "Wrapped version of Neovim with additional helper scripts";