neovim

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

arduino.vim (2183B)


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