blob: 371a78cbcd05b9051f2c27cf533bf17ce244a044 [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" Vim filetype plugin file
2" Language: C
3" Maintainer: Bram Moolenaar <Bram@vim.org>
Bram Moolenaar01164a62017-11-02 22:58:42 +01004" Last Change: 2017 Sep 28
Bram Moolenaar071d4272004-06-13 20:20:40 +00005
6" Only do this when not done yet for this buffer
7if exists("b:did_ftplugin")
8 finish
9endif
10
11" Don't load another plugin for this buffer
12let b:did_ftplugin = 1
13
Bram Moolenaar582fd852005-03-28 20:58:01 +000014" Using line continuation here.
Bram Moolenaar30abd282005-06-22 22:35:10 +000015let s:cpo_save = &cpo
Bram Moolenaar071d4272004-06-13 20:20:40 +000016set cpo-=C
17
Bram Moolenaare344bea2005-09-01 20:46:49 +000018let b:undo_ftplugin = "setl fo< com< ofu< | if has('vms') | setl isk< | endif"
Bram Moolenaar071d4272004-06-13 20:20:40 +000019
20" Set 'formatoptions' to break comment lines but not other lines,
21" and insert the comment leader when hitting <CR> or using "o".
22setlocal fo-=t fo+=croql
23
Bram Moolenaare344bea2005-09-01 20:46:49 +000024" Set completion with CTRL-X CTRL-O to autoloaded function.
25if exists('&ofu')
26 setlocal ofu=ccomplete#Complete
27endif
28
Bram Moolenaar071d4272004-06-13 20:20:40 +000029" Set 'comments' to format dashed lists in comments.
30setlocal comments=sO:*\ -,mO:*\ \ ,exO:*/,s1:/*,mb:*,ex:*/,://
31
32" In VMS C keywords contain '$' characters.
33if has("vms")
34 setlocal iskeyword+=$
35endif
36
Bram Moolenaar446cb832008-06-24 21:56:24 +000037" When the matchit plugin is loaded, this makes the % command skip parens and
Bram Moolenaar01164a62017-11-02 22:58:42 +010038" braces in comments properly.
39let b:match_words = '^\s*#\s*if\(\|def\|ndef\)\>:^\s*#\s*elif\>:^\s*#\s*else\>:^\s*#\s*endif\>'
Bram Moolenaarc95a3022016-06-12 23:01:46 +020040let b:match_skip = 's:comment\|string\|character\|special'
Bram Moolenaar446cb832008-06-24 21:56:24 +000041
Bram Moolenaar071d4272004-06-13 20:20:40 +000042" Win32 can filter files in the browse dialog
Bram Moolenaar30b65812012-07-12 22:01:11 +020043if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")
Bram Moolenaar071d4272004-06-13 20:20:40 +000044 if &ft == "cpp"
45 let b:browsefilter = "C++ Source Files (*.cpp *.c++)\t*.cpp;*.c++\n" .
46 \ "C Header Files (*.h)\t*.h\n" .
47 \ "C Source Files (*.c)\t*.c\n" .
48 \ "All Files (*.*)\t*.*\n"
Bram Moolenaard4755bb2004-09-02 19:12:26 +000049 elseif &ft == "ch"
Bram Moolenaar071d4272004-06-13 20:20:40 +000050 let b:browsefilter = "Ch Source Files (*.ch *.chf)\t*.ch;*.chf\n" .
51 \ "C Header Files (*.h)\t*.h\n" .
52 \ "C Source Files (*.c)\t*.c\n" .
53 \ "All Files (*.*)\t*.*\n"
54 else
55 let b:browsefilter = "C Source Files (*.c)\t*.c\n" .
56 \ "C Header Files (*.h)\t*.h\n" .
57 \ "Ch Source Files (*.ch *.chf)\t*.ch;*.chf\n" .
58 \ "C++ Source Files (*.cpp *.c++)\t*.cpp;*.c++\n" .
59 \ "All Files (*.*)\t*.*\n"
60 endif
61endif
Bram Moolenaar30abd282005-06-22 22:35:10 +000062
63let &cpo = s:cpo_save
64unlet s:cpo_save