robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
7ed6966023
master
1" Vim filetype plugin file 2" Language: Visual Basic (ft=vb) 3" Maintainer: Doug Kearns <dougkearns@gmail.com> 4" Previous Maintainer: Johannes Zellner <johannes@zellner.org> 5" Last Change: 2024 Jan 14 6 7if exists ( "b:did_ftplugin" ) 8finish 9endif 10let b: did_ftplugin = 1 11 12let s: cpo_save = & cpo 13set cpo & vim 14 15setlocal comments = sr:'\ -,mb:'\ \ ,el:'\ \ ,:' 16setlocal commentstring = '\ %s 17setlocal formatoptions -= tformatoptions += croql 18 19let b: undo_ftplugin = "setlocal com< cms< fo<" 20 21" we need this wrapper, as call doesn't allow a count 22function ! s: VbSearch ( pattern , flags ) 23let cnt = v: count1 24while cnt > 0 25call search ( a: pattern , a: flags ) 26let cnt = cnt - 1 27endwhile 28endfunction 29 30if ! exists ( "no_plugin_maps" ) && ! exists ( "no_vb_maps" ) 31nnoremap <buffer> <silent> [[<Cmd> call <SID> VbSearch ( '^\s*\%(\%(private\<Bar>public\)\s\+\)\=\%(function\<Bar>sub\)' , 'sbW' ) <CR> 32vnoremap <buffer> <silent> [[<Cmd> call <SID> VbSearch ( '^\s*\%(\%(private\<Bar>public\)\s\+\)\=\%(function\<Bar>sub\)' , 'sbW' ) <CR> 33nnoremap <buffer> <silent> ]]<Cmd> call <SID> VbSearch ( '^\s*\%(\%(private\<Bar>public\)\s\+\)\=\%(function\<Bar>sub\)' , 'sW' ) <CR> 34vnoremap <buffer> <silent> ]]<Cmd> call <SID> VbSearch ( '^\s*\%(\%(private\<Bar>public\)\s\+\)\=\%(function\<Bar>sub\)' , 'sW' ) <CR> 35nnoremap <buffer> <silent> []<Cmd> call <SID> VbSearch ( '^\s*end\s\+\%(function\<Bar>sub\)' , 'sbW' ) <CR> 36vnoremap <buffer> <silent> []<Cmd> call <SID> VbSearch ( '^\s*end\s\+\%(function\<Bar>sub\)' , 'sbW' ) <CR> 37nnoremap <buffer> <silent> ][<Cmd> call <SID> VbSearch ( '^\s*end\s\+\%(function\<Bar>sub\)' , 'sW' ) <CR> 38vnoremap <buffer> <silent> ][<Cmd> call <SID> VbSearch ( '^\s*end\s\+\%(function\<Bar>sub\)' , 'sW' ) <CR> 39let b: undo_ftplugin .= " | sil! exe 'nunmap <buffer> [[' | sil! exe 'vunmap <buffer> [['" . 40 \" | sil! exe 'nunmap <buffer> ]]' | sil! exe 'vunmap <buffer> ]]'" . 41 \" | sil! exe 'nunmap <buffer> []' | sil! exe 'vunmap <buffer> []'" . 42 \" | sil! exe 'nunmap <buffer> ][' | sil! exe 'vunmap <buffer> ]['" 43endif 44 45" TODO: line start anchors are almost certainly overly restrictive - allow 46" after statement separators. Even in QuickBasic only block IF statements 47" were required to be at the start of a line. 48if exists ( "loaded_matchit" ) && ! exists ( "b:match_words" ) 49let b: match_ignorecase = 1 50let b: match_words = 51 \'\%(^\s*\)\@<=\<if\>.*\<then\>\s*\%($\|''\):\%(^\s*\)\@<=\<else\>:\%(^\s*\)\@<=\<elseif\>:\%(^\s*\)\@<=\<end\>\s\+\<if\>,' . 52 \'\%(^\s*\)\@<=\<for\>:\%(^\s*\)\@<=\<next\>,' . 53 \'\%(^\s*\)\@<=\<while\>:\%(^\s*\)\@<=\<wend\>,' . 54 \'\%(^\s*\)\@<=\<do\>:\%(^\s*\)\@<=\<loop\>\s\+\<while\>,' . 55 \'\%(^\s*\)\@<=\<select\>\s\+\<case\>:\%(^\s*\)\@<=\<case\>:\%(^\s*\)\@<=\<end\>\s\+\<select\>,' . 56 \'\%(^\s*\)\@<=\<enum\>:\%(^\s*\)\@<=\<end\>\s\<enum\>,' . 57 \'\%(^\s*\)\@<=\<with\>:\%(^\s*\)\@<=\<end\>\s\<with\>,' . 58 \'\%(^\s*\)\@<=\%(\<\%(private\|public\)\>\s\+\)\=\<function\>\s\+\([^ \t(]\+\):\%(^\s*\)\@<=\<\1\>\s*=:\%(^\s*\)\@<=\<end\>\s\+\<function\>,' . 59 \'\%(^\s*\)\@<=\%(\<\%(private\|public\)\>\s\+\)\=\<sub\>\s\+:\%(^\s*\)\@<=\<end\>\s\+\<sub\>' 60let b: undo_ftplugin .= " | unlet! b:match_words b:match_ignorecase" 61endif 62 63if ( has ( "gui_win32" ) || has ( "gui_gtk" )) && ! exists ( "b:browsefilter" ) 64let b: browsefilter = "Visual Basic Source Files (*.bas)\t*.bas\n" . 65 \"Visual Basic Form Files (*.frm)\t*.frm\n" 66if has ( "win32" ) 67let b: browsefilter .= "All Files (*.*)\t*\n" 68else 69let b: browsefilter .= "All Files (*)\t*\n" 70endif 71let b: undo_ftplugin .= " | unlet! b:browsefilter" 72endif 73 74let & cpo = s: cpo_save 75unlet s: cpo_save