plugins/new-file-template: init module

This commit is contained in:
jacekpoz 2024-08-02 13:34:16 +02:00
parent 773186d93d
commit 6f4df2e8aa
No known key found for this signature in database
5 changed files with 85 additions and 1 deletions

View file

@ -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;
};
};
}

View file

@ -4,6 +4,7 @@
./ccc
./gestures
./motion
./new-file-template
./telescope
./icon-picker
./images

View file

@ -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})
'';
};
};
}

View file

@ -0,0 +1,6 @@
_: {
imports = [
./config.nix
./new-file-template.nix
];
}

View file

@ -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";
};
};
};
}