add c file templates
This commit is contained in:
parent
a48647a1c5
commit
92e30040f1
2 changed files with 29 additions and 2 deletions
|
@ -32,8 +32,8 @@ end
|
||||||
--- - `filename` (string): The filename of the new file, e.g., "init.lua".
|
--- - `filename` (string): The filename of the new file, e.g., "init.lua".
|
||||||
return function(opts)
|
return function(opts)
|
||||||
local template = {
|
local template = {
|
||||||
{ pattern = ".*h", content = h_template },
|
{ pattern = ".*\.h", content = h_template },
|
||||||
{ pattern = ".*c", content = c_template },
|
{ pattern = ".*\.c", content = c_template },
|
||||||
}
|
}
|
||||||
|
|
||||||
return utils.find_entry(template, opts)
|
return utils.find_entry(template, opts)
|
||||||
|
|
27
modules/tui/neovim/runtime/lua/templates/sh.lua
Normal file
27
modules/tui/neovim/runtime/lua/templates/sh.lua
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
local utils = require("new-file-template.utils")
|
||||||
|
|
||||||
|
local function bash_template(relative_path, filename)
|
||||||
|
return [[
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
]]
|
||||||
|
end
|
||||||
|
|
||||||
|
local function sh_template(relative_path, filename)
|
||||||
|
return [[
|
||||||
|
#!/usr/bin/env sh
|
||||||
|
]]
|
||||||
|
end
|
||||||
|
|
||||||
|
--- @param opts table
|
||||||
|
--- A table containing the following fields:
|
||||||
|
--- - `full_path` (string): The full path of the new file, e.g., "lua/new-file-template/templates/init.lua".
|
||||||
|
--- - `relative_path` (string): The relative path of the new file, e.g., "lua/new-file-template/templates/init.lua".
|
||||||
|
--- - `filename` (string): The filename of the new file, e.g., "init.lua".
|
||||||
|
return function(opts)
|
||||||
|
local template = {
|
||||||
|
{ pattern = ".*bash", content = bash_template },
|
||||||
|
{ pattern = ".*sh", content = sh_template },
|
||||||
|
}
|
||||||
|
|
||||||
|
return utils.find_entry(template, opts)
|
||||||
|
end
|
Loading…
Reference in a new issue