blob: 60b11dab1a78b715e0c5929329f9c3d1dce65d05 [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
Riley Bruins0a083062024-06-03 20:40:45 +02006" 2024 Jun 02 by Riley Bruins <ribru17@gmail.com> ('commentstring')
K.Takata957d9032024-05-20 21:13:35 +09007"
8" Most of the part was copied from c.vim.
9
10" Only do this when not done yet for this buffer
11if exists("b:did_ftplugin")
12 finish
13endif
14
15" Don't load another plugin for this buffer
16let b:did_ftplugin = 1
17
18" Using line continuation here.
19let s:cpo_save = &cpo
20set cpo-=C
21
22let b:undo_ftplugin = "setl fo< com< ofu< cms< def< inc<"
23
24if !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<"
28endif
29
30" Set 'formatoptions' to break comment lines but not other lines,
31" and insert the comment leader when hitting <CR> or using "o".
32setlocal fo-=t fo+=croql
33
34" These options have the right value as default, but the user may have
35" overruled that.
Riley Bruins0a083062024-06-03 20:40:45 +020036setlocal commentstring=/*\ %s\ */ define& include&
K.Takata957d9032024-05-20 21:13:35 +090037
38" Set completion with CTRL-X CTRL-O to autoloaded function.
39if exists('&ofu')
40 setlocal ofu=ccomplete#Complete
41endif
42
43" Set 'comments' to format dashed lists in comments.
44" Also include ///, used for Doxygen.
45setlocal 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.
49if !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"
53endif
54
55" Win32 and GTK can filter files in the browse dialog
56if (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"
64endif
65
66let &cpo = s:cpo_save
67unlet s:cpo_save