feat: add per-language template file support
Problem: new solution files were always created empty, requiring users to manually paste boilerplate or rely on editor snippets that fire outside cp.nvim's control. Solution: add an optional template field to the language config. When set to a file path, its contents are written into every newly created solution buffer before the setup_code hook runs. Existing files are never overwritten.
This commit is contained in:
parent
4ccab9ee1f
commit
bdf1f90f33
2 changed files with 46 additions and 12 deletions
|
|
@ -7,6 +7,7 @@
|
|||
---@class CpLanguage
|
||||
---@field extension string
|
||||
---@field commands CpLangCommands
|
||||
---@field template? string
|
||||
|
||||
---@class CpPlatformOverrides
|
||||
---@field extension? string
|
||||
|
|
@ -215,6 +216,10 @@ local function validate_language(id, lang)
|
|||
commands = { lang.commands, { 'table' } },
|
||||
})
|
||||
|
||||
if lang.template ~= nil then
|
||||
vim.validate({ template = { lang.template, 'string' } })
|
||||
end
|
||||
|
||||
if not lang.commands.run then
|
||||
error(('[cp.nvim] languages.%s.commands.run is required'):format(id))
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue