Feature: VimwikiVar to list, get and set variables

Refaction:
- Add g:vimwiki_syntax_list to set syntaxlocal variables
- Delete: syntax/vimwiki_markdown.vim and friends
- Change: vimwiki_syntax_variables -> vimwiki_syntaxlocal_vars for consistency
- Include: some doc in design notes
This commit is contained in:
Tinmarino 2020-08-17 22:28:15 -04:00
parent ee2d67751e
commit a51052cbe6
17 changed files with 817 additions and 583 deletions

View File

@ -2163,7 +2163,7 @@ function! vimwiki#base#AddHeaderLevel(...) abort
endif endif
let lnum = line('.') let lnum = line('.')
let line = getline(lnum) let line = getline(lnum)
let rxHdr = vimwiki#vars#get_syntaxlocal('rxH') let rxHdr = vimwiki#vars#get_syntaxlocal('header_symbol')
if line =~# '^\s*$' if line =~# '^\s*$'
return return
endif endif
@ -2197,7 +2197,7 @@ function! vimwiki#base#RemoveHeaderLevel(...) abort
endif endif
let lnum = line('.') let lnum = line('.')
let line = getline(lnum) let line = getline(lnum)
let rxHdr = vimwiki#vars#get_syntaxlocal('rxH') let rxHdr = vimwiki#vars#get_syntaxlocal('header_symbol')
if line =~# '^\s*$' if line =~# '^\s*$'
return return
endif endif
@ -2269,7 +2269,7 @@ function! s:collect_headers() abort
endif endif
" Clause: markdown headers must start in the first column " Clause: markdown headers must start in the first column
if vimwiki#vars#get_wikilocal('syntax') ==# 'markdown' if vimwiki#vars#get_wikilocal('syntax') ==# 'markdown'
\ && stridx(line_content, vimwiki#vars#get_syntaxlocal('rxH')) > 0 \ && stridx(line_content, vimwiki#vars#get_syntaxlocal('header_symbol')) > 0
continue continue
endif endif
" Get header level " Get header level

View File

@ -1296,8 +1296,9 @@ function! s:parse_line(line, state) abort
" current line while not marking as processed in the scenario where some " current line while not marking as processed in the scenario where some
" text remains that needs to go through additional processing " text remains that needs to go through additional processing
if !processed if !processed
let mc_start = vimwiki#vars#get_syntaxlocal('rxMultilineCommentStart') let mc_format = vimwiki#vars#get_syntaxlocal('multiline_comment_format')
let mc_end = vimwiki#vars#get_syntaxlocal('rxMultilineCommentEnd') let mc_start = mc_format.pre_mark
let mc_end = mc_format.post_mark
" If either start or end is empty, we want to skip multiline handling " If either start or end is empty, we want to skip multiline handling
if !empty(mc_start) && !empty(mc_end) if !empty(mc_start) && !empty(mc_end)
@ -1396,7 +1397,7 @@ function! s:parse_line(line, state) abort
endif endif
if !processed if !processed
if line =~# vimwiki#vars#get_syntaxlocal('rxComment') if line =~# vimwiki#vars#get_syntaxlocal('comment_regex')
let processed = 1 let processed = 1
endif endif
endif endif

View File

@ -5,17 +5,22 @@
" Echo: msg " Echo: msg
" :param: (1) <string> highlighting group " :param: (1) <string> highlighting group
" :param: (2) <string> echo suffix (ex: 'n', 'm' " :param: (2) <string> echo suffix (ex: 'n', 'm')
" :param: (3) <string> message prefix, default Vimwiki
function! vimwiki#u#echo(msg, ...) abort function! vimwiki#u#echo(msg, ...) abort
let hl_group = a:0 > 0 ? a:1 : '' let hl_group = a:0 > 0 ? a:1 : ''
let echo_suffix = a:0 > 1 ? a:2 : '' let echo_suffix = a:0 > 1 ? a:2 : ''
let msg_prefix = a:0 > 2 ? a:3 : 'Vimwiki: '
" Start highlighting " Start highlighting
if hl_group !=# '' if hl_group !=# ''
exe 'echohl ' . hl_group exe 'echohl ' . hl_group
endif endif
" Print
" Escape
let msg = substitute(a:msg, "'", "''", 'g') let msg = substitute(a:msg, "'", "''", 'g')
exe 'echo'.echo_suffix . " 'Vimwiki: " . msg . "'" " Print
exe 'echo'.echo_suffix . " '" . msg_prefix . msg . "'"
" Stop highlighting " Stop highlighting
if hl_group !=# '' if hl_group !=# ''
echohl None echohl None
@ -267,7 +272,7 @@ endfunction
" :param: syntax <string> to retrive, default to current " :param: syntax <string> to retrive, default to current
function! vimwiki#u#get_syntax_dic(...) abort function! vimwiki#u#get_syntax_dic(...) abort
let syntax = a:0 ? a:1 : vimwiki#vars#get_wikilocal('syntax') let syntax = a:0 ? a:1 : vimwiki#vars#get_wikilocal('syntax')
return g:vimwiki_syntax_variables[syntax] return g:vimwiki_syntaxlocal_vars[syntax]
endfunction endfunction

File diff suppressed because it is too large Load Diff

View File

@ -1,12 +1,12 @@
# Design Notes # Design Notes
This file is meant to document design decisions and algorithms inside vimwiki This file is meant to document design decisions and algorithms inside Vimwiki
which are too large for code comments, and not necessarily interesting to which are too large for code comments, and not necessarily interesting to
users. Please create a new section to document each behavior. users. Please create a new section to document each behavior.
## Formatting tables ## Formatting tables
In vimwiki, formatting tables occurs dynamically, when navigating between cells In Vimwiki, formatting tables occurs dynamically, when navigating between cells
and adding new rows in a table in the Insert mode, or statically, when pressing and adding new rows in a table in the Insert mode, or statically, when pressing
`gqq` or `gqw` (which are mappings for commands `VimwikiTableAlignQ` and `gqq` or `gqw` (which are mappings for commands `VimwikiTableAlignQ` and
`VimwikiTableAlignW` respectively) in the Normal mode. It also triggers when `VimwikiTableAlignW` respectively) in the Normal mode. It also triggers when
@ -107,7 +107,7 @@ variable `g:vimwiki_table_auto_fmt` is set. This means that formatting of the
whole table is called on all those multiple interleaves between the Insert and whole table is called on all those multiple interleaves between the Insert and
the Normal mode in `s:kbd_create_new_row` (notice `\<ESC>`, `o`, etc.). the Normal mode in `s:kbd_create_new_row` (notice `\<ESC>`, `o`, etc.).
### The newer table formating algorithm ### The newer table formatting algorithm
The newer algorithm was introduced to struggle against performance issues when The newer algorithm was introduced to struggle against performance issues when
formatting large tables. formatting large tables.
@ -184,3 +184,55 @@ viewport) until one of the being edited cells grows in length to a value big
enough to trigger the older algorithm and the whole table gets aligned. When enough to trigger the older algorithm and the whole table gets aligned. When
partial formatting is not desirable, the whole table can be formatted by partial formatting is not desirable, the whole table can be formatted by
pressing `gqq` in the Normal mode. pressing `gqq` in the Normal mode.
## Scoped Variable
Vimwiki's variables have a scope. They can be:
1. Global [ex: `global_ext`]
2. Wikilocal (1, 2, 3 ...) [ex: `path`]
3. Syntaxlocal (default, markdown, media) [ex: `bullet_types`]
4. Bufferlocal [ex: `b:vimwiki_wiki_nr`]
They all can be configured, changed by user
As a comparison, Vim's variables also have a scope (`:h variable-scope`) and
can also be configured by users.
While features kept stacking, it became more and more difficult to maintain the
coherence and configurability between these variables: a type of markers, say
`bullet_types`, can affect folding, highlighting, keystrokes mapping, indentation.
All of those aspects often requires internal variables that should be calculated
only once's when user is changing the variable and affect only the scope in which
they are defined: a `markdown` syntax configuration should affect all `markdown`
wikis but not `default` ones. So it was decided (#894) to keep a 3 global
dictionaries to hold internal variables (there is only one bufferlocal variable
so a dictionary was clearly overkill) and 3 other dictionaries for user
configuration. The internal dictionaries get updated at startup (`:h extend`)
with the user content but do not modify it. They can also be updated later with
`VimwikiVar` function.
Here, `key` is the variable name, `2` the wiki number and `markdown` the syntax
```vim
" External -> Internal
g:vimwiki_{key} -> g:vimwiki_global_vars[key]
g:vimwiki_syntax_list['markdown'][key]
-> g:vimwiki_syntaxlocal_vars['markdown'][key]
g:vimwiki_list[2][key] -> g:vimwiki_wikilocal_vars[2][key]
```
All are defined in `vars.vim` and in case of a conflict while executing it, the
innermost scope if privileged (as usual for variable scoping conflicts). The
reasons for such a complex system is:
1. The diversity of variables and developers
2. The nature of new (2020) issues asking for some deep customisation (ex: of
the link format) or high functionality (ex: on demand wiki creation and
configuration)
3. Historical excuses that Vimwiki was not designed to be highly configurable at
beginning and many temporary internal variables where created to "fix some
holes"
<!-- vim: set tw=80: -->

View File

@ -46,7 +46,8 @@ CONTENTS *vimwiki*
12.1. Registered Wiki |vimwiki-register-wiki| 12.1. Registered Wiki |vimwiki-register-wiki|
12.2. Temporary Wiki |vimwiki-temporary-wiki| 12.2. Temporary Wiki |vimwiki-temporary-wiki|
12.3. Per-Wiki Options |vimwiki-local-options| 12.3. Per-Wiki Options |vimwiki-local-options|
12.4. Global Options |vimwiki-global-options| 12.4. Per-Syntax Options |vimwiki-syntax-options|
12.5. Global Options |vimwiki-global-options|
13. Getting help |vimwiki-help| 13. Getting help |vimwiki-help|
14. Contributing & Bug reports |vimwiki-contributing| 14. Contributing & Bug reports |vimwiki-contributing|
15. Development |vimwiki-development| 15. Development |vimwiki-development|
@ -722,6 +723,13 @@ These key mappings can be modified by replacing the default keys: >
Displays a list of registered wikis and opens the index file of the Displays a list of registered wikis and opens the index file of the
selected wiki. selected wiki.
*:VimwikiVar* [varname] [value]
Get / Set vimwiki variable. Depending on the number of argument:
0. Echo vimwiki's variables
1. Echo variable varname. Completion works with existing variables
2. Set variable varname to value. Completion works with the current value
of variable
*:VimwikiDiaryIndex* [count] *:VimwikiDiaryIndex* [count]
Open diary index file of the current wiki. If a [count] is given the Open diary index file of the current wiki. If a [count] is given the
corresponding wiki from |g:vimwiki_list| is opened instead. corresponding wiki from |g:vimwiki_list| is opened instead.
@ -2077,7 +2085,7 @@ before plugin/vimwiki.vim is sourced). If this is not possible, try this
command after the Vimwiki settings are (re-) set: > command after the Vimwiki settings are (re-) set: >
:call vimwiki#vars#init() :call vimwiki#vars#init()
If you also want to reload syntax variables, prefix the last command by: > If you also want to reload syntax variables, prefix the last command by: >
:unlet g:vimwiki_syntax_variables :unlet g:vimwiki_syntaxlocal_vars
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
12.1 Registered Wiki *g:vimwiki_list* *vimwiki-register-wiki* 12.1 Registered Wiki *g:vimwiki_list* *vimwiki-register-wiki*
@ -2812,12 +2820,29 @@ Default: 0
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
12.4 Global Options *vimwiki-global-options* 12.4 Syntax Options *vimwiki-global-options*
Syntax options are configured using the following pattern: >
let g:vimwiki_syntax_list['markdown']['bullet_type'] = ['*', '-', '+']
Where:
- `markdown` is the syntax name. It can be (`default`, `markdown` or `media`)
- `bullet_type` is the option_name (see below)
- `['*', '-', '+']` is the option value
------------------------------------------------------------------------------
12.5 Global Options *vimwiki-global-options*
Global options are configured using the following pattern: > Global options are configured using the following pattern: >
let g:option_name = option_value let g:vimwiki_global_ext = 1
Where:
- `global_ext` is the option name
- `1` is the option value
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
@ -3788,6 +3813,7 @@ http://code.google.com/p/vimwiki/issues/list. They may be accessible from
https://github.com/vimwiki-backup/vimwiki/issues. https://github.com/vimwiki-backup/vimwiki/issues.
New:~ New:~
* Feature: PR #988: Command VimwikiVar to list, get and set variables
* Feature: #837 extract web page <title> from URL under cursor and create * Feature: #837 extract web page <title> from URL under cursor and create
a nice wiki link a nice wiki link
* Feature: #922 #928: g:vimwiki_tag_format to change the tag format * Feature: #922 #928: g:vimwiki_tag_format to change the tag format

