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.

67 lines
1.7 KiB

  1. local aucmd_dict = {
  2. FileType = {
  3. {
  4. -- Set tabstop to 2 for Dart, Vue, JavaScript, TypeScript, and JSON files
  5. pattern = "dart,vue,javascript,typescript,json,markdown",
  6. callback = function()
  7. vim.opt_local.tabstop = 2
  8. vim.opt_local.softtabstop = 2
  9. vim.opt_local.shiftwidth = 2
  10. end,
  11. },
  12. {
  13. pattern = 'dart',
  14. callback = function ()
  15. vim.bo.commentstring = '// %s'
  16. end
  17. },
  18. },
  19. BufWritePre = {
  20. {
  21. -- Remove trailing whitespace on save
  22. command = [[%s/\s\+$//e]],
  23. },
  24. },
  25. BufRead = {
  26. {
  27. -- Return cursor to where it was previously when re-opening a file
  28. callback = function()
  29. if vim.fn.expand('%:p') ~= '.git/COMMIT_EDITMSG' and vim.fn.line("'\"") > 1 and vim.fn.line("'\"") <= vim.fn.line("$") then
  30. vim.cmd("normal! g`\"")
  31. end
  32. end
  33. },
  34. {
  35. -- Set syntax for Dockerfiles
  36. pattern = { '*.docker' },
  37. callback = function()
  38. vim.opt_local.syntax = 'dockerfile'
  39. end
  40. },
  41. {
  42. pattern = { '*.blade.php' },
  43. command = [[set syntax=html]],
  44. },
  45. },
  46. BufNewFile = {
  47. {
  48. -- Set syntax for Dockerfiles
  49. pattern = { '*.docker' },
  50. callback = function()
  51. vim.opt_local.syntax = 'dockerfile'
  52. end
  53. },
  54. },
  55. }
  56. for event, opt_tbls in pairs(aucmd_dict) do
  57. for _, opt_tbl in pairs(opt_tbls) do
  58. vim.api.nvim_create_autocmd(event, opt_tbl)
  59. end
  60. end