synload.vim 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. " Vim syntax support file
  2. " Maintainer: Bram Moolenaar <Bram@vim.org>
  3. " Last Change: 2020 Apr 13
  4. " This file sets up for syntax highlighting.
  5. " It is loaded from "syntax.vim" and "manual.vim".
  6. " 1. Set the default highlight groups.
  7. " 2. Install Syntax autocommands for all the available syntax files.
  8. if !has("syntax")
  9. finish
  10. endif
  11. " let others know that syntax has been switched on
  12. let syntax_on = 1
  13. " Line continuation is used here, remove 'C' from 'cpoptions'
  14. let s:cpo_save = &cpo
  15. set cpo&vim
  16. " First remove all old syntax autocommands.
  17. au! Syntax
  18. au Syntax * call s:SynSet()
  19. fun! s:SynSet()
  20. " clear syntax for :set syntax=OFF and any syntax name that doesn't exist
  21. syn clear
  22. if exists("b:current_syntax")
  23. unlet b:current_syntax
  24. endif
  25. let s = expand("<amatch>")
  26. if s == "ON"
  27. " :set syntax=ON
  28. if &filetype == ""
  29. echohl ErrorMsg
  30. echo "filetype unknown"
  31. echohl None
  32. endif
  33. let s = &filetype
  34. elseif s == "OFF"
  35. let s = ""
  36. endif
  37. if s != ""
  38. " Load the syntax file(s). When there are several, separated by dots,
  39. " load each in sequence. Skip empty entries.
  40. for name in split(s, '\.')
  41. if !empty(name)
  42. exe "runtime! syntax/" . name . ".vim syntax/" . name . "/*.vim"
  43. exe "runtime! syntax/" . name . ".lua syntax/" . name . "/*.lua"
  44. endif
  45. endfor
  46. endif
  47. endfun
  48. " Handle adding doxygen to other languages (C, C++, C#, IDL, java, php, DataScript)
  49. au Syntax c,cpp,cs,idl,java,php,datascript
  50. \ if (exists('b:load_doxygen_syntax') && b:load_doxygen_syntax)
  51. \ || (exists('g:load_doxygen_syntax') && g:load_doxygen_syntax)
  52. \ | runtime! syntax/doxygen.vim
  53. \ | endif
  54. " Source the user-specified syntax highlighting file
  55. if exists("mysyntaxfile")
  56. let s:fname = expand(mysyntaxfile)
  57. if filereadable(s:fname)
  58. execute "source " . fnameescape(s:fname)
  59. endif
  60. endif
  61. " Restore 'cpoptions'
  62. let &cpo = s:cpo_save
  63. unlet s:cpo_save