From 6f4df2e8aa6440ea1013dac93d5e6179f5543a20 Mon Sep 17 00:00:00 2001 From: jacekpoz Date: Fri, 2 Aug 2024 13:34:16 +0200 Subject: [PATCH 1/8] plugins/new-file-template: init module --- 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 | 48 +++++++++++++++++++ 5 files changed, 85 insertions(+), 1 deletion(-) 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/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..7bcfbd1 --- /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..808cd5a --- /dev/null +++ b/modules/plugins/utility/new-file-template/new-file-template.nix @@ -0,0 +1,48 @@ +{ + 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"; + }; + + 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 templates for specific filetypes (only disables default templates, user templates will still work)"; + }; + + 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 b7c832b251a524ecc98102a29630d5e01ef51414 Mon Sep 17 00:00:00 2001 From: jacekpoz Date: Fri, 2 Aug 2024 13:38:56 +0200 Subject: [PATCH 2/8] docs: add release note entry about new-file-template.nvim --- docs/release-notes/rl-0.7.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/release-notes/rl-0.7.md b/docs/release-notes/rl-0.7.md index 87bd3b6..2c5f72a 100644 --- a/docs/release-notes/rl-0.7.md +++ b/docs/release-notes/rl-0.7.md @@ -65,11 +65,14 @@ configuration formats. [jacekpoz](https://github.com/jacekpoz): [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`. From be990ce421fc6e843fee1ebe602b7210b411abba Mon Sep 17 00:00:00 2001 From: jacekpoz Date: Fri, 2 Aug 2024 13:40:03 +0200 Subject: [PATCH 3/8] docs: update jacekpoz's link --- docs/release-notes/rl-0.5.md | 2 +- docs/release-notes/rl-0.6.md | 2 +- docs/release-notes/rl-0.7.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) 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 2c5f72a..21edbdd 100644 --- a/docs/release-notes/rl-0.7.md +++ b/docs/release-notes/rl-0.7.md @@ -62,7 +62,7 @@ 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 From 1f82a248a4e040fbcba7fbd2ddbf3dd2d7823da9 Mon Sep 17 00:00:00 2001 From: jacekpoz Date: Fri, 2 Aug 2024 13:53:42 +0200 Subject: [PATCH 4/8] plugins/new-file-template: remove _: in default.nix --- modules/plugins/utility/new-file-template/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/plugins/utility/new-file-template/default.nix b/modules/plugins/utility/new-file-template/default.nix index 7bcfbd1..c698759 100644 --- a/modules/plugins/utility/new-file-template/default.nix +++ b/modules/plugins/utility/new-file-template/default.nix @@ -1,4 +1,4 @@ -_: { +{ imports = [ ./config.nix ./new-file-template.nix From eedd58c9034090fa41d3bb7057934e2e65f8296b Mon Sep 17 00:00:00 2001 From: jacekpoz Date: Fri, 2 Aug 2024 14:19:36 +0200 Subject: [PATCH 5/8] plugins/new-file-template: add example for disableSpecific --- .../plugins/utility/new-file-template/new-file-template.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/plugins/utility/new-file-template/new-file-template.nix b/modules/plugins/utility/new-file-template/new-file-template.nix index 808cd5a..f4fa9aa 100644 --- a/modules/plugins/utility/new-file-template/new-file-template.nix +++ b/modules/plugins/utility/new-file-template/new-file-template.nix @@ -36,6 +36,9 @@ in { type = attrsOf (listOf str); default = {}; description = "Disable specific regexp for the default templates. Example: { ruby = [ \".*\" ]; }"; + example = { + ruby = [".*"]; + }; }; suffixAsFiletype = mkOption { From 4018f31087382878fac7c4af4aaa25bc7c1baafb Mon Sep 17 00:00:00 2001 From: jacekpoz Date: Fri, 2 Aug 2024 14:21:25 +0200 Subject: [PATCH 6/8] plugins/new-file-template: add docs on how to add custom templates --- modules/plugins/utility/new-file-template/new-file-template.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/plugins/utility/new-file-template/new-file-template.nix b/modules/plugins/utility/new-file-template/new-file-template.nix index f4fa9aa..88054ab 100644 --- a/modules/plugins/utility/new-file-template/new-file-template.nix +++ b/modules/plugins/utility/new-file-template/new-file-template.nix @@ -10,7 +10,7 @@ in { enable = mkOption { type = bool; default = false; - description = "new-file-template.nvim: Automatically insert a template on new files in neovim"; + description = "new-file-template.nvim: Automatically insert a template on new files in neovim. To add custom templates add a directory containing `lua/templates/*.lua` to `vim.additionalRuntimePaths`."; }; setupOpts = mkPluginSetupOption "nvim-file-template.nvim" { From 5d219a0a7b901f8ea4b1bae826e2f0a7f5fdf0b9 Mon Sep 17 00:00:00 2001 From: jacekpoz Date: Fri, 2 Aug 2024 19:08:32 +0200 Subject: [PATCH 7/8] plugins/new-file-template: fix disableSpecific example --- .../plugins/utility/new-file-template/new-file-template.nix | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/modules/plugins/utility/new-file-template/new-file-template.nix b/modules/plugins/utility/new-file-template/new-file-template.nix index 88054ab..d7314cc 100644 --- a/modules/plugins/utility/new-file-template/new-file-template.nix +++ b/modules/plugins/utility/new-file-template/new-file-template.nix @@ -36,9 +36,7 @@ in { type = attrsOf (listOf str); default = {}; description = "Disable specific regexp for the default templates. Example: { ruby = [ \".*\" ]; }"; - example = { - ruby = [".*"]; - }; + example = "{ ruby = [\".*\"]; }"; }; suffixAsFiletype = mkOption { From ef9b08a4621a07d9868804090f1e903299e51a53 Mon Sep 17 00:00:00 2001 From: jacekpoz Date: Wed, 7 Aug 2024 17:09:04 +0200 Subject: [PATCH 8/8] plugins/new-file-template: improve documentation --- .../plugins/utility/new-file-template/new-file-template.nix | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/plugins/utility/new-file-template/new-file-template.nix b/modules/plugins/utility/new-file-template/new-file-template.nix index d7314cc..6b86a60 100644 --- a/modules/plugins/utility/new-file-template/new-file-template.nix +++ b/modules/plugins/utility/new-file-template/new-file-template.nix @@ -10,7 +10,11 @@ in { enable = mkOption { type = bool; default = false; - description = "new-file-template.nvim: Automatically insert a template on new files in neovim. To add custom templates add a directory containing `lua/templates/*.lua` to `vim.additionalRuntimePaths`."; + description = '' + new-file-template.nvim: Automatically insert a template on new files in neovim. + To add custom templates add a directory containing `lua/templates/*.lua` to `vim.additionalRuntimePaths`. + More documentation on the templates available at https://github.com/otavioschwanck/new-file-template.nvim?tab=readme-ov-file#creating-new-templates + ''; }; setupOpts = mkPluginSetupOption "nvim-file-template.nvim" {