27459
|
1 " Vim filetype plugin file
|
|
2 " Language: FreeBASIC
|
|
3 " Maintainer: Doug Kearns <dougkearns@gmail.com>
|
|
4 " Last Change: 2021 Mar 16
|
|
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 skip = "has('syntax_items') && synIDattr(synID(line('.'), col('.'), 1), 'name') =~ 'Comment$'"
|
|
22 let pat = '\c^\s*\%(#\s*lang\s\+\|''\s*$lang\s*:\s*\)"\([^"]*\)"'
|
|
23
|
|
24 let save_cursor = getcurpos()
|
|
25 call cursor(1, 1)
|
|
26 let lnum = search(pat, 'n', '', '', skip)
|
|
27 call setpos('.', save_cursor)
|
|
28
|
|
29 if lnum
|
|
30 let word = matchlist(getline(lnum), pat)[1]
|
|
31 if word =~? '\%(fb\|deprecated\|fblite\|qb\)'
|
|
32 let dialect = word
|
|
33 else
|
|
34 echomsg "freebasic#GetDialect: Invalid lang, found '" .. word .. "' at line " .. lnum .. " " .. getline(lnum)
|
|
35 endif
|
|
36 endif
|
|
37
|
|
38 return dialect
|
|
39 endfunction
|
|
40
|
|
41 " vim: nowrap sw=2 sts=2 ts=8 noet fdm=marker:
|