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.

52 lines
1.3 KiB

  1. local aucmd_dict = {
  2. FileType = {
  3. {
  4. pattern = "dart,vue,js",
  5. callback = function()
  6. vim.opt_local.tabstop = 2
  7. vim.opt_local.softtabstop = 2
  8. vim.opt_local.shiftwidth = 2
  9. end,
  10. },
  11. },
  12. BufWritePre = {
  13. {
  14. command = [[%s/\s\+$//e]],
  15. },
  16. {
  17. pattern = 'go',
  18. callback = function () require('go.format').gofmt() end,
  19. },
  20. },
  21. BufRead = {
  22. {
  23. command = [[if @% !~# '\.git[\/\\]COMMIT_EDITMSG$' && line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif]]
  24. },
  25. {
  26. pattern = { '*.docker' },
  27. callback = function()
  28. vim.opt_local.syntax = 'dockerfile'
  29. end
  30. }
  31. },
  32. BufNewFile = {
  33. {
  34. pattern = { '*.docker' },
  35. callback = function()
  36. vim.opt_local.syntax = 'dockerfile'
  37. end
  38. }
  39. },
  40. VimLeave = {
  41. {
  42. command = [[mksession! ~/.config/nvim/session/shutdown_session.vim]]
  43. },
  44. },
  45. }
  46. for event, opt_tbls in pairs(aucmd_dict) do
  47. for _, opt_tbl in pairs(opt_tbls) do
  48. vim.api.nvim_create_autocmd(event, opt_tbl)
  49. end
  50. end