Compare commits
17 Commits
Author | SHA1 | Date | |
---|---|---|---|
3bd3d9b860 | |||
e0d72759a6 | |||
f9045a40e0 | |||
9be96884ba | |||
2a70e1517e | |||
c565b38bb6 | |||
37aae9c3ce | |||
c2b0fd843b | |||
77fca9080c | |||
3eb20a6c98 | |||
7124a9be97 | |||
5247de4a0b | |||
0d3f526a88 | |||
d265df42f5 | |||
7df0405c4e | |||
8231433bad | |||
399e9a4512 |
@ -141,18 +141,12 @@ endfunction " }}}
|
||||
|
||||
" vimwiki#base#cache_buffer_state
|
||||
function! vimwiki#base#cache_buffer_state() "{{{
|
||||
if !exists('g:vimwiki_current_idx') && g:vimwiki_debug
|
||||
echo "[Vimwiki Internal Error]: Missing global state variable: 'g:vimwiki_current_idx'"
|
||||
endif
|
||||
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')
|
||||
if g:vimwiki_debug
|
||||
echo "[Vimwiki Internal Error]: Missing buffer state variable: 'b:vimwiki_idx'"
|
||||
endif
|
||||
return 0
|
||||
else
|
||||
let g:vimwiki_current_idx = b:vimwiki_idx
|
||||
@ -191,7 +185,6 @@ endfunction "}}}
|
||||
" vimwiki#base#subdir
|
||||
"FIXME TODO slow and faulty
|
||||
function! vimwiki#base#subdir(path, filename) "{{{
|
||||
let g:VimwikiLog.subdir += 1 "XXX
|
||||
let path = a:path
|
||||
" ensure that we are not fooled by a symbolic link
|
||||
"FIXME if we are not "fooled", we end up in a completely different wiki?
|
||||
@ -380,7 +373,7 @@ function! vimwiki#base#system_open_link(url) "{{{
|
||||
execute 'silent ! start "Title" /B ' . url
|
||||
endfunction
|
||||
function! s:macunix_handler(url)
|
||||
execute '!open ' . shellescape(a:url, 1)
|
||||
call system('open ' . shellescape(a:url).' &')
|
||||
endfunction
|
||||
function! s:linux_handler(url)
|
||||
call system('xdg-open ' . shellescape(a:url).' &')
|
||||
@ -404,10 +397,6 @@ endfunction "}}}
|
||||
function! vimwiki#base#open_link(cmd, link, ...) "{{{
|
||||
let link_infos = vimwiki#base#resolve_link(a:link)
|
||||
|
||||
if g:vimwiki_debug
|
||||
echom 'open_link:' string(link_infos)
|
||||
endif
|
||||
|
||||
if link_infos.filename == ''
|
||||
echom 'Vimwiki Error: Unable to resolve link!'
|
||||
return
|
||||
@ -1143,27 +1132,47 @@ function! vimwiki#base#update_listing_in_buffer(strings, start_header,
|
||||
return
|
||||
endif
|
||||
|
||||
let old_cursor_pos = getpos('.')
|
||||
let winview_save = winsaveview()
|
||||
let cursor_line = winview_save.lnum
|
||||
let is_cursor_after_listing = 0
|
||||
|
||||
let is_fold_closed = 1
|
||||
|
||||
let lines_diff = 0
|
||||
|
||||
if already_there
|
||||
let is_fold_closed = ( foldclosed(start_lnum) > -1 )
|
||||
" delete the old listing
|
||||
let whitespaces_in_first_line = matchstr(getline(start_lnum), '\m^\s*')
|
||||
let end_lnum = start_lnum + 1
|
||||
while end_lnum <= line('$') && getline(end_lnum) =~# a:content_regex
|
||||
let end_lnum += 1
|
||||
endwhile
|
||||
let is_cursor_after_listing = ( cursor_line >= end_lnum )
|
||||
" We'll be removing a range. But, apparently, if folds are enabled, Vim
|
||||
" won't let you remove a range that overlaps with closed fold -- the entire
|
||||
" fold gets deleted. So we temporarily disable folds, and then reenable
|
||||
" them right back.
|
||||
let foldenable_save = &l:foldenable
|
||||
setlo nofoldenable
|
||||
silent exe start_lnum.','.string(end_lnum - 1).'delete _'
|
||||
let &l:foldenable = foldenable_save
|
||||
let lines_diff = 0 - (end_lnum - start_lnum)
|
||||
else
|
||||
let start_lnum = a:default_lnum
|
||||
let is_cursor_after_listing = ( cursor_line > a:default_lnum )
|
||||
let whitespaces_in_first_line = ''
|
||||
endif
|
||||
|
||||
let start_of_listing = start_lnum
|
||||
|
||||
" write new listing
|
||||
let new_header = whitespaces_in_first_line
|
||||
\ . substitute(g:vimwiki_rxH1_Template,
|
||||
\ '__Header__', '\='."'".a:start_header."'", '')
|
||||
call append(start_lnum - 1, new_header)
|
||||
let start_lnum += 1
|
||||
let lines_diff += 1 + len(a:strings)
|
||||
for string in a:strings
|
||||
call append(start_lnum - 1, string)
|
||||
let start_lnum += 1
|
||||
@ -1171,9 +1180,19 @@ function! vimwiki#base#update_listing_in_buffer(strings, start_header,
|
||||
" append an empty line if there is not one
|
||||
if start_lnum <= line('$') && getline(start_lnum) !~# '\m^\s*$'
|
||||
call append(start_lnum - 1, '')
|
||||
let lines_diff += 1
|
||||
endif
|
||||
|
||||
call setpos('.', old_cursor_pos)
|
||||
" Open fold, if needed
|
||||
if !is_fold_closed && ( foldclosed(start_of_listing) > -1 )
|
||||
exe start_of_listing
|
||||
norm! zo
|
||||
endif
|
||||
|
||||
if is_cursor_after_listing
|
||||
let winview_save.lnum += lines_diff
|
||||
endif
|
||||
call winrestview(winview_save)
|
||||
endfunction "}}}
|
||||
|
||||
" WIKI link following functions {{{
|
||||
@ -1280,10 +1299,7 @@ function! vimwiki#base#goto_index(wnum, ...) "{{{
|
||||
let cmd = 'edit'
|
||||
endif
|
||||
|
||||
if g:vimwiki_debug == 3
|
||||
echom "--- Goto_index g:curr_idx=".g:vimwiki_current_idx." ww_idx=".idx.""
|
||||
endif
|
||||
|
||||
call Validate_wiki_options(idx)
|
||||
call vimwiki#base#edit_file(cmd,
|
||||
\ VimwikiGet('path', idx).VimwikiGet('index', idx).
|
||||
\ VimwikiGet('ext', idx),
|
||||
@ -1878,9 +1894,6 @@ function! s:normalize_link_syntax_n() " {{{
|
||||
\ g:vimwiki_rxWikiLinkMatchUrl, g:vimwiki_rxWikiLinkMatchDescr,
|
||||
\ g:vimwiki_WikiLinkTemplate2)
|
||||
call vimwiki#base#replacestr_at_cursor(g:vimwiki_rxWikiLink, sub)
|
||||
if g:vimwiki_debug > 1
|
||||
echomsg "WikiLink: ".lnk." Sub: ".sub
|
||||
endif
|
||||
return
|
||||
endif
|
||||
|
||||
@ -1888,9 +1901,6 @@ function! s:normalize_link_syntax_n() " {{{
|
||||
let lnk = vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWikiIncl)
|
||||
if !empty(lnk)
|
||||
" NO-OP !!
|
||||
if g:vimwiki_debug > 1
|
||||
echomsg "WikiIncl: ".lnk." Sub: ".lnk
|
||||
endif
|
||||
return
|
||||
endif
|
||||
|
||||
@ -1907,9 +1917,6 @@ function! s:normalize_link_syntax_n() " {{{
|
||||
\ g:vimwiki_WikiLinkTemplate1)
|
||||
endif
|
||||
call vimwiki#base#replacestr_at_cursor('\V'.lnk, sub)
|
||||
if g:vimwiki_debug > 1
|
||||
echomsg "Word: ".lnk." Sub: ".sub
|
||||
endif
|
||||
return
|
||||
endif
|
||||
|
||||
|
@ -83,7 +83,7 @@ fun! s:read_captions(files) "{{{
|
||||
return result
|
||||
endfun "}}}
|
||||
|
||||
fun! s:get_diary_links(...) "{{{
|
||||
fun! s:get_diary_links() "{{{
|
||||
let rx = '^\d\{4}-\d\d-\d\d'
|
||||
let s_files = glob(VimwikiGet('path').VimwikiGet('diary_rel_path').'*'.VimwikiGet('ext'))
|
||||
let files = split(s_files, '\n')
|
||||
@ -92,9 +92,6 @@ fun! s:get_diary_links(...) "{{{
|
||||
" remove backup files (.wiki~)
|
||||
call filter(files, 'v:val !~# ''.*\~$''')
|
||||
|
||||
if a:0
|
||||
call add(files, a:1)
|
||||
endif
|
||||
let links_with_captions = s:read_captions(files)
|
||||
|
||||
return links_with_captions
|
||||
@ -129,14 +126,10 @@ function! s:sort(lst) "{{{
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
function! s:format_diary(...) "{{{
|
||||
function! s:format_diary() "{{{
|
||||
let result = []
|
||||
|
||||
if a:0
|
||||
let g_files = s:group_links(s:get_diary_links(a:1))
|
||||
else
|
||||
let g_files = s:group_links(s:get_diary_links())
|
||||
endif
|
||||
let g_files = s:group_links(s:get_diary_links())
|
||||
|
||||
for year in s:sort(keys(g_files))
|
||||
call add(result, '')
|
||||
|
@ -396,11 +396,6 @@ function! s:tag_wikiincl(value) "{{{
|
||||
|
||||
let link_infos = vimwiki#base#resolve_link(url_0)
|
||||
|
||||
" TODO: migrate non-essential debugging messages into g:VimwikiLog
|
||||
if g:vimwiki_debug > 1
|
||||
echom string(link_infos)
|
||||
endif
|
||||
|
||||
if link_infos.scheme =~# '\mlocal\|wiki\d\+\|diary'
|
||||
let url = vimwiki#path#relpath(fnamemodify(s:current_html_file, ':h'),
|
||||
\ link_infos.filename)
|
||||
@ -455,12 +450,6 @@ function! s:tag_wikilink(value) "{{{
|
||||
let html_link = link_infos.filename
|
||||
endif
|
||||
|
||||
" generate html output
|
||||
" TODO: migrate non-essential debugging messages into g:VimwikiLog
|
||||
if g:vimwiki_debug > 1
|
||||
echom string(link_infos)
|
||||
endif
|
||||
|
||||
if link_infos.anchor != ''
|
||||
let anchor = substitute(link_infos.anchor, '#', '-', 'g')
|
||||
let html_link .= '#'.anchor
|
||||
@ -1378,9 +1367,6 @@ function! vimwiki#html#CustomWiki2HTML(path, wikifile, force) "{{{
|
||||
endfunction " }}}
|
||||
|
||||
function! vimwiki#html#Wiki2HTML(path_html, wikifile) "{{{
|
||||
|
||||
let starttime = reltime() " start the clock
|
||||
|
||||
let done = 0
|
||||
|
||||
let wikifile = fnamemodify(a:wikifile, ":p")
|
||||
@ -1403,10 +1389,6 @@ function! vimwiki#html#Wiki2HTML(path_html, wikifile) "{{{
|
||||
let lsource = readfile(wikifile)
|
||||
let ldest = []
|
||||
|
||||
"if g:vimwiki_debug
|
||||
" echo 'Generating HTML ... '
|
||||
"endif
|
||||
|
||||
call vimwiki#path#mkdir(path_html)
|
||||
|
||||
" nohtml placeholder -- to skip html generation.
|
||||
@ -1511,7 +1493,7 @@ function! vimwiki#html#Wiki2HTML(path_html, wikifile) "{{{
|
||||
call map(html_lines, 'substitute(v:val, "%encoding%", "'. enc .'", "g")')
|
||||
|
||||
let html_lines = s:html_insert_contents(html_lines, ldest) " %contents%
|
||||
|
||||
|
||||
"" make html file.
|
||||
call writefile(html_lines, path_html.htmlfile)
|
||||
let done = 1
|
||||
@ -1523,13 +1505,6 @@ function! vimwiki#html#Wiki2HTML(path_html, wikifile) "{{{
|
||||
return
|
||||
endif
|
||||
|
||||
" measure the elapsed time
|
||||
let time1 = vimwiki#u#time(starttime) "XXX
|
||||
call VimwikiLog_extend('html',[htmlfile,time1])
|
||||
"if g:vimwiki_debug
|
||||
" echon "\r".htmlfile.' written (time: '.time1.'s)'
|
||||
"endif
|
||||
|
||||
return path_html.htmlfile
|
||||
endfunction "}}}
|
||||
|
||||
|
@ -133,9 +133,6 @@ function! s:normalize_link_syntax_n() " {{{
|
||||
let lnk = vimwiki#base#matchstr_at_cursor(g:vimwiki_rxWikiIncl)
|
||||
if !empty(lnk)
|
||||
" NO-OP !!
|
||||
if g:vimwiki_debug > 1
|
||||
echomsg "WikiIncl: ".lnk." Sub: ".lnk
|
||||
endif
|
||||
return
|
||||
endif
|
||||
|
||||
@ -146,9 +143,6 @@ function! s:normalize_link_syntax_n() " {{{
|
||||
\ g:vimwiki_rxWikiLinkMatchUrl, g:vimwiki_rxWikiLinkMatchDescr,
|
||||
\ g:vimwiki_WikiLink1Template2)
|
||||
call vimwiki#base#replacestr_at_cursor(g:vimwiki_rxWikiLink0, sub)
|
||||
if g:vimwiki_debug > 1
|
||||
echomsg "WikiLink: ".lnk." Sub: ".sub
|
||||
endif
|
||||
return
|
||||
endif
|
||||
|
||||
@ -159,9 +153,6 @@ function! s:normalize_link_syntax_n() " {{{
|
||||
\ g:vimwiki_rxWikiLinkMatchUrl, g:vimwiki_rxWikiLinkMatchDescr,
|
||||
\ g:vimwiki_WikiLinkTemplate2)
|
||||
call vimwiki#base#replacestr_at_cursor(g:vimwiki_rxWikiLink1, sub)
|
||||
if g:vimwiki_debug > 1
|
||||
echomsg "WikiLink: ".lnk." Sub: ".sub
|
||||
endif
|
||||
return
|
||||
endif
|
||||
|
||||
@ -172,9 +163,6 @@ function! s:normalize_link_syntax_n() " {{{
|
||||
\ g:vimwiki_rxWeblinkMatchUrl, g:vimwiki_rxWeblinkMatchDescr,
|
||||
\ g:vimwiki_Weblink1Template)
|
||||
call vimwiki#base#replacestr_at_cursor(g:vimwiki_rxWeblink, sub)
|
||||
if g:vimwiki_debug > 1
|
||||
echomsg "WebLink: ".lnk." Sub: ".sub
|
||||
endif
|
||||
return
|
||||
endif
|
||||
|
||||
@ -187,9 +175,6 @@ function! s:normalize_link_syntax_n() " {{{
|
||||
\ g:vimwiki_rxWord, '',
|
||||
\ g:vimwiki_WikiLinkTemplate1)
|
||||
call vimwiki#base#replacestr_at_cursor('\V'.lnk, sub)
|
||||
if g:vimwiki_debug > 1
|
||||
echomsg "Word: ".lnk." Sub: ".sub
|
||||
endif
|
||||
return
|
||||
endif
|
||||
|
||||
|
@ -213,6 +213,38 @@ function! s:merge_tags(metadata, pagename, file_metadata) "{{{
|
||||
return metadata
|
||||
endfunction " }}}
|
||||
|
||||
" s:tags_entry_cmp
|
||||
" Compares two actual lines from tags file. Return value is in strcmp style.
|
||||
" See help on sort() -- that's what this function is going to be used for.
|
||||
" See also s:write_tags_metadata below -- that's where we compose these tags
|
||||
" file lines.
|
||||
"
|
||||
" This function is needed for tags sorting, since plain sort() compares line
|
||||
" numbers as strings, not integers, and so, for example, tag at line 14
|
||||
" preceeds the same tag on the same page at line 9. (Because string "14" is
|
||||
" alphabetically 'less than' string "9".)
|
||||
function! s:tags_entry_cmp(i1, i2) "{{{
|
||||
let items = []
|
||||
for orig_item in [a:i1, a:i2]
|
||||
let fields = split(orig_item, "\t")
|
||||
let item = {}
|
||||
let item.text = fields[0]."\t".fields[1]
|
||||
let item.lineno = 0 + matchstr(fields[2], '\m\d\+')
|
||||
call add(items, item)
|
||||
endfor
|
||||
if items[0].text > items[1].text
|
||||
return 1
|
||||
elseif items[0].text < items[1].text
|
||||
return -1
|
||||
elseif items[0].lineno > items[1].lineno
|
||||
return 1
|
||||
elseif items[0].lineno < items[1].lineno
|
||||
return -1
|
||||
else
|
||||
return 0
|
||||
endif
|
||||
endfunction " }}}
|
||||
|
||||
" s:write_tags_metadata
|
||||
" Saves metadata object into a file. Throws exceptions in case of problems.
|
||||
function! s:write_tags_metadata(metadata) "{{{
|
||||
@ -234,7 +266,7 @@ function! s:write_tags_metadata(metadata) "{{{
|
||||
\)
|
||||
endfor
|
||||
endfor
|
||||
call sort(tags)
|
||||
call sort(tags, "s:tags_entry_cmp")
|
||||
call insert(tags, "!_TAG_FILE_SORTED\t1\t")
|
||||
call writefile(tags, metadata_path)
|
||||
endfunction " }}}
|
||||
|
@ -32,11 +32,6 @@ function! vimwiki#u#is_macos()
|
||||
return os == 'Darwin' || os == 'Mac'
|
||||
endfunction
|
||||
|
||||
function! vimwiki#u#time(starttime) "{{{
|
||||
" measure the elapsed time and cut away miliseconds and smaller
|
||||
return matchstr(reltimestr(reltime(a:starttime)),'\d\+\(\.\d\d\)\=')
|
||||
endfunction "}}}
|
||||
|
||||
function! vimwiki#u#count_first_sym(line) "{{{
|
||||
let first_sym = matchstr(a:line, '\S')
|
||||
return len(matchstr(a:line, first_sym.'\+'))
|
||||
|
@ -2594,19 +2594,6 @@ Note:
|
||||
Default: 15
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
*g:vimwiki_debug*
|
||||
|
||||
Controls verbosity of debugging output, for example, the diagnostic
|
||||
information about HTML conversion.
|
||||
|
||||
Value Description~
|
||||
0 Do not show debug messages.
|
||||
1 Show debug messages.
|
||||
|
||||
Default: 0
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
*g:vimwiki_diary_months*
|
||||
|
||||
@ -2713,12 +2700,28 @@ Contributors and their Github usernames in roughly chronological order:
|
||||
- 修昊 (Svtter)
|
||||
- Marcelo D Montu (mMontu)
|
||||
- John Kaul
|
||||
- Hongbo Liu (hiberabyss)
|
||||
|
||||
|
||||
==============================================================================
|
||||
15. Changelog *vimwiki-changelog*
|
||||
|
||||
2.2~
|
||||
|
||||
2.2.1 (2015-12-10)~
|
||||
|
||||
Removed:~
|
||||
* Removed the option g:vimwiki_debug, which probably nobody used. If you
|
||||
want it back, file an issue at Github.
|
||||
|
||||
Fixed:~
|
||||
* Don't do random things when the user has remapped the z key
|
||||
* Don't ask for confirmation when following an URL in MacOS
|
||||
* Always jump to the first occurrence of a tag in a file
|
||||
* Don't move the cursor when updating the TOC
|
||||
* Fix some issues with the TOC when folding is enabled
|
||||
|
||||
|
||||
2.2 (2015-11-25)~
|
||||
|
||||
New:~
|
||||
* Support for anchors, see |vimwiki-anchors|
|
||||
@ -2744,6 +2747,8 @@ New:~
|
||||
* Add Chinese Readme file
|
||||
|
||||
Changed:~
|
||||
* Wiki files must not contain # anymore, because # is used to separate the
|
||||
file from an anchor in a link.
|
||||
* replace the function vimwiki#base#resolve_scheme() by
|
||||
vimwiki#base#resolve_link() (relevant if you have a custom
|
||||
|VimwikiLinkHandler| which used this function)
|
||||
|
@ -11,18 +11,6 @@ let g:loaded_vimwiki = 1
|
||||
let s:old_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
" Logging and performance instrumentation "{{{
|
||||
let g:VimwikiLog = {}
|
||||
let g:VimwikiLog.path = 0 " # of calls to VimwikiGet with path or path_html
|
||||
let g:VimwikiLog.path_html = 0 " # of calls to path_html()
|
||||
let g:VimwikiLog.normalize_path = 0 " # of calls to normalize_path()
|
||||
let g:VimwikiLog.subdir = 0 " # of calls to vimwiki#base#subdir()
|
||||
let g:VimwikiLog.timing = [] " various timing measurements
|
||||
let g:VimwikiLog.html = [] " html conversion timing
|
||||
function! VimwikiLog_extend(what,...) "{{{
|
||||
call extend(g:VimwikiLog[a:what],a:000)
|
||||
endfunction "}}}
|
||||
"}}}
|
||||
|
||||
" HELPER functions {{{
|
||||
function! s:default(varname, value) "{{{
|
||||
@ -36,14 +24,12 @@ function! s:path_html(idx) "{{{
|
||||
if !empty(path_html)
|
||||
return path_html
|
||||
else
|
||||
let g:VimwikiLog.path_html += 1 "XXX
|
||||
let path = VimwikiGet('path', a:idx)
|
||||
return substitute(path, '[/\\]\+$', '', '').'_html/'
|
||||
endif
|
||||
endfunction "}}}
|
||||
|
||||
function! s:normalize_path(path) "{{{
|
||||
let g:VimwikiLog.normalize_path += 1 "XXX
|
||||
" resolve doesn't work quite right with symlinks ended with / or \
|
||||
let path = substitute(a:path, '[/\\]\+$', '', '')
|
||||
if path !~# '^scp:'
|
||||
@ -71,16 +57,10 @@ function! s:vimwiki_idx() " {{{
|
||||
endfunction " }}}
|
||||
|
||||
function! s:setup_buffer_leave() "{{{
|
||||
if g:vimwiki_debug == 3
|
||||
echom "Setup_buffer_leave g:curr_idx=".g:vimwiki_current_idx." b:curr_idx=".s:vimwiki_idx().""
|
||||
endif
|
||||
if &filetype ==? 'vimwiki'
|
||||
" cache global vars of current state XXX: SLOW!?
|
||||
call vimwiki#base#cache_buffer_state()
|
||||
endif
|
||||
if g:vimwiki_debug == 3
|
||||
echom " Setup_buffer_leave g:curr_idx=".g:vimwiki_current_idx." b:curr_idx=".s:vimwiki_idx().""
|
||||
endif
|
||||
|
||||
let &autowriteall = s:vimwiki_autowriteall
|
||||
|
||||
@ -91,16 +71,9 @@ function! s:setup_buffer_leave() "{{{
|
||||
endfunction "}}}
|
||||
|
||||
function! s:setup_filetype() "{{{
|
||||
if g:vimwiki_debug == 3
|
||||
echom "Setup_filetype g:curr_idx=".g:vimwiki_current_idx." b:curr_idx=".s:vimwiki_idx().""
|
||||
endif
|
||||
let time0 = reltime() " start the clock "XXX
|
||||
" Find what wiki current buffer belongs to.
|
||||
let path = expand('%:p:h')
|
||||
let idx = vimwiki#base#find_wiki(path)
|
||||
if g:vimwiki_debug == 3
|
||||
echom " Setup_filetype g:curr_idx=".g:vimwiki_current_idx." find_idx=".idx." b:curr_idx=".s:vimwiki_idx().""
|
||||
endif
|
||||
|
||||
if idx == -1 && g:vimwiki_global_ext == 0
|
||||
return
|
||||
@ -124,24 +97,12 @@ function! s:setup_filetype() "{{{
|
||||
endif
|
||||
" initialize and cache global vars of current state
|
||||
call vimwiki#base#setup_buffer_state(idx)
|
||||
if g:vimwiki_debug ==3
|
||||
echom " Setup_filetype g:curr_idx=".g:vimwiki_current_idx." (reset_wiki_state) b:curr_idx=".s:vimwiki_idx().""
|
||||
endif
|
||||
|
||||
unlet! b:vimwiki_fs_rescan
|
||||
set filetype=vimwiki
|
||||
if g:vimwiki_debug ==3
|
||||
echom " Setup_filetype g:curr_idx=".g:vimwiki_current_idx." (set ft=vimwiki) b:curr_idx=".s:vimwiki_idx().""
|
||||
endif
|
||||
let time1 = vimwiki#u#time(time0) "XXX
|
||||
call VimwikiLog_extend('timing',['plugin:setup_filetype:time1',time1])
|
||||
endfunction "}}}
|
||||
|
||||
function! s:setup_buffer_enter() "{{{
|
||||
if g:vimwiki_debug ==3
|
||||
echom "Setup_buffer_enter g:curr_idx=".g:vimwiki_current_idx." b:curr_idx=".s:vimwiki_idx().""
|
||||
endif
|
||||
let time0 = reltime() " start the clock "XXX
|
||||
if !vimwiki#base#recall_buffer_state()
|
||||
" Find what wiki current buffer belongs to.
|
||||
" If wiki does not exist in g:vimwiki_list -- add new wiki there with
|
||||
@ -150,9 +111,6 @@ function! s:setup_buffer_enter() "{{{
|
||||
let path = expand('%:p:h')
|
||||
let idx = vimwiki#base#find_wiki(path)
|
||||
|
||||
if g:vimwiki_debug ==3
|
||||
echom " Setup_buffer_enter g:curr_idx=".g:vimwiki_current_idx." find_idx=".idx." b:curr_idx=".s:vimwiki_idx().""
|
||||
endif
|
||||
" The buffer's file is not in the path and user *does NOT* want his wiki
|
||||
" extension to be global -- Do not add new wiki.
|
||||
if idx == -1 && g:vimwiki_global_ext == 0
|
||||
@ -176,9 +134,6 @@ function! s:setup_buffer_enter() "{{{
|
||||
endif
|
||||
" initialize and cache global vars of current state
|
||||
call vimwiki#base#setup_buffer_state(idx)
|
||||
if g:vimwiki_debug ==3
|
||||
echom " Setup_buffer_enter g:curr_idx=".g:vimwiki_current_idx." (reset_wiki_state) b:curr_idx=".s:vimwiki_idx().""
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
@ -188,22 +143,15 @@ function! s:setup_buffer_enter() "{{{
|
||||
" au GUIEnter * nested VimwikiIndex
|
||||
if &filetype == ''
|
||||
set filetype=vimwiki
|
||||
if g:vimwiki_debug ==3
|
||||
echom " Setup_buffer_enter g:curr_idx=".g:vimwiki_current_idx." (set ft vimwiki) b:curr_idx=".s:vimwiki_idx().""
|
||||
endif
|
||||
elseif &syntax ==? 'vimwiki'
|
||||
" to force a rescan of the filesystem which may have changed
|
||||
" and update VimwikiLinks syntax group that depends on it;
|
||||
" b:vimwiki_fs_rescan indicates that setup_filetype() has not been run
|
||||
if exists("b:vimwiki_fs_rescan") && VimwikiGet('maxhi')
|
||||
set syntax=vimwiki
|
||||
if g:vimwiki_debug ==3
|
||||
echom " Setup_buffer_enter g:curr_idx=".g:vimwiki_current_idx." (set syntax=vimwiki) b:curr_idx=".s:vimwiki_idx().""
|
||||
endif
|
||||
endif
|
||||
let b:vimwiki_fs_rescan = 1
|
||||
endif
|
||||
let time1 = vimwiki#u#time(time0) "XXX
|
||||
|
||||
" Settings foldmethod, foldexpr and foldtext are local to window. Thus in a
|
||||
" new tab with the same buffer folding is reset to vim defaults. So we
|
||||
@ -221,7 +169,7 @@ function! s:setup_buffer_enter() "{{{
|
||||
setlocal foldtext=VimwikiFoldText()
|
||||
else
|
||||
setlocal fdm=manual
|
||||
exe "normal zE"
|
||||
normal! zE
|
||||
endif
|
||||
|
||||
" And conceal level too.
|
||||
@ -233,21 +181,13 @@ function! s:setup_buffer_enter() "{{{
|
||||
if g:vimwiki_menu != ""
|
||||
exe 'nmenu enable '.g:vimwiki_menu.'.Table'
|
||||
endif
|
||||
"let time2 = vimwiki#u#time(time0) "XXX
|
||||
call VimwikiLog_extend('timing',['plugin:setup_buffer_enter:time1',time1])
|
||||
endfunction "}}}
|
||||
|
||||
function! s:setup_buffer_reenter() "{{{
|
||||
if g:vimwiki_debug ==3
|
||||
echom "Setup_buffer_reenter g:curr_idx=".g:vimwiki_current_idx." b:curr_idx=".s:vimwiki_idx().""
|
||||
endif
|
||||
if !vimwiki#base#recall_buffer_state()
|
||||
" Do not repeat work of s:setup_buffer_enter() and s:setup_filetype()
|
||||
" Once should be enough ...
|
||||
endif
|
||||
if g:vimwiki_debug ==3
|
||||
echom " Setup_buffer_reenter g:curr_idx=".g:vimwiki_current_idx." b:curr_idx=".s:vimwiki_idx().""
|
||||
endif
|
||||
if !exists("s:vimwiki_autowriteall")
|
||||
let s:vimwiki_autowriteall = &autowriteall
|
||||
endif
|
||||
@ -444,7 +384,6 @@ call s:default('html_header_numbering', 0)
|
||||
call s:default('html_header_numbering_sym', '')
|
||||
call s:default('conceallevel', 2)
|
||||
call s:default('url_maxsave', 15)
|
||||
call s:default('debug', 0)
|
||||
|
||||
call s:default('diary_months',
|
||||
\ {
|
||||
|
@ -10,14 +10,12 @@ elseif exists("b:current_syntax")
|
||||
endif
|
||||
|
||||
"TODO do nothing if ...? (?)
|
||||
let g:starttime = reltime() " start the clock
|
||||
if VimwikiGet('maxhi')
|
||||
let b:existing_wikifiles =
|
||||
\ vimwiki#base#get_wikilinks(g:vimwiki_current_idx, 1)
|
||||
let b:existing_wikidirs =
|
||||
\ vimwiki#base#get_wiki_directories(g:vimwiki_current_idx)
|
||||
endif
|
||||
let s:timescans = vimwiki#u#time(g:starttime) "XXX
|
||||
"let b:xxx = 1
|
||||
"TODO ? update wikilink syntax group here if really needed (?) for :e and such
|
||||
"if VimwikiGet('maxhi')
|
||||
@ -47,8 +45,6 @@ let g:vimwiki_rxWeblinkUrl = g:vimwiki_rxWebProtocols .
|
||||
|
||||
call vimwiki#u#reload_regexes()
|
||||
|
||||
let s:time0 = vimwiki#u#time(g:starttime) "XXX
|
||||
|
||||
" LINKS: setup of larger regexes {{{
|
||||
|
||||
" LINKS: setup wikilink regexps {{{
|
||||
@ -177,9 +173,6 @@ let g:vimwiki_rxAnyLink = g:vimwiki_rxWikiLink.'\|'.
|
||||
|
||||
" LINKS: highlighting is complicated due to "nonexistent" links feature {{{
|
||||
function! s:add_target_syntax_ON(target, type) " {{{
|
||||
if g:vimwiki_debug > 1
|
||||
echom '[vimwiki_debug] syntax target > '.a:target
|
||||
endif
|
||||
let prefix0 = 'syntax match '.a:type.' `'
|
||||
let suffix0 = '` display contains=@NoSpell,VimwikiLinkRest,'.a:type.'Char'
|
||||
let prefix1 = 'syntax match '.a:type.'T `'
|
||||
@ -189,9 +182,6 @@ function! s:add_target_syntax_ON(target, type) " {{{
|
||||
endfunction "}}}
|
||||
|
||||
function! s:add_target_syntax_OFF(target) " {{{
|
||||
if g:vimwiki_debug > 1
|
||||
echom '[vimwiki_debug] syntax target > '.a:target
|
||||
endif
|
||||
let prefix0 = 'syntax match VimwikiNoExistsLink `'
|
||||
let suffix0 = '` display contains=@NoSpell,VimwikiLinkRest,VimwikiLinkChar'
|
||||
let prefix1 = 'syntax match VimwikiNoExistsLinkT `'
|
||||
@ -252,16 +242,12 @@ if VimwikiGet('maxhi')
|
||||
call s:add_target_syntax_OFF(g:vimwiki_rxWikiIncl)
|
||||
|
||||
" Subsequently, links verified on vimwiki's path are highlighted as existing
|
||||
let s:time01 = vimwiki#u#time(g:starttime) "XXX
|
||||
call s:highlight_existing_links()
|
||||
let s:time02 = vimwiki#u#time(g:starttime) "XXX
|
||||
else
|
||||
let s:time01 = vimwiki#u#time(g:starttime) "XXX
|
||||
" Wikilink
|
||||
call s:add_target_syntax_ON(g:vimwiki_rxWikiLink, 'VimwikiLink')
|
||||
" WikiIncl
|
||||
call s:add_target_syntax_ON(g:vimwiki_rxWikiIncl, 'VimwikiLink')
|
||||
let s:time02 = vimwiki#u#time(g:starttime) "XXX
|
||||
endif
|
||||
|
||||
" Weblink
|
||||
@ -344,14 +330,6 @@ execute 'syn match VimwikiSubScript contained /'.g:vimwiki_char_subscript.'/'.s:
|
||||
" }}}
|
||||
|
||||
" concealed link parts " {{{
|
||||
if g:vimwiki_debug > 1
|
||||
echom 'WikiLink Prefix: '.s:rx_wikilink_prefix
|
||||
echom 'WikiLink Suffix: '.s:rx_wikilink_suffix
|
||||
echom 'WikiLink Prefix1: '.s:rx_wikilink_prefix1
|
||||
echom 'WikiLink Suffix1: '.s:rx_wikilink_suffix1
|
||||
echom 'WikiIncl Prefix: '.g:vimwiki_rxWikiInclPrefix1
|
||||
echom 'WikiIncl Suffix: '.g:vimwiki_rxWikiInclSuffix1
|
||||
endif
|
||||
|
||||
" define the conceal attribute for links only if Vim is new enough to handle it
|
||||
" and the user has g:vimwiki_url_maxsave > 0
|
||||
@ -627,6 +605,3 @@ call vimwiki#base#nested_syntax('tex',
|
||||
|
||||
|
||||
syntax spell toplevel
|
||||
|
||||
let s:timeend = vimwiki#u#time(g:starttime) "XXX
|
||||
call VimwikiLog_extend('timing',['syntax:scans',s:timescans],['syntax:regexloaded',s:time0],['syntax:beforeHLexisting',s:time01],['syntax:afterHLexisting',s:time02],['syntax:end',s:timeend])
|
||||
|
@ -204,9 +204,6 @@ let g:vimwiki_rxMkdRefMatchUrl = '\['.g:vimwiki_rxWikiLinkDescr.']:\%(\s\+\|\n\)
|
||||
|
||||
" LINKS: highlighting is complicated due to "nonexistent" links feature {{{
|
||||
function! s:add_target_syntax_ON(target, type) " {{{
|
||||
if g:vimwiki_debug > 1
|
||||
echom '[vimwiki_debug] syntax target > '.a:target
|
||||
endif
|
||||
let prefix0 = 'syntax match '.a:type.' `'
|
||||
let suffix0 = '` display contains=@NoSpell,VimwikiLinkRest,'.a:type.'Char'
|
||||
let prefix1 = 'syntax match '.a:type.'T `'
|
||||
@ -216,9 +213,6 @@ function! s:add_target_syntax_ON(target, type) " {{{
|
||||
endfunction "}}}
|
||||
|
||||
function! s:add_target_syntax_OFF(target, type) " {{{
|
||||
if g:vimwiki_debug > 1
|
||||
echom '[vimwiki_debug] syntax target > '.a:target
|
||||
endif
|
||||
let prefix0 = 'syntax match VimwikiNoExistsLink `'
|
||||
let suffix0 = '` display contains=@NoSpell,VimwikiLinkRest,'.a:type.'Char'
|
||||
let prefix1 = 'syntax match VimwikiNoExistsLinkT `'
|
||||
@ -291,14 +285,10 @@ if VimwikiGet('maxhi')
|
||||
call s:add_target_syntax_OFF(g:vimwiki_rxWikiLink1, 'VimwikiWikiLink1')
|
||||
|
||||
" Subsequently, links verified on vimwiki's path are highlighted as existing
|
||||
let s:time01 = vimwiki#u#time(g:starttime) "XXX
|
||||
call s:highlight_existing_links()
|
||||
let s:time02 = vimwiki#u#time(g:starttime) "XXX
|
||||
else
|
||||
let s:time01 = vimwiki#u#time(g:starttime) "XXX
|
||||
" Wikilink
|
||||
call s:add_target_syntax_ON(g:vimwiki_rxWikiLink1, 'VimwikiWikiLink1')
|
||||
let s:time02 = vimwiki#u#time(g:starttime) "XXX
|
||||
endif
|
||||
|
||||
" Weblink
|
||||
@ -340,13 +330,6 @@ endif
|
||||
|
||||
syntax spell toplevel
|
||||
|
||||
if g:vimwiki_debug > 1
|
||||
echom 'WikiLink1 Prefix: '.g:vimwiki_rxWikiLink1Prefix1
|
||||
echom 'WikiLink1 Suffix: '.g:vimwiki_rxWikiLink1Suffix1
|
||||
echom 'Weblink1 Prefix: '.g:vimwiki_rxWeblink1Prefix1
|
||||
echom 'Weblink1 Suffix: '.g:vimwiki_rxWeblink1Suffix1
|
||||
endif
|
||||
|
||||
" VimwikiWikiLink1Char is for syntax markers (and also URL when a description
|
||||
" is present) and may be concealed
|
||||
let s:options = ' contained transparent contains=NONE'
|
||||
|
Reference in New Issue
Block a user