neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

c.vim (2437B)


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