blob: dae3dd83d3b0c723b84fce0c350b16bcaa58aa52 [file] [log] [blame]
K.Takata957d9032024-05-20 21:13:35 +09001" 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
10if exists("b:did_ftplugin")
11 finish
12endif
13
14" Don't load another plugin for this buffer
15let b:did_ftplugin = 1
16
17" Using line continuation here.
18let s:cpo_save = &cpo
19set cpo-=C
20
21let b:undo_ftplugin = "setl fo< com< ofu< cms< def< inc<"
22
23if !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<"
27endif
28
29" Set 'formatoptions' to break comment lines but not other lines,
30" and insert the comment leader when hitting <CR> or using "o".
31setlocal fo-=t fo+=croql
32
33" These options have the right value as default, but the user may have
34" overruled that.
35setlocal commentstring& define& include&
36
37" Set completion with CTRL-X CTRL-O to autoloaded function.
38if exists('&ofu')
39 setlocal ofu=ccomplete#Complete
40endif
41
42" Set 'comments' to format dashed lists in comments.
43" Also include ///, used for Doxygen.
44setlocal 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.
48if !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"
52endif
53
54" Win32 and GTK can filter files in the browse dialog
55if (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"
63endif
64
65let &cpo = s:cpo_save
66unlet s:cpo_save