vimwiki/test/syntax.vader

608 lines
17 KiB
Plaintext

# Syntax and Highlight
# 1 Typeface {{{1
#################
# With vimwiki_hl_cb_checked {{{2
Given vimwiki (task list with code):
Normal syntax
- [X] Lorem __sit__ `sed do eiusmod
tempor` incididunt ut labore et dolore magna aliqua
Normal syntax
Execute (let g:vimwiki_hl_cb_checked = 1):
let g:vimwiki_hl_cb_checked = 1
unlet g:vimwiki_syntax_variables
call vimwiki#vars#init()
call SetSyntax('markdown')
Execute (Assert Done Syntax 1):
AssertEqual '' , SyntaxAt(1, 7)
AssertEqual 'VimwikiCheckBoxDone', SyntaxAt(2, 7)
AssertEqual 'VimwikiCode' , SyntaxAt(3, 7)
AssertEqual '' , SyntaxAt(4, 7)
Given vimwiki (task list with code):
Normal syntax
- [X] Lorem __sit__ `sed do eiusmod
tempor` incididunt ut labore et dolore magna aliqua
Normal syntax
Execute (let g:vimwiki_hl_cb_checked = 2):
let g:vimwiki_hl_cb_checked = 2
unlet g:vimwiki_syntax_variables
call vimwiki#vars#init()
call SetSyntax('markdown')
Execute (Assert Done Syntax 2):
AssertEqual '' , SyntaxAt(1, 7)
AssertEqual 'VimwikiCheckBoxDone', SyntaxAt(2, 7)
AssertEqual 'VimwikiCheckBoxDone', SyntaxAt(3, 7)
AssertEqual '' , SyntaxAt(4, 7)
# Extended types {{{2
Given vimwiki (Extended Types mono):
`code `
~~ strike ~~
$ equation $
^superscript ^
,, subscript ,,
Execute (Set syntax markdown):
call SetSyntax('markdown')
Execute (Assert Syntax extended types mono):
AssertEqual 'VimwikiCode' , SyntaxAt(1, 8)
AssertEqual 'VimwikiDelText' , SyntaxAt(2, 8)
AssertEqual 'VimwikiEqIn' , SyntaxAt(3, 8)
AssertEqual 'VimwikiSuperScript' , SyntaxAt(4, 8)
AssertEqual 'VimwikiSubScript' , SyntaxAt(5, 8)
Given vimwiki (Extended Types nested in basic):
From __bold `code in bold ` end of bold__ morF
From _it and ~~ strieout in i~~ end of it_ morF
From __bold $ equation $ end bold __
**bold ^superscript ^ end of bold morF**
From normal ,, subscript ,, still normal morF
Execute (Set syntax markdown):
call SetSyntax('markdown')
Execute (Assert Syntax extended types mono):
AssertEqual 'VimwikiCode' , SyntaxAt(1, 23)
AssertEqual 'VimwikiDelText' , SyntaxAt(2, 23)
AssertEqual 'VimwikiEqIn' , SyntaxAt(3, 23)
AssertEqual 'VimwikiSuperScript' , SyntaxAt(4, 23)
AssertEqual 'VimwikiSubScript' , SyntaxAt(5, 23)
Given vimwiki (Extended Types nested in extended):
From ^super to`code this ` is crazy but^ morF
From ,,sub to~~ strike ~~why not,, morF
From ~~strike $ equation $ end of strike~~morF
From $eq to ^super ^ Just inline morF$
From ^super t,,sub ,, end super eol ^
Execute (Set syntax markdown):
call SetSyntax('markdown')
Execute (Assert Syntax extended types nested in extended):
AssertEqual 'VimwikiCode' , SyntaxAt(1, 23)
AssertEqual 'VimwikiDelText' , SyntaxAt(2, 23)
AssertEqual 'VimwikiEqIn' , SyntaxAt(3, 23)
AssertEqual 'VimwikiSuperScript' , SyntaxAt(4, 23)
AssertEqual 'VimwikiSubScript' , SyntaxAt(5, 23)
Given vimwiki (Basic Types nested in extended):
From ^super t__bold __ is crazy but^ morF
From ,,sub to _italic with en_ aaaaaaa,, morF
From $eq to **boldboldboldbo** aaaaaaaaa $
From ^super t *italic aaaaaaa*aaaaaaaaaaaaaaaaaaaaa
From ~~strike__ bbbbbbbbbbbbb__ssssssssssssssssss~~
Execute (Set syntax markdown):
call SetSyntax('markdown')
Execute (Assert Syntax extended types nested in extended):
AssertEqual 'VimwikiBold' , SyntaxAt(1, 23)
AssertEqual 'VimwikiItalic' , SyntaxAt(2, 23)
AssertEqual 'VimwikiBold' , SyntaxAt(3, 23)
AssertEqual 'VimwikiItalic' , SyntaxAt(4, 23)
AssertEqual 'VimwikiBold' , SyntaxAt(5, 23)
Given vimwiki (Try to nest in code):
From `codeto__no onenest in code__ end`
From `codeto _no onenest in code_ end`
From `codeto ^no onenest in code^ end`
From `codeto ~~no onenest in code~~ end`
From `codeto ___no onenest in code___ end`
Execute (Set syntax markdown):
call SetSyntax('markdown')
Execute (Assert Syntax extended types nested in extended):
AssertEqual 'VimwikiCode' , SyntaxAt(1, 23)
AssertEqual 'VimwikiCode' , SyntaxAt(2, 23)
AssertEqual 'VimwikiCode' , SyntaxAt(3, 23)
AssertEqual 'VimwikiCode' , SyntaxAt(4, 23)
AssertEqual 'VimwikiCode' , SyntaxAt(5, 23)
Given vimwiki (Multiline Typfaces Basic and extended):
__and bold
multiline__
_and it
mutliline_
~~and mutltie
strikeout~~
`
and mutli
path
`
and $ multi
equation
$
^ but no multi
sup ^
,,
but no multi
sub ,,
Execute (Set syntax markdown):
call SetSyntax('markdown')
Execute (Multiline syantax but not sup and sub):
AssertEqual 'VimwikiBold' , SyntaxAt(2, 1)
AssertEqual 'VimwikiItalic' , SyntaxAt(5, 1)
AssertEqual 'VimwikiDelText' , SyntaxAt(8, 1)
AssertEqual 'VimwikiCode' , SyntaxAt(11, 1)
AssertEqual 'VimwikiEqIn' , SyntaxAt(14, 1)
AssertEqual '' , SyntaxAt(17, 1)
AssertEqual '' , SyntaxAt(20, 1)
# HTML types {{{2
# Rememner Bold > Italic > Underline (my convention [Tinmarino])
Given vimwiki (Typeface for Italic var_with_underscore):
var_with_underscore
_this is
italic_
Execute (Set syntax markdown):
call SetSyntax('markdown')
Execute (Assert Syntax for typeface 1):
AssertEqual '' , SyntaxAt(1, 1)
AssertEqual 'VimwikiError' , SyntaxAt(1, 4)
AssertEqual '' , SyntaxAt(1, 5)
AssertEqual 'VimwikiItalic' , SyntaxAt(2, 2)
AssertEqual 'VimwikiItalic' , SyntaxAt(3, 2)
Given vimwiki (Typeface for html 1 like italic):
<b> ---- this is bold text 1 ---- </b>
<strong> - this is bold 2 - </strong>
<i> Italic 1 --cacacacacacacaca-- </i>
<em> Italic 2 -cacacacacacacaca- </em>
<u> Underline -cacacacacc acaca- </u>
Execute (Set syntax markdown):
call SetSyntax('markdown')
Execute (Assert Syntax for typeface 1):
AssertEqual 'VimwikiBold' , SyntaxAt(1, 15)
AssertEqual 'VimwikiBold' , SyntaxAt(2, 15)
AssertEqual 'VimwikiItalic' , SyntaxAt(3, 15)
AssertEqual 'VimwikiItalic' , SyntaxAt(4, 15)
AssertEqual 'VimwikiUnderline' , SyntaxAt(5, 15)
Given vimwiki (Typeface for html 2 like italicUnderline):
<b> bold this is bold<i>bold italic ---------</i> text 1 ---- </b>
<strong> - this is bo<u>bold underline ------</u>d 2 - </strong>
<i> Italic 1 --cacaca<b>bold italic----------</b>acacacaca-- </i>
<em> Italic 2 -cacaca<u>italic underline-----</u>cacacaca- </em>
<u> Underline -cacaca<b>bold underline-------</b>asacc acaca- </u>
<u> Underline -cacaca<i>italic underline-----</i>asdacacc acaca- </u>
Execute (Assert Syntax for typeface 2):
AssertEqual 'VimwikiBoldItalic' , GetSyntaxGroup(1, 30)
AssertEqual 'VimwikiBoldUnderline' , GetSyntaxGroup(2, 30)
AssertEqual 'VimwikiBoldItalic' , GetSyntaxGroup(3, 30)
AssertEqual 'VimwikiItalicUnderline', GetSyntaxGroup(4, 30)
AssertEqual 'VimwikiBoldUnderline' , GetSyntaxGroup(5, 30)
AssertEqual 'VimwikiItalicUnderline', GetSyntaxGroup(6, 30)
Given vimwiki (Typeface for html 3 like boldItalicUnderline):
<b><i><u> bold italic underline </u></i></b>
<b><u><i> bold italic underline </i></u></b>
<i><b><u> bold italic underline </u></b></i>
<i><u><b> bold italic underline </b></u></i>
<u><b> <i> bold italic underline </i> </b></u>
<u><i><b> bold italic underline </b></i></u>
Execute (Assert Syntax for typeface 3):
AssertEqual 'VimwikiBoldItalicUnderline1', GetSyntaxGroup(1, 22).1
AssertEqual 'VimwikiBoldItalicUnderline2', GetSyntaxGroup(2, 22).2
AssertEqual 'VimwikiBoldItalicUnderline3', GetSyntaxGroup(3, 22).3
AssertEqual 'VimwikiBoldItalicUnderline4', GetSyntaxGroup(4, 22).4
AssertEqual 'VimwikiBoldItalicUnderline5', GetSyntaxGroup(5, 22).5
AssertEqual 'VimwikiBoldItalicUnderline6', GetSyntaxGroup(6, 22).6
# Keyword uppercase {{{2
Given vimwiki (TODO, XXX):
TODO
DONE
STARTED
FIXME
FIXED
XXX
Execute (Assert Syntax VimwikiTodo):
AssertEqual SyntaxAt(1, 1), 'VimwikiTodo'
AssertEqual SyntaxAt(2, 1), 'VimwikiTodo'
AssertEqual SyntaxAt(3, 1), 'VimwikiTodo'
AssertEqual SyntaxAt(4, 1), 'VimwikiTodo'
AssertEqual SyntaxAt(5, 1), 'VimwikiTodo'
AssertEqual SyntaxAt(6, 1), 'VimwikiTodo'
# Mardown types {{{2
Given vimwiki (Typeface for markdown like italic):
**bold text 1**
__bold text 2__
*italic text 1*
_italic text 2_
***bold italic text 1***
___bold italic text 2___
~~strikeout text~~
`code (no syntax) text`
sp^script^
sb,,script,,
Execute (Set syntax markdown):
call SetSyntax('markdown')
Execute (Assert Syntax for typeface):
AssertEqual 'VimwikiBold' , SyntaxAt(1, 5)
AssertEqual 'VimwikiBold' , SyntaxAt(2, 5)
AssertEqual 'VimwikiItalic' , SyntaxAt(3, 5)
AssertEqual 'VimwikiItalic' , SyntaxAt(4, 5)
AssertEqual 'VimwikiBoldItalic' , SyntaxAt(5, 5)
AssertEqual 'VimwikiBoldItalic' , SyntaxAt(6, 5)
AssertEqual 'VimwikiDelText' , SyntaxAt(7, 5)
AssertEqual 'VimwikiCode' , SyntaxAt(8, 5)
AssertEqual 'VimwikiSuperScript' , SyntaxAt(9, 5)
AssertEqual 'VimwikiSubScript' , SyntaxAt(10, 5)
# 2 Links {{{1
#################
Given vimwiki (Wiki Links):
Plain link: >
[[This is a link]]
With description: >
[[This is a link source|Description of the link]]
Interwiki1: >
[[wiki1:This is a link]]
Interwiki2: >
[[wn.My Name:This is a link]]
Interwiki3: >
[[wn.MyWiki:This is a link source|Description of the link]]
Diary: >
[[diary:2012-03-05]]
Anchor1: >
[[Todo List#Tomorrow|Tasks for tomorrow]]
Anchor2: >
[[#Tomorrow]]
Raw1: >
https://github.com/vimwiki/vimwiki.git
Raw2: >
mailto:habamax@gmail.com
Raw3: >
ftp://vim.org
File1: >
[[file:/home/somebody/a/b/c/music.mp3]]
File2: >
[[file:C:/Users/somebody/d/e/f/music.mp3]]
File3: >
[[file:~/a/b/c/music.mp3]]
File4: >
[[file:../assets/data.csv|Important Data]]
File5: >
[[local:C:/Users/somebody/d/e/f/music.mp3]]
File6: >
[[file:/home/user/documents/|Link to a directory]]
Thumbnail links: >
[[http://someaddr.com/bigpicture.jpg|{{http://someaddr.com/thumbnail.jpg}}]]
Execute (Assert Syntax link):
AssertEqual 'VimwikiLink', SyntaxAt(2, 6)
AssertEqual 'VimwikiLink', SyntaxAt(4, 6)
AssertEqual 'VimwikiLink', SyntaxAt(6, 6)
AssertEqual 'VimwikiLink', SyntaxAt(8, 6)
AssertEqual 'VimwikiLink', SyntaxAt(10, 6)
AssertEqual 'VimwikiLink', SyntaxAt(12, 6)
AssertEqual 'VimwikiLink', SyntaxAt(14, 6)
AssertEqual 'VimwikiLink', SyntaxAt(16, 6)
AssertEqual 'VimwikiLink', SyntaxAt(18, 6)
AssertEqual 'VimwikiLink', SyntaxAt(20, 6)
AssertEqual 'VimwikiLink', SyntaxAt(22, 6)
AssertEqual 'VimwikiLink', SyntaxAt(24, 6)
AssertEqual 'VimwikiLink', SyntaxAt(26, 6)
AssertEqual 'VimwikiLink', SyntaxAt(28, 6)
AssertEqual 'VimwikiLink', SyntaxAt(30, 6)
AssertEqual 'VimwikiLink', SyntaxAt(32, 6)
AssertEqual 'VimwikiLink', SyntaxAt(34, 6)
AssertEqual 'VimwikiLink', SyntaxAt(36, 6)
Given vimwiki (Markdown Links):
Inline link: >
[Looks like this](URL)
Image link: >
![Looks like this](URL)
Reference-style links: >
a) [Link Name][Id]
b) [Id][], using the "implicit link name" shortcut
Execute (Set syntax markdown):
call SetSyntax('markdown')
Execute (Assert Syntax link):
AssertEqual 'VimwikiWeblink1' , SyntaxAt(2, 8)
AssertEqual 'VimwikiImage' , SyntaxAt(5, 8)
AssertEqual 'VimwikiWikiLink1' , SyntaxAt(8, 8)
AssertEqual 'VimwikiWikiLink1' , SyntaxAt(9, 8)
# 3 Header {{{1
###############
Given vimwiki (Markdown SetExt Headers):
One
===
two
---
Execute (Set syntax markdown):
call SetSyntax('markdown')
Execute (Assert Syntax Header SetExt):
AssertEqual 'VimwikiHeader1', SyntaxAt(1, 1)
AssertEqual 'VimwikiHeader1', SyntaxAt(2, 1)
AssertEqual 'VimwikiHeader2', SyntaxAt(3, 1)
AssertEqual 'VimwikiHeader2', SyntaxAt(4, 1)
Given vimwiki (Wiki Headers):
= Header level 1 =
== Header level 2 ==
=== Header level 3 ===
==== Header level 4 ====
===== Header level 5 =====
====== Header level 6 ======
Execute (Set syntax default):
call SetSyntax('default')
Execute (Assert Syntax Header):
AssertEqual 'VimwikiHeader1', SyntaxAt(1, 10)
AssertEqual 'VimwikiHeader2', SyntaxAt(2, 10)
AssertEqual 'VimwikiHeader3', SyntaxAt(3, 10)
AssertEqual 'VimwikiHeader4', SyntaxAt(4, 10)
AssertEqual 'VimwikiHeader5', SyntaxAt(5, 10)
AssertEqual 'VimwikiHeader6', SyntaxAt(6, 10)
Given vimwiki (Markdown Headers):
# Header level 1
## Header level 2
### Header level 3
#### Header level 4
##### Header level 5
###### Header level 6
Execute (Set syntax markdown):
call SetSyntax('markdown')
Execute (Assert Syntax Header):
AssertEqual 'VimwikiHeader1' , SyntaxAt(1, 10)
AssertEqual 'VimwikiHeader2' , SyntaxAt(2, 10)
AssertEqual 'VimwikiHeader3' , SyntaxAt(3, 10)
AssertEqual 'VimwikiHeader4' , SyntaxAt(4, 10)
AssertEqual 'VimwikiHeader5' , SyntaxAt(5, 10)
AssertEqual 'VimwikiHeader6' , SyntaxAt(6, 10)
# 10 Comments {{{1
###############
Given vimwiki (%%):
%% This is a line comment
%% This is also a comment
Execute (Set syntax default):
call SetSyntax('default')
Execute (Assert Syntax VimwikiComment):
AssertEqual 'VimwikiComment' , SyntaxAt(1, 1)
AssertEqual 'VimwikiComment' , SyntaxAt(2, 4)
Given vimwiki (%%+, +%%):
%%+ This
is a
multiline
comment +%%
%%+ This is a comment on one line +%%
%%+ One +%% Not a comment %%+ Two +%% Not a comment
Execute (Set syntax default):
call SetSyntax('default')
Execute (Assert Syntax VimwikiMultilineComment):
AssertEqual 'VimwikiMultilineComment' , SyntaxAt(1, 1)
AssertEqual 'VimwikiMultilineComment' , SyntaxAt(1, 8)
AssertEqual 'VimwikiMultilineComment' , SyntaxAt(2, 1)
AssertEqual 'VimwikiMultilineComment' , SyntaxAt(3, 1)
AssertEqual 'VimwikiMultilineComment' , SyntaxAt(4, 1)
AssertEqual 'VimwikiMultilineComment' , SyntaxAt(5, 1)
AssertEqual 'VimwikiMultilineComment' , SyntaxAt(6, 1)
AssertEqual 'VimwikiMultilineComment' , SyntaxAt(6, 11)
AssertEqual '' , SyntaxAt(6, 12)
AssertEqual '' , SyntaxAt(6, 26)
AssertEqual 'VimwikiMultilineComment' , SyntaxAt(6, 27)
AssertEqual 'VimwikiMultilineComment' , SyntaxAt(6, 37)
AssertEqual '' , SyntaxAt(6, 38)
AssertEqual '' , SyntaxAt(6, 51)
# 10 Code {{{1
# 10.1 Code Indent (4 spaces) {{{2
#################################
Given vimwiki (Code indent):
this is markdown
this is code
Execute (Assert Syntax normal (i.e. no hi)):
AssertEqual SyntaxAt(1, 5), ''
AssertEqual SyntaxAt(2, 5), ''
# 10.2 Code Inline (1 backtick) {{{2
###################################
Given vimwiki (Code inline):
Well use the `man`
Execute (Assert Syntax Code):
AssertEqual SyntaxAt(1, 16), 'VimwikiCode'
# 10.3 Code Block (3 backtiks) {{{2
##################################
Given vimwiki (Markdown, Text and Vim):
this is markdown
this is TODO
```
this is text
```
```vim
" this is vim
set hlsearch
```
`````vim
" this is vim
set hlsearch
`````
~~~vim
" this is vim
set hlsearch
~~~
~~~~~vim
" this is vim
set hlsearch
~~~~~~~~~~~
Execute (Set syntax markdown):
let g:vimwiki_global_vars['vimwiki_automatic_nested_syntaxes'] = 1
call SetSyntax('markdown')
Execute (Assert ft, normal syntax and VimwikiTodo):
AssertEqual &ft, 'vimwiki'
AssertEqual '', SyntaxAt(1, 1)
AssertEqual 'VimwikiTodo', SyntaxAt(2, 9)
Execute (Assert Code syntax):
AssertEqual 'VimwikiPreDelim', SyntaxAt(4, 1)
AssertEqual 'VimwikiPre' , SyntaxAt(5, 1)
AssertEqual 'vimLineComment' , SyntaxAt(9, 1)
AssertEqual 'vimCommand' , SyntaxAt(10, 1)
AssertEqual 'VimwikiPre' , SyntaxAt(13, 1)
AssertEqual 'vimLineComment' , SyntaxAt(14, 1)
AssertEqual 'vimCommand' , SyntaxAt(15, 1)
AssertEqual 'VimwikiPre' , SyntaxAt(16, 1)
AssertEqual 'VimwikiPre' , SyntaxAt(18, 1)
AssertEqual 'vimLineComment' , SyntaxAt(19, 1)
AssertEqual 'vimCommand' , SyntaxAt(20, 1)
AssertEqual 'VimwikiPre' , SyntaxAt(21, 1)
AssertEqual 'VimwikiPre' , SyntaxAt(23, 1)
AssertEqual 'vimLineComment' , SyntaxAt(24, 1)
AssertEqual 'vimCommand' , SyntaxAt(25, 1)
AssertEqual 'VimwikiPre' , SyntaxAt(26, 1)
# 11 Math {{{1
# 11.1 Math Markdown {{{2
#######################
Given vimwiki (Math markdown):
math inline: $ \sum_i a_i^2 = 1 $
math block:
$$
\sum_i a_i^2
=
1
$$
math block env:
$$%align%
\sum_i a_i^2 &= 1 + 1 \\
&= 2.
$$
Execute (Set syntax markdown):
call SetSyntax('markdown')
Execute (Assert math syntax 1):
AssertEqual 'VimwikiEqIn', SyntaxAt(1, 18)
let syntax_5 = SyntaxAt(5, 1)
Assert syntax_5 == 'texStatement' || syntax_5 == 'texMathSymbol'
let syntax_12 = SyntaxAt(12, 1)
Assert syntax_12 == 'texStatement' || syntax_5 == 'texMathSymbol'
# 11.2 Math Wiki {{{2
##############################
Given vimwiki (Math wiki):
math inline: $ \sum_i a_i^2 = 1 $
math block:
{{$
\sum_i a_i^2
=
1
}}$
math block env:
{{$%align%
\sum_i a_i^2 &= 1 + 1 \\
&= 2.
}}$
Execute (Set syntax default):
call SetSyntax('default')
Execute (Assert math syntax 2):
AssertEqual 'VimwikiEqIn', SyntaxAt(1, 18)
let syntax_5 = SyntaxAt(5, 1)
Assert syntax_5 == 'texStatement' || syntax_5 == 'texMathSymbol'
let syntax_12 = SyntaxAt(12, 1)
Assert syntax_12 == 'texStatement' || syntax_5 == 'texMathSymbol'
# vim: foldmethod=marker foldlevel=30 sw=2