View File

@ -380,6 +380,9 @@ command! VimwikiDiaryGenerateLinks
command! VimwikiShowVersion call s:get_version() command! VimwikiShowVersion call s:get_version()
command! -nargs=* -complete=customlist,vimwiki#vars#complete
\ VimwikiVar call vimwiki#vars#cmd(<q-args>)
" Declare global maps " Declare global maps
" <Plug> global definitions " <Plug> global definitions
@ -404,12 +407,12 @@ nnoremap <silent><script> <Plug>VimwikiMakeTomorrowDiaryNote
\ :<C-U>call vimwiki#diary#make_note(v:count, 0, \ :<C-U>call vimwiki#diary#make_note(v:count, 0,
\ vimwiki#diary#diary_date_link(localtime(), 1))<CR> \ vimwiki#diary#diary_date_link(localtime(), 1))<CR>
" Get the user defined prefix (default <leader>w)
let s:map_prefix = vimwiki#vars#get_global('map_prefix')
" Set default global key mappings " Set default global key mappings
if str2nr(vimwiki#vars#get_global('key_mappings').global) if str2nr(vimwiki#vars#get_global('key_mappings').global)
" Get the user defined prefix (default <leader>w)
let s:map_prefix = vimwiki#vars#get_global('map_prefix')
call vimwiki#u#map_key('n', s:map_prefix . 'w', '<Plug>VimwikiIndex', 2) call vimwiki#u#map_key('n', s:map_prefix . 'w', '<Plug>VimwikiIndex', 2)
call vimwiki#u#map_key('n', s:map_prefix . 't', '<Plug>VimwikiTabIndex', 2) call vimwiki#u#map_key('n', s:map_prefix . 't', '<Plug>VimwikiTabIndex', 2)
call vimwiki#u#map_key('n', s:map_prefix . 's', '<Plug>VimwikiUISelect', 2) call vimwiki#u#map_key('n', s:map_prefix . 's', '<Plug>VimwikiUISelect', 2)

View File

@ -21,43 +21,13 @@ let b:vimwiki_syntax_concealends = has('conceal') ? ' concealends' : ''
" Populate all syntax vars " Populate all syntax vars
" Include syntax/vimwiki_markdown.vim as "side effect" " Include syntax/vimwiki_markdown.vim as "side effect"
call vimwiki#vars#populate_syntax_vars(s:current_syntax) call vimwiki#vars#populate_syntax_vars(s:current_syntax)
let syntax_dic = g:vimwiki_syntax_variables[s:current_syntax] let syntax_dic = g:vimwiki_syntaxlocal_vars[s:current_syntax]
" Declare nesting capabilities " Declare nesting capabilities
" -- to be embeded in standard: bold, italic, underline " -- to be embeded in standard: bold, italic, underline
let syntax_dic.nested_extended = 'VimwikiError,VimwikiPre,VimwikiCode,VimwikiEqIn,VimwikiSuperScript,VimwikiSubScript,textSnipTEX'
" -- to be embeded in exetended (the one above)
let syntax_dic.nested_typeface = 'VimwikiBold,VimwikiItalic,VimwikiUmderline,VimwikiDelText'
let syntax_dic.nested = syntax_dic.nested_extended . ',' . syntax_dic.nested_typeface
" text: `code` or ``code`` only inline " text: `code` or ``code`` only inline
" Note: `\%(^\|[^`]\)\@<=` means after a new line or a non ` " Note: `\%(^\|[^`]\)\@<=` means after a new line or a non `
let syntax_dic.dTypeface.code = [
\ ['\%(^\|[^`]\)\@<=`\%($\|[^`]\)\@=',
\ '\%(^\|[^`]\)\@<=`\%($\|[^`]\)\@='],
\ ['\%(^\|[^`]\)\@<=``\%($\|[^`]\)\@=',
\ '\%(^\|[^`]\)\@<=``\%($\|[^`]\)\@='],
\ ]
" text: ~~deleted text~~
let syntax_dic.dTypeface.del = ([
\ ['\~\~', '\~\~']])
" text: ^superscript^
let syntax_dic.dTypeface.sup = ([
\ ['\^', '\^']])
" text: ,,subscript,,
let syntax_dic.dTypeface.sub = ([
\ [',,', ',,']])
" text: $ equation_inline $
" Match only one $
" ( ^ or not $) before $ and after: not $
let syntax_dic.dTypeface.eq = ([
\ ['\%(^\|[^$]\)\@<=\$\%($\|[^$]\)\@=',
\ '\%(^\|[^$]\)\@<=\$\%($\|[^$]\)\@=']])
" LINKS: highlighting is complicated due to "nonexistent" links feature " LINKS: highlighting is complicated due to "nonexistent" links feature
function! s:add_target_syntax_ON(target, type) abort function! s:add_target_syntax_ON(target, type) abort
@ -236,7 +206,7 @@ execute 'syn match VimwikiLinkChar /'.vimwiki#vars#get_global('rxWikiInclSuffix1
" non concealed chars " non concealed chars
execute 'syn match VimwikiHeaderChar contained /\%(^\s*'. execute 'syn match VimwikiHeaderChar contained /\%(^\s*'.
\ vimwiki#vars#get_syntaxlocal('rxH').'\+\)\|\%('.vimwiki#vars#get_syntaxlocal('rxH'). \ vimwiki#vars#get_syntaxlocal('header_symbol').'\+\)\|\%('.vimwiki#vars#get_syntaxlocal('header_symbol').
\ '\+\s*$\)/' \ '\+\s*$\)/'
@ -308,10 +278,32 @@ syntax match VimwikiPlaceholderParam /.*/ contained
" Html Tag: <u> " Html Tag: <u>
if vimwiki#vars#get_global('valid_html_tags') !=? '' if vimwiki#vars#get_global('valid_html_tags') !=? ''
" Include: Source html file here let s:html_tags = join(split(vimwiki#vars#get_global('valid_html_tags'), '\s*,\s*'), '\|')
execute 'source ' . expand('<sfile>:h') . '/vimwiki_html.vim' exe 'syntax match VimwikiHTMLtag #\c</\?\%('.s:html_tags.'\)\%(\s\{-1}\S\{-}\)\{-}\s*/\?>#'
" Typeface:
let html_typeface = {
\ 'bold': [['<b>', '</b\_s*>'], ['<strong>', '</strong\_s*>']],
\ 'italic': [['<i>', '</i\_s*>'], ['<em>', '</em\_s*>']],
\ 'underline': [['<u>', '</u\_s*>']],
\ 'code': [['<code>', '</code\_s*>']],
\ 'del': [['<del>', '</del\_s*>']],
\ 'eq': [],
\ 'sup': [['<sup>', '</sup\_s*>']],
\ 'sub': [['<sub>', '</sub\_s*>']],
\ }
call vimwiki#u#hi_typeface(html_typeface)
endif endif
" Comment: home made
execute 'syntax match VimwikiComment /'.vimwiki#vars#get_syntaxlocal('comment_regex').
\ '/ contains=@Spell,VimwikiTodo'
" Only do syntax highlighting for multiline comments if they exist
let mc_format = vimwiki#vars#get_syntaxlocal('multiline_comment_format')
if !empty(mc_format.pre_mark) && !empty(mc_format.post_mark)
execute 'syntax region VimwikiMultilineComment start=/'.mc_format.pre_mark.
\ '/ end=/'.mc_format.post_mark.'/ contains=@NoSpell,VimwikiTodo'
endif
" Tag: " Tag:
let tag_cmd = 'syntax match VimwikiTag /'.vimwiki#vars#get_syntaxlocal('rxTags').'/' let tag_cmd = 'syntax match VimwikiTag /'.vimwiki#vars#get_syntaxlocal('rxTags').'/'
@ -343,7 +335,7 @@ endif
" Typeface: -> u.vim " Typeface: -> u.vim
let s:typeface_dic = vimwiki#vars#get_syntaxlocal('dTypeface') let s:typeface_dic = vimwiki#vars#get_syntaxlocal('typeface')
call vimwiki#u#hi_typeface(s:typeface_dic) call vimwiki#u#hi_typeface(s:typeface_dic)
@ -500,7 +492,7 @@ call vimwiki#base#nested_syntax('tex',
\ vimwiki#vars#get_syntaxlocal('rxMathEnd'), 'VimwikiMath') \ vimwiki#vars#get_syntaxlocal('rxMathEnd'), 'VimwikiMath')
" LaTeX: Inline " LaTeX: Inline
for u in syntax_dic.dTypeface.eq for u in syntax_dic.typeface.eq
execute 'syntax region textSniptex matchgroup=texSnip' execute 'syntax region textSniptex matchgroup=texSnip'
\ . ' start="'.u[0].'" end="'.u[1].'"' \ . ' start="'.u[0].'" end="'.u[1].'"'
\ . ' contains=@texMathZoneGroup' \ . ' contains=@texMathZoneGroup'

