basic.vim 2.0 KB

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