diff --git a/autoload/vimwiki/base.vim b/autoload/vimwiki/base.vim index 6d4ead6..14592cf 100644 --- a/autoload/vimwiki/base.vim +++ b/autoload/vimwiki/base.vim @@ -24,43 +24,6 @@ function! s:vimwiki_get_known_syntaxes() " {{{ return keys(syntaxes) endfunction " }}} -" vimwiki#base#setup_buffer_state -function! vimwiki#base#setup_buffer_state(idx) " {{{ Init page-specific variables - " Only call this function *after* opening a wiki page. - if a:idx < 0 - return - endif - - let g:vimwiki_current_idx = a:idx - - " The following state depends on the current active wiki page - let subdir = vimwiki#base#current_subdir(a:idx) - call VimwikiSet('subdir', subdir, a:idx) - call VimwikiSet('invsubdir', vimwiki#base#invsubdir(subdir), a:idx) - - if vimwiki#vars#get_global('auto_chdir') == 1 - exe 'lcd' vimwiki#vars#get_wikilocal('path') - endif - - " update cache - call vimwiki#base#cache_buffer_state() -endfunction " }}} - -" vimwiki#base#cache_buffer_state -function! vimwiki#base#cache_buffer_state() "{{{ - let b:vimwiki_idx = g:vimwiki_current_idx -endfunction "}}} - -" vimwiki#base#recall_buffer_state -function! vimwiki#base#recall_buffer_state() "{{{ - if !exists('b:vimwiki_idx') - return 0 - else - let g:vimwiki_current_idx = b:vimwiki_idx - return 1 - endif -endfunction " }}} - " vimwiki#base#file_pattern function! vimwiki#base#file_pattern(files) "{{{ Get search regex from glob() " string. Aim to support *all* special characters, forcing the user to choose @@ -97,8 +60,8 @@ function! vimwiki#base#subdir(path, filename) "{{{ endfunction "}}} " vimwiki#base#current_subdir -function! vimwiki#base#current_subdir(idx)"{{{ - return vimwiki#base#subdir(vimwiki#vars#get_wikilocal('path', a:idx), expand('%:p')) +function! vimwiki#base#current_subdir()"{{{ + return vimwiki#base#subdir(vimwiki#vars#get_wikilocal('path'), expand('%:p')) endfunction"}}} " vimwiki#base#invsubdir @@ -1229,7 +1192,7 @@ endfunction "}}} " vimwiki#base#rename_link " Rename current file, update all links to it function! vimwiki#base#rename_link() "{{{ - let subdir = VimwikiGet('subdir') + let subdir = vimwiki#vars#get_bufferlocal('subdir') let old_fname = subdir.expand('%:t') " there is no file (new one maybe) diff --git a/autoload/vimwiki/diary.vim b/autoload/vimwiki/diary.vim index 682668f..3f662ed 100644 --- a/autoload/vimwiki/diary.vim +++ b/autoload/vimwiki/diary.vim @@ -21,12 +21,12 @@ function! s:prefix_zero(num) "{{{ endfunction "}}} function! s:diary_path(...) "{{{ - let idx = a:0 == 0 ? g:vimwiki_current_idx : a:1 + let idx = a:0 == 0 ? vimwiki#vars#get_bufferlocal('wiki_nr') : a:1 return vimwiki#vars#get_wikilocal('path', idx).vimwiki#vars#get_wikilocal('diary_rel_path', idx) endfunction "}}} function! s:diary_index(...) "{{{ - let idx = a:0 == 0 ? g:vimwiki_current_idx : a:1 + let idx = a:0 == 0 ? vimwiki#vars#get_bufferlocal('wiki_nr') : a:1 return s:diary_path(idx).vimwiki#vars#get_wikilocal('diary_index', idx).vimwiki#vars#get_wikilocal('ext', idx) endfunction "}}} @@ -62,14 +62,15 @@ endfun "}}} " Diary index stuff {{{ fun! s:read_captions(files) "{{{ let result = {} + let rx_header = vimwiki#vars#get_syntaxlocal('rxHeader') for fl in a:files " remove paths and extensions let fl_key = fnamemodify(fl, ':t:r') if filereadable(fl) for line in readfile(fl, '', s:vimwiki_max_scan_for_caption) - if line =~# g:vimwiki_rxHeader && !has_key(result, fl_key) - let result[fl_key] = vimwiki#u#trim(matchstr(line, g:vimwiki_rxHeader)) + if line =~# rx_header && !has_key(result, fl_key) + let result[fl_key] = vimwiki#u#trim(matchstr(line, rx_header)) endif endfor endif @@ -132,19 +133,19 @@ function! s:format_diary() "{{{ for year in s:sort(keys(g_files)) call add(result, '') - call add(result, substitute(g:vimwiki_rxH2_Template, '__Header__', year , '')) + call add(result, substitute(vimwiki#vars#get_syntaxlocal('rxH2_Template'), '__Header__', year , '')) for month in s:sort(keys(g_files[year])) call add(result, '') - call add(result, substitute(g:vimwiki_rxH3_Template, '__Header__', s:get_month_name(month), '')) + call add(result, substitute(vimwiki#vars#get_syntaxlocal('rxH3_Template'), '__Header__', s:get_month_name(month), '')) for [fl, cap] in s:sort(items(g_files[year][month])) if empty(cap) - let entry = substitute(g:vimwiki_WikiLinkTemplate1, '__LinkUrl__', fl, '') + let entry = substitute(vimwiki#vars#get_global('WikiLinkTemplate1'), '__LinkUrl__', fl, '') let entry = substitute(entry, '__LinkDescription__', cap, '') call add(result, repeat(' ', &sw).'* '.entry) else - let entry = substitute(g:vimwiki_WikiLinkTemplate2, '__LinkUrl__', fl, '') + let entry = substitute(vimwiki#vars#get_global('WikiLinkTemplate2'), '__LinkUrl__', fl, '') let entry = substitute(entry, '__LinkDescription__', cap, '') call add(result, repeat(' ', &sw).'* '.entry) endif @@ -185,7 +186,6 @@ function! vimwiki#diary#make_note(wnum, ...) "{{{ endif call vimwiki#base#open_link(cmd, link, s:diary_index(idx)) - call vimwiki#base#setup_buffer_state(idx) endfunction "}}} function! vimwiki#diary#goto_diary_index(wnum) "{{{ @@ -202,7 +202,6 @@ function! vimwiki#diary#goto_diary_index(wnum) "{{{ endif call vimwiki#base#edit_file('e', s:diary_index(idx), '') - call vimwiki#base#setup_buffer_state(idx) endfunction "}}} function! vimwiki#diary#goto_next_day() "{{{ @@ -249,7 +248,7 @@ function! vimwiki#diary#generate_diary_section() "{{{ let current_file = vimwiki#path#path_norm(expand("%:p")) let diary_file = vimwiki#path#path_norm(s:diary_index()) if vimwiki#path#is_equal(current_file, diary_file) - let content_rx = '^\%(\s*\* \)\|\%(^\s*$\)\|\%('.g:vimwiki_rxHeader.'\)' + let content_rx = '^\%(\s*\* \)\|\%(^\s*$\)\|\%('.vimwiki#vars#get_syntaxlocal('rxHeader').'\)' call vimwiki#base#update_listing_in_buffer(s:format_diary(), \ vimwiki#vars#get_wikilocal('diary_header'), content_rx, line('$')+1, 1) else @@ -278,7 +277,7 @@ function! vimwiki#diary#calendar_action(day, month, year, week, dir) "{{{ endif " XXX: Well, +1 is for inconsistent index basing... - call vimwiki#diary#make_note(g:vimwiki_current_idx+1, 0, link) + call vimwiki#diary#make_note(vimwiki#vars#get_bufferlocal('wiki_nr')+1, 0, link) endfunction "}}} " Sign function. diff --git a/autoload/vimwiki/html.vim b/autoload/vimwiki/html.vim index 17f64f1..671ddc1 100644 --- a/autoload/vimwiki/html.vim +++ b/autoload/vimwiki/html.vim @@ -231,7 +231,7 @@ function! s:is_html_uptodate(wikifile) "{{{ endif let wikifile = fnamemodify(a:wikifile, ":p") - let htmlfile = expand(vimwiki#vars#get_wikilocal('path_html') . VimwikiGet('subdir') . + let htmlfile = expand(vimwiki#vars#get_wikilocal('path_html') . vimwiki#vars#get_bufferlocal('subdir') . \fnamemodify(wikifile, ":t:r").".html") if getftime(wikifile) <= getftime(htmlfile) && tpl_time <= getftime(htmlfile) @@ -345,12 +345,12 @@ endfunction "}}} " match n-th ARG within {{URL[|ARG1|ARG2|...]}} " {{{ " *c,d,e),... function! vimwiki#html#incl_match_arg(nn_index) - let rx = g:vimwiki_rxWikiInclPrefix. g:vimwiki_rxWikiInclUrl - let rx = rx. repeat(g:vimwiki_rxWikiInclSeparator. g:vimwiki_rxWikiInclArg, a:nn_index-1) + let rx = vimwiki#vars#get_global('rxWikiInclPrefix'). vimwiki#vars#get_global('rxWikiInclUrl') + let rx = rx. repeat(vimwiki#vars#get_global('rxWikiInclSeparator'). vimwiki#vars#get_global('rxWikiInclArg'), a:nn_index-1) if a:nn_index > 0 - let rx = rx. g:vimwiki_rxWikiInclSeparator. '\zs'. g:vimwiki_rxWikiInclArg. '\ze' + let rx = rx. vimwiki#vars#get_global('rxWikiInclSeparator'). '\zs'. vimwiki#vars#get_global('rxWikiInclArg'). '\ze' endif - let rx = rx. g:vimwiki_rxWikiInclArgs. g:vimwiki_rxWikiInclSuffix + let rx = rx. vimwiki#vars#get_global('rxWikiInclArgs'). vimwiki#vars#get_global('rxWikiInclSuffix') return rx endfunction "}}} @@ -359,7 +359,7 @@ function! vimwiki#html#linkify_link(src, descr) "{{{ let src_str = ' href="'.s:safe_html_anchor(a:src).'"' let descr = substitute(a:descr,'^\s*\(.*\)\s*$','\1','') let descr = (descr == "" ? a:src : descr) - let descr_str = (descr =~# g:vimwiki_rxWikiIncl + let descr_str = (descr =~# vimwiki#vars#get_global('rxWikiIncl') \ ? s:tag_wikiincl(descr) \ : descr) return ''.descr_str.'' @@ -375,8 +375,8 @@ endfunction "}}} function! s:tag_weblink(value) "{{{ " Weblink Template -> descr let str = a:value - let url = matchstr(str, g:vimwiki_rxWeblinkMatchUrl) - let descr = matchstr(str, g:vimwiki_rxWeblinkMatchDescr) + let url = matchstr(str, vimwiki#vars#get_global('rxWeblinkMatchUrl')) + let descr = matchstr(str, vimwiki#vars#get_global('rxWeblinkMatchDescr')) let line = vimwiki#html#linkify_link(url, descr) return line endfunction "}}} @@ -391,7 +391,7 @@ function! s:tag_wikiincl(value) "{{{ let line = VimwikiWikiIncludeHandler(str) " otherwise, assume image transclusion if line == '' - let url_0 = matchstr(str, g:vimwiki_rxWikiInclMatchUrl) + let url_0 = matchstr(str, vimwiki#vars#get_global('rxWikiInclMatchUrl')) let descr = matchstr(str, vimwiki#html#incl_match_arg(1)) let verbatim_str = matchstr(str, vimwiki#html#incl_match_arg(2)) @@ -424,8 +424,8 @@ function! s:tag_wikilink(value) "{{{ " [[url#a1#a2]] -> url#a1#a2 " [[#a1#a2]] -> #a1#a2 let str = a:value - let url = matchstr(str, g:vimwiki_rxWikiLinkMatchUrl) - let descr = matchstr(str, g:vimwiki_rxWikiLinkMatchDescr) + let url = matchstr(str, vimwiki#vars#get_global('rxWikiLinkMatchUrl')) + let descr = matchstr(str, vimwiki#vars#get_global('rxWikiLinkMatchDescr')) let descr = (substitute(descr,'^\s*\(.*\)\s*$','\1','') != '' ? descr : url) let line = VimwikiLinkConverter(url, s:current_wiki_file, @@ -514,16 +514,16 @@ function! s:make_tag(line, regexp, func, ...) "{{{ " Exclude preformatted text and href links. " FIXME let patt_splitter = '\(`[^`]\+`\)\|'. - \ '\('.g:vimwiki_rxPreStart.'.\+'.g:vimwiki_rxPreEnd.'\)\|'. + \ '\('.vimwiki#vars#get_syntaxlocal('rxPreStart').'.\+'.vimwiki#vars#get_syntaxlocal('rxPreEnd').'\)\|'. \ '\(\)\|'. \ '\(\)\|'. \ '\(\)\|'. - \ '\('.g:vimwiki_rxEqIn.'\)' + \ '\('.vimwiki#vars#get_syntaxlocal('rxEqIn').'\)' "FIXME FIXME !!! these can easily occur on the same line! "XXX {{{ }}} ??? obsolete if '`[^`]\+`' ==# a:regexp || '{{{.\+}}}' ==# a:regexp || - \ g:vimwiki_rxEqIn ==# a:regexp + \ vimwiki#vars#get_syntaxlocal('rxEqIn') ==# a:regexp let res_line = s:subst_func(a:line, a:regexp, a:func) else let pos = 0 @@ -557,23 +557,23 @@ endfunction " }}} function! s:process_tags_typefaces(line, header_ids) "{{{ let line = a:line - let line = s:make_tag(line, g:vimwiki_rxItalic, 's:tag_em') - let line = s:make_tag(line, g:vimwiki_rxBold, 's:tag_strong', a:header_ids) - let line = s:make_tag(line, g:vimwiki_rxTodo, 's:tag_todo') - let line = s:make_tag(line, g:vimwiki_rxDelText, 's:tag_strike') - let line = s:make_tag(line, g:vimwiki_rxSuperScript, 's:tag_super') - let line = s:make_tag(line, g:vimwiki_rxSubScript, 's:tag_sub') - let line = s:make_tag(line, g:vimwiki_rxCode, 's:tag_code') - let line = s:make_tag(line, g:vimwiki_rxEqIn, 's:tag_eqin') - let line = s:make_tag(line, g:vimwiki_rxTags, 's:tag_tags', a:header_ids) + let line = s:make_tag(line, vimwiki#vars#get_syntaxlocal('rxItalic'), 's:tag_em') + let line = s:make_tag(line, vimwiki#vars#get_syntaxlocal('rxBold'), 's:tag_strong', a:header_ids) + let line = s:make_tag(line, vimwiki#vars#get_syntaxlocal('rxTodo'), 's:tag_todo') + let line = s:make_tag(line, vimwiki#vars#get_syntaxlocal('rxDelText'), 's:tag_strike') + let line = s:make_tag(line, vimwiki#vars#get_syntaxlocal('rxSuperScript'), 's:tag_super') + let line = s:make_tag(line, vimwiki#vars#get_syntaxlocal('rxSubScript'), 's:tag_sub') + let line = s:make_tag(line, vimwiki#vars#get_syntaxlocal('rxCode'), 's:tag_code') + let line = s:make_tag(line, vimwiki#vars#get_syntaxlocal('rxEqIn'), 's:tag_eqin') + let line = s:make_tag(line, vimwiki#vars#get_syntaxlocal('rxTags'), 's:tag_tags', a:header_ids) return line endfunction " }}} function! s:process_tags_links(line) " {{{ let line = a:line - let line = s:make_tag(line, g:vimwiki_rxWikiLink, 's:tag_wikilink') - let line = s:make_tag(line, g:vimwiki_rxWikiIncl, 's:tag_wikiincl') - let line = s:make_tag(line, g:vimwiki_rxWeblink, 's:tag_weblink') + let line = s:make_tag(line, vimwiki#vars#get_global('rxWikiLink'), 's:tag_wikilink') + let line = s:make_tag(line, vimwiki#vars#get_global('rxWikiIncl'), 's:tag_wikiincl') + let line = s:make_tag(line, vimwiki#vars#get_global('rxWeblink'), 's:tag_weblink') return line endfunction " }}} @@ -859,7 +859,7 @@ function! s:process_tag_list(line, lists) "{{{ let st_tag = '
  • ' let chk = matchlist(a:line, a:rx_list) if !empty(chk) && len(chk[1]) > 0 - let completion = index(g:vimwiki_listsyms_list, chk[1]) + let completion = index(vimwiki#vars#get_syntaxlocal('listsyms_list'), chk[1]) if completion >= 0 && completion <=4 let st_tag = '
  • ' endif @@ -873,7 +873,7 @@ function! s:process_tag_list(line, lists) "{{{ " text. " XXX necessary? in *bold* text, no space must follow the first * if !in_list - let pos = match(a:line, '^\s*'.g:vimwiki_rxBold) + let pos = match(a:line, '^\s*'.vimwiki#vars#get_syntaxlocal('rxBold')) if pos != -1 return [0, []] endif @@ -994,12 +994,12 @@ function! s:process_tag_h(line, id) "{{{ let h_text = '' let h_id = '' - if a:line =~# g:vimwiki_rxHeader + if a:line =~# vimwiki#vars#get_syntaxlocal('rxHeader') let h_level = vimwiki#u#count_first_sym(a:line) endif if h_level > 0 - let h_text = vimwiki#u#trim(matchstr(line, g:vimwiki_rxHeader)) + let h_text = vimwiki#u#trim(matchstr(line, vimwiki#vars#get_syntaxlocal('rxHeader'))) let h_number = '' let h_complete_id = '' let h_id = s:safe_html_anchor(h_text) @@ -1175,7 +1175,7 @@ function! s:parse_line(line, state) " {{{ "}}} if !processed - if line =~# g:vimwiki_rxComment + if line =~# vimwiki#vars#get_syntaxlocal('rxComment') let processed = 1 endif endif @@ -1364,7 +1364,7 @@ function! vimwiki#html#CustomWiki2HTML(path, wikifile, force) "{{{ \ (len(vimwiki#vars#get_wikilocal('template_path')) > 1 ? shellescape(expand(vimwiki#vars#get_wikilocal('template_path'))) : '-'). ' '. \ (len(vimwiki#vars#get_wikilocal('template_default')) > 0 ? vimwiki#vars#get_wikilocal('template_default') : '-'). ' '. \ (len(vimwiki#vars#get_wikilocal('template_ext')) > 0 ? vimwiki#vars#get_wikilocal('template_ext') : '-'). ' '. - \ (len(VimwikiGet('subdir')) > 0 ? shellescape(s:root_path(VimwikiGet('subdir'))) : '-')) + \ (len(vimwiki#vars#get_bufferlocal('subdir')) > 0 ? shellescape(s:root_path(vimwiki#vars#get_bufferlocal('subdir'))) : '-')) endfunction " }}} function! s:convert_file(path_html, wikifile) "{{{ @@ -1372,7 +1372,7 @@ function! s:convert_file(path_html, wikifile) "{{{ let wikifile = fnamemodify(a:wikifile, ":p") - let path_html = expand(a:path_html).VimwikiGet('subdir') + let path_html = expand(a:path_html).vimwiki#vars#get_bufferlocal('subdir') let htmlfile = fnamemodify(wikifile, ":t:r").'.html' " the currently processed file name is needed when processing links @@ -1481,7 +1481,7 @@ function! s:convert_file(path_html, wikifile) "{{{ " processing template variables (refactor to a function) call map(html_lines, 'substitute(v:val, "%title%", "'. title .'", "g")') call map(html_lines, 'substitute(v:val, "%root_path%", "'. - \ s:root_path(VimwikiGet('subdir')) .'", "g")') + \ s:root_path(vimwiki#vars#get_bufferlocal('subdir')) .'", "g")') let css_name = expand(vimwiki#vars#get_wikilocal('css_name')) let css_name = substitute(css_name, '\', '/', 'g') @@ -1541,8 +1541,8 @@ function! vimwiki#html#WikiAll2HTML(path_html) "{{{ setlocal nomore " temporarily adjust current_subdir global state variable - let current_subdir = VimwikiGet('subdir') - let current_invsubdir = VimwikiGet('invsubdir') + let current_subdir = vimwiki#vars#get_bufferlocal('subdir') + let current_invsubdir = vimwiki#vars#get_bufferlocal('invsubdir') let wikifiles = split(glob(vimwiki#vars#get_wikilocal('path').'**/*'.vimwiki#vars#get_wikilocal('ext')), '\n') for wikifile in wikifiles @@ -1550,8 +1550,8 @@ function! vimwiki#html#WikiAll2HTML(path_html) "{{{ " temporarily adjust 'subdir' and 'invsubdir' state variables let subdir = vimwiki#base#subdir(vimwiki#vars#get_wikilocal('path'), wikifile) - call VimwikiSet('subdir', subdir) - call VimwikiSet('invsubdir', vimwiki#base#invsubdir(subdir)) + call vimwiki#vars#set_bufferlocal('subdir', subdir) + call vimwiki#vars#set_bufferlocal('invsubdir', vimwiki#base#invsubdir(subdir)) if !s:is_html_uptodate(wikifile) echomsg 'Vimwiki: Processing '.wikifile @@ -1562,8 +1562,8 @@ function! vimwiki#html#WikiAll2HTML(path_html) "{{{ endif endfor " reset 'subdir' state variable - call VimwikiSet('subdir', current_subdir) - call VimwikiSet('invsubdir', current_invsubdir) + call vimwiki#vars#set_bufferlocal('subdir', current_subdir) + call vimwiki#vars#set_bufferlocal('invsubdir', current_invsubdir) let created = s:create_default_CSS(path_html) if created diff --git a/autoload/vimwiki/lst.vim b/autoload/vimwiki/lst.vim index 9f8ab32..fce1596 100644 --- a/autoload/vimwiki/lst.vim +++ b/autoload/vimwiki/lst.vim @@ -109,7 +109,7 @@ else endif "}}} function! vimwiki#lst#default_symbol() "{{{ - return g:vimwiki_list_markers[0] + return vimwiki#vars#get_syntaxlocal('list_markers')[0] endfunction "}}} function! vimwiki#lst#get_list_margin() "{{{ @@ -124,16 +124,16 @@ endfunction "}}} "Returns: the column where the text of a line starts (possible list item "markers and checkboxes are skipped) function! s:text_begin(lnum) "{{{ - return s:string_length(matchstr(getline(a:lnum), g:vimwiki_rxListItem)) + return s:string_length(matchstr(getline(a:lnum), vimwiki#vars#get_syntaxlocal('rxListItem'))) endfunction "}}} "Returns: 2 if there is a marker and text " 1 for a marker and no text " 0 for no marker at all (empty line or only text) function! s:line_has_marker(lnum) "{{{ - if getline(a:lnum) =~# g:vimwiki_rxListItem.'\s*$' + if getline(a:lnum) =~# vimwiki#vars#get_syntaxlocal('rxListItem').'\s*$' return 1 - elseif getline(a:lnum) =~# g:vimwiki_rxListItem.'\s*\S' + elseif getline(a:lnum) =~# vimwiki#vars#get_syntaxlocal('rxListItem').'\s*\S' return 2 else return 0 @@ -157,7 +157,7 @@ function! s:get_item(lnum) "{{{ return item endif - let matches = matchlist(getline(a:lnum), g:vimwiki_rxListItem) + let matches = matchlist(getline(a:lnum), vimwiki#vars#get_syntaxlocal('rxListItem')) if matches == [] || \ (matches[1] == '' && matches[2] == '') || \ (matches[1] != '' && matches[2] != '') @@ -377,10 +377,10 @@ endfunction "}}} "If there is no second argument, 0 is returned at a header, otherwise the "header is skipped function! s:get_next_line(lnum, ...) "{{{ - if getline(a:lnum) =~# g:vimwiki_rxPreStart + if getline(a:lnum) =~# vimwiki#vars#get_syntaxlocal('rxPreStart') let cur_ln = a:lnum + 1 while cur_ln <= line('$') && - \ getline(cur_ln) !~# g:vimwiki_rxPreEnd + \ getline(cur_ln) !~# vimwiki#vars#get_syntaxlocal('rxPreEnd') let cur_ln += 1 endwhile let next_line = cur_ln @@ -388,12 +388,12 @@ function! s:get_next_line(lnum, ...) "{{{ let next_line = nextnonblank(a:lnum+1) endif - if a:0 > 0 && getline(next_line) =~# g:vimwiki_rxHeader + if a:0 > 0 && getline(next_line) =~# vimwiki#vars#get_syntaxlocal('rxHeader') let next_line = s:get_next_line(next_line, 1) endif if next_line < 0 || next_line > line('$') || - \ (getline(next_line) =~# g:vimwiki_rxHeader && a:0 == 0) + \ (getline(next_line) =~# vimwiki#vars#get_syntaxlocal('rxHeader') && a:0 == 0) return 0 endif @@ -405,10 +405,10 @@ endfunction "}}} function! s:get_prev_line(lnum) "{{{ let prev_line = prevnonblank(a:lnum-1) - if getline(prev_line) =~# g:vimwiki_rxPreEnd + if getline(prev_line) =~# vimwiki#vars#get_syntaxlocal('rxPreEnd') let cur_ln = a:lnum - 1 while 1 - if cur_ln == 0 || getline(cur_ln) =~# g:vimwiki_rxPreStart + if cur_ln == 0 || getline(cur_ln) =~# vimwiki#vars#get_syntaxlocal('rxPreStart') break endif let cur_ln -= 1 @@ -417,7 +417,7 @@ function! s:get_prev_line(lnum) "{{{ endif if prev_line < 0 || prev_line > line('$') || - \ getline(prev_line) =~# g:vimwiki_rxHeader + \ getline(prev_line) =~# vimwiki#vars#get_syntaxlocal('rxHeader') return 0 endif @@ -694,7 +694,7 @@ function! s:get_rate(item) "{{{ return -1 endif let state = a:item.cb - return index(g:vimwiki_listsyms_list, state) * 25 + return index(vimwiki#vars#get_syntaxlocal('listsyms_list'), state) * 25 endfunction "}}} "Set state of the list item to [ ] or [o] or whatever @@ -731,15 +731,15 @@ endfunction "}}} function! s:rate_to_state(rate) "{{{ let state = '' if a:rate == 100 - let state = g:vimwiki_listsyms_list[4] + let state = vimwiki#vars#get_syntaxlocal('listsyms_list')[4] elseif a:rate == 0 - let state = g:vimwiki_listsyms_list[0] + let state = vimwiki#vars#get_syntaxlocal('listsyms_list')[0] elseif a:rate >= 67 - let state = g:vimwiki_listsyms_list[3] + let state = vimwiki#vars#get_syntaxlocal('listsyms_list')[3] elseif a:rate >= 34 - let state = g:vimwiki_listsyms_list[2] + let state = vimwiki#vars#get_syntaxlocal('listsyms_list')[2] else - let state = g:vimwiki_listsyms_list[1] + let state = vimwiki#vars#get_syntaxlocal('listsyms_list')[1] endif return state endfunction "}}} @@ -793,7 +793,7 @@ function! s:create_cb(item) "{{{ endif let new_item = a:item - let new_item.cb = g:vimwiki_listsyms_list[0] + let new_item.cb = vimwiki#vars#get_syntaxlocal('listsyms_list')[0] call s:substitute_rx_in_line(new_item.lnum, \ vimwiki#u#escape(new_item.mrkr) . '\zs\ze', ' [' . new_item.cb . ']') @@ -1081,31 +1081,33 @@ function! s:get_idx_list_markers(item) "{{{ else let m = s:guess_kind_of_numbered_item(a:item) . a:item.mrkr[-1:] endif - return index(g:vimwiki_list_markers, m) + return index(vimwiki#vars#get_syntaxlocal('list_markers'), m) endfunction "}}} "changes the marker of the given item to the next in g:vimwiki_list_markers function! s:get_next_mrkr(item) "{{{ + let markers = vimwiki#vars#get_syntaxlocal('list_markers') if a:item.type == 0 - let new_mrkr = g:vimwiki_list_markers[0] + let new_mrkr = markers[0] else let idx = s:get_idx_list_markers(a:item) - let new_mrkr = g:vimwiki_list_markers[(idx+1) % len(g:vimwiki_list_markers)] + let new_mrkr = markers[(idx+1) % len(markers)] endif return new_mrkr endfunction "}}} "changes the marker of the given item to the previous in g:vimwiki_list_markers function! s:get_prev_mrkr(item) "{{{ + let markers = vimwiki#vars#get_syntaxlocal('list_markers') if a:item.type == 0 - return g:vimwiki_list_markers[-1] + return markers[-1] endif let idx = s:get_idx_list_markers(a:item) if idx == -1 - return g:vimwiki_list_markers[-1] + return markers[-1] else - return g:vimwiki_list_markers[(idx - 1 + len(g:vimwiki_list_markers)) % - \ len(g:vimwiki_list_markers)] + return markers[(idx - 1 + len(markers)) % + \ len(markers)] endif endfunction "}}} @@ -1260,7 +1262,7 @@ function! s:create_marker(lnum) "{{{ call s:clone_marker_from_to(new_sibling.lnum, a:lnum) else let cur_item = s:get_item(a:lnum) - call s:set_new_mrkr(cur_item, g:vimwiki_list_markers[0]) + call s:set_new_mrkr(cur_item, vimwiki#vars#get_syntaxlocal('list_markers')[0]) call s:adjust_numbered_list(cur_item, 0, 0) endif endfunction "}}} diff --git a/autoload/vimwiki/markdown_base.vim b/autoload/vimwiki/markdown_base.vim index e35e8b0..7412176 100644 --- a/autoload/vimwiki/markdown_base.vim +++ b/autoload/vimwiki/markdown_base.vim @@ -17,20 +17,20 @@ function! vimwiki#markdown_base#scan_reflinks() " {{{ " construct list of references using vimgrep try " Why noautocmd? Because https://github.com/vimwiki/vimwiki/issues/121 - noautocmd execute 'vimgrep #'.g:vimwiki_rxMkdRef.'#j %' + noautocmd execute 'vimgrep #'.vimwiki#vars#get_syntaxlocal('rxMkdRef').'#j %' catch /^Vim\%((\a\+)\)\=:E480/ " No Match "Ignore it, and move on to the next file endtry " for d in getqflist() let matchline = join(getline(d.lnum, min([d.lnum+1, line('$')])), ' ') - let descr = matchstr(matchline, g:vimwiki_rxMkdRefMatchDescr) - let url = matchstr(matchline, g:vimwiki_rxMkdRefMatchUrl) + let descr = matchstr(matchline, vimwiki#vars#get_syntaxlocal('rxMkdRefMatchDescr')) + let url = matchstr(matchline, vimwiki#vars#get_syntaxlocal('rxMkdRefMatchUrl')) if descr != '' && url != '' let mkd_refs[descr] = url endif endfor - call VimwikiSet('markdown_refs', mkd_refs) + call vimwiki#vars#set_bufferlocal('markdown_refs', mkd_refs) return mkd_refs endfunction "}}} @@ -39,7 +39,7 @@ endfunction "}}} function! vimwiki#markdown_base#get_reflinks() " {{{ let done = 1 try - let mkd_refs = VimwikiGet('markdown_refs') + let mkd_refs = vimwiki#vars#get_bufferlocal('markdown_refs') catch " work-around hack let done = 0 @@ -92,17 +92,17 @@ function! vimwiki#markdown_base#follow_link(split, ...) "{{{ Parse link at curso endif " try WikiLink - let lnk = matchstr(vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWikiLink), - \ g:vimwiki_rxWikiLinkMatchUrl) + let lnk = matchstr(vimwiki#base#matchstr_at_cursor(vimwiki#vars#get_global('rxWikiLink')), + \ vimwiki#vars#get_global('rxWikiLinkMatchUrl')) " try WikiIncl if lnk == "" - let lnk = matchstr(vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWikiIncl), - \ g:vimwiki_rxWikiInclMatchUrl) + let lnk = matchstr(vimwiki#base#matchstr_at_cursor(vimwiki#vars#get_global('rxWikiIncl')), + \ vimwiki#vars#get_global('rxWikiInclMatchUrl')) endif " try Weblink if lnk == "" - let lnk = matchstr(vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWeblink), - \ g:vimwiki_rxWeblinkMatchUrl) + let lnk = matchstr(vimwiki#base#matchstr_at_cursor(vimwiki#vars#get_global('rxWeblink')), + \ vimwiki#vars#get_global('rxWeblinkMatchUrl')) endif if lnk != "" @@ -132,50 +132,50 @@ function! s:normalize_link_syntax_n() " {{{ let lnum = line('.') " try WikiIncl - let lnk = vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWikiIncl) + let lnk = vimwiki#base#matchstr_at_cursor(vimwiki#vars#get_global('rxWikiIncl')) if !empty(lnk) " NO-OP !! return endif " try WikiLink0: replace with WikiLink1 - let lnk = vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWikiLink0) + let lnk = vimwiki#base#matchstr_at_cursor(vimwiki#vars#get_syntaxlocal('rxWikiLink0')) if !empty(lnk) let sub = vimwiki#base#normalize_link_helper(lnk, - \ g:vimwiki_rxWikiLinkMatchUrl, g:vimwiki_rxWikiLinkMatchDescr, - \ g:vimwiki_WikiLink1Template2) - call vimwiki#base#replacestr_at_cursor(g:vimwiki_rxWikiLink0, sub) + \ vimwiki#vars#get_global('rxWikiLinkMatchUrl'), vimwiki#vars#get_global('rxWikiLinkMatchDescr'), + \ vimwiki#vars#get_syntaxlocal('WikiLink1Template2')) + call vimwiki#base#replacestr_at_cursor(vimwiki#vars#get_syntaxlocal('rxWikiLink0'), sub) return endif " try WikiLink1: replace with WikiLink0 - let lnk = vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWikiLink1) + let lnk = vimwiki#base#matchstr_at_cursor(vimwiki#vars#get_syntaxlocal('rxWikiLink1')) if !empty(lnk) let sub = vimwiki#base#normalize_link_helper(lnk, - \ g:vimwiki_rxWikiLinkMatchUrl, g:vimwiki_rxWikiLinkMatchDescr, - \ g:vimwiki_WikiLinkTemplate2) - call vimwiki#base#replacestr_at_cursor(g:vimwiki_rxWikiLink1, sub) + \ vimwiki#vars#get_global('rxWikiLinkMatchUrl'), vimwiki#vars#get_global('rxWikiLinkMatchDescr'), + \ vimwiki#vars#get_global('WikiLinkTemplate2')) + call vimwiki#base#replacestr_at_cursor(vimwiki#vars#get_syntaxlocal('rxWikiLink1'), sub) return endif " try Weblink - let lnk = vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWeblink) + let lnk = vimwiki#base#matchstr_at_cursor(vimwiki#vars#get_global('rxWeblink')) if !empty(lnk) let sub = vimwiki#base#normalize_link_helper(lnk, - \ g:vimwiki_rxWeblinkMatchUrl, g:vimwiki_rxWeblinkMatchDescr, - \ g:vimwiki_Weblink1Template) - call vimwiki#base#replacestr_at_cursor(g:vimwiki_rxWeblink, sub) + \ vimwiki#vars#get_global('rxWeblinkMatchUrl'), vimwiki#vars#get_global('rxWeblinkMatchDescr'), + \ vimwiki#vars#get_syntaxlocal('Weblink1Template')) + call vimwiki#base#replacestr_at_cursor(vimwiki#vars#get_global('rxWeblink'), sub) return endif " try Word (any characters except separators) " rxWord is less permissive than rxWikiLinkUrl which is used in " normalize_link_syntax_v - let lnk = vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWord) + let lnk = vimwiki#base#matchstr_at_cursor(vimwiki#vars#get_global('rxWord')) if !empty(lnk) let sub = vimwiki#base#normalize_link_helper(lnk, - \ g:vimwiki_rxWord, '', - \ g:vimwiki_Weblink1Template) + \ vimwiki#vars#get_global('rxWord'), '', + \ vimwiki#vars#get_syntaxlocal('Weblink1Template')) call vimwiki#base#replacestr_at_cursor('\V'.lnk, sub) return endif @@ -194,7 +194,7 @@ function! s:normalize_link_syntax_v() " {{{ try norm! gvy let visual_selection = @" - let link = substitute(g:vimwiki_Weblink1Template, '__LinkUrl__', '\='."'".visual_selection."'", '') + let link = substitute(vimwiki#vars#get_syntaxlocal('Weblink1Template'), '__LinkUrl__', '\='."'".visual_selection."'", '') let link = substitute(link, '__LinkDescription__', '\='."'".visual_selection."'", '') call setreg('"', link, 'v') diff --git a/autoload/vimwiki/tags.vim b/autoload/vimwiki/tags.vim index 6a7b636..8b2c249 100644 --- a/autoload/vimwiki/tags.vim +++ b/autoload/vimwiki/tags.vim @@ -28,7 +28,7 @@ function! vimwiki#tags#update_tags(full_rebuild, all_files) "{{{ let all_files = a:all_files != '' if !a:full_rebuild " Updating for one page (current) - let page_name = VimwikiGet('subdir') . expand('%:t:r') + let page_name = vimwiki#vars#get_bufferlocal('subdir') . expand('%:t:r') " Collect tags in current file let tags = s:scan_tags(getline(1, '$'), page_name) " Load metadata file @@ -40,8 +40,8 @@ function! vimwiki#tags#update_tags(full_rebuild, all_files) "{{{ " Save call s:write_tags_metadata(metadata) else " full rebuild - let files = vimwiki#base#find_files(g:vimwiki_current_idx, 0) - let wiki_base_dir = vimwiki#vars#get_wikilocal('path', g:vimwiki_current_idx) + let files = vimwiki#base#find_files(vimwiki#vars#get_bufferlocal('wiki_nr'), 0) + let wiki_base_dir = vimwiki#vars#get_wikilocal('path') let tags_file_last_modification = \ getftime(vimwiki#tags#metadata_file_path()) let metadata = s:load_tags_metadata() @@ -68,9 +68,8 @@ function! s:scan_tags(lines, page_name) "{{{ " Code wireframe to scan for headers -- borrowed from " vimwiki#base#get_anchors(), with minor modifications. - let syntax = vimwiki#vars#get_wikilocal('syntax') - let rxheader = g:vimwiki_{syntax}_header_search - let rxtag = g:vimwiki_{syntax}_tag_search + let rxheader = vimwiki#vars#get_syntaxlocal('header_search') + let rxtag = vimwiki#vars#get_syntaxlocal('tag_search') let anchor_level = ['', '', '', '', '', '', ''] let current_complete_anchor = '' @@ -316,18 +315,18 @@ function! vimwiki#tags#generate_tags(...) abort "{{{ if need_all_tags || index(specific_tags, tagname) != -1 call extend(lines, [ \ '', - \ substitute(g:vimwiki_rxH2_Template, '__Header__', tagname, ''), + \ substitute(vimwiki#vars#get_syntaxlocal('rxH2_Template'), '__Header__', tagname, ''), \ '' ]) for taglink in sort(tags_entries[tagname]) call add(lines, bullet . - \ substitute(g:vimwiki_WikiLinkTemplate1, '__LinkUrl__', taglink, '')) + \ substitute(vimwiki#vars#get_global('WikiLinkTemplate1'), '__LinkUrl__', taglink, '')) endfor endif endfor - let links_rx = '\m\%(^\s*$\)\|\%('.g:vimwiki_rxH2.'\)\|\%(^\s*' + let links_rx = '\m\%(^\s*$\)\|\%('.vimwiki#vars#get_syntaxlocal('rxH2').'\)\|\%(^\s*' \ .vimwiki#u#escape(vimwiki#lst#default_symbol()).' ' - \ .g:vimwiki_rxWikiLink.'$\)' + \ .vimwiki#vars#get_global('rxWikiLink').'$\)' call vimwiki#base#update_listing_in_buffer(lines, 'Generated Tags', links_rx, \ line('$')+1, 1) diff --git a/autoload/vimwiki/tbl.vim b/autoload/vimwiki/tbl.vim index 05204fe..d9c7134 100644 --- a/autoload/vimwiki/tbl.vim +++ b/autoload/vimwiki/tbl.vim @@ -19,7 +19,7 @@ let s:textwidth = &tw " Misc functions {{{ function! s:rxSep() "{{{ - return g:vimwiki_rxTableSep + return vimwiki#vars#get_syntaxlocal('rxTableSep') endfunction "}}} function! s:wide_len(str) "{{{ diff --git a/autoload/vimwiki/vars.vim b/autoload/vimwiki/vars.vim index b13c147..d34a032 100644 --- a/autoload/vimwiki/vars.vim +++ b/autoload/vimwiki/vars.vim @@ -401,11 +401,18 @@ function! vimwiki#vars#get_bufferlocal(key) elseif a:key ==# 'wiki_nr' let b:vimwiki_wiki_nr = vimwiki#base#find_wiki(expand('%:p')) return b:vimwiki_wiki_nr + elseif a:key ==# 'subdir' + let b:vimwiki_subdir = vimwiki#base#current_subdir() + return b:vimwiki_subdir + elseif a:key ==# 'invsubdir' + let subdir = vimwiki#vars#get_bufferlocal('subdir') + let b:vimwiki_invsubdir = vimwiki#base#invsubdir(subdir) + return b:vimwiki_invsubdir endif endfunction -function! vimwiki#vars#set_buffer_var(key, value) +function! vimwiki#vars#set_bufferlocal(key, value) let b:vimwiki_{a:key} = a:value endfunction diff --git a/ftplugin/vimwiki.vim b/ftplugin/vimwiki.vim index b9f74e3..e5763f3 100644 --- a/ftplugin/vimwiki.vim +++ b/ftplugin/vimwiki.vim @@ -86,7 +86,7 @@ function! Complete_wikifiles(findstart, base) let prefix = matchstr(a:base, '^diary:\zs.*') let scheme = matchstr(a:base, '^diary:\ze') else " current wiki - let wikinumber = g:vimwiki_current_idx + let wikinumber = vimwiki#vars#get_bufferlocal('wiki_nr') let prefix = a:base let scheme = '' endif @@ -168,12 +168,12 @@ function! VimwikiFoldLevel(lnum) "{{{ let line = getline(a:lnum) " Header/section folding... - if line =~# g:vimwiki_rxHeader + if line =~# vimwiki#vars#get_syntaxlocal('rxHeader') return '>'.vimwiki#u#count_first_sym(line) " Code block folding... - elseif line =~# g:vimwiki_rxPreStart + elseif line =~# vimwiki#vars#get_syntaxlocal('rxPreStart') return 'a1' - elseif line =~# g:vimwiki_rxPreEnd + elseif line =~# vimwiki#vars#get_syntaxlocal('rxPreEnd') return 's1' else return "=" @@ -219,7 +219,7 @@ function! VimwikiFoldText() "{{{ let main_text = substitute(line, '^\s*', repeat(' ',indent(v:foldstart)), '') let fold_len = v:foldend - v:foldstart + 1 let len_text = ' ['.fold_len.'] ' - if line !~# g:vimwiki_rxPreStart + if line !~# vimwiki#vars#get_syntaxlocal('rxPreStart') let [main_text, spare_len] = s:shorten_text(main_text, 50) return main_text.len_text else diff --git a/syntax/omnipresent_syntax.vim b/syntax/omnipresent_syntax.vim deleted file mode 100644 index aaf3545..0000000 --- a/syntax/omnipresent_syntax.vim +++ /dev/null @@ -1,35 +0,0 @@ -" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79 -" Vimwiki syntax file -" Desc: Syntax definitions which are always available -" Home: https://github.com/vimwiki/vimwiki/ - - -" Define Regexes of anchors for every syntax. -" This has to be separated from vimwiki_default.vim, vimwiki_markdown.vim, etc. -" because the latter are only loaded and available if the current wiki has the -" corresponding syntax -let g:vimwiki_default_header_search = '^\s*\(=\{1,6}\)\([^=].*[^=]\)\1\s*$' -let g:vimwiki_default_header_match = '^\s*\(=\{1,6}\)=\@!\s*__Header__\s*\1=\@!\s*$' -let g:vimwiki_default_bold_search = '\%(^\|\s\|[[:punct:]]\)\@<=\*\zs\%([^*`[:space:]][^*`]*[^*`[:space:]]\|[^*`[:space:]]\)\ze\*\%([[:punct:]]\|\s\|$\)\@=' -let g:vimwiki_default_bold_match = '\%(^\|\s\|[[:punct:]]\)\@<=\*__Text__\*\%([[:punct:]]\|\s\|$\)\@=' -let g:vimwiki_default_wikilink = '\[\[\zs[^\\\]|]\+\ze\%(|[^\\\]]\+\)\?\]\]' -let g:vimwiki_default_tag_search = '\(^\|\s\)\zs:\([^:''[:space:]]\+:\)\+\ze\(\s\|$\)' -let g:vimwiki_default_tag_match = '\(^\|\s\):\([^:''[:space:]]\+:\)*__Tag__:\([^:[:space:]]\+:\)*\(\s\|$\)' - -let g:vimwiki_markdown_header_search = '^\s*\(#\{1,6}\)\([^#].*\)$' -let g:vimwiki_markdown_header_match = '^\s*\(#\{1,6}\)#\@!\s*__Header__\s*$' -let g:vimwiki_markdown_bold_search = '\%(^\|\s\|[[:punct:]]\)\@<=\*\zs\%([^*`[:space:]][^*`]*[^*`[:space:]]\|[^*`[:space:]]\)\ze\*\%([[:punct:]]\|\s\|$\)\@=' -let g:vimwiki_markdown_bold_match = '\%(^\|\s\|[[:punct:]]\)\@<=\*__Text__\*\%([[:punct:]]\|\s\|$\)\@=' -let g:vimwiki_markdown_wikilink = g:vimwiki_default_wikilink "XXX plus markdown-style links -let g:vimwiki_markdown_tag_search = g:vimwiki_default_tag_search -let g:vimwiki_markdown_tag_match = g:vimwiki_default_tag_match - -let g:vimwiki_media_header_search = '^\s*\(=\{1,6}\)\([^=].*[^=]\)\1\s*$' -let g:vimwiki_media_header_match = '^\s*\(=\{1,6}\)=\@!\s*__Header__\s*\1=\@!\s*$' -let g:vimwiki_media_bold_search = "'''\\zs[^']\\+\\ze'''" -let g:vimwiki_media_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 g:vimwiki_media_wikilink = g:vimwiki_default_wikilink -let g:vimwiki_media_tag_search = g:vimwiki_default_tag_search " XXX rework to mediawiki categories format? -let g:vimwiki_media_tag_match = g:vimwiki_default_tag_match " XXX rework to mediawiki categories format? diff --git a/syntax/vimwiki_markdown.vim b/syntax/vimwiki_markdown.vim index 54e241e..d181b95 100644 --- a/syntax/vimwiki_markdown.vim +++ b/syntax/vimwiki_markdown.vim @@ -3,86 +3,97 @@ " Desc: Defines markdown syntax " Home: https://github.com/vimwiki/vimwiki/ +" see the comments in vimwiki_default.vim for some info about this file + +let s:markdown_syntax = g:vimwiki_syntax_variables['markdown'] + " text: $ equation_inline $ -let g:vimwiki_rxEqIn = '\$[^$`]\+\$' -let g:vimwiki_char_eqin = '\$' +let s:markdown_syntax.rxEqIn = '\$[^$`]\+\$' +let s:markdown_syntax.char_eqin = '\$' " text: *strong* -" let g:vimwiki_rxBold = '\*[^*]\+\*' -let g:vimwiki_rxBold = '\%(^\|\s\|[[:punct:]]\)\@<='. +" let s:markdown_syntax.rxBold = '\*[^*]\+\*' +let s:markdown_syntax.rxBold = '\%(^\|\s\|[[:punct:]]\)\@<='. \'\*'. \'\%([^*`[:space:]][^*`]*[^*`[:space:]]\|[^*`[:space:]]\)'. \'\*'. \'\%([[:punct:]]\|\s\|$\)\@=' -let g:vimwiki_char_bold = '*' +let s:markdown_syntax.char_bold = '*' " text: _emphasis_ -" let g:vimwiki_rxItalic = '_[^_]\+_' -let g:vimwiki_rxItalic = '\%(^\|\s\|[[:punct:]]\)\@<='. +" let s:markdown_syntax.rxItalic = '_[^_]\+_' +let s:markdown_syntax.rxItalic = '\%(^\|\s\|[[:punct:]]\)\@<='. \'_'. \'\%([^_`[:space:]][^_`]*[^_`[:space:]]\|[^_`[:space:]]\)'. \'_'. \'\%([[:punct:]]\|\s\|$\)\@=' -let g:vimwiki_char_italic = '_' +let s:markdown_syntax.char_italic = '_' " text: *_bold italic_* or _*italic bold*_ -let g:vimwiki_rxBoldItalic = '\%(^\|\s\|[[:punct:]]\)\@<='. +let s:markdown_syntax.rxBoldItalic = '\%(^\|\s\|[[:punct:]]\)\@<='. \'\*_'. \'\%([^*_`[:space:]][^*_`]*[^*_`[:space:]]\|[^*_`[:space:]]\)'. \'_\*'. \'\%([[:punct:]]\|\s\|$\)\@=' -let g:vimwiki_char_bolditalic = '\*_' +let s:markdown_syntax.char_bolditalic = '\*_' -let g:vimwiki_rxItalicBold = '\%(^\|\s\|[[:punct:]]\)\@<='. +let s:markdown_syntax.rxItalicBold = '\%(^\|\s\|[[:punct:]]\)\@<='. \'_\*'. \'\%([^*_`[:space:]][^*_`]*[^*_`[:space:]]\|[^*_`[:space:]]\)'. \'\*_'. \'\%([[:punct:]]\|\s\|$\)\@=' -let g:vimwiki_char_italicbold = '_\*' +let s:markdown_syntax.char_italicbold = '_\*' " text: `code` -let g:vimwiki_rxCode = '`[^`]\+`' -let g:vimwiki_char_code = '`' +let s:markdown_syntax.rxCode = '`[^`]\+`' +let s:markdown_syntax.char_code = '`' " text: ~~deleted text~~ -let g:vimwiki_rxDelText = '\~\~[^~`]\+\~\~' -let g:vimwiki_char_deltext = '\~\~' +let s:markdown_syntax.rxDelText = '\~\~[^~`]\+\~\~' +let s:markdown_syntax.char_deltext = '\~\~' " text: ^superscript^ -let g:vimwiki_rxSuperScript = '\^[^^`]\+\^' -let g:vimwiki_char_superscript = '^' +let s:markdown_syntax.rxSuperScript = '\^[^^`]\+\^' +let s:markdown_syntax.char_superscript = '^' " text: ,,subscript,, -let g:vimwiki_rxSubScript = ',,[^,`]\+,,' -let g:vimwiki_char_subscript = ',,' +let s:markdown_syntax.rxSubScript = ',,[^,`]\+,,' +let s:markdown_syntax.char_subscript = ',,' " generic headers -let g:vimwiki_rxH = '#' -let g:vimwiki_symH = 0 +let s:markdown_syntax.rxH = '#' +let s:markdown_syntax.symH = 0 "
    , horizontal rule -let g:vimwiki_rxHR = '^-----*$' +let s:markdown_syntax.rxHR = '^-----*$' " Tables. Each line starts and ends with '|'; each cell is separated by '|' -let g:vimwiki_rxTableSep = '|' +let s:markdown_syntax.rxTableSep = '|' " Lists -let g:vimwiki_bullet_types = ['-', '*', '+'] -let s:media_syntax.recurring_bullets = 0 -let g:vimwiki_number_types = ['1.'] -let g:vimwiki_list_markers = ['-', '*', '+', '1.'] -let g:vimwiki_rxListDefine = '::\%(\s\|$\)' -call vimwiki#lst#setup_marker_infos() +let s:markdown_syntax.bullet_types = ['-', '*', '+'] +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\|$\)' " Preformatted text -let g:vimwiki_rxPreStart = '```' -let g:vimwiki_rxPreEnd = '```' +let s:markdown_syntax.rxPreStart = '```' +let s:markdown_syntax.rxPreEnd = '```' " Math block -let g:vimwiki_rxMathStart = '\$\$' -let g:vimwiki_rxMathEnd = '\$\$' +let s:markdown_syntax.rxMathStart = '\$\$' +let s:markdown_syntax.rxMathEnd = '\$\$' -let g:vimwiki_rxComment = '^\s*%%.*$' -let g:vimwiki_rxTags = '\%(^\|\s\)\@<=:\%([^:[:space:]]\+:\)\+\%(\s\|$\)\@=' +let s:markdown_syntax.rxComment = '^\s*%%.*$' +let s:markdown_syntax.rxTags = '\%(^\|\s\)\@<=:\%([^:[:space:]]\+:\)\+\%(\s\|$\)\@=' + +let s:markdown_syntax.header_search = '^\s*\(#\{1,6}\)\([^#].*\)$' +let s:markdown_syntax.header_match = '^\s*\(#\{1,6}\)#\@!\s*__Header__\s*$' +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\%(|[^\\\]]\+\)\?\]\]' "XXX plus markdown-style links +let s:markdown_syntax.tag_search = '\(^\|\s\)\zs:\([^:''[:space:]]\+:\)\+\ze\(\s\|$\)' +let s:markdown_syntax.tag_match = '\(^\|\s\):\([^:''[:space:]]\+:\)*__Tag__:\([^:[:space:]]\+:\)*\(\s\|$\)' diff --git a/syntax/vimwiki_media.vim b/syntax/vimwiki_media.vim index 9b3ff12..dfdc9d9 100644 --- a/syntax/vimwiki_media.vim +++ b/syntax/vimwiki_media.vim @@ -3,67 +3,80 @@ " Desc: 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: $ equation_inline $ -let g:vimwiki_rxEqIn = '\$[^$`]\+\$' -let g:vimwiki_char_eqin = '\$' +let s:media_syntax.rxEqIn = '\$[^$`]\+\$' +let s:media_syntax.char_eqin = '\$' " text: '''strong''' -let g:vimwiki_rxBold = "'''[^']\\+'''" -let g:vimwiki_char_bold = "'''" +let s:media_syntax.rxBold = "'''[^']\\+'''" +let s:media_syntax.char_bold = "'''" " text: ''emphasis'' -let g:vimwiki_rxItalic = "''[^']\\+''" -let g:vimwiki_char_italic = "''" +let s:media_syntax.rxItalic = "''[^']\\+''" +let s:media_syntax.char_italic = "''" " text: '''''strong italic''''' -let g:vimwiki_rxBoldItalic = "'''''[^']\\+'''''" -let g:vimwiki_rxItalicBold = g:vimwiki_rxBoldItalic -let g:vimwiki_char_bolditalic = "'''''" -let g:vimwiki_char_italicbold = g:vimwiki_char_bolditalic +let s:media_syntax.rxBoldItalic = "'''''[^']\\+'''''" +let s:media_syntax.rxItalicBold = s:media_syntax.rxBoldItalic +let s:media_syntax.char_bolditalic = "'''''" +let s:media_syntax.char_italicbold = s:media_syntax.char_bolditalic " text: `code` -let g:vimwiki_rxCode = '`[^`]\+`' -let g:vimwiki_char_code = '`' +let s:media_syntax.rxCode = '`[^`]\+`' +let s:media_syntax.char_code = '`' " text: ~~deleted text~~ -let g:vimwiki_rxDelText = '\~\~[^~]\+\~\~' -let g:vimwiki_char_deltext = '\~\~' +let s:media_syntax.rxDelText = '\~\~[^~]\+\~\~' +let s:media_syntax.char_deltext = '\~\~' " text: ^superscript^ -let g:vimwiki_rxSuperScript = '\^[^^]\+\^' -let g:vimwiki_char_superscript = '^' +let s:media_syntax.rxSuperScript = '\^[^^]\+\^' +let s:media_syntax.char_superscript = '^' " text: ,,subscript,, -let g:vimwiki_rxSubScript = ',,[^,]\+,,' -let g:vimwiki_char_subscript = ',,' +let s:media_syntax.rxSubScript = ',,[^,]\+,,' +let s:media_syntax.char_subscript = ',,' " generic headers -let g:vimwiki_rxH = '=' -let g:vimwiki_symH = 1 +let s:media_syntax.rxH = '=' +let s:media_syntax.symH = 1 "
    , horizontal rule -let g:vimwiki_rxHR = '^-----*$' +let s:media_syntax.rxHR = '^-----*$' " Tables. Each line starts and ends with '|'; each cell is separated by '|' -let g:vimwiki_rxTableSep = '|' +let s:media_syntax.rxTableSep = '|' " Lists -let g:vimwiki_bullet_types = ['*', '#'] +let s:media_syntax.bullet_types = ['*', '#'] let s:media_syntax.recurring_bullets = 1 -let g:vimwiki_number_types = [] -let g:vimwiki_list_markers = ['*', '#'] -let g:vimwiki_rxListDefine = '^\%(;\|:\)\s' -call vimwiki#lst#setup_marker_infos() +let s:media_syntax.number_types = [] +let s:media_syntax.list_markers = ['*', '#'] +let s:media_syntax.rxListDefine = '^\%(;\|:\)\s' " Preformatted text -let g:vimwiki_rxPreStart = '
    '
    -let g:vimwiki_rxPreEnd = '<\/pre>'
    +let s:media_syntax.rxPreStart = '
    '
    +let s:media_syntax.rxPreEnd = '<\/pre>'
     
     " Math block
    -let g:vimwiki_rxMathStart = '{{\$'
    -let g:vimwiki_rxMathEnd = '}}\$'
    +let s:media_syntax.rxMathStart = '{{\$'
    +let s:media_syntax.rxMathEnd = '}}\$'
     
    -let g:vimwiki_rxComment = '^\s*%%.*$'
    -let g:vimwiki_rxTags = '\%(^\|\s\)\@<=:\%([^:[:space:]]\+:\)\+\%(\s\|$\)\@='
    +let s:media_syntax.rxComment = '^\s*%%.*$'
    +let s:media_syntax.rxTags = '\%(^\|\s\)\@<=:\%([^:[:space:]]\+:\)\+\%(\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\%(|[^\\\]]\+\)\?\]\]'
    +let s:media_syntax.tag_search = '\(^\|\s\)\zs:\([^:''[:space:]]\+:\)\+\ze\(\s\|$\)' " XXX rework to mediawiki categories format?
    +let s:media_syntax.tag_match = '\(^\|\s\):\([^:''[:space:]]\+:\)*__Tag__:\([^:[:space:]]\+:\)*\(\s\|$\)' " XXX rework to mediawiki categories format?