View File

@ -1,74 +0,0 @@
" vim:tabstop=2:shiftwidth=2:expandtab:textwidth=99
" Vimwiki syntax file
" Description: Defines default syntax
" Home: https://github.com/vimwiki/vimwiki/
" s:default_syntax is kind of a reference to the dict in
" g:vimwiki_syntax_variables['default']. It is used here simply as an
" abbreviation for the latter.
let s:default_syntax = g:vimwiki_syntax_variables['default']
" TODO mutualise
" Get config: possibly concealed chars
let b:vimwiki_syntax_conceal = exists('+conceallevel') ? ' conceal' : ''
let b:vimwiki_syntax_concealends = has('conceal') ? ' concealends' : ''
" text: *strong*
let s:default_syntax.dTypeface.bold = vimwiki#u#hi_expand_regex([
\ ['\*', '\*']])
" text: _italic_
let s:default_syntax.dTypeface.italic = vimwiki#u#hi_expand_regex([
\ ['_', '_']])
" text: no underline defined
let s:default_syntax.dTypeface.underline = []
" text: *_bold italic_* or _*italic bold*_
let s:default_syntax.dTypeface.bold_italic = vimwiki#u#hi_expand_regex([
\ ['\*_', '_\*'], ['_\*', '\*_']])
" generic headers
let s:default_syntax.rxH = '='
let s:default_syntax.symH = 1
" <hr>, horizontal rule
let s:default_syntax.rxHR = '^-----*$'
" Tables. Each line starts and ends with '|'; each cell is separated by '|'
let s:default_syntax.rxTableSep = '|'
" Lists
let s:default_syntax.bullet_types = ['-', '*', '#']
" 1 means the bullets can be repeatet to indicate the level, like * ** ***
" 0 means the bullets stand on their own and the level is indicated by the indentation
let s:default_syntax.recurring_bullets = 0
let s:default_syntax.number_types = ['1)', '1.', 'i)', 'I)', 'a)', 'A)']
"this should contain at least one element
"it is used for i_<C-L><C-J> among other things
let s:default_syntax.list_markers = ['-', '1.', '*', 'I)', 'a)']
let s:default_syntax.rxListDefine = '::\(\s\|$\)'
" Preformatted text
let s:default_syntax.rxPreStart = '{{{'
let s:default_syntax.rxPreEnd = '}}}'
" Math block
let s:default_syntax.rxMathStart = '{{\$'
let s:default_syntax.rxMathEnd = '}}\$'
let s:default_syntax.rxMultilineCommentStart = '%%+'
let s:default_syntax.rxMultilineCommentEnd = '+%%'
let s:default_syntax.rxComment = '^\s*%%.*$'
let s:default_syntax.header_search = '^\s*\(=\{1,6}\)\([^=].*[^=]\)\1\s*$'
let s:default_syntax.header_match = '^\s*\(=\{1,6}\)=\@!\s*__Header__\s*\1=\@!\s*$'
let s:default_syntax.bold_search = '\%(^\|\s\|[[:punct:]]\)\@<=\*\zs\%([^*`[:space:]][^*`]*'.
\ '[^*`[:space:]]\|[^*`[:space:]]\)\ze\*\%([[:punct:]]\|\s\|$\)\@='
let s:default_syntax.bold_match = '\%(^\|\s\|[[:punct:]]\)\@<=\*__Text__\*'.
\ '\%([[:punct:]]\|\s\|$\)\@='
let s:default_syntax.wikilink = '\[\[\zs[^\\\]|]\+\ze\%(|[^\\\]]\+\)\?\]\]'

