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