blob: 1680e84c9ccbc1e1b9e02654cbc3b7ea954269cd [file] [log] [blame]
Bram Moolenaare0e39172021-01-25 21:14:57 +01001" Vim filetype plugin file
Bram Moolenaarf10911e2022-01-29 22:20:48 +00002" Language: FreeBASIC
Bram Moolenaare0e39172021-01-25 21:14:57 +01003" Maintainer: Doug Kearns <dougkearns@gmail.com>
Bram Moolenaar0d878b92022-07-01 18:45:04 +01004" Last Change: 2022 Jun 24
Bram Moolenaare0e39172021-01-25 21:14:57 +01005
Bram Moolenaarf10911e2022-01-29 22:20:48 +00006" Setup {{{1
Bram Moolenaare0e39172021-01-25 21:14:57 +01007if exists("b:did_ftplugin")
8 finish
9endif
Bram Moolenaarf10911e2022-01-29 22:20:48 +000010
11let s:cpo_save = &cpo
12set cpo&vim
Bram Moolenaare0e39172021-01-25 21:14:57 +010013
14runtime! ftplugin/basic.vim
15
Bram Moolenaarf10911e2022-01-29 22:20:48 +000016let s:dialect = freebasic#GetDialect()
17
18" Comments {{{1
19" add ''comments before 'comments
20let &l:comments = "sO:*\ -,mO:*\ \ ,exO:*/,s1:/',mb:',ex:'/,:''," .. &l:comments
21
22" Match words {{{1
23if exists("loaded_matchit")
Bram Moolenaar0d878b92022-07-01 18:45:04 +010024 let s:line_start = '\%(^\s*\)\@<='
25 let s:not_end = '\%(end\s\+\)\@<!'
Bram Moolenaarf10911e2022-01-29 22:20:48 +000026
27 let b:match_words ..= ','
28
29 if s:dialect == 'fb'
30 let b:match_words ..= s:not_end .. '\<constructor\>:\<end\s\+constructor\>,' ..
31 \ s:not_end .. '\<destructor\>:\<end\s\+destructor\>,' ..
32 \ s:not_end .. '\<property\>:\<end\s\+property\>,' ..
33 \ s:not_end .. '\<operator\>:\<end\s\+operator\>,' ..
34 \ s:not_end .. '\<extern\%(\s\+"\)\@=:\<end\s\+extern\>,'
35 endif
36
37 if s:dialect == 'fb' || s:dialect == 'deprecated'
38 let b:match_words ..= s:not_end .. '\<scope\>:\<end\s\+scope\>,'
39 endif
40
41 if s:dialect == 'qb'
42 let b:match_words ..= s:not_end .. '\<__asm\>:\<end\s\+__asm\>,' ..
43 \ s:not_end .. '\<__union\>:\<end\s\+__union\>,' ..
44 \ s:not_end .. '\<__with\>:\<end\s\+__with\>,'
45 else
46 let b:match_words ..= s:not_end .. '\<asm\>:\<end\s\+asm\>,' ..
47 \ s:not_end .. '\<namespace\>:\<end\s\+namespace\>,' ..
48 \ s:not_end .. '\<union\>:\<end\s\+union\>,' ..
49 \ s:not_end .. '\<with\>:\<end\s\+with\>,'
50 endif
51
52 let b:match_words ..= s:not_end .. '\<enum\>:\<end\s\+enum\>,' ..
Bram Moolenaar0d878b92022-07-01 18:45:04 +010053 \ s:line_start .. '#\s*\%(if\|ifdef\|ifndef\)\>:' ..
54 \ s:line_start .. '#\s*\%(else\|elseif\)\>:' ..
55 \ s:line_start .. '#\s*endif\>,' ..
56 \ s:line_start .. '#\s*macro\>:' .. s:line_start .. '#\s*endmacro\>,' ..
57 \ "/':'/"
Bram Moolenaarf10911e2022-01-29 22:20:48 +000058
Bram Moolenaar0d878b92022-07-01 18:45:04 +010059 " skip "function = <retval>" and "continue { do | for | while }"
60 if s:dialect == "qb"
61 let s:continue = "__continue"
62 else
63 let s:continue = "continue"
64 endif
65 let b:match_skip ..= ' || strpart(getline("."), col(".") - 1) =~? "^\\<function\\s\\+="' ..
66 \ ' || strpart(getline("."), 0, col(".") ) =~? "\\<' .. s:continue .. '\\s\\+"'
Bram Moolenaarf10911e2022-01-29 22:20:48 +000067
Bram Moolenaar0d878b92022-07-01 18:45:04 +010068 unlet s:not_end s:line_start
69endif
70
71if (has("gui_win32") || has("gui_gtk")) && exists("b:basic_set_browsefilter")
72 let b:browsefilter = "FreeBASIC Source Files (*.bas)\t*.bas\n" ..
73 \ "FreeBASIC Header Files (*.bi)\t*.bi\n" ..
74 \ "All Files (*.*)\t*.*\n"
Bram Moolenaarf10911e2022-01-29 22:20:48 +000075endif
76
77" Cleanup {{{1
78let &cpo = s:cpo_save
Bram Moolenaar0d878b92022-07-01 18:45:04 +010079unlet s:cpo_save s:dialect
Bram Moolenaarf10911e2022-01-29 22:20:48 +000080
81" vim: nowrap sw=2 sts=2 ts=8 noet fdm=marker: