freebasic.vim 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. " Vim filetype plugin file
  2. " Language: FreeBASIC
  3. " Maintainer: Doug Kearns <dougkearns@gmail.com>
  4. " Last Change: 2022 Jun 24
  5. " Setup {{{1
  6. if exists("b:did_ftplugin")
  7. finish
  8. endif
  9. let s:cpo_save = &cpo
  10. set cpo&vim
  11. runtime! ftplugin/basic.vim
  12. let s:dialect = freebasic#GetDialect()
  13. " Comments {{{1
  14. " add ''comments before 'comments
  15. let &l:comments = "sO:*\ -,mO:*\ \ ,exO:*/,s1:/',mb:',ex:'/,:''," .. &l:comments
  16. " Match words {{{1
  17. if exists("loaded_matchit")
  18. let s:line_start = '\%(^\s*\)\@<='
  19. let s:not_end = '\%(end\s\+\)\@<!'
  20. let b:match_words ..= ','
  21. if s:dialect == 'fb'
  22. let b:match_words ..= s:not_end .. '\<constructor\>:\<end\s\+constructor\>,' ..
  23. \ s:not_end .. '\<destructor\>:\<end\s\+destructor\>,' ..
  24. \ s:not_end .. '\<property\>:\<end\s\+property\>,' ..
  25. \ s:not_end .. '\<operator\>:\<end\s\+operator\>,' ..
  26. \ s:not_end .. '\<extern\%(\s\+"\)\@=:\<end\s\+extern\>,'
  27. endif
  28. if s:dialect == 'fb' || s:dialect == 'deprecated'
  29. let b:match_words ..= s:not_end .. '\<scope\>:\<end\s\+scope\>,'
  30. endif
  31. if s:dialect == 'qb'
  32. let b:match_words ..= s:not_end .. '\<__asm\>:\<end\s\+__asm\>,' ..
  33. \ s:not_end .. '\<__union\>:\<end\s\+__union\>,' ..
  34. \ s:not_end .. '\<__with\>:\<end\s\+__with\>,'
  35. else
  36. let b:match_words ..= s:not_end .. '\<asm\>:\<end\s\+asm\>,' ..
  37. \ s:not_end .. '\<namespace\>:\<end\s\+namespace\>,' ..
  38. \ s:not_end .. '\<union\>:\<end\s\+union\>,' ..
  39. \ s:not_end .. '\<with\>:\<end\s\+with\>,'
  40. endif
  41. let b:match_words ..= s:not_end .. '\<enum\>:\<end\s\+enum\>,' ..
  42. \ s:line_start .. '#\s*\%(if\|ifdef\|ifndef\)\>:' ..
  43. \ s:line_start .. '#\s*\%(else\|elseif\)\>:' ..
  44. \ s:line_start .. '#\s*endif\>,' ..
  45. \ s:line_start .. '#\s*macro\>:' .. s:line_start .. '#\s*endmacro\>,' ..
  46. \ "/':'/"
  47. " skip "function = <retval>" and "continue { do | for | while }"
  48. if s:dialect == "qb"
  49. let s:continue = "__continue"
  50. else
  51. let s:continue = "continue"
  52. endif
  53. let b:match_skip ..= ' || strpart(getline("."), col(".") - 1) =~? "^\\<function\\s\\+="' ..
  54. \ ' || strpart(getline("."), 0, col(".") ) =~? "\\<' .. s:continue .. '\\s\\+"'
  55. unlet s:not_end s:line_start
  56. endif
  57. if (has("gui_win32") || has("gui_gtk")) && exists("b:basic_set_browsefilter")
  58. let b:browsefilter = "FreeBASIC Source Files (*.bas)\t*.bas\n" ..
  59. \ "FreeBASIC Header Files (*.bi)\t*.bi\n" ..
  60. \ "All Files (*.*)\t*.*\n"
  61. endif
  62. " Cleanup {{{1
  63. let &cpo = s:cpo_save
  64. unlet s:cpo_save s:dialect
  65. " vim: nowrap sw=2 sts=2 ts=8 noet fdm=marker: