basic.vim 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. " Vim filetype plugin file
  2. " Language: BASIC (QuickBASIC 4.5)
  3. " Maintainer: Doug Kearns <dougkearns@gmail.com>
  4. " Last Change: 2024 Jan 14
  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. if has("win32")
  41. let b:browsefilter ..= "All Files (*.*)\t*\n"
  42. else
  43. let b:browsefilter ..= "All Files (*)\t*\n"
  44. endif
  45. let b:basic_set_browsefilter = 1
  46. let b:undo_ftplugin ..= " | unlet! b:browsefilter b:basic_set_browsefilter"
  47. endif
  48. let &cpo = s:cpo_save
  49. unlet s:cpo_save
  50. " vim: nowrap sw=2 sts=2 ts=8 noet fdm=marker: