diff --git a/autoload/vimwiki/base.vim b/autoload/vimwiki/base.vim index da21350..2862d6b 100644 --- a/autoload/vimwiki/base.vim +++ b/autoload/vimwiki/base.vim @@ -500,7 +500,7 @@ function! vimwiki#base#goto(...) abort " Save current file pos let vimwiki_prev_link = [vimwiki#path#current_wiki_file(), getpos('.')] - call vimwiki#base#edit_file(':e', + call vimwiki#base#edit_file('edit', \ vimwiki#vars#get_wikilocal('path') . key . vimwiki#vars#get_wikilocal('ext'), \ anchor, \ vimwiki_prev_link, @@ -1120,7 +1120,7 @@ function! vimwiki#base#edit_file(command, filename, anchor, ...) abort " which happens if we jump to an achor in the current file. " This hack is necessary because apparently Vim messes up the result of " getpos() directly after this command. Strange. - if !(a:command ==# ':e ' && vimwiki#path#is_equal(a:filename, expand('%:p'))) + if !(a:command =~# ':\?[ed].*' && vimwiki#path#is_equal(a:filename, expand('%:p'))) try execute a:command fname catch /E37:/ @@ -1130,6 +1130,10 @@ function! vimwiki#base#edit_file(command, filename, anchor, ...) abort catch /E325:/ call vimwiki#u#warn('Vim couldn''t open the file, probably because a swapfile already exists. See :h E325.') return + catch /E319:/ + call vimwiki#u#warn('Vim couldn''t open the file, cannot launch the drop command. See :h E319.') + execute 'edit' fname + return endtry " If the opened file was not already loaded by Vim, an autocommand is " triggered at this point @@ -1391,7 +1395,7 @@ endfunction function! s:open_wiki_buffer(item) abort " Edit wiki file. " Called: by rename_file: Usefull for buffer commands - call vimwiki#base#edit_file(':e', a:item[0], '') + call vimwiki#base#edit_file('edit', a:item[0], '') if !empty(a:item[1]) call vimwiki#vars#set_bufferlocal('prev_links', a:item[1], a:item[0]) endif @@ -1665,23 +1669,26 @@ function! vimwiki#base#follow_link(split, ...) abort endif if a:split ==# 'hsplit' - let cmd = ':split ' + let cmd = 'split' elseif a:split ==# 'vsplit' - let cmd = ':vsplit ' + let cmd = 'vsplit' elseif a:split ==# 'badd' - let cmd = ':badd ' + let cmd = 'badd' elseif a:split ==# 'tab' - let cmd = ':tabnew ' + let cmd = 'tabnew' elseif a:split ==# 'tabdrop' " Use tab drop if we've already got the file open in an existing tab - let cmd = ':tab drop ' + let cmd = 'tab edit' + if exists(':drop') == 2 + let cmd = 'tab drop' + endif else " Same as above - doing this by default reduces incidence of multiple " tabs with the same file. We default to :e just in case :drop doesn't " exist in the current build. - let cmd = ':e ' - if exists(':drop') - let cmd = ':drop ' + let cmd = 'edit' + if exists(':drop') == 2 && has('windows') + let cmd = 'drop' endif endif @@ -1691,7 +1698,7 @@ function! vimwiki#base#follow_link(split, ...) abort let previous_window_nr = winnr('#') if previous_window_nr > 0 && previous_window_nr != winnr() execute previous_window_nr . 'wincmd w' - let cmd = ':e' + let cmd = ':edit' endif endif @@ -1739,8 +1746,14 @@ function! vimwiki#base#go_back_link() abort " Jump to target with edit_file if !empty(prev_link) " go back to saved wiki link - call vimwiki#base#edit_file(':e ', prev_link[0], '') - call setpos('.', prev_link[1]) + " Change file if required lazy + let file = prev_link[0] + let pos = prev_link[1] + " Removed the filereadable check for Vader + if !(vimwiki#path#is_equal(file, expand('%:p'))) + call vimwiki#base#edit_file('edit', file, '') + endif + call setpos('.', pos) else " maybe we came here by jumping to a tag -> pop from the tag stack silent! pop! diff --git a/autoload/vimwiki/diary.vim b/autoload/vimwiki/diary.vim index 9ab42d7..c43bfc4 100644 --- a/autoload/vimwiki/diary.vim +++ b/autoload/vimwiki/diary.vim @@ -299,20 +299,23 @@ function! vimwiki#diary#make_note(wnum, ...) abort call vimwiki#path#mkdir(vimwiki#vars#get_wikilocal('path', wiki_nr). \ vimwiki#vars#get_wikilocal('diary_rel_path', wiki_nr)) - let cmd = 'edit' + let cmd = ':edit' if a:0 if a:1 == 1 - let cmd = 'tabedit' + let cmd = ':tabedit' elseif a:1 == 2 - let cmd = 'split' + let cmd = ':split' elseif a:1 == 3 - let cmd = 'vsplit' + let cmd = ':vsplit' elseif a:1 == 4 - let cmd = 'tab drop' + let cmd = ':tab edit' + if exists(':drop') == 2 + let cmd = ':tab drop' + endif elseif a:1 == 5 - let cmd = 'drop' - if exists(':drop') - let cmd = 'drop' + let cmd = ':edit' + if exists(':drop') == 2 + let cmd = ':drop' endif endif endif diff --git a/autoload/vimwiki/html.vim b/autoload/vimwiki/html.vim index 934350c..c6e3753 100644 --- a/autoload/vimwiki/html.vim +++ b/autoload/vimwiki/html.vim @@ -1884,26 +1884,26 @@ function! s:convert_file(path_html, wikifile) abort endif call vimwiki#path#mkdir(path_html) - if g:vimwiki_global_vars['listing_hl'] > 0 && has("unix") + if g:vimwiki_global_vars['listing_hl'] > 0 && has('unix') let i = 0 while i < len(html_lines) - if html_lines[i] =~ '^
'
+        if html_lines[i] =~# '^
'
           let type = split(split(split(html_lines[i], 'type=')[1], '>')[0], '\s\+')[0]
           let attr = split(split(html_lines[i], '
')[0]
           let start = i + 1
           let cur = start
 
-          while html_lines[cur] !~ '^<\/pre>'
+          while html_lines[cur] !~# '^<\/pre>'
             let cur += 1
           endwhile
 
           let tmp = ('tmp'. split(system('mktemp -p . --suffix=.' . type, 'silent'), 'tmp')[-1])[:-2]
-          call system('echo ' . shellescape(join(html_lines[start:cur - 1], '\n')) . ' > ' . tmp)
+          call system('echo ' . shellescape(join(html_lines[start : cur - 1], '\n')) . ' > ' . tmp)
           call system(g:vimwiki_global_vars['listing_hl_command'] . ' ' . tmp  . ' > ' . tmp . '.html')
           let html_out = system('cat ' . tmp . '.html')
           call system('rm ' . tmp . ' ' . tmp . '.html')
           let i = cur
-          let html_lines = html_lines[0:start - 1] + split(html_out, '\n') + html_lines[cur:]
+          let html_lines = html_lines[0 : start - 1] + split(html_out, '\n') + html_lines[cur : ]
         endif
         let i += 1
       endwhile
diff --git a/autoload/vimwiki/u.vim b/autoload/vimwiki/u.vim
index a3aba65..88d4b11 100644
--- a/autoload/vimwiki/u.vim
+++ b/autoload/vimwiki/u.vim
@@ -304,18 +304,55 @@ function! vimwiki#u#hi_expand_regex(lst) abort
   " :param: list> with reduced regex
   " Return: list with extended regex delimiters (not inside a word)
   "   -- [['\*_', '_\*']] -> [['\*_\S\@=', '\S\@<=_\*\%(\s\|$\)\@=']]
+  " Note: For purposes of this definition, the beginning and the end of the line count as Unicode whitespace.
   " See: https://github.github.com/gfm/#left-flanking-delimiter-run
   let res = []
-  let p = vimwiki#u#get_punctuation_string()
-  for delimiters in a:lst
-    let r_prefix = '\(^\|[[:space:]]\@<=\)'
-    " Regex Start: not preceded by backslash, not ended by space
-    let r_start = r_prefix . delimiters[0] . '\S\@='
-    " Regex End: not preceded by backslash or space, ended by punctuation or space
-    let r_prefix = '\(^\|[^[:space:]\\]\@<=\)'
-    let r_end = r_prefix . delimiters[1] . '\%(\_[[:space:]' . p . ']\)\@='
+  let punctuation = vimwiki#u#get_punctuation_string()
+
+  " Iterate on (left delimiter, right delimiter pair)
+  for a_delimiter in a:lst
+    let r_left_del = a_delimiter[0]
+    let r_right_del = a_delimiter[1]
+
+    " Regex Start:
+    " Left-Flanking is not followed by space (or ned of line)
+    let r_left_prefix = '\%(^\|[[:space:]]\@<=\)'
+    let r_left_prefix = '\\\@VimwikiNormalizeLink')
   call vimwiki#u#map_key('v', '+', 'VimwikiNormalizeLinkVisual')
   call vimwiki#u#map_key('v', '', 'VimwikiNormalizeLinkVisualCR')
-  call vimwiki#u#map_key('n', '', 'VimwikiTabDropLink')
-  call vimwiki#u#map_key('n', '', 'VimwikiTabDropLink', 1)
   call vimwiki#u#map_key('n', '', 'VimwikiGoBackLink')
   call vimwiki#u#map_key('n', '', 'VimwikiNextLink')
   call vimwiki#u#map_key('n', '', 'VimwikiPrevLink')