From e10f501b997cf2a985ff3446cea5f420564364e5 Mon Sep 17 00:00:00 2001 From: "Andy K. Massimino" Date: Tue, 31 Oct 2017 18:05:18 -0400 Subject: [PATCH] Add some test examples --- ftplugin/matchuptest.vim | 35 +++++++++++++++++++++++++++++++++++ test/augment.matchuptest | 10 ++++++++++ test/forwhile.vim | 33 +++++++++++++++++++++++++++++++++ test/minvimrc | 14 ++++++++++++++ test/mwe.vim | 9 +++++++++ test/parens.txt | 18 ++++++++++++++++++ test/test.html | 13 +++++++++++++ test/transmute.html | 5 +++++ 8 files changed, 137 insertions(+) create mode 100644 ftplugin/matchuptest.vim create mode 100644 test/augment.matchuptest create mode 100644 test/forwhile.vim create mode 100644 test/minvimrc create mode 100644 test/mwe.vim create mode 100644 test/parens.txt create mode 100644 test/test.html create mode 100644 test/transmute.html diff --git a/ftplugin/matchuptest.vim b/ftplugin/matchuptest.vim new file mode 100644 index 0000000..25c6630 --- /dev/null +++ b/ftplugin/matchuptest.vim @@ -0,0 +1,35 @@ + +" Only do this when not done yet for this buffer +if exists("b:did_ftplugin") + finish +endif + +" Don't load another plugin for this buffer +let b:did_ftplugin = 1 + +let s:cpo_save = &cpo +set cpo-=C + +" Let the matchit plugin know what items can be matched. +if exists("loaded_matchit") + let b:match_ignorecase = 0 + " let b:match_words = + " \ '\:\:\,' . + " \ '\<\(wh\%[ile]\|for\)\>:\:\:\,' . + " \ '\:\:\,' . + " \ '\:\:\:\,' . + " \ '\\)\@!\S:\,' . + " \ '(:)' + + " very tricky examples: + " bad: let b:match_words = '\(foo\)\(bar\):more\1:and\2:end\1\2' + " good: + let b:match_words = '\<\(\(foo\)\(bar\)\):\3\2:end\1' + + let b:match_skip = 'synIDattr(synID(line("."),col("."),1),"name") + \ =~? "comment\\|string\\|vimSynReg\\|vimSet"' +endif + +let &cpo = s:cpo_save +unlet s:cpo_save + diff --git a/test/augment.matchuptest b/test/augment.matchuptest new file mode 100644 index 0000000..e02f37b --- /dev/null +++ b/test/augment.matchuptest @@ -0,0 +1,10 @@ + +foobar + +barfoo + +endfoobar + +" \<\(\(foo\)\(bar\)\):\3\2:end\1 + +" vim: set ft=matchuptest diff --git a/test/forwhile.vim b/test/forwhile.vim new file mode 100644 index 0000000..a11e132 --- /dev/null +++ b/test/forwhile.vim @@ -0,0 +1,33 @@ + if a:findstart + if exists('s:completer') | unlet s:completer | endif + + let l:pos = col('.') - 1 + let l:line = getline('.')[:l:pos-1] + for l:completer in s:completers + if !get(l:completer, 'enabled', 1) | continue | endif + + for l:pattern in l:completer.patterns + if l:line =~# l:pattern + let s:completer = l:completer + while l:pos > 0 + if l:line[l:pos - 1] =~# '{\|,\|\[\|\\' + \ || l:line[l:pos-2:l:pos-1] ==# ', ' + let s:completer.context = matchstr(l:line, '\S*$') + return l:pos + else + let l:pos -= 1 + endif + endwhile + return -2 + endif + endfor + endfor + return -3 + else + if !exists('s:completer') | return [] | endif + + return g:matchup_complete_close_braces && get(s:completer, 'inside_braces', 1) + \ ? s:close_braces(s:completer.complete(a:base)) + \ : s:completer.complete(a:base) + endif + diff --git a/test/minvimrc b/test/minvimrc new file mode 100644 index 0000000..14ea936 --- /dev/null +++ b/test/minvimrc @@ -0,0 +1,14 @@ +set nocompatible + +" load match-up +let &rtp = '~/.vim/bundle/matchup.vim,' . &rtp +let &rtp .= ',~/.vim/bundle/matchup.vim/after' + +" load other plugins, if necessary +" let &rtp = '~/path/to/other/plugin,' . &rtp + +filetype plugin indent on +syntax enable + +" match-up options go here + diff --git a/test/mwe.vim b/test/mwe.vim new file mode 100644 index 0000000..6e0e593 --- /dev/null +++ b/test/mwe.vim @@ -0,0 +1,9 @@ + +if l:x == 1 + call one() +else + call two() +elseif + call three() +endif + diff --git a/test/parens.txt b/test/parens.txt new file mode 100644 index 0000000..9cd2e31 --- /dev/null +++ b/test/parens.txt @@ -0,0 +1,18 @@ + +---- + ( + something + ) +---- + + ( (( ) )) + + ( + hello + ) + +---- + ( ( (( )) ) ) +---- + + diff --git a/test/test.html b/test/test.html new file mode 100644 index 0000000..b8ca0e9 --- /dev/null +++ b/test/test.html @@ -0,0 +1,13 @@ + + + + +Title of the document + + + +Content of the document...... + + + + diff --git a/test/transmute.html b/test/transmute.html new file mode 100644 index 0000000..52c67cc --- /dev/null +++ b/test/transmute.html @@ -0,0 +1,5 @@ + + + + +