auto.vim 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. autocmd FileType plaintex,tex,latex syntax spell toplevel
  2. " Automatically wrap at 80 characters for Markdown
  3. " autocmd BufRead,BufNewFile *.md setlocal textwidth=80
  4. function! MathAndLiquid()
  5. "" Define certain regions
  6. " Block math. Look for "$$[anything]$$"
  7. syn region math start=/\$\$/ end=/\$\$/
  8. " inline math. Look for "$[not $][anything]$"
  9. syn match math_block '\$[^$].\{-}\$'
  10. " Liquid single line. Look for "{%[anything]%}"
  11. syn match liquid '{%.*%}'
  12. " Liquid multiline. Look for "{%[anything]%}[anything]{%[anything]%}"
  13. syn region highlight_block start='{% highlight .*%}' end='{%.*%}'
  14. " Fenced code blocks, used in GitHub Flavored Markdown (GFM)
  15. syn region highlight_block start='```' end='```'
  16. "" Actually highlight those regions.
  17. hi link math Statement
  18. hi link liquid Statement
  19. hi link highlight_block Function
  20. hi link math_block Function
  21. endfunction
  22. " Call everytime we open a Markdown file
  23. autocmd BufRead,BufNewFile,BufEnter *.md,*.markdown call MathAndLiquid()
  24. "Plug 'vim-pandoc/vim-pandoc-syntax'
  25. let g:vim_markdown_math = 1
  26. " active to autocompile docs on saving
  27. "autocmd BufWritePost *.ms !compile % | fold -w200
  28. "autocmd BufWritePost *.tex !compile % | fold -w200
  29. " disable automatic comment
  30. autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o
  31. " clear a TeX build after exiting vim
  32. autocmd VimLeavePre *.tex !texclear "%"
  33. autocmd VimLeavePre *.md !texclear "%"
  34. autocmd VimLeavePre *.c !rm -rf .ccls-cache
  35. autocmd VimLeavePre *.cc !rm -rf .ccls-cache
  36. autocmd VimLeavePre *.cpp !rm -rf .ccls-cache
  37. autocmd VimLeavePre *.h !rm -rf .ccls-cache
  38. autocmd VimLeavePre *.hh !rm -rf .ccls-cache
  39. " use python syntax highlighting for .tibasic files
  40. autocmd BufNewFile,BufRead *.tibasic set filetype=python
  41. autocmd BufNewFile,BufRead *.tib set filetype=python