CHORE: officially renamed files to be deprecated and also made making
templates simpler
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
local M = {}
|
||||
|
||||
function M.imp(ft, template, name)
|
||||
ft, template, name = ft or "", template or "", name or ""
|
||||
if ft == "" or template == "" or name == "" then
|
||||
return
|
||||
end
|
||||
local ok, mod = pcall(require, "vern.templates." .. ft)
|
||||
if ok and type(mod) ~= "table" then
|
||||
return string.gsub(mod[template], "%%s", name)
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
@@ -1,29 +1,18 @@
|
||||
local M = {}
|
||||
|
||||
M.main = function(opts)
|
||||
local template = [=[
|
||||
return {
|
||||
main = vim.trim([=[
|
||||
def main() -> None:
|
||||
print("Hello from %s!")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
]=]
|
||||
return string.format(template, opts)
|
||||
end
|
||||
|
||||
M.__init__ = function(opts)
|
||||
local template = [=[
|
||||
# %s
|
||||
]=]),
|
||||
__init__ = vim.trim([=[
|
||||
# %s init
|
||||
|
||||
__all__: list[str] = []
|
||||
]=]
|
||||
return string.format(template, opts.project_name)
|
||||
end
|
||||
|
||||
M.pyproject = function(opts)
|
||||
local n = opts.project_name
|
||||
local template = [=[
|
||||
]=]),
|
||||
pyproject = vim.trim([=[
|
||||
[build-system]
|
||||
requires = ["hatchling"]
|
||||
build-backend = "hatchling.build"
|
||||
@@ -38,17 +27,11 @@ dependencies = []
|
||||
|
||||
[project.scripts]
|
||||
%s = "%s.main:main"
|
||||
]=]
|
||||
return string.format(template, n, n, n, n)
|
||||
end
|
||||
|
||||
M.module = function(opts)
|
||||
local template = [=[
|
||||
]=]),
|
||||
module = vim.trim([=[
|
||||
"""
|
||||
%s module
|
||||
Module: %s
|
||||
"""
|
||||
]=]
|
||||
return string.format(template, opts)
|
||||
end
|
||||
|
||||
return M
|
||||
]=]),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user