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.

59 lines
1.5 KiB

  1. local aucmd_dict = {
  2. FileType = {
  3. {
  4. pattern = "dart,vue,javascript,typescript,json",
  5. callback = function()
  6. vim.opt_local.tabstop = 2
  7. vim.opt_local.softtabstop = 2
  8. vim.opt_local.shiftwidth = 2
  9. -- vim.bo.tabstop = 2 -- size of a hard tabstop (ts).
  10. -- vim.bo.shiftwidth = 2 -- size of an indentation (sw).
  11. -- vim.bo.softtabstop = 2 -- number of spaces a <Tab> counts for. When 0, feature is off (sts).
  12. end,
  13. },
  14. },
  15. BufWritePre = {
  16. {
  17. command = [[%s/\s\+$//e]],
  18. },
  19. {
  20. pattern = "*.go",
  21. command = 'silent! lua require(\'go.format\').goimport()'
  22. },
  23. },
  24. BufRead = {
  25. {
  26. command = [[if @% !~# '\.git[\/\\]COMMIT_EDITMSG$' && line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif]]
  27. },
  28. {
  29. pattern = { '*.docker' },
  30. callback = function()
  31. vim.opt_local.syntax = 'dockerfile'
  32. end
  33. }
  34. },
  35. BufNewFile = {
  36. {
  37. pattern = { '*.docker' },
  38. callback = function()
  39. vim.opt_local.syntax = 'dockerfile'
  40. end
  41. }
  42. },
  43. VimLeave = {
  44. {
  45. command = [[mksession! ~/.cache/nvim/session/shutdown_session.vim]]
  46. },
  47. },
  48. }
  49. for event, opt_tbls in pairs(aucmd_dict) do
  50. for _, opt_tbl in pairs(opt_tbls) do
  51. vim.api.nvim_create_autocmd(event, opt_tbl)
  52. end
  53. end