-
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
8 changed files
with
97 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
./ccc | ||
./gestures | ||
./motion | ||
./new-file-template | ||
./telescope | ||
./icon-picker | ||
./images | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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}) | ||
''; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
imports = [ | ||
./config.nix | ||
./new-file-template.nix | ||
]; | ||
} |
54 changes: 54 additions & 0 deletions
54
modules/plugins/utility/new-file-template/new-file-template.nix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"; | ||
}; | ||
}; | ||
}; | ||
} |