arduino.vim 2.1 KB

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