View File

@ -1,39 +0,0 @@
" vim:tabstop=2:shiftwidth=2:expandtab:textwidth=99
" Vimwiki syntax file
" Home: https://github.com/vimwiki/vimwiki/
" Description: Defines html syntax
" Loaded: conditionaly by syntax/vimwiki.vim
" Copied from $VIMRUNTIME
" Note: The me=s-1 was omited from the region definition
" See: `syn region VimwikiBoldUnderlineItalic contained start="<i\>" end="</i\_s*>"me=s-1 contains=VimwikiHTMLTag...`
" Note: Not configurable
let s:html_tags = join(split(vimwiki#vars#get_global('valid_html_tags'), '\s*,\s*'), '\|')
exe 'syntax match VimwikiHTMLtag #\c</\?\%('.s:html_tags.'\)\%(\s\{-1}\S\{-}\)\{-}\s*/\?>#'
" Typeface:
let html_typeface = {
\ 'bold': [['<b>', '</b\_s*>'], ['<strong>', '</strong\_s*>']],
\ 'italic': [['<i>', '</i\_s*>'], ['<em>', '</em\_s*>']],
\ 'underline': [['<u>', '</u\_s*>']],
\ 'code': [['<code>', '</code\_s*>']],
\ 'del': [['<del>', '</del\_s*>']],
\ 'eq': [],
\ 'sup': [['<sup>', '</sup\_s*>']],
\ 'sub': [['<sub>', '</sub\_s*>']],
\ }
call vimwiki#u#hi_typeface(html_typeface)
" Comment: home made
execute 'syntax match VimwikiComment /'.vimwiki#vars#get_syntaxlocal('rxComment').
\ '/ contains=@Spell,VimwikiTodo'
" Only do syntax highlighting for multiline comments if they exist
let s:mc_start = vimwiki#vars#get_syntaxlocal('rxMultilineCommentStart')
let s:mc_end = vimwiki#vars#get_syntaxlocal('rxMultilineCommentEnd')
if !empty(s:mc_start) && !empty(s:mc_end)
execute 'syntax region VimwikiMultilineComment start=/'.s:mc_start.
\ '/ end=/'.s:mc_end.'/ contains=@NoSpell,VimwikiTodo'
endif

View File

@ -1,88 +0,0 @@
" vim:tabstop=2:shiftwidth=2:expandtab:textwidth=99
" Vimwiki syntax file
" Home: https://github.com/vimwiki/vimwiki/
" Description: Defines markdown syntax
" Called: vars.vim => Many other (common) variables are defined there
" More in u.vim, base.vim (nested_syntax for multiline code)
let s:markdown_syntax = g:vimwiki_syntax_variables['markdown']
" TODO mutualise
" Get config: possibly concealed chars
let b:vimwiki_syntax_conceal = exists('+conceallevel') ? ' conceal' : ''
let b:vimwiki_syntax_concealends = has('conceal') ? ' concealends' : ''
" text: **bold** or __bold__
let s:markdown_syntax.dTypeface.bold = vimwiki#u#hi_expand_regex([
\ ['__', '__'], ['\*\*', '\*\*']])
" text: *italic* or _italic_
let s:markdown_syntax.dTypeface.italic = vimwiki#u#hi_expand_regex([
\ ['\*', '\*'], ['_', '_']])
" text: no underline defined
let s:markdown_syntax.dTypeface.underline = []
" text: *_bold italic_* or _*italic bold*_ or ___bi___ or ***bi***
let s:markdown_syntax.dTypeface.bold_italic = vimwiki#u#hi_expand_regex([
\ ['\*_', '_\*'], ['_\*', '\*_'], ['\*\*\*', '\*\*\*'], ['___', '___']])
" generic headers
let s:markdown_syntax.rxH = '#'
let s:markdown_syntax.symH = 0
" <hr>, horizontal rule
let s:markdown_syntax.rxHR = '\(^---*$\|^___*$\|^\*\*\**$\)'
" Tables. Each line starts and ends with '|'; each cell is separated by '|'
let s:markdown_syntax.rxTableSep = '|'
" Lists
let s:markdown_syntax.recurring_bullets = 0
let s:markdown_syntax.number_types = ['1.']
let s:markdown_syntax.list_markers = ['-', '*', '+', '1.']
let s:markdown_syntax.rxListDefine = '::\%(\s\|$\)'
let s:markdown_syntax.bullet_types = ['*', '-', '+']
" Preformatted text (code blocks)
let s:markdown_syntax.rxPreStart = '\%(`\{3,}\|\~\{3,}\)'
let s:markdown_syntax.rxPreEnd = '\%(`\{3,}\|\~\{3,}\)'
" TODO see syntax/vimwiki_markdown_custom.vim for more info
" let s:markdown_syntax.rxIndentedCodeBlock = '\%(^\n\)\@1<=\%(\%(\s\{4,}\|\t\+\).*\n\)\+'
" Math block
let s:markdown_syntax.rxMathStart = '\$\$'
let s:markdown_syntax.rxMathEnd = '\$\$'
" NOTE: There is no multi-line comment syntax for Markdown
let s:markdown_syntax.rxMultilineCommentStart = ''
let s:markdown_syntax.rxMultilineCommentEnd = ''
let s:markdown_syntax.rxComment = '^\s*%%.*$\|<!--[^>]*-->'
" Used in code (base.vim)
"""""""""""""""""""""""""
" Header
" TODO mutualise with rxHeader in vars.vim := Define atx_regex only onces
" TODO regex_or function => (1|2)
let atx_header_search = '^\s*\(#\{1,6}\)\([^#].*\)$'
let atx_header_match = '^\s*\(#\{1,6}\)#\@!\s*__Header__\s*$'
let setex_header_search = '^\s\{0,3}\zs[^>].*\ze\n'
let setex_header_search .= '^\s\{0,3}[=-]\{2,}$'
let setex_header_match = '^\s\{0,3}>\@!__Header__\n'
let setex_header_match .= '^\s\{0,3}[=-][=-]\+$'
let s:markdown_syntax.header_search = '\%(' . atx_header_search . '\|' . setex_header_search . '\)'
let s:markdown_syntax.header_match = '\%(' . atx_header_match . '\|' . setex_header_match . '\)'
let s:markdown_syntax.bold_search = '\%(^\|\s\|[[:punct:]]\)\@<=\*\zs'.
\ '\%([^*`[:space:]][^*`]*[^*`[:space:]]\|[^*`[:space:]]\)\ze\*\%([[:punct:]]\|\s\|$\)\@='
let s:markdown_syntax.bold_match = '\%(^\|\s\|[[:punct:]]\)\@<=\*__Text__\*'.
\ '\%([[:punct:]]\|\s\|$\)\@='
let s:markdown_syntax.wikilink = '\[\[\zs[^\\\]|]\+\ze\%(|[^\\\]]\+\)\?\]\]'

