c.vim 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. " Vim filetype plugin file
  2. " Language: C
  3. " Maintainer: The Vim Project <https://github.com/vim/vim>
  4. " Last Change: 2023 Aug 22
  5. " 2024 Jun 02 by Riley Bruins <ribru17@gmail.com> ('commentstring')
  6. " Former Maintainer: Bram Moolenaar <Bram@vim.org>
  7. " Only do this when not done yet for this buffer
  8. if exists("b:did_ftplugin")
  9. finish
  10. endif
  11. " Don't load another plugin for this buffer
  12. let b:did_ftplugin = 1
  13. " Using line continuation here.
  14. let s:cpo_save = &cpo
  15. set cpo-=C
  16. let b:undo_ftplugin = "setl fo< com< ofu< cms< def< inc<"
  17. " Set 'formatoptions' to break comment lines but not other lines,
  18. " and insert the comment leader when hitting <CR> or using "o".
  19. setlocal fo-=t fo+=croql
  20. " These options have the right value as default, but the user may have
  21. " overruled that.
  22. setlocal commentstring=/*\ %s\ */ define& include&
  23. " Set completion with CTRL-X CTRL-O to autoloaded function.
  24. if exists('&ofu')
  25. setlocal ofu=ccomplete#Complete
  26. endif
  27. " Set 'comments' to format dashed lists in comments.
  28. " Also include ///, used for Doxygen.
  29. setlocal comments=sO:*\ -,mO:*\ \ ,exO:*/,s1:/*,mb:*,ex:*/,:///,://
  30. " When the matchit plugin is loaded, this makes the % command skip parens and
  31. " braces in comments properly.
  32. if !exists("b:match_words")
  33. let b:match_words = '^\s*#\s*if\(\|def\|ndef\)\>:^\s*#\s*elif\>:^\s*#\s*else\>:^\s*#\s*endif\>'
  34. let b:match_skip = 's:comment\|string\|character\|special'
  35. let b:undo_ftplugin ..= " | unlet! b:match_skip b:match_words"
  36. endif
  37. " Win32 and GTK can filter files in the browse dialog
  38. if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")
  39. if &ft == "cpp"
  40. let b:browsefilter = "C++ Source Files (*.cpp, *.c++)\t*.cpp;*.c++\n" ..
  41. \ "C Header Files (*.h)\t*.h\n" ..
  42. \ "C Source Files (*.c)\t*.c\n"
  43. elseif &ft == "ch"
  44. let b:browsefilter = "Ch Source Files (*.ch, *.chf)\t*.ch;*.chf\n" ..
  45. \ "C Header Files (*.h)\t*.h\n" ..
  46. \ "C Source Files (*.c)\t*.c\n"
  47. else
  48. let b:browsefilter = "C Source Files (*.c)\t*.c\n" ..
  49. \ "C Header Files (*.h)\t*.h\n" ..
  50. \ "Ch Source Files (*.ch, *.chf)\t*.ch;*.chf\n" ..
  51. \ "C++ Source Files (*.cpp, *.c++)\t*.cpp;*.c++\n"
  52. endif
  53. if has("win32")
  54. let b:browsefilter ..= "All Files (*.*)\t*\n"
  55. else
  56. let b:browsefilter ..= "All Files (*)\t*\n"
  57. endif
  58. let b:undo_ftplugin ..= " | unlet! b:browsefilter"
  59. endif
  60. let b:man_default_sects = '3,2'
  61. let &cpo = s:cpo_save
  62. unlet s:cpo_save