autocmd.lua 794 B

123456789101112131415161718192021222324252627282930
  1. -- apply default terminal settings
  2. vim.api.nvim_create_autocmd('TermOpen', {
  3. callback = function()
  4. vim.bo.scrollback = 10000
  5. vim.opt_local.number = false
  6. vim.opt_local.relativenumber = false
  7. end
  8. })
  9. -- automatically enter/leave terminal mode
  10. vim.api.nvim_create_autocmd('TermOpen', { command = 'startinsert' })
  11. vim.api.nvim_create_autocmd({'WinEnter','BufWinEnter'}, {
  12. pattern = 'term://*',
  13. command = 'startinsert',
  14. })
  15. vim.api.nvim_create_autocmd('BufLeave', {
  16. pattern = 'term://*',
  17. command = 'stopinsert',
  18. })
  19. -- strip trailing whitespace
  20. vim.api.nvim_create_autocmd('BufWritePre', { command = '%s/\\s\\+$//e' })
  21. -- filetype specific options
  22. vim.api.nvim_create_autocmd('FileType', {
  23. pattern = 'markdown',
  24. callback = function()
  25. vim.bo.textwidth = 80
  26. end,
  27. })