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.

38 lines
1.1 KiB

  1. -- Remove any trailing whitespace from the file on write
  2. vim.api.nvim_create_autocmd({ 'BufWritePre' }, { command = [[%s/\s\+$//e]] })
  3. vim.api.nvim_create_autocmd({ 'BufWritePre' }, {
  4. pattern = { '*.go' },
  5. callback = function () require('go.format').gofmt() end,
  6. })
  7. -- Load file on last line
  8. -- TODO: change this to use lua
  9. vim.api.nvim_create_autocmd({ 'BufRead' }, {
  10. command = [[if @% !~# '\.git[\/\\]COMMIT_EDITMSG$' && line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif]]
  11. })
  12. -- Save session on VimLeave
  13. vim.api.nvim_create_autocmd({ 'VimLeave' }, {
  14. command = [[mksession! ~/.config/nvim/session/shutdown_session.vim]]
  15. })
  16. -- Set tabs to 2 for dart, vue, and js files
  17. vim.api.nvim_create_autocmd({ 'BufNewFile', 'BufRead' }, {
  18. pattern = { '*.dart', '*.vue', '*.js' },
  19. callback = function()
  20. vim.o.tabstop = 2
  21. vim.o.softtabstop = 2
  22. vim.o.shiftwidth = 2
  23. end
  24. })
  25. -- Ensure to read .docker files as a dockerfile
  26. vim.api.nvim_create_autocmd({ 'BufNewFile', 'BufRead' }, {
  27. pattern = { '*.docker' },
  28. callback = function()
  29. vim.o.syntax = 'dockerfile'
  30. end
  31. })