blob: 4ddc4a539257abfad7a9faad8a7af4d53fe7cb1a [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" Vim filetype plugin file
2" Language: C
Christian Brabandte978b452023-08-13 10:33:05 +02003" Maintainer: The Vim Project <https://github.com/vim/vim>
4" Last Change: 2023 Aug 10
5" Former Maintainer: Bram Moolenaar <Bram@vim.org>
Bram Moolenaar071d4272004-06-13 20:20:40 +00006
7" Only do this when not done yet for this buffer
8if exists("b:did_ftplugin")
9 finish
10endif
11
12" Don't load another plugin for this buffer
13let b:did_ftplugin = 1
14
Bram Moolenaar582fd852005-03-28 20:58:01 +000015" Using line continuation here.
Bram Moolenaar30abd282005-06-22 22:35:10 +000016let s:cpo_save = &cpo
Bram Moolenaar071d4272004-06-13 20:20:40 +000017set cpo-=C
18
Bram Moolenaar560979e2020-02-04 22:53:05 +010019let b:undo_ftplugin = "setl fo< com< ofu< cms< def< inc< | if has('vms') | setl isk< | endif"
Bram Moolenaar071d4272004-06-13 20:20:40 +000020
21" Set 'formatoptions' to break comment lines but not other lines,
22" and insert the comment leader when hitting <CR> or using "o".
23setlocal fo-=t fo+=croql
24
Bram Moolenaar560979e2020-02-04 22:53:05 +010025" These options have the right value as default, but the user may have
26" overruled that.
27setlocal commentstring& define& include&
28
Bram Moolenaare344bea2005-09-01 20:46:49 +000029" Set completion with CTRL-X CTRL-O to autoloaded function.
30if exists('&ofu')
31 setlocal ofu=ccomplete#Complete
32endif
33
Bram Moolenaar071d4272004-06-13 20:20:40 +000034" Set 'comments' to format dashed lists in comments.
Bram Moolenaarcbaff5e2022-04-08 17:45:08 +010035" Also include ///, used for Doxygen.
36setlocal comments=sO:*\ -,mO:*\ \ ,exO:*/,s1:/*,mb:*,ex:*/,:///,://
Bram Moolenaar071d4272004-06-13 20:20:40 +000037
38" In VMS C keywords contain '$' characters.
39if has("vms")
40 setlocal iskeyword+=$
41endif
42
Bram Moolenaar446cb832008-06-24 21:56:24 +000043" When the matchit plugin is loaded, this makes the % command skip parens and
Bram Moolenaar01164a62017-11-02 22:58:42 +010044" braces in comments properly.
Bram Moolenaar34cc7d82021-09-21 20:09:51 +020045if !exists("b:match_words")
46 let b:match_words = '^\s*#\s*if\(\|def\|ndef\)\>:^\s*#\s*elif\>:^\s*#\s*else\>:^\s*#\s*endif\>'
47 let b:match_skip = 's:comment\|string\|character\|special'
48 let b:undo_ftplugin ..= " | unlet! b:match_skip b:match_words"
49endif
Bram Moolenaar446cb832008-06-24 21:56:24 +000050
Bram Moolenaar071d4272004-06-13 20:20:40 +000051" Win32 can filter files in the browse dialog
Bram Moolenaar30b65812012-07-12 22:01:11 +020052if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")
Bram Moolenaar071d4272004-06-13 20:20:40 +000053 if &ft == "cpp"
54 let b:browsefilter = "C++ Source Files (*.cpp *.c++)\t*.cpp;*.c++\n" .
55 \ "C Header Files (*.h)\t*.h\n" .
56 \ "C Source Files (*.c)\t*.c\n" .
57 \ "All Files (*.*)\t*.*\n"
Bram Moolenaard4755bb2004-09-02 19:12:26 +000058 elseif &ft == "ch"
Bram Moolenaar071d4272004-06-13 20:20:40 +000059 let b:browsefilter = "Ch Source Files (*.ch *.chf)\t*.ch;*.chf\n" .
60 \ "C Header Files (*.h)\t*.h\n" .
61 \ "C Source Files (*.c)\t*.c\n" .
62 \ "All Files (*.*)\t*.*\n"
63 else
64 let b:browsefilter = "C Source Files (*.c)\t*.c\n" .
65 \ "C Header Files (*.h)\t*.h\n" .
66 \ "Ch Source Files (*.ch *.chf)\t*.ch;*.chf\n" .
67 \ "C++ Source Files (*.cpp *.c++)\t*.cpp;*.c++\n" .
68 \ "All Files (*.*)\t*.*\n"
69 endif
Bram Moolenaar34cc7d82021-09-21 20:09:51 +020070 let b:undo_ftplugin ..= " | unlet! b:browsefilter"
Bram Moolenaar071d4272004-06-13 20:20:40 +000071endif
Bram Moolenaar30abd282005-06-22 22:35:10 +000072
73let &cpo = s:cpo_save
74unlet s:cpo_save