This commit is contained in:
Adam Stankiewicz
2022-02-17 04:31:35 +01:00
parent 2c5af8f89d
commit b77c5f1107
42 changed files with 1855 additions and 1187 deletions

View File

@@ -3,9 +3,9 @@ if polyglot#init#is_disabled(expand('<sfile>:p'), 'basic', 'ftplugin/basic.vim')
endif
" Vim filetype plugin file
" Language: BASIC
" Language: BASIC (QuickBASIC 4.5)
" Maintainer: Doug Kearns <dougkearns@gmail.com>
" Last Change: 2015 Jan 10
" Last Change: 2021 Mar 16
if exists("b:did_ftplugin")
finish
@@ -15,17 +15,46 @@ let b:did_ftplugin = 1
let s:cpo_save = &cpo
set cpo&vim
setlocal comments=:REM,:'
setlocal comments=:REM\ ,:Rem\ ,:rem\ ,:'
setlocal commentstring='\ %s
setlocal formatoptions-=t formatoptions+=croql
if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")
let b:browsefilter = "BASIC Source Files (*.bas)\t*.bas\n" .
\ "All Files (*.*)\t*.*\n"
" TODO: support exit ... as middle matches?
if exists("loaded_matchit") && !exists("b:match_words")
let s:line_start = '\%(^\s*\)\@<='
let s:not_end = '\%(end\s\+\)\@<!'
let s:not_end_or_exit = '\%(\%(end\|exit\)\s\+\)\@<!'
let b:match_ignorecase = 1
let b:match_words =
\ s:not_end_or_exit .. '\<def\s\+fn:\<end\s\+def\>,' ..
\ s:not_end_or_exit .. '\<function\>:\<end\s\+function\>,' ..
\ s:not_end_or_exit .. '\<sub\>:\<end\s\+sub\>,' ..
\ s:not_end .. '\<type\>:\<end\s\+type\>,' ..
\ s:not_end .. '\<select\>:\%(select\s\+\)\@<!\<case\%(\s\+\%(else\|is\)\)\=\>:\<end\s\+select\>,' ..
\ '\<do\>:\<loop\>,' ..
\ '\<for\>\%(\s\+\%(input\|output\|random\|append\|binary\)\)\@!:\<next\>,' ..
\ '\<while\>:\<wend\>,' ..
\ s:line_start .. 'if\%(.*\<then\s*\%($\|''\)\)\@=:\<\%(' .. s:line_start .. 'else\|elseif\)\>:\<end\s\+if\>,' ..
\ '\<lock\>:\<unlock\>'
let b:match_skip = 'synIDattr(synID(line("."),col("."),1),"name") =~? "comment\\|string" || ' ..
\ 'strpart(getline("."), 0, col(".") ) =~? "\\<exit\\s\\+"'
unlet s:line_start s:not_end s:not_end_or_exit
endif
let b:undo_ftplugin = "setl fo< com< cms< sua<" .
\ " | unlet! b:browsefilter"
if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")
let b:browsefilter = "BASIC Source Files (*.bas)\t*.bas\n" ..
\ "BASIC Include Files (*.bi, *.bm)\t*.bi;*.bm\n" ..
\ "All Files (*.*)\t*.*\n"
endif
let b:undo_ftplugin = "setl fo< com< cms<" ..
\ " | unlet! b:match_ignorecase b:match_skip b:match_words" ..
\ " | unlet! b:browsefilter"
let &cpo = s:cpo_save
unlet s:cpo_save
" vim: nowrap sw=2 sts=2 ts=8 noet fdm=marker:

View File

