Bram Moolenaar | e0e3917 | 2021-01-25 21:14:57 +0100 | [diff] [blame] | 1 | " Vim filetype plugin file |
Bram Moolenaar | f10911e | 2022-01-29 22:20:48 +0000 | [diff] [blame] | 2 | " Language: FreeBASIC |
Bram Moolenaar | e0e3917 | 2021-01-25 21:14:57 +0100 | [diff] [blame] | 3 | " Maintainer: Doug Kearns <dougkearns@gmail.com> |
Bram Moolenaar | 0d878b9 | 2022-07-01 18:45:04 +0100 | [diff] [blame] | 4 | " Last Change: 2022 Jun 24 |
Bram Moolenaar | e0e3917 | 2021-01-25 21:14:57 +0100 | [diff] [blame] | 5 | |
Bram Moolenaar | f10911e | 2022-01-29 22:20:48 +0000 | [diff] [blame] | 6 | " Setup {{{1 |
Bram Moolenaar | e0e3917 | 2021-01-25 21:14:57 +0100 | [diff] [blame] | 7 | if exists("b:did_ftplugin") |
| 8 | finish |
| 9 | endif |
Bram Moolenaar | f10911e | 2022-01-29 22:20:48 +0000 | [diff] [blame] | 10 | |
| 11 | let s:cpo_save = &cpo |
| 12 | set cpo&vim |
Bram Moolenaar | e0e3917 | 2021-01-25 21:14:57 +0100 | [diff] [blame] | 13 | |
| 14 | runtime! ftplugin/basic.vim |
| 15 | |
Bram Moolenaar | f10911e | 2022-01-29 22:20:48 +0000 | [diff] [blame] | 16 | let s:dialect = freebasic#GetDialect() |
| 17 | |
| 18 | " Comments {{{1 |
| 19 | " add ''comments before 'comments |
| 20 | let &l:comments = "sO:*\ -,mO:*\ \ ,exO:*/,s1:/',mb:',ex:'/,:''," .. &l:comments |
| 21 | |
| 22 | " Match words {{{1 |
| 23 | if exists("loaded_matchit") |
Bram Moolenaar | 0d878b9 | 2022-07-01 18:45:04 +0100 | [diff] [blame] | 24 | let s:line_start = '\%(^\s*\)\@<=' |
| 25 | let s:not_end = '\%(end\s\+\)\@<!' |
Bram Moolenaar | f10911e | 2022-01-29 22:20:48 +0000 | [diff] [blame] | 26 | |
| 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 Moolenaar | 0d878b9 | 2022-07-01 18:45:04 +0100 | [diff] [blame] | 53 | \ 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 Moolenaar | f10911e | 2022-01-29 22:20:48 +0000 | [diff] [blame] | 58 | |
Bram Moolenaar | 0d878b9 | 2022-07-01 18:45:04 +0100 | [diff] [blame] | 59 | " 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 Moolenaar | f10911e | 2022-01-29 22:20:48 +0000 | [diff] [blame] | 67 | |
Bram Moolenaar | 0d878b9 | 2022-07-01 18:45:04 +0100 | [diff] [blame] | 68 | unlet s:not_end s:line_start |
| 69 | endif |
| 70 | |
| 71 | if (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 Moolenaar | f10911e | 2022-01-29 22:20:48 +0000 | [diff] [blame] | 75 | endif |
| 76 | |
| 77 | " Cleanup {{{1 |
| 78 | let &cpo = s:cpo_save |
Bram Moolenaar | 0d878b9 | 2022-07-01 18:45:04 +0100 | [diff] [blame] | 79 | unlet s:cpo_save s:dialect |
Bram Moolenaar | f10911e | 2022-01-29 22:20:48 +0000 | [diff] [blame] | 80 | |
| 81 | " vim: nowrap sw=2 sts=2 ts=8 noet fdm=marker: |