add c file templates

This commit is contained in:
jacekpoz 2024-10-13 22:01:10 +02:00
parent a48647a1c5
commit 92e30040f1
Signed by: poz
SSH key fingerprint: SHA256:JyLeVWE4bF3tDnFeUpUaJsPsNlJyBldDGV/dIKSLyN8
2 changed files with 29 additions and 2 deletions

View file

@ -32,8 +32,8 @@ end
--- - `filename` (string): The filename of the new file, e.g., "init.lua".
return function(opts)
local template = {
{ pattern = ".*h", content = h_template },
{ pattern = ".*c", content = c_template },
{ pattern = ".*\.h", content = h_template },
{ pattern = ".*\.c", content = c_template },
}
return utils.find_entry(template, opts)

View 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