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