View File

@ -1,68 +0,0 @@
" vim:tabstop=2:shiftwidth=2:expandtab:textwidth=99
" Vimwiki syntax file
" Description: Defines mediaWiki syntax
" Home: https://github.com/vimwiki/vimwiki/
" see the comments in vimwiki_default.vim for some info about this file
let s:media_syntax = g:vimwiki_syntax_variables['media']
" text: '''strong'''
let s:media_syntax.dTypeface['bold'] = [
\ ['\S\@<=''''''\|''''''\S\@=', '\S\@<=''''''\|''''''\S\@='],
\ ]
" text: ''italic''
let s:media_syntax.dTypeface['italic'] = [
\ ['\S\@<=''''\|''''\S\@=', '\S\@<=''''\|''''\S\@='],
\ ]
" text: no underline defined
let s:media_syntax.dTypeface['underline'] = []
" text: '''''strong italic'''''
let s:media_syntax.dTypeface['bold_italic'] = [
\ ['\S\@<=''''''''''\|''''''''''\S\@=', '\S\@<=''''''''''\|''''''''''\S\@='],
\ ]
" generic headers
let s:media_syntax.rxH = '='
let s:media_syntax.symH = 1
" <hr>, horizontal rule
let s:media_syntax.rxHR = '^-----*$'
" Tables. Each line starts and ends with '|'; each cell is separated by '|'
let s:media_syntax.rxTableSep = '|'
" Lists
let s:media_syntax.bullet_types = ['*', '#']
let s:media_syntax.recurring_bullets = 1
let s:media_syntax.number_types = []
let s:media_syntax.list_markers = ['*', '#']
let s:media_syntax.rxListDefine = '^\%(;\|:\)\s'
" Preformatted text
let s:media_syntax.rxPreStart = '<pre>'
let s:media_syntax.rxPreEnd = '<\/pre>'
" Math block
let s:media_syntax.rxMathStart = '{{\$'
let s:media_syntax.rxMathEnd = '}}\$'
" NOTE: There is no multi-line comment syntax for MediaWiki
let s:media_syntax.rxMultilineCommentStart = ''
let s:media_syntax.rxMultilineCommentEnd = ''
let s:media_syntax.rxComment = '^\s*%%.*$'
let s:media_syntax.header_search = '^\s*\(=\{1,6}\)\([^=].*[^=]\)\1\s*$'
let s:media_syntax.header_match = '^\s*\(=\{1,6}\)=\@!\s*__Header__\s*\1=\@!\s*$'
let s:media_syntax.bold_search = "'''\\zs[^']\\+\\ze'''"
let s:media_syntax.bold_match = '''''''__Text__'''''''
" ^- this strange looking thing is equivalent to "'''__Text__'''" but since we later
" want to call escape() on this string, we must keep it in single quotes
let s:media_syntax.wikilink = '\[\[\zs[^\\\]|]\+\ze\%(|[^\\\]]\+\)\?\]\]'

View File

@ -39,7 +39,7 @@ Execute (Configure: Set vimwiki list to markdown resource):
\ 'g:loaded_vimwiki', \ 'g:loaded_vimwiki',
\ 'g:vimwiki_global_vars', \ 'g:vimwiki_global_vars',
\ 'g:vimwiki_wikilocal_vars', \ 'g:vimwiki_wikilocal_vars',
\ 'g:vimwiki_syntax_variables', \ 'g:vimwiki_syntaxlocal_vars',
\ ] \ ]
if exists(i) if exists(i)
exe 'unlet ' . i exe 'unlet ' . i
@ -467,8 +467,8 @@ Execute (file .md):
set sw=2 set sw=2
file toto.md file toto.md
edit! edit!
let g:vimwiki_syntax_variables['markdown']['cycle_bullets'] = 1 let g:vimwiki_syntaxlocal_vars['markdown']['cycle_bullets'] = 1
let g:vimwiki_syntax_variables['markdown']['bullet_types'] = ['*', '-', '+'] let g:vimwiki_syntaxlocal_vars['markdown']['bullet_types'] = ['*', '-', '+']
AssertEqual 'vimwiki', &ft AssertEqual 'vimwiki', &ft
Do (gLl): Do (gLl):
@ -518,9 +518,9 @@ Execute (file toto.md):
file toto.md file toto.md
edit! edit!
Log "Cycle bullets" Log "Cycle bullets"
let g:vimwiki_syntax_variables['bullet_types'] = ['*', '-'] let g:vimwiki_syntaxlocal_vars['bullet_types'] = ['*', '-']
let g:vimwiki_syntax_variables['markdown']['cycle_bullets'] = 1 let g:vimwiki_syntaxlocal_vars['markdown']['cycle_bullets'] = 1
AssertEqual g:vimwiki_syntax_variables['markdown']['cycle_bullets'], 1 AssertEqual g:vimwiki_syntaxlocal_vars['markdown']['cycle_bullets'], 1
AssertEqual 'vimwiki', &ft AssertEqual 'vimwiki', &ft
set sw=2 set sw=2
set expandtab " Otherwise, getting some tab before some items, when enought space set expandtab " Otherwise, getting some tab before some items, when enought space

View File

@ -18,8 +18,8 @@ Given vimwiki (abc def ghi jkl):
Execute (Set filename wiki_test.md): Execute (Set filename wiki_test.md):
call SetSyntax('markdown') call SetSyntax('markdown')
let save_link = g:vimwiki_syntax_variables.markdown.Link1 let save_link = g:vimwiki_syntaxlocal_vars.markdown.Link1
let g:vimwiki_syntax_variables.markdown.Link1 = vimwiki#vars#get_global('WikiLinkTemplate1') let g:vimwiki_syntaxlocal_vars.markdown.Link1 = vimwiki#vars#get_global('WikiLinkTemplate1')
Do (vee<CR>): Do (vee<CR>):
vee\<CR> vee\<CR>
@ -28,7 +28,7 @@ Expect (append md suffix):
[[abc def]] ghi jkl [[abc def]] ghi jkl
Execute (restore): Execute (restore):
let g:vimwiki_syntax_variables.markdown.Link1 = save_link let g:vimwiki_syntaxlocal_vars.markdown.Link1 = save_link
# vimwiki_markdown_link_ext {{{1 # vimwiki_markdown_link_ext {{{1

View File

@ -88,7 +88,7 @@ Given vimwiki (task list with code):
Execute (let g:vimwiki_hl_cb_checked = 1): Execute (let g:vimwiki_hl_cb_checked = 1):
let g:vimwiki_hl_cb_checked = 1 let g:vimwiki_hl_cb_checked = 1
unlet g:vimwiki_syntax_variables unlet g:vimwiki_syntaxlocal_vars
call vimwiki#vars#init() call vimwiki#vars#init()
call SetSyntax('markdown') call SetSyntax('markdown')
@ -106,7 +106,7 @@ Given vimwiki (task list with code):
Execute (let g:vimwiki_hl_cb_checked = 2): Execute (let g:vimwiki_hl_cb_checked = 2):
let g:vimwiki_hl_cb_checked = 2 let g:vimwiki_hl_cb_checked = 2
unlet g:vimwiki_syntax_variables unlet g:vimwiki_syntaxlocal_vars
call vimwiki#vars#init() call vimwiki#vars#init()
call SetSyntax('markdown') call SetSyntax('markdown')

View File

@ -13,7 +13,7 @@ Execute (Setup):
###################################################################### ######################################################################
Execute (Change delimiter <tag1|tag2> {{{1): Execute (Change delimiter <tag1|tag2> {{{1):
let g:vimwiki_tag_format = {'pre_mark': '<', 'post_mark': '>', 'sep': '|'} let g:vimwiki_tag_format = {'pre_mark': '<', 'post_mark': '>', 'sep': '|'}
unlet g:vimwiki_syntax_variables unlet g:vimwiki_syntaxlocal_vars
call vimwiki#vars#init() call vimwiki#vars#init()
edit $HOME/testmarkdown/Test-Tag.md edit $HOME/testmarkdown/Test-Tag.md
AssertEqual $HOME . '/testmarkdown/Test-Tag.md', expand('%') AssertEqual $HOME . '/testmarkdown/Test-Tag.md', expand('%')
@ -89,7 +89,7 @@ Expect (Good jump {{{3):
Execute (Clean Test-Tag and .vimwiki_tags -2): Execute (Clean Test-Tag and .vimwiki_tags -2):
let g:vimwiki_tag_format = {} let g:vimwiki_tag_format = {}
unlet g:vimwiki_syntax_variables unlet g:vimwiki_syntaxlocal_vars
call vimwiki#vars#init() call vimwiki#vars#init()
call system("rm $HOME/testmarkdown/Test.md") call system("rm $HOME/testmarkdown/Test.md")
call system("rm $HOME/testmarkdown/.vimwiki_tags") call system("rm $HOME/testmarkdown/.vimwiki_tags")

View File

@ -140,7 +140,7 @@
\ 'g:loaded_vimwiki', \ 'g:loaded_vimwiki',
\ 'g:vimwiki_global_vars', \ 'g:vimwiki_global_vars',
\ 'g:vimwiki_wikilocal_vars', \ 'g:vimwiki_wikilocal_vars',
\ 'g:vimwiki_syntax_variables', \ 'g:vimwiki_syntaxlocal_vars',
\ 'g:vimwiki_list', \ 'g:vimwiki_list',
\ ] \ ]
if exists(i) if exists(i)
@ -172,7 +172,7 @@
function! ReloadVars() function! ReloadVars()
" vars#init will not reload syntax varaible if not set " vars#init will not reload syntax varaible if not set
unlet g:vimwiki_syntax_variables unlet g:vimwiki_syntaxlocal_vars
call vimwiki#vars#init() call vimwiki#vars#init()
endfunction endfunction