auto.vim 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. augroup wrapJavaAt100LinesException
  9. autocmd!
  10. autocmd FileType java set colorcolumn=100
  11. augroup END
  12. function! MathAndLiquid()
  13. "" Define certain regions
  14. " Block math. Look for "$$[anything]$$"
  15. syn region math start=/\$\$/ end=/\$\$/
  16. " inline math. Look for "$[not $][anything]$"
  17. syn match math_block '\$[^$].\{-}\$'
  18. " Liquid single line. Look for "{%[anything]%}"
  19. syn match liquid '{%.*%}'
  20. " Liquid multiline. Look for "{%[anything]%}[anything]{%[anything]%}"
  21. syn region highlight_block start='{% highlight .*%}' end='{%.*%}'
  22. " Fenced code blocks, used in GitHub Flavored Markdown (GFM)
  23. syn region highlight_block start='```' end='```'
  24. "" Actually highlight those regions.
  25. hi link math Statement
  26. hi link liquid Statement
  27. hi link highlight_block Function
  28. hi link math_block Function
  29. endfunction
  30. " Call everytime we open a Markdown file
  31. augroup callMathFunction
  32. autocmd!
  33. autocmd BufRead,BufNewFile,BufEnter *.md,*.markdown call MathAndLiquid()
  34. augroup END
  35. " active to autocompile docs on saving
  36. "autocmd BufWritePost *.ms !compile % | fold -w200
  37. "autocmd BufWritePost *.tex !compile % | fold -w200
  38. " disable automatic comment
  39. augroup disableAutoComment
  40. autocmd!
  41. autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o
  42. augroup END
  43. " clear a TeX build after exiting vim
  44. augroup texclear
  45. autocmd!
  46. autocmd VimLeavePre *.tex !texclear "%"
  47. autocmd VimLeavePre *.md !texclear "%"
  48. augroup END
  49. " use python syntax highlighting for .tibasic files
  50. augroup tibasic
  51. autocmd!
  52. autocmd BufNewFile,BufRead *.tibasic set filetype=python
  53. autocmd BufNewFile,BufRead *.tib set filetype=python
  54. augroup END
  55. function! FernInitReload() abort
  56. augroup FernGroupLocal
  57. autocmd! * <buffer>
  58. autocmd BufEnter <buffer> silent execute "normal \<Plug>(fern-action-reload)"
  59. augroup END
  60. endfunction
  61. augroup OnEnteringFernWindow
  62. autocmd!
  63. autocmd FileType fern call FernInitReload()
  64. augroup END
  65. " enable emmet only for html / css files
  66. augroup EmmetEnabler
  67. autocmd!
  68. autocmd FileType html,css EmmetInstall
  69. augroup END
  70. " colored nerdfont icons on fern + startify buffers
  71. augroup my-glyph-palette
  72. autocmd! *
  73. autocmd FileType fern call glyph_palette#apply()
  74. autocmd FileType startify call glyph_palette#apply()
  75. augroup END
  76. " relative line numbers
  77. augroup numbertoggle
  78. autocmd!
  79. autocmd BufEnter,FocusGained,InsertLeave * set relativenumber
  80. autocmd BufLeave,FocusLost,InsertEnter * set norelativenumber
  81. augroup END
  82. " ugly fix fo the vimspector log file
  83. augroup fixVimSpectorLogFile
  84. autocmd User VimspectorDebugEnded call system("mv ~/.vimspector.log " . $XDG_CACHE_HOME."/vim/")