freebasic.vim 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. " Vim filetype plugin file
  2. " Language: FreeBASIC
  3. " Maintainer: Doug Kearns <dougkearns@gmail.com>
  4. " Last Change: 2022 June 24
  5. " Dialects can be one of fb, qb, fblite, or deprecated
  6. " Precedence is forcelang > #lang > lang
  7. function! freebasic#GetDialect() abort
  8. if exists("g:freebasic_forcelang")
  9. return g:freebasic_forcelang
  10. endif
  11. if exists("g:freebasic_lang")
  12. let dialect = g:freebasic_lang
  13. else
  14. let dialect = "fb"
  15. endif
  16. " override with #lang directive or metacommand
  17. let pat = '\c^\s*\%(#\s*lang\s\+\|''\s*$lang\s*:\s*\)"\([^"]*\)"'
  18. let save_cursor = getcurpos()
  19. call cursor(1, 1)
  20. let lnum = search(pat, 'cn')
  21. call setpos('.', save_cursor)
  22. if lnum
  23. let word = matchlist(getline(lnum), pat)[1]
  24. if word =~? '\<\%(fb\|deprecated\|fblite\|qb\)\>'
  25. let dialect = word
  26. else
  27. echomsg "freebasic#GetDialect: Invalid lang, found '" .. word .. "' at line " .. lnum .. " " .. getline(lnum)
  28. endif
  29. endif
  30. return dialect
  31. endfunction
  32. " vim: nowrap sw=2 sts=2 ts=8 noet fdm=marker: