basic.vim 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. " Vim filetype plugin file
  2. " Language: BASIC (QuickBASIC 4.5)
  3. " Maintainer: Doug Kearns <dougkearns@gmail.com>
  4. " Last Change: 2021 Mar 16
  5. if exists("b:did_ftplugin")
  6. finish
  7. endif
  8. let b:did_ftplugin = 1
  9. let s:cpo_save = &cpo
  10. set cpo&vim
  11. setlocal comments=:REM\ ,:Rem\ ,:rem\ ,:'
  12. setlocal commentstring='\ %s
  13. setlocal formatoptions-=t formatoptions+=croql
  14. " TODO: support exit ... as middle matches?
  15. if exists("loaded_matchit") && !exists("b:match_words")
  16. let s:line_start = '\%(^\s*\)\@<='
  17. let s:not_end = '\%(end\s\+\)\@<!'
  18. let s:not_end_or_exit = '\%(\%(end\|exit\)\s\+\)\@<!'
  19. let b:match_ignorecase = 1
  20. let b:match_words =
  21. \ s:not_end_or_exit .. '\<def\s\+fn:\<end\s\+def\>,' ..
  22. \ s:not_end_or_exit .. '\<function\>:\<end\s\+function\>,' ..
  23. \ s:not_end_or_exit .. '\<sub\>:\<end\s\+sub\>,' ..
  24. \ s:not_end .. '\<type\>:\<end\s\+type\>,' ..
  25. \ s:not_end .. '\<select\>:\%(select\s\+\)\@<!\<case\%(\s\+\%(else\|is\)\)\=\>:\<end\s\+select\>,' ..
  26. \ '\<do\>:\<loop\>,' ..
  27. \ '\<for\>\%(\s\+\%(input\|output\|random\|append\|binary\)\)\@!:\<next\>,' ..
  28. \ '\<while\>:\<wend\>,' ..
  29. \ s:line_start .. 'if\%(.*\<then\s*\%($\|''\)\)\@=:\<\%(' .. s:line_start .. 'else\|elseif\)\>:\<end\s\+if\>,' ..
  30. \ '\<lock\>:\<unlock\>'
  31. let b:match_skip = 'synIDattr(synID(line("."),col("."),1),"name") =~? "comment\\|string" || ' ..
  32. \ 'strpart(getline("."), 0, col(".") ) =~? "\\<exit\\s\\+"'
  33. unlet s:line_start s:not_end s:not_end_or_exit
  34. endif
  35. if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")
  36. let b:browsefilter = "BASIC Source Files (*.bas)\t*.bas\n" ..
  37. \ "BASIC Include Files (*.bi, *.bm)\t*.bi;*.bm\n" ..
  38. \ "All Files (*.*)\t*.*\n"
  39. endif
  40. let b:undo_ftplugin = "setl fo< com< cms<" ..
  41. \ " | unlet! b:match_ignorecase b:match_skip b:match_words" ..
  42. \ " | unlet! b:browsefilter"
  43. let &cpo = s:cpo_save
  44. unlet s:cpo_save
  45. " vim: nowrap sw=2 sts=2 ts=8 noet fdm=marker: