Another copy of my dotfiles. Because I don't completely trust GitHub.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
636 B

  1. local function load_skeleton(filetype)
  2. -- do nothing if no filetype
  3. if filetype == "" then return end
  4. -- glob every directory of 'runtimepath' to search for skeleton/filetype
  5. local skeletons = vim.api.nvim_get_runtime_file('skeleton/' .. filetype, true)
  6. if #skeletons == 0 then return end
  7. -- read last skeleton into 1st line.
  8. vim.api.nvim_command('0read ' .. skeletons[#skeletons])
  9. end
  10. -- augroup setup
  11. vim.api.nvim_create_augroup('aug_skeleton', {clear = true})
  12. vim.api.nvim_create_autocmd('BufNewFile', {
  13. group = 'aug_skeleton',
  14. pattern = '*',
  15. callback = function()
  16. load_skeleton(vim.bo.filetype)
  17. end,
  18. })