From b77c5f11070ecb2ff343aa18b4ea859e6168f16c Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Thu, 17 Feb 2022 04:31:35 +0100 Subject: Update --- ftplugin/basic.vim | 43 +++++++++++++++++++++---- ftplugin/freebasic.vim | 60 ++++++++++++++++++++++++++++++++--- ftplugin/markdown.vim | 86 +++++++++++++++++++++++++------------------------- ftplugin/plantuml.vim | 1 - 4 files changed, 135 insertions(+), 55 deletions(-) (limited to 'ftplugin') diff --git a/ftplugin/basic.vim b/ftplugin/basic.vim index 016253f6..1702fbd6 100644 --- a/ftplugin/basic.vim +++ b/ftplugin/basic.vim @@ -3,9 +3,9 @@ if polyglot#init#is_disabled(expand(':p'), 'basic', 'ftplugin/basic.vim') endif " Vim filetype plugin file -" Language: BASIC +" Language: BASIC (QuickBASIC 4.5) " Maintainer: Doug Kearns -" 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 +" 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\+\)\@,' .. + \ s:not_end_or_exit .. '\:\,' .. + \ s:not_end_or_exit .. '\:\,' .. + \ s:not_end .. '\:\,' .. + \ s:not_end .. '\:\%(select\s\+\)\@:\,' .. + \ '\:\,' .. + \ '\\%(\s\+\%(input\|output\|random\|append\|binary\)\)\@!:\,' .. + \ '\:\,' .. + \ s:line_start .. 'if\%(.*\:\,' .. + \ '\:\' + + let b:match_skip = 'synIDattr(synID(line("."),col("."),1),"name") =~? "comment\\|string" || ' .. + \ 'strpart(getline("."), 0, col(".") ) =~? "\\:p'), 'freebasic', 'ftplugin/freebas endif " Vim filetype plugin file -" Language: FreeBasic +" Language: FreeBASIC " Maintainer: Doug Kearns -" 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\+\)\@:\,' .. + \ s:not_end .. '\:\,' .. + \ s:not_end .. '\:\,' .. + \ s:not_end .. '\:\,' .. + \ s:not_end .. '\,' + endif + + if s:dialect == 'fb' || s:dialect == 'deprecated' + let b:match_words .= s:not_end .. '\:\,' + endif + + if s:dialect == 'qb' + let b:match_words .= s:not_end .. '\<__asm\>:\,' .. + \ s:not_end .. '\<__union\>:\,' .. + \ s:not_end .. '\<__with\>:\,' + else + let b:match_words .= s:not_end .. '\:\,' .. + \ s:not_end .. '\:\,' .. + \ s:not_end .. '\:\,' .. + \ s:not_end .. '\:\,' + endif + + let b:match_words .= s:not_end .. '\:\,' .. + \ '^#\s*\%(if\|ifdef\|ifndef\)\>:^#\s*\%(else\|elseif\)\>:^#\s*endif\>,' .. + \ '^#\s*macro\>:^#\s*endmacro\>' + + " skip "function = " + let b:match_skip .= '|| strpart(getline("."), col(".") - 1) =~? "^\\ -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 . ' ' endif endfunction endif @@ -754,7 +754,7 @@ if !get(g:, 'vim_markdown_no_default_key_mappings', 0) call MapNotHasmapto('][', 'Markdown_MoveToNextSiblingHeader') call MapNotHasmapto('[]', 'Markdown_MoveToPreviousSiblingHeader') call MapNotHasmapto(']u', 'Markdown_MoveToParentHeader') - call MapNotHasmapto(']c', 'Markdown_MoveToCurHeader') + call MapNotHasmapto(']h', 'Markdown_MoveToCurHeader') call MapNotHasmapto('gx', 'Markdown_OpenUrlUnderCursor') call MapNotHasmapto('ge', 'Markdown_EditUrlUnderCursor') endif @@ -774,8 +774,8 @@ command! -buffer -nargs=? InsertNToc call s:InsertToc('numbers', ) 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 diff --git a/ftplugin/plantuml.vim b/ftplugin/plantuml.vim index 9f525dc3..5d59c507 100644 --- a/ftplugin/plantuml.vim +++ b/ftplugin/plantuml.vim @@ -5,7 +5,6 @@ endif scriptencoding utf-8 " Vim filetype plugin file " Language: PlantUML -" Maintainer: Anders Thøgersen " License: VIM LICENSE if exists('b:loaded_plantuml_plugin') -- cgit v1.2.3