auto.vim 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. " fix latex commenting
  2. augroup fixLatexComments
  3. autocmd!
  4. autocmd FileType plaintex,tex,latex syntax spell toplevel
  5. augroup END
  6. " Automatically wrap at 80 characters for Markdown
  7. " autocmd BufRead,BufNewFile *.md setlocal textwidth=80
  8. function! MathAndLiquid()
  9. "" Define certain regions
  10. " Block math. Look for "$$[anything]$$"
  11. syn region math start=/\$\$/ end=/\$\$/
  12. " inline math. Look for "$[not $][anything]$"
  13. syn match math_block '\$[^$].\{-}\$'
  14. " Liquid single line. Look for "{%[anything]%}"
  15. syn match liquid '{%.*%}'
  16. " Liquid multiline. Look for "{%[anything]%}[anything]{%[anything]%}"
  17. syn region highlight_block start='{% highlight .*%}' end='{%.*%}'
  18. " Fenced code blocks, used in GitHub Flavored Markdown (GFM)
  19. syn region highlight_block start='```' end='```'
  20. "" Actually highlight those regions.
  21. hi link math Statement
  22. hi link liquid Statement
  23. hi link highlight_block Function
  24. hi link math_block Function
  25. endfunction
  26. " Call everytime we open a Markdown file
  27. augroup callMathFunction
  28. autocmd!
  29. autocmd BufRead,BufNewFile,BufEnter *.md,*.markdown call MathAndLiquid()
  30. augroup END
  31. " active to autocompile docs on saving
  32. "autocmd BufWritePost *.ms !compile % | fold -w200
  33. "autocmd BufWritePost *.tex !compile % | fold -w200
  34. " disable automatic comment
  35. augroup disableAutoComment
  36. autocmd!
  37. autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o
  38. augroup END
  39. " clear a TeX build after exiting vim
  40. augroup texclear
  41. autocmd!
  42. autocmd VimLeavePre *.tex !texclear "%"
  43. autocmd VimLeavePre *.md !texclear "%"
  44. augroup END
  45. "autocmd VimLeavePre *.c !rm -rf .ccls-cache
  46. "autocmd VimLeavePre *.cc !rm -rf .ccls-cache
  47. "autocmd VimLeavePre *.cpp !rm -rf .ccls-cache
  48. "autocmd VimLeavePre *.h !rm -rf .ccls-cache
  49. "autocmd VimLeavePre *.hh !rm -rf .ccls-cache
  50. " use python syntax highlighting for .tibasic files
  51. augroup tibasic
  52. autocmd!
  53. autocmd BufNewFile,BufRead *.tibasic set filetype=python
  54. autocmd BufNewFile,BufRead *.tib set filetype=python
  55. augroup END
  56. function! FernInitReload() abort
  57. augroup FernGroupLocal
  58. autocmd! * <buffer>
  59. autocmd BufEnter <buffer> silent execute "normal \<Plug>(fern-action-reload)"
  60. augroup END
  61. endfunction
  62. augroup OnEnteringFernWindow
  63. autocmd!
  64. autocmd FileType fern call FernInitReload()
  65. augroup END
  66. " enable emmet only for html / css files
  67. augroup EmmetEnabler
  68. autocmd!
  69. autocmd FileType html,css EmmetInstall
  70. augroup END