codekingpro/portable-devtools
114k
1" Vim filetype plugin file2" Language: C3" Maintainer: The Vim Project <https://github.com/vim/vim>4" Last Change: 2026 Feb 35" Former Maintainer: Bram Moolenaar <Bram@vim.org>6 7" Only do this when not done yet for this buffer8if exists("b:did_ftplugin")9 finish10endif11 12" Don't load another plugin for this buffer13let b:did_ftplugin = 114 15" Using line continuation here.16let s:cpo_save = &cpo17set cpo-=C18 19let b:undo_ftplugin = "setl fo< com< ofu< cms< def< inc< | if has('vms') | setl isk< | endif"20 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+=croql24 25" These options have the right value as default, but the user may have26" overruled that.27setlocal commentstring=/*\ %s\ */ define& include&28 29" Set completion with CTRL-X CTRL-O to autoloaded function.30if exists('&ofu') && has("vim9script")31 setlocal ofu=ccomplete#Complete32endif33 34" Set 'comments' to format dashed lists in comments.35" Also include ///, used for Doxygen.36setlocal comments=sO:*\ -,mO:*\ \ ,exO:*/,s1:/*,mb:*,ex:*/,:///,://37 38" In VMS C keywords contain '$' characters.39if has("vms")40 setlocal iskeyword+=$41endif42 43" Use terminal window for gui44if has('gui_running') && exists(':terminal') == 2 && executable("man")45 setlocal keywordprg=:CKeywordPrg46 47 command! -buffer -nargs=1 -count CKeywordPrg call s:CKeywordPrg(<q-args>, <count>)48 49 function! s:CKeywordPrg(arg, count) abort50 if a:count > 051 exe printf('term ++close man -s %d %s', a:count, a:arg)52 else53 exe printf('term ++close man %s', a:arg)54 endif55 endfunction56 57 let b:undo_ftplugin .= ' | setl kp< | sil! delc -buffer CKeywordPrg'58endif59 60" When the matchit plugin is loaded, this makes the % command skip parens and61" braces in comments properly.62if !exists("b:match_words")63 let b:match_words = '^\s*#\s*if\%(\|def\|ndef\)\>:^\s*#\s*elif\%(\|def\|ndef\)\>:^\s*#\s*else\>:^\s*#\s*endif\>'64 let b:match_skip = 's:comment\|string\|character\|special'65 let b:undo_ftplugin ..= " | unlet! b:match_skip b:match_words"66endif67 68" Win32 and GTK can filter files in the browse dialog69if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")70 if &ft == "cpp"71 let b:browsefilter = "C++ Source Files (*.cpp, *.c++)\t*.cpp;*.c++\n" ..72 \ "C Header Files (*.h)\t*.h\n" ..73 \ "C Source Files (*.c)\t*.c\n"74 elseif &ft == "ch"75 let b:browsefilter = "Ch Source Files (*.ch, *.chf)\t*.ch;*.chf\n" ..76 \ "C Header Files (*.h)\t*.h\n" ..77 \ "C Source Files (*.c)\t*.c\n"78 else79 let b:browsefilter = "C Source Files (*.c)\t*.c\n" ..80 \ "C Header Files (*.h)\t*.h\n" ..81 \ "Ch Source Files (*.ch, *.chf)\t*.ch;*.chf\n" ..82 \ "C++ Source Files (*.cpp, *.c++)\t*.cpp;*.c++\n"83 endif84 if has("win32")85 let b:browsefilter ..= "All Files (*.*)\t*\n"86 else87 let b:browsefilter ..= "All Files (*)\t*\n"88 endif89 let b:undo_ftplugin ..= " | unlet! b:browsefilter"90endif91 92let &cpo = s:cpo_save93unlet s:cpo_save94 