use {
'xvzc/skeleton.nvim',
config = function()
require('skeleton').setup({
template_path = vim.fn.stdpath('config') .. '/templates',
patterns = {}
tags = {
author = 'my-nickname'
}
})
end
}
There's a couple of built-int tags, you can also override those tags.
{{ author }} // This will be replaced with the output of 'git config user.name' or 'whoami', also you can replcae this tag with any other function or string values
{{ timestamp }} // The default format of timestamp tag will be '%Y-%m-%d %H:%M:%S' format.
You can use the custom tags with {{ key }}
syntax in your template files, and it will be replaced with the values (or functions) when you call load()
function.
{
tags = {
key1 = 'value1',
key2 = function()
return os.date("%Y-%m-%d")
end
}
}
When using telescope, skeleton.nvim will basically give you the list of files that has same filetype as the current buffer, but we can also set list of patterns for each filetypes, so that template files that have different filetypes can be listed.
{
patterns = {
javascript = { "*.cjs" }
}
}
Add the line below to the bottom of your Telescope config.
telescope.load_extension('skeleton')
:lua require('skeleton').load('/home/john/example.txt')
:Telescope skeleton load_template<CR>