auto.vim 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. " use python syntax highlighting for .tibasic files
  46. augroup tibasic
  47. autocmd!
  48. autocmd BufNewFile,BufRead *.tibasic set filetype=python
  49. autocmd BufNewFile,BufRead *.tib set filetype=python
  50. augroup END
  51. function! FernInitReload() abort
  52. augroup FernGroupLocal
  53. autocmd! * <buffer>
  54. autocmd BufEnter <buffer> silent execute "normal \<Plug>(fern-action-reload)"
  55. augroup END
  56. endfunction
  57. augroup OnEnteringFernWindow
  58. autocmd!
  59. autocmd FileType fern call FernInitReload()
  60. augroup END
  61. " enable emmet only for html / css files
  62. augroup EmmetEnabler
  63. autocmd!
  64. autocmd FileType html,css EmmetInstall
  65. augroup END
  66. " colored nerdfont icons on fern + startify buffers
  67. augroup my-glyph-palette
  68. autocmd! *
  69. autocmd FileType fern call glyph_palette#apply()
  70. autocmd FileType startify call glyph_palette#apply()
  71. augroup END
  72. " relative line numbers
  73. augroup numbertoggle
  74. autocmd!
  75. autocmd BufEnter,FocusGained,InsertLeave * set relativenumber
  76. autocmd BufLeave,FocusLost,InsertEnter * set norelativenumber
  77. augroup END