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