@@ -3,15 +3,67 @@ if polyglot#init#is_disabled(expand('<sfile>:p'), 'freebasic', 'ftplugin/freebas
endif
" Vim filetype plugin file
" Language: FreeBasic
" Language: FreeBASIC
" Maintainer: Doug Kearns <dougkearns@gmail.com>
" Last Change: 2015 Jan 10
" Last Change: 2021 Mar 16
" Setup {{{1
if exists("b:did_ftplugin")
finish
endif
let b:did_ftplugin = 1
let s:cpo_save = &cpo
set cpo&vim
runtime! ftplugin/basic.vim
" vim: ts=8
let s:dialect = freebasic#GetDialect()
" Comments {{{1
" add ''comments before 'comments
let &l:comments = "sO:*\ -,mO:*\ \ ,exO:*/,s1:/',mb:',ex:'/,:''," .. &l:comments
" Match words {{{1
if exists("loaded_matchit")
let s:not_end = '\%(end\s\+\)\@<!'
let b:match_words .= ','
if s:dialect == 'fb'
let b:match_words .= s:not_end .. '\<constructor\>:\<end\s\+constructor\>,' ..
\ s:not_end .. '\<destructor\>:\<end\s\+destructor\>,' ..
\ s:not_end .. '\<property\>:\<end\s\+property\>,' ..
\ s:not_end .. '\<operator\>:\<end\s\+operator\>,' ..
\ s:not_end .. '\<extern\%(\s\+"\)\@=:\<end\s\+extern\>,'
endif
if s:dialect == 'fb' || s:dialect == 'deprecated'
let b:match_words .= s:not_end .. '\<scope\>:\<end\s\+scope\>,'
endif
if s:dialect == 'qb'
let b:match_words .= s:not_end .. '\<__asm\>:\<end\s\+__asm\>,' ..
\ s:not_end .. '\<__union\>:\<end\s\+__union\>,' ..
\ s:not_end .. '\<__with\>:\<end\s\+__with\>,'
else
let b:match_words .= s:not_end .. '\<asm\>:\<end\s\+asm\>,' ..
\ s:not_end .. '\<namespace\>:\<end\s\+namespace\>,' ..
\ s:not_end .. '\<union\>:\<end\s\+union\>,' ..
\ s:not_end .. '\<with\>:\<end\s\+with\>,'
endif
let b:match_words .= s:not_end .. '\<enum\>:\<end\s\+enum\>,' ..
\ '^#\s*\%(if\|ifdef\|ifndef\)\>:^#\s*\%(else\|elseif\)\>:^#\s*endif\>,' ..
\ '^#\s*macro\>:^#\s*endmacro\>'
" skip "function = <retval>"
let b:match_skip .= '|| strpart(getline("."), col(".") - 1) =~? "^\\<function\\s\\+="'
unlet s:not_end
endif
" Cleanup {{{1
let &cpo = s:cpo_save
unlet s:cpo_save
" vim: nowrap sw=2 sts=2 ts=8 noet fdm=marker:

View File

@@ -98,7 +98,7 @@ endfunction
"
function! s:MoveToCurHeader()
let l:lineNum = s:GetHeaderLineNum()
if l:lineNum != 0
if l:lineNum !=# 0
call cursor(l:lineNum, 1)
else
echo 'outside any header'
@@ -151,7 +151,7 @@ function! s:GetHeaderLevel(...)
let l:line = a:1
endif
let l:linenum = s:GetHeaderLineNum(l:line)
if l:linenum != 0
if l:linenum !=# 0
return s:GetLevelOfHeaderAtLine(l:linenum)
else
return 0
@@ -165,13 +165,13 @@ function! s:GetHeaderList()
let l:fenced_block = 0
let l:front_matter = 0
let l:header_list = []
let l:vim_markdown_frontmatter = get(g:, "vim_markdown_frontmatter", 0)
let l:vim_markdown_frontmatter = get(g:, 'vim_markdown_frontmatter', 0)
for i in range(1, line('$'))
let l:lineraw = getline(i)
let l:l1 = getline(i+1)
let l:line = substitute(l:lineraw, "#", "\\\#", "g")
let l:line = substitute(l:lineraw, '#', "\\\#", 'g')
" exclude lines in fenced code blocks
if l:line =~ '````*' || l:line =~ '\~\~\~\~*'
if l:line =~# '````*' || l:line =~# '\~\~\~\~*'
if l:fenced_block == 0
let l:fenced_block = 1
elseif l:fenced_block == 1
@@ -180,24 +180,24 @@ function! s:GetHeaderList()
" exclude lines in frontmatters
elseif l:vim_markdown_frontmatter == 1
if l:front_matter == 1
if l:line == '---'
if l:line ==# '---'
let l:front_matter = 0
endif
elseif i == 1
if l:line == '---'
if l:line ==# '---'
let l:front_matter = 1
endif
endif
endif
" match line against header regex
if join(getline(i, i + 1), "\n") =~ s:headersRegexp && l:line =~ '^\S'
if join(getline(i, i + 1), "\n") =~# s:headersRegexp && l:line =~# '^\S'
let l:is_header = 1
else
let l:is_header = 0
endif
if l:is_header == 1 && l:fenced_block == 0 && l:front_matter == 0
if l:is_header ==# 1 && l:fenced_block ==# 0 && l:front_matter ==# 0
" remove hashes from atx headers
if match(l:line, "^#") > -1
if match(l:line, '^#') > -1
let l:line = substitute(l:line, '\v^#*[ ]*', '', '')
let l:line = substitute(l:line, '\v[ ]*#*$', '', '')
endif
@@ -365,11 +365,11 @@ function! s:Toc(...)
let l:header_list = s:GetHeaderList()
let l:indented_header_list = []
if len(l:header_list) == 0
echom "Toc: No headers."
echom 'Toc: No headers.'
return
endif
let l:header_max_len = 0
let l:vim_markdown_toc_autofit = get(g:, "vim_markdown_toc_autofit", 0)
let l:vim_markdown_toc_autofit = get(g:, 'vim_markdown_toc_autofit', 0)
for h in l:header_list
" set header number of the cursor position
if l:cursor_header == 0
@@ -442,7 +442,7 @@ function! s:InsertToc(format, ...)
let l:toc = []
let l:header_list = s:GetHeaderList()
if len(l:header_list) == 0
echom "InsertToc: No headers."
echom 'InsertToc: No headers.'
return
endif
@@ -554,7 +554,7 @@ function! s:TableFormat()
" Move colons for alignment to left or right side of the cell.
execute 's/:\( \+\)|/\1:|/e' . l:flags
execute 's/|\( \+\):/|:\1/e' . l:flags
execute 's/ /-/' . l:flags
execute 's/|:\?\zs[ -]\+\ze:\?|/\=repeat("-", len(submatch(0)))/' . l:flags
call setpos('.', l:pos)
endfunction
@@ -657,7 +657,7 @@ endfunction
"
function! s:OpenUrlUnderCursor()
let l:url = s:Markdown_GetUrlForPosition(line('.'), col('.'))
if l:url != ''
if l:url !=# ''
call s:VersionAwareNetrwBrowseX(l:url)
else
echomsg 'The cursor is not on a link.'
@@ -668,8 +668,24 @@ endfunction
" script while this function is running. We must not replace it.
if !exists('*s:EditUrlUnderCursor')
function s:EditUrlUnderCursor()
let l:editmethod = ''
" determine how to open the linked file (split, tab, etc)
if exists('g:vim_markdown_edit_url_in')
if g:vim_markdown_edit_url_in ==# 'tab'
let l:editmethod = 'tabnew'
elseif g:vim_markdown_edit_url_in ==# 'vsplit'
let l:editmethod = 'vsp'
elseif g:vim_markdown_edit_url_in ==# 'hsplit'
let l:editmethod = 'sp'
else
let l:editmethod = 'edit'
endif
else
" default to current buffer
let l:editmethod = 'edit'
endif
let l:url = s:Markdown_GetUrlForPosition(line('.'), col('.'))
if l:url != ''
if l:url !=# ''
if get(g:, 'vim_markdown_autowrite', 0)
write
endif
@@ -679,14 +695,14 @@ if !exists('*s:EditUrlUnderCursor')
if len(l:parts) == 2
let [l:url, l:anchor] = parts
let l:anchorexpr = get(g:, 'vim_markdown_anchorexpr', '')
if l:anchorexpr != ''
if l:anchorexpr !=# ''
let l:anchor = eval(substitute(
\ l:anchorexpr, 'v:anchor',
\ escape('"'.l:anchor.'"', '"'), ''))
endif
endif
endif
if l:url != ''
if l:url !=# ''
let l:ext = ''
if get(g:, 'vim_markdown_no_extensions_in_markdown', 0)
" use another file extension if preferred
@@ -697,29 +713,13 @@ if !exists('*s:EditUrlUnderCursor')
endif
endif
let l:url = fnameescape(fnamemodify(expand('%:h').'/'.l:url.l:ext, ':.'))
let l:editmethod = ''
" determine how to open the linked file (split, tab, etc)
if exists('g:vim_markdown_edit_url_in')
if g:vim_markdown_edit_url_in == 'tab'
let l:editmethod = 'tabnew'
elseif g:vim_markdown_edit_url_in == 'vsplit'
let l:editmethod = 'vsp'
elseif g:vim_markdown_edit_url_in == 'hsplit'
let l:editmethod = 'sp'
else
let l:editmethod = 'edit'
endif
else
" default to current buffer
let l:editmethod = 'edit'
endif
execute l:editmethod l:url
endif
if l:anchor != ''
if l:anchor !=# ''
silent! execute '/'.l:anchor
endif
else
echomsg 'The cursor is not on a link.'
execute l:editmethod . ' <cfile>'
endif
endfunction
endif
@@ -754,7 +754,7 @@ if !get(g:, 'vim_markdown_no_default_key_mappings', 0)
call <sid>MapNotHasmapto('][', 'Markdown_MoveToNextSiblingHeader')
call <sid>MapNotHasmapto('[]', 'Markdown_MoveToPreviousSiblingHeader')
call <sid>MapNotHasmapto(']u', 'Markdown_MoveToParentHeader')
call <sid>MapNotHasmapto(']c', 'Markdown_MoveToCurHeader')
call <sid>MapNotHasmapto(']h', 'Markdown_MoveToCurHeader')
call <sid>MapNotHasmapto('gx', 'Markdown_OpenUrlUnderCursor')
call <sid>MapNotHasmapto('ge', 'Markdown_EditUrlUnderCursor')
endif
@@ -774,8 +774,8 @@ command! -buffer -nargs=? InsertNToc call s:InsertToc('numbers', <args>)
if exists('g:vim_markdown_fenced_languages')
let s:filetype_dict = {}
for s:filetype in g:vim_markdown_fenced_languages
let key = matchstr(s:filetype, "[^=]*")
let val = matchstr(s:filetype, "[^=]*$")
let key = matchstr(s:filetype, '[^=]*')
let val = matchstr(s:filetype, '[^=]*$')
let s:filetype_dict[key] = val
endfor
else
@@ -793,7 +793,7 @@ function! s:MarkdownHighlightSources(force)
let filetypes = {}
for line in getline(1, '$')
let ft = matchstr(line, '```\s*\zs[0-9A-Za-z_+-]*\ze.*')
if !empty(ft) && ft !~ '^\d*$' | let filetypes[ft] = 1 | endif
if !empty(ft) && ft !~# '^\d*$' | let filetypes[ft] = 1 | endif
endfor
if !exists('b:mkd_known_filetypes')
let b:mkd_known_filetypes = {}
@@ -816,7 +816,7 @@ function! s:MarkdownHighlightSources(force)
else
let filetype = ft
endif
let group = 'mkdSnippet' . toupper(substitute(filetype, "[+-]", "_", "g"))
let group = 'mkdSnippet' . toupper(substitute(filetype, '[+-]', '_', 'g'))
if !has_key(b:mkd_included_filetypes, filetype)
let include = s:SyntaxInclude(filetype)
let b:mkd_included_filetypes[filetype] = 1
@@ -858,13 +858,13 @@ endfunction
function! s:MarkdownRefreshSyntax(force)
if &filetype =~ 'markdown' && line('$') > 1
if &filetype =~# 'markdown' && line('$') > 1
call s:MarkdownHighlightSources(a:force)
endif
endfunction
function! s:MarkdownClearSyntaxVariables()
if &filetype =~ 'markdown'
if &filetype =~# 'markdown'
unlet! b:mkd_included_filetypes
endif
endfunction

View File

@@ -5,7 +5,6 @@ endif
scriptencoding utf-8
" Vim filetype plugin file
" Language: PlantUML
" Maintainer: Anders Thøgersen <first name at bladre dot dk>
" License: VIM LICENSE
if exists('b:loaded_plantuml_plugin')