synload.vim 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. " Vim syntax support file
  2. " Maintainer: Bram Moolenaar <Bram@vim.org>
  3. " Last Change: 2022 Apr 12
  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. " Set the default highlighting colors. Use a color scheme if specified.
  14. if exists("colors_name")
  15. exe "colors " . colors_name
  16. else
  17. runtime! syntax/syncolor.vim
  18. endif
  19. " Line continuation is used here, remove 'C' from 'cpoptions'
  20. let s:cpo_save = &cpo
  21. set cpo&vim
  22. " First remove all old syntax autocommands.
  23. au! Syntax
  24. au Syntax * call s:SynSet()
  25. fun! s:SynSet()
  26. " clear syntax for :set syntax=OFF and any syntax name that doesn't exist
  27. syn clear
  28. if exists("b:current_syntax")
  29. unlet b:current_syntax
  30. endif
  31. 0verbose let s = expand("<amatch>")
  32. if s == "ON"
  33. " :set syntax=ON
  34. if &filetype == ""
  35. echohl ErrorMsg
  36. echo "filetype unknown"
  37. echohl None
  38. endif
  39. let s = &filetype
  40. elseif s == "OFF"
  41. let s = ""
  42. endif
  43. if s != ""
  44. " Load the syntax file(s). When there are several, separated by dots,
  45. " load each in sequence. Skip empty entries.
  46. for name in split(s, '\.')
  47. if !empty(name)
  48. exe "runtime! syntax/" . name . ".vim syntax/" . name . "/*.vim"
  49. endif
  50. endfor
  51. endif
  52. endfun
  53. " Handle adding doxygen to other languages (C, C++, C#, IDL, java, php, DataScript)
  54. au Syntax c,cpp,cs,idl,java,php,datascript
  55. \ if (exists('b:load_doxygen_syntax') && b:load_doxygen_syntax)
  56. \ || (exists('g:load_doxygen_syntax') && g:load_doxygen_syntax)
  57. \ | runtime! syntax/doxygen.vim
  58. \ | endif
  59. " Source the user-specified syntax highlighting file
  60. if exists("mysyntaxfile")
  61. let s:fname = expand(mysyntaxfile)
  62. if filereadable(s:fname)
  63. execute "source " . fnameescape(s:fname)
  64. endif
  65. endif
  66. " Restore 'cpoptions'
  67. let &cpo = s:cpo_save
  68. unlet s:cpo_save