Stylistic changes to pass vint tests.
Two non-stylistic errors were also fixed: 1. Removed duplicate function with invalid argument usage 2. Added missing quotes to a function call argument
This commit is contained in:
		
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -4,13 +4,13 @@ | ||||
| " Home: https://github.com/vimwiki/vimwiki/ | ||||
|  | ||||
|  | ||||
| if exists("g:loaded_vimwiki_diary_auto") || &cp | ||||
| if exists('g:loaded_vimwiki_diary_auto') || &compatible | ||||
|   finish | ||||
| endif | ||||
| let g:loaded_vimwiki_diary_auto = 1 | ||||
|  | ||||
|  | ||||
| function! s:prefix_zero(num) | ||||
| function! s:prefix_zero(num) abort | ||||
|   if a:num < 10 | ||||
|     return '0'.a:num | ||||
|   endif | ||||
| @@ -18,20 +18,20 @@ function! s:prefix_zero(num) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:diary_path(...) | ||||
| function! s:diary_path(...) abort | ||||
|   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(...) | ||||
| function! s:diary_index(...) abort | ||||
|   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 | ||||
|  | ||||
|  | ||||
| function! vimwiki#diary#diary_date_link(...) | ||||
| function! vimwiki#diary#diary_date_link(...) abort | ||||
|   if a:0 | ||||
|     return strftime('%Y-%m-%d', a:1) | ||||
|   else | ||||
| @@ -40,7 +40,7 @@ function! vimwiki#diary#diary_date_link(...) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:get_position_links(link) | ||||
| function! s:get_position_links(link) abort | ||||
|   let idx = -1 | ||||
|   let links = [] | ||||
|   if a:link =~# '^\d\{4}-\d\d-\d\d' | ||||
| @@ -56,11 +56,11 @@ function! s:get_position_links(link) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:get_month_name(month) | ||||
| function! s:get_month_name(month) abort | ||||
|   return vimwiki#vars#get_global('diary_months')[str2nr(a:month)] | ||||
| endfunction | ||||
|  | ||||
| function! s:get_first_header(fl) | ||||
| function! s:get_first_header(fl) abort | ||||
|   " Get the first header in the file within the first s:vimwiki_max_scan_for_caption lines. | ||||
|   let header_rx = vimwiki#vars#get_syntaxlocal('rxHeader') | ||||
|  | ||||
| @@ -72,7 +72,7 @@ function! s:get_first_header(fl) | ||||
|   return '' | ||||
| endfunction | ||||
|  | ||||
| function! s:get_all_headers(fl, maxlevel) | ||||
| function! s:get_all_headers(fl, maxlevel) abort | ||||
|   " Get a list of all headers in a file up to a given level. | ||||
|   " Returns a list whose elements are pairs [level, title] | ||||
|   let headers_rx = {} | ||||
| @@ -92,7 +92,7 @@ function! s:get_all_headers(fl, maxlevel) | ||||
|   return headers | ||||
| endfunction | ||||
|  | ||||
| function! s:count_headers_level_less_equal(headers, maxlevel) | ||||
| function! s:count_headers_level_less_equal(headers, maxlevel) abort | ||||
|   " Count headers with level <=  maxlevel in a list of [level, title] pairs. | ||||
|   let l:count = 0 | ||||
|   for [header_level, _] in a:headers | ||||
| @@ -103,7 +103,7 @@ function! s:count_headers_level_less_equal(headers, maxlevel) | ||||
|   return l:count | ||||
| endfunction | ||||
|  | ||||
| function! s:get_min_header_level(headers) | ||||
| function! s:get_min_header_level(headers) abort | ||||
|   " The minimum level of any header in a list of [level, title] pairs. | ||||
|   if len(a:headers) == 0 | ||||
|     return 0 | ||||
| @@ -116,7 +116,7 @@ function! s:get_min_header_level(headers) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:read_captions(files) | ||||
| function! s:read_captions(files) abort | ||||
|   let result = {} | ||||
|   let caption_level = vimwiki#vars#get_wikilocal('diary_caption_level') | ||||
|  | ||||
| @@ -157,7 +157,7 @@ function! s:read_captions(files) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:get_diary_files() | ||||
| function! s:get_diary_files() abort | ||||
|   let rx = '^\d\{4}-\d\d-\d\d' | ||||
|   let s_files = glob(vimwiki#vars#get_wikilocal('path'). | ||||
|         \ vimwiki#vars#get_wikilocal('diary_rel_path').'*'.vimwiki#vars#get_wikilocal('ext')) | ||||
| @@ -171,7 +171,7 @@ function! s:get_diary_files() | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:group_links(links) | ||||
| function! s:group_links(links) abort | ||||
|   let result = {} | ||||
|   let p_year = 0 | ||||
|   let p_month = 0 | ||||
| @@ -193,7 +193,7 @@ function! s:group_links(links) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:sort(lst) | ||||
| function! s:sort(lst) abort | ||||
|   if vimwiki#vars#get_wikilocal('diary_sort') ==? 'desc' | ||||
|     return reverse(sort(a:lst)) | ||||
|   else | ||||
| @@ -205,7 +205,7 @@ endfunction | ||||
| " The given wiki number a:wnum is 1 for the first wiki, 2 for the second and so on. This is in | ||||
| " contrast to most other places, where counting starts with 0. When a:wnum is 0, the current wiki | ||||
| " is used. | ||||
| function! vimwiki#diary#make_note(wnum, ...) | ||||
| function! vimwiki#diary#make_note(wnum, ...) abort | ||||
|   if a:wnum == 0 | ||||
|     let wiki_nr = vimwiki#vars#get_bufferlocal('wiki_nr') | ||||
|     if wiki_nr < 0  " this happens when e.g. VimwikiMakeDiaryNote was called outside a wiki buffer | ||||
| @@ -242,7 +242,7 @@ function! vimwiki#diary#make_note(wnum, ...) | ||||
|   call vimwiki#base#open_link(cmd, link, s:diary_index(wiki_nr)) | ||||
| endfunction | ||||
|  | ||||
| function! vimwiki#diary#goto_diary_index(wnum) | ||||
| function! vimwiki#diary#goto_diary_index(wnum) abort | ||||
|  | ||||
|   " if wnum = 0 the current wiki is used | ||||
|   if a:wnum == 0 | ||||
| @@ -268,7 +268,7 @@ function! vimwiki#diary#goto_diary_index(wnum) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! vimwiki#diary#goto_next_day() | ||||
| function! vimwiki#diary#goto_next_day() abort | ||||
|   let link = '' | ||||
|   let [idx, links] = s:get_position_links(expand('%:t:r')) | ||||
|  | ||||
| @@ -289,7 +289,7 @@ function! vimwiki#diary#goto_next_day() | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! vimwiki#diary#goto_prev_day() | ||||
| function! vimwiki#diary#goto_prev_day() abort | ||||
|   let link = '' | ||||
|   let [idx, links] = s:get_position_links(expand('%:t:r')) | ||||
|  | ||||
| @@ -310,10 +310,10 @@ function! vimwiki#diary#goto_prev_day() | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! vimwiki#diary#generate_diary_section() | ||||
| function! vimwiki#diary#generate_diary_section() abort | ||||
|  | ||||
|   let GeneratorDiary = copy(l:) | ||||
|   function! GeneratorDiary.f() | ||||
|   function! GeneratorDiary.f() abort | ||||
|     let lines = [] | ||||
|  | ||||
|     let links_with_captions = s:read_captions(s:get_diary_files()) | ||||
| @@ -332,7 +332,7 @@ function! vimwiki#diary#generate_diary_section() | ||||
|         call add(lines, substitute(vimwiki#vars#get_syntaxlocal('rxH3_Template'), | ||||
|               \ '__Header__', s:get_month_name(month), '')) | ||||
|  | ||||
|         if vimwiki#vars#get_wikilocal('syntax') == 'markdown' | ||||
|         if vimwiki#vars#get_wikilocal('syntax') ==# 'markdown' | ||||
|           for _ in range(vimwiki#vars#get_global('markdown_header_style')) | ||||
|             call add(lines, '') | ||||
|           endfor | ||||
| @@ -342,7 +342,7 @@ function! vimwiki#diary#generate_diary_section() | ||||
|           let topcap = captions['top'] | ||||
|           let link_tpl = vimwiki#vars#get_global('WikiLinkTemplate2') | ||||
|  | ||||
|           if vimwiki#vars#get_wikilocal('syntax') == 'markdown' | ||||
|           if vimwiki#vars#get_wikilocal('syntax') ==# 'markdown' | ||||
|             let link_tpl = vimwiki#vars#get_syntaxlocal('Weblink1Template') | ||||
|  | ||||
|             if empty(topcap) " When using markdown syntax, we should ensure we always have a link description. | ||||
| @@ -386,7 +386,7 @@ function! vimwiki#diary#generate_diary_section() | ||||
|     return lines | ||||
|   endfunction | ||||
|  | ||||
|   let current_file = vimwiki#path#path_norm(expand("%:p")) | ||||
|   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 = '^\%('.vimwiki#vars#get_syntaxlocal('rxHeader').'\)\|'. | ||||
| @@ -406,7 +406,7 @@ endfunction | ||||
|  | ||||
|  | ||||
| " Callback function for Calendar.vim | ||||
| function! vimwiki#diary#calendar_action(day, month, year, week, dir) | ||||
| function! vimwiki#diary#calendar_action(day, month, year, week, dir) abort | ||||
|   let day = s:prefix_zero(a:day) | ||||
|   let month = s:prefix_zero(a:month) | ||||
|  | ||||
| @@ -428,7 +428,7 @@ function! vimwiki#diary#calendar_action(day, month, year, week, dir) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function vimwiki#diary#calendar_sign(day, month, year) | ||||
| function! vimwiki#diary#calendar_sign(day, month, year) abort | ||||
|   let day = s:prefix_zero(a:day) | ||||
|   let month = s:prefix_zero(a:month) | ||||
|   let sfile = vimwiki#vars#get_wikilocal('path').vimwiki#vars#get_wikilocal('diary_rel_path'). | ||||
|   | ||||
| @@ -4,30 +4,30 @@ | ||||
| " Home: https://github.com/vimwiki/vimwiki/ | ||||
|  | ||||
|  | ||||
| if exists("g:loaded_vimwiki_html_auto") || &cp | ||||
| if exists('g:loaded_vimwiki_html_auto') || &compatible | ||||
|   finish | ||||
| endif | ||||
| let g:loaded_vimwiki_html_auto = 1 | ||||
|  | ||||
|  | ||||
| function! s:root_path(subdir) | ||||
| function! s:root_path(subdir) abort | ||||
|   return repeat('../', len(split(a:subdir, '[/\\]'))) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:syntax_supported() | ||||
|   return vimwiki#vars#get_wikilocal('syntax') ==? "default" | ||||
| function! s:syntax_supported() abort | ||||
|   return vimwiki#vars#get_wikilocal('syntax') ==? 'default' | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:remove_blank_lines(lines) | ||||
| function! s:remove_blank_lines(lines) abort | ||||
|   while !empty(a:lines) && a:lines[-1] =~# '^\s*$' | ||||
|     call remove(a:lines, -1) | ||||
|   endwhile | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:is_web_link(lnk) | ||||
| function! s:is_web_link(lnk) abort | ||||
|   if a:lnk =~# '^\%(https://\|http://\|www.\|ftp://\|file://\|mailto:\)' | ||||
|     return 1 | ||||
|   endif | ||||
| @@ -35,7 +35,7 @@ function! s:is_web_link(lnk) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:is_img_link(lnk) | ||||
| function! s:is_img_link(lnk) abort | ||||
|   if tolower(a:lnk) =~# '\.\%(png\|jpg\|gif\|jpeg\)$' | ||||
|     return 1 | ||||
|   endif | ||||
| @@ -43,7 +43,7 @@ function! s:is_img_link(lnk) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:has_abs_path(fname) | ||||
| function! s:has_abs_path(fname) abort | ||||
|   if a:fname =~# '\(^.:\)\|\(^/\)' | ||||
|     return 1 | ||||
|   endif | ||||
| @@ -51,10 +51,10 @@ function! s:has_abs_path(fname) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:find_autoload_file(name) | ||||
| function! s:find_autoload_file(name) abort | ||||
|   for path in split(&runtimepath, ',') | ||||
|     let fname = path.'/autoload/vimwiki/'.a:name | ||||
|     if glob(fname) != '' | ||||
|     if glob(fname) !=? '' | ||||
|       return fname | ||||
|     endif | ||||
|   endfor | ||||
| @@ -62,19 +62,19 @@ function! s:find_autoload_file(name) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:default_CSS_full_name(path) | ||||
| function! s:default_CSS_full_name(path) abort | ||||
|   let path = expand(a:path) | ||||
|   let css_full_name = path . vimwiki#vars#get_wikilocal('css_name') | ||||
|   return css_full_name | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:create_default_CSS(path) | ||||
| function! s:create_default_CSS(path) abort | ||||
|   let css_full_name = s:default_CSS_full_name(a:path) | ||||
|   if glob(css_full_name) == "" | ||||
|   if glob(css_full_name) ==? '' | ||||
|     call vimwiki#path#mkdir(fnamemodify(css_full_name, ':p:h')) | ||||
|     let default_css = s:find_autoload_file('style.css') | ||||
|     if default_css != '' | ||||
|     if default_css !=? '' | ||||
|       let lines = readfile(default_css) | ||||
|       call writefile(lines, css_full_name) | ||||
|       return 1 | ||||
| @@ -84,8 +84,8 @@ function! s:create_default_CSS(path) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:template_full_name(name) | ||||
|   if a:name == '' | ||||
| function! s:template_full_name(name) abort | ||||
|   if a:name ==? '' | ||||
|     let name = vimwiki#vars#get_wikilocal('template_default') | ||||
|   else | ||||
|     let name = a:name | ||||
| @@ -102,11 +102,11 @@ function! s:template_full_name(name) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:get_html_template(template) | ||||
| function! s:get_html_template(template) abort | ||||
|   " TODO: refactor it!!! | ||||
|   let lines=[] | ||||
|  | ||||
|   if a:template != '' | ||||
|   if a:template !=? '' | ||||
|     let template_name = s:template_full_name(a:template) | ||||
|     try | ||||
|       let lines = readfile(template_name) | ||||
| @@ -118,7 +118,7 @@ function! s:get_html_template(template) | ||||
|  | ||||
|   let default_tpl = s:template_full_name('') | ||||
|  | ||||
|   if default_tpl == '' | ||||
|   if default_tpl ==? '' | ||||
|     let default_tpl = s:find_autoload_file('default.tpl') | ||||
|   endif | ||||
|  | ||||
| @@ -127,19 +127,19 @@ function! s:get_html_template(template) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:safe_html_preformatted(line) | ||||
| function! s:safe_html_preformatted(line) abort | ||||
|   let line = substitute(a:line,'<','\<', 'g') | ||||
|   let line = substitute(line,'>','\>', 'g') | ||||
|   return line | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:escape_html_attribute(string) | ||||
| function! s:escape_html_attribute(string) abort | ||||
|   return substitute(a:string, '"', '\"', 'g') | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:safe_html_line(line) | ||||
| function! s:safe_html_line(line) abort | ||||
|   " escape & < > when producing HTML text | ||||
|   " s:lt_pattern, s:gt_pattern depend on g:vimwiki_valid_html_tags | ||||
|   " and are set in vimwiki#html#Wiki2HTML() | ||||
| @@ -151,18 +151,18 @@ function! s:safe_html_line(line) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:delete_html_files(path) | ||||
| function! s:delete_html_files(path) abort | ||||
|   let htmlfiles = split(glob(a:path.'**/*.html'), '\n') | ||||
|   for fname in htmlfiles | ||||
|     " ignore user html files, e.g. search.html,404.html | ||||
|     if stridx(vimwiki#vars#get_global('user_htmls'), fnamemodify(fname, ":t")) >= 0 | ||||
|     if stridx(vimwiki#vars#get_global('user_htmls'), fnamemodify(fname, ':t')) >= 0 | ||||
|       continue | ||||
|     endif | ||||
|  | ||||
|     " delete if there is no corresponding wiki file | ||||
|     let subdir = vimwiki#base#subdir(vimwiki#vars#get_wikilocal('path_html'), fname) | ||||
|     let wikifile = vimwiki#vars#get_wikilocal('path').subdir. | ||||
|           \fnamemodify(fname, ":t:r").vimwiki#vars#get_wikilocal('ext') | ||||
|           \fnamemodify(fname, ':t:r').vimwiki#vars#get_wikilocal('ext') | ||||
|     if filereadable(wikifile) | ||||
|       continue | ||||
|     endif | ||||
| @@ -176,22 +176,22 @@ function! s:delete_html_files(path) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:mid(value, cnt) | ||||
| function! s:mid(value, cnt) abort | ||||
|   return strpart(a:value, a:cnt, len(a:value) - 2 * a:cnt) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:subst_func(line, regexp, func, ...) | ||||
| function! s:subst_func(line, regexp, func, ...) abort | ||||
|   " Substitute text found by regexp with result of | ||||
|   " func(matched) function. | ||||
|  | ||||
|   let pos = 0 | ||||
|   let lines = split(a:line, a:regexp, 1) | ||||
|   let res_line = "" | ||||
|   let res_line = '' | ||||
|   for line in lines | ||||
|     let res_line = res_line.line | ||||
|     let matched = matchstr(a:line, a:regexp, pos) | ||||
|     if matched != "" | ||||
|     if matched !=? '' | ||||
|       if a:0 | ||||
|         let res_line = res_line.{a:func}(matched, a:1) | ||||
|       else | ||||
| @@ -204,7 +204,7 @@ function! s:subst_func(line, regexp, func, ...) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:process_date(placeholders, default_date) | ||||
| function! s:process_date(placeholders, default_date) abort | ||||
|   if !empty(a:placeholders) | ||||
|     for [placeholder, row, idx] in a:placeholders | ||||
|       let [type, param] = placeholder | ||||
| @@ -217,7 +217,7 @@ function! s:process_date(placeholders, default_date) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:process_title(placeholders, default_title) | ||||
| function! s:process_title(placeholders, default_title) abort | ||||
|   if !empty(a:placeholders) | ||||
|     for [placeholder, row, idx] in a:placeholders | ||||
|       let [type, param] = placeholder | ||||
| @@ -230,15 +230,15 @@ function! s:process_title(placeholders, default_title) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:is_html_uptodate(wikifile) | ||||
| function! s:is_html_uptodate(wikifile) abort | ||||
|   let tpl_time = -1 | ||||
|  | ||||
|   let tpl_file = s:template_full_name('') | ||||
|   if tpl_file != '' | ||||
|   if tpl_file !=? '' | ||||
|     let tpl_time = getftime(tpl_file) | ||||
|   endif | ||||
|  | ||||
|   let wikifile = fnamemodify(a:wikifile, ":p") | ||||
|   let wikifile = fnamemodify(a:wikifile, ':p') | ||||
|  | ||||
|   if vimwiki#vars#get_wikilocal('html_filename_parameterization') | ||||
|     let parameterized_wikiname = s:parameterized_wikiname(wikifile) | ||||
| @@ -246,7 +246,7 @@ function! s:is_html_uptodate(wikifile) | ||||
|           \ vimwiki#vars#get_bufferlocal('subdir') . parameterized_wikiname) | ||||
|   else | ||||
|     let htmlfile = expand(vimwiki#vars#get_wikilocal('path_html') . | ||||
|           \ vimwiki#vars#get_bufferlocal('subdir') . fnamemodify(wikifile, ":t:r").".html") | ||||
|           \ vimwiki#vars#get_bufferlocal('subdir') . fnamemodify(wikifile, ':t:r').'.html') | ||||
|   endif | ||||
|  | ||||
|   if getftime(wikifile) <= getftime(htmlfile) && tpl_time <= getftime(htmlfile) | ||||
| @@ -255,17 +255,17 @@ function! s:is_html_uptodate(wikifile) | ||||
|   return 0 | ||||
| endfunction | ||||
|  | ||||
| function! s:parameterized_wikiname(wikifile) | ||||
|   let initial = fnamemodify(a:wikifile, ":t:r") | ||||
| function! s:parameterized_wikiname(wikifile) abort | ||||
|   let initial = fnamemodify(a:wikifile, ':t:r') | ||||
|   let lower_sanitized = tolower(initial) | ||||
|   let substituted = substitute(lower_sanitized, '[^a-z0-9_-]\+',"-", "g") | ||||
|   let substituted = substitute(substituted, '\-\+',"-", "g") | ||||
|   let substituted = substitute(substituted, '^-', '', "g") | ||||
|   let substituted = substitute(substituted, '-$', '', "g") | ||||
|   return substitute(substituted, '\-\+',"-", "g") . ".html" | ||||
|   let substituted = substitute(lower_sanitized, '[^a-z0-9_-]\+','-', 'g') | ||||
|   let substituted = substitute(substituted, '\-\+','-', 'g') | ||||
|   let substituted = substitute(substituted, '^-', '', 'g') | ||||
|   let substituted = substitute(substituted, '-$', '', 'g') | ||||
|   return substitute(substituted, '\-\+','-', 'g') . '.html' | ||||
| endfunction | ||||
|  | ||||
| function! s:html_insert_contents(html_lines, content) | ||||
| function! s:html_insert_contents(html_lines, content) abort | ||||
|   let lines = [] | ||||
|   for line in a:html_lines | ||||
|     if line =~# '%content%' | ||||
| @@ -288,27 +288,27 @@ function! s:html_insert_contents(html_lines, content) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:tag_eqin(value) | ||||
| function! s:tag_eqin(value) abort | ||||
|   " mathJAX wants \( \) for inline maths | ||||
|   return '\('.s:mid(a:value, 1).'\)' | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:tag_em(value) | ||||
| function! s:tag_em(value) abort | ||||
|   return '<em>'.s:mid(a:value, 1).'</em>' | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:tag_strong(value, header_ids) | ||||
| function! s:tag_strong(value, header_ids) abort | ||||
|   let text = s:mid(a:value, 1) | ||||
|   let id = s:escape_html_attribute(text) | ||||
|   let complete_id = '' | ||||
|   for l in range(6) | ||||
|     if a:header_ids[l][0] != '' | ||||
|     if a:header_ids[l][0] !=? '' | ||||
|       let complete_id .= a:header_ids[l][0].'-' | ||||
|     endif | ||||
|   endfor | ||||
|   if a:header_ids[5][0] == '' | ||||
|   if a:header_ids[5][0] ==? '' | ||||
|     let complete_id = complete_id[:-2] | ||||
|   endif | ||||
|   let complete_id .= '-'.id | ||||
| @@ -317,14 +317,14 @@ function! s:tag_strong(value, header_ids) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:tag_tags(value, header_ids) | ||||
| function! s:tag_tags(value, header_ids) abort | ||||
|   let complete_id = '' | ||||
|   for level in range(6) | ||||
|     if a:header_ids[level][0] != '' | ||||
|     if a:header_ids[level][0] !=? '' | ||||
|       let complete_id .= a:header_ids[level][0].'-' | ||||
|     endif | ||||
|   endfor | ||||
|   if a:header_ids[5][0] == '' | ||||
|   if a:header_ids[5][0] ==? '' | ||||
|     let complete_id = complete_id[:-2] | ||||
|   endif | ||||
|   let complete_id = s:escape_html_attribute(complete_id) | ||||
| @@ -339,44 +339,44 @@ function! s:tag_tags(value, header_ids) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:tag_todo(value) | ||||
| function! s:tag_todo(value) abort | ||||
|   return '<span class="todo">'.a:value.'</span>' | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:tag_strike(value) | ||||
| function! s:tag_strike(value) abort | ||||
|   return '<del>'.s:mid(a:value, 2).'</del>' | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:tag_super(value) | ||||
| function! s:tag_super(value) abort | ||||
|   return '<sup><small>'.s:mid(a:value, 1).'</small></sup>' | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:tag_sub(value) | ||||
| function! s:tag_sub(value) abort | ||||
|   return '<sub><small>'.s:mid(a:value, 2).'</small></sub>' | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:tag_code(value) | ||||
| function! s:tag_code(value) abort | ||||
|   let l:retstr = '<code' | ||||
|  | ||||
|   let l:str = s:mid(a:value, 1) | ||||
|   let l:match = match(l:str, '^#[a-fA-F0-9]\{6\}$') | ||||
|  | ||||
|   if l:match != -1 | ||||
|     let l:r = eval("0x".l:str[1:2]) | ||||
|     let l:g = eval("0x".l:str[3:4]) | ||||
|     let l:b = eval("0x".l:str[5:6]) | ||||
|     let l:r = eval('0x'.l:str[1:2]) | ||||
|     let l:g = eval('0x'.l:str[3:4]) | ||||
|     let l:b = eval('0x'.l:str[5:6]) | ||||
|  | ||||
|     let l:fg_color = | ||||
|           \ (((0.299 * r + 0.587 * g + 0.114 * b) / 0xFF) > 0.5) | ||||
|           \ ? "black" : "white" | ||||
|           \ ? 'black' : 'white' | ||||
|  | ||||
|     let l:retstr .= | ||||
|           \ " style='background-color:" . l:str . | ||||
|           \ ";color:" . l:fg_color . ";'" | ||||
|           \ ';color:' . l:fg_color . ";'" | ||||
|   endif | ||||
|  | ||||
|   let l:retstr .= '>'.s:safe_html_preformatted(l:str).'</code>' | ||||
| @@ -386,7 +386,7 @@ endfunction | ||||
|  | ||||
| "   match n-th ARG within {{URL[|ARG1|ARG2|...]}} | ||||
| " *c,d,e),... | ||||
| function! s:incl_match_arg(nn_index) | ||||
| function! s:incl_match_arg(nn_index) abort | ||||
|   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) | ||||
| @@ -400,10 +400,10 @@ function! s:incl_match_arg(nn_index) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:linkify_link(src, descr) | ||||
| function! s:linkify_link(src, descr) abort | ||||
|   let src_str = ' href="'.s:escape_html_attribute(a:src).'"' | ||||
|   let descr = vimwiki#u#trim(a:descr) | ||||
|   let descr = (descr == "" ? a:src : descr) | ||||
|   let descr = (descr ==? '' ? a:src : descr) | ||||
|   let descr_str = (descr =~# vimwiki#vars#get_global('rxWikiIncl') | ||||
|         \ ? s:tag_wikiincl(descr) | ||||
|         \ : descr) | ||||
| @@ -411,15 +411,15 @@ function! s:linkify_link(src, descr) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:linkify_image(src, descr, verbatim_str) | ||||
| function! s:linkify_image(src, descr, verbatim_str) abort | ||||
|   let src_str = ' src="'.a:src.'"' | ||||
|   let descr_str = (a:descr != '' ? ' alt="'.a:descr.'"' : '') | ||||
|   let verbatim_str = (a:verbatim_str != '' ? ' '.a:verbatim_str : '') | ||||
|   let descr_str = (a:descr !=? '' ? ' alt="'.a:descr.'"' : '') | ||||
|   let verbatim_str = (a:verbatim_str !=? '' ? ' '.a:verbatim_str : '') | ||||
|   return '<img'.src_str.descr_str.verbatim_str.' />' | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:tag_weblink(value) | ||||
| function! s:tag_weblink(value) abort | ||||
|   " Weblink Template -> <a href="url">descr</a> | ||||
|   let str = a:value | ||||
|   let url = matchstr(str, vimwiki#vars#get_syntaxlocal('rxWeblinkMatchUrl')) | ||||
| @@ -429,7 +429,7 @@ function! s:tag_weblink(value) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:tag_wikiincl(value) | ||||
| function! s:tag_wikiincl(value) abort | ||||
|   " {{imgurl|arg1|arg2}}    -> ??? | ||||
|   " {{imgurl}}                -> <img src="imgurl"/> | ||||
|   " {{imgurl|descr|style="A"}} -> <img src="imgurl" alt="descr" style="A" /> | ||||
| @@ -438,7 +438,7 @@ function! s:tag_wikiincl(value) | ||||
|   " custom transclusions | ||||
|   let line = VimwikiWikiIncludeHandler(str) | ||||
|   " otherwise, assume image transclusion | ||||
|   if line == '' | ||||
|   if line ==? '' | ||||
|     let url_0 = matchstr(str, vimwiki#vars#get_global('rxWikiInclMatchUrl')) | ||||
|     let descr = matchstr(str, s:incl_match_arg(1)) | ||||
|     let verbatim_str = matchstr(str, s:incl_match_arg(2)) | ||||
| @@ -463,7 +463,7 @@ function! s:tag_wikiincl(value) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:tag_wikilink(value) | ||||
| function! s:tag_wikilink(value) abort | ||||
|   " [[url]]                   -> <a href="url.html">url</a> | ||||
|   " [[url|descr]]             -> <a href="url.html">descr</a> | ||||
|   " [[url|{{...}}]]           -> <a href="url.html"> ... </a> | ||||
| @@ -475,10 +475,10 @@ function! s:tag_wikilink(value) | ||||
|   let url = matchstr(str, vimwiki#vars#get_syntaxlocal('rxWikiLinkMatchUrl')) | ||||
|   let descr = matchstr(str, vimwiki#vars#get_syntaxlocal('rxWikiLinkMatchDescr')) | ||||
|   let descr = vimwiki#u#trim(descr) | ||||
|   let descr = (descr != '' ? descr : url) | ||||
|   let descr = (descr !=? '' ? descr : url) | ||||
|  | ||||
|   let line = VimwikiLinkConverter(url, s:current_wiki_file, s:current_html_file) | ||||
|   if line == '' | ||||
|   if line ==? '' | ||||
|     let link_infos = vimwiki#base#resolve_link(url, s:current_wiki_file) | ||||
|  | ||||
|     if link_infos.scheme ==# 'file' | ||||
| @@ -492,14 +492,14 @@ function! s:tag_wikilink(value) | ||||
|       let html_link = vimwiki#path#relpath( | ||||
|             \ fnamemodify(s:current_wiki_file, ':h'), | ||||
|             \ fnamemodify(link_infos.filename, ':r')) | ||||
|       if html_link !~ '\m/$' | ||||
|       if html_link !~? '\m/$' | ||||
|         let html_link .= '.html' | ||||
|       endif | ||||
|     else " other schemes, like http, are left untouched | ||||
|       let html_link = link_infos.filename | ||||
|     endif | ||||
|  | ||||
|     if link_infos.anchor != '' | ||||
|     if link_infos.anchor !=? '' | ||||
|       let anchor = substitute(link_infos.anchor, '#', '-', 'g') | ||||
|       let html_link .= '#'.anchor | ||||
|     endif | ||||
| @@ -511,19 +511,19 @@ function! s:tag_wikilink(value) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:tag_remove_internal_link(value) | ||||
| function! s:tag_remove_internal_link(value) abort | ||||
|   let value = s:mid(a:value, 2) | ||||
|  | ||||
|   let line = '' | ||||
|   if value =~# '|' | ||||
|     let link_parts = split(value, "|", 1) | ||||
|     let link_parts = split(value, '|', 1) | ||||
|   else | ||||
|     let link_parts = split(value, "][", 1) | ||||
|     let link_parts = split(value, '][', 1) | ||||
|   endif | ||||
|  | ||||
|   if len(link_parts) > 1 | ||||
|     if len(link_parts) < 3 | ||||
|       let style = "" | ||||
|       let style = '' | ||||
|     else | ||||
|       let style = link_parts[2] | ||||
|     endif | ||||
| @@ -535,7 +535,7 @@ function! s:tag_remove_internal_link(value) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:tag_remove_external_link(value) | ||||
| function! s:tag_remove_external_link(value) abort | ||||
|   let value = s:mid(a:value, 1) | ||||
|  | ||||
|   let line = '' | ||||
| @@ -543,7 +543,7 @@ function! s:tag_remove_external_link(value) | ||||
|     let lnkElements = split(value) | ||||
|     let head = lnkElements[0] | ||||
|     let rest = join(lnkElements[1:]) | ||||
|     if rest == "" | ||||
|     if rest ==? '' | ||||
|       let rest = head | ||||
|     endif | ||||
|     let line = rest | ||||
| @@ -558,7 +558,7 @@ function! s:tag_remove_external_link(value) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:make_tag(line, regexp, func, ...) | ||||
| function! s:make_tag(line, regexp, func, ...) abort | ||||
|   " Make tags for a given matched regexp. | ||||
|   " Exclude preformatted text and href links. | ||||
|   " FIXME | ||||
| @@ -584,7 +584,7 @@ function! s:make_tag(line, regexp, func, ...) | ||||
|     " result: | ||||
|     " ['hello world ', ' simple ', 'type of', ' prg'] | ||||
|     let lines = split(a:line, patt_splitter, 1) | ||||
|     let res_line = "" | ||||
|     let res_line = '' | ||||
|     for line in lines | ||||
|       if a:0 | ||||
|         let res_line = res_line.s:subst_func(line, a:regexp, a:func, a:1) | ||||
| @@ -599,7 +599,7 @@ function! s:make_tag(line, regexp, func, ...) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:process_tags_remove_links(line) | ||||
| function! s:process_tags_remove_links(line) abort | ||||
|   let line = a:line | ||||
|   let line = s:make_tag(line, '\[\[.\{-}\]\]', 's:tag_remove_internal_link') | ||||
|   let line = s:make_tag(line, '\[.\{-}\]', 's:tag_remove_external_link') | ||||
| @@ -607,7 +607,7 @@ function! s:process_tags_remove_links(line) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:process_tags_typefaces(line, header_ids) | ||||
| function! s:process_tags_typefaces(line, header_ids) abort | ||||
|   let line = a:line | ||||
|   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) | ||||
| @@ -622,7 +622,7 @@ function! s:process_tags_typefaces(line, header_ids) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:process_tags_links(line) | ||||
| function! s:process_tags_links(line) abort | ||||
|   let line = a:line | ||||
|   let line = s:make_tag(line, vimwiki#vars#get_syntaxlocal('rxWikiLink'), 's:tag_wikilink') | ||||
|   let line = s:make_tag(line, vimwiki#vars#get_global('rxWikiIncl'), 's:tag_wikiincl') | ||||
| @@ -631,23 +631,23 @@ function! s:process_tags_links(line) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:process_inline_tags(line, header_ids) | ||||
| function! s:process_inline_tags(line, header_ids) abort | ||||
|   let line = s:process_tags_links(a:line) | ||||
|   let line = s:process_tags_typefaces(line, a:header_ids) | ||||
|   return line | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:close_tag_pre(pre, ldest) | ||||
| function! s:close_tag_pre(pre, ldest) abort | ||||
|   if a:pre[0] | ||||
|     call insert(a:ldest, "</pre>") | ||||
|     call insert(a:ldest, '</pre>') | ||||
|     return 0 | ||||
|   endif | ||||
|   return a:pre | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:close_tag_math(math, ldest) | ||||
| function! s:close_tag_math(math, ldest) abort | ||||
|   if a:math[0] | ||||
|     call insert(a:ldest, "\\\]") | ||||
|     return 0 | ||||
| @@ -656,25 +656,25 @@ function! s:close_tag_math(math, ldest) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:close_tag_quote(quote, ldest) | ||||
| function! s:close_tag_quote(quote, ldest) abort | ||||
|   if a:quote | ||||
|     call insert(a:ldest, "</blockquote>") | ||||
|     call insert(a:ldest, '</blockquote>') | ||||
|     return 0 | ||||
|   endif | ||||
|   return a:quote | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:close_tag_para(para, ldest) | ||||
| function! s:close_tag_para(para, ldest) abort | ||||
|   if a:para | ||||
|     call insert(a:ldest, "</p>") | ||||
|     call insert(a:ldest, '</p>') | ||||
|     return 0 | ||||
|   endif | ||||
|   return a:para | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:close_tag_table(table, ldest, header_ids) | ||||
| function! s:close_tag_table(table, ldest, header_ids) abort | ||||
|   " The first element of table list is a string which tells us if table should be centered. | ||||
|   " The rest elements are rows which are lists of columns: | ||||
|   " ['center', | ||||
| @@ -684,7 +684,7 @@ function! s:close_tag_table(table, ldest, header_ids) | ||||
|   " ] | ||||
|   " And CELLx is: { 'body': 'col_x', 'rowspan': r, 'colspan': c } | ||||
|  | ||||
|   function! s:sum_rowspan(table) | ||||
|   function! s:sum_rowspan(table) abort | ||||
|     let table = a:table | ||||
|  | ||||
|     " Get max cells | ||||
| @@ -716,7 +716,7 @@ function! s:close_tag_table(table, ldest, header_ids) | ||||
|     endfor | ||||
|   endfunction | ||||
|  | ||||
|   function! s:sum_colspan(table) | ||||
|   function! s:sum_colspan(table) abort | ||||
|     for row in a:table[1:] | ||||
|       let cols = 1 | ||||
|  | ||||
| @@ -731,7 +731,7 @@ function! s:close_tag_table(table, ldest, header_ids) | ||||
|     endfor | ||||
|   endfunction | ||||
|  | ||||
|   function! s:close_tag_row(row, header, ldest, header_ids) | ||||
|   function! s:close_tag_row(row, header, ldest, header_ids) abort | ||||
|     call add(a:ldest, '<tr>') | ||||
|  | ||||
|     " Set tag element of columns | ||||
| @@ -775,7 +775,7 @@ function! s:close_tag_table(table, ldest, header_ids) | ||||
|     if table[0] ==# 'center' | ||||
|       call add(ldest, "<table class='center'>") | ||||
|     else | ||||
|       call add(ldest, "<table>") | ||||
|       call add(ldest, '<table>') | ||||
|     endif | ||||
|  | ||||
|     " Empty lists are table separators. | ||||
| @@ -803,14 +803,14 @@ function! s:close_tag_table(table, ldest, header_ids) | ||||
|         call s:close_tag_row(row, 0, ldest, a:header_ids) | ||||
|       endfor | ||||
|     endif | ||||
|     call add(ldest, "</table>") | ||||
|     call add(ldest, '</table>') | ||||
|     let table = [] | ||||
|   endif | ||||
|   return table | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:close_tag_list(lists, ldest) | ||||
| function! s:close_tag_list(lists, ldest) abort | ||||
|   while len(a:lists) | ||||
|     let item = remove(a:lists, 0) | ||||
|     call insert(a:ldest, item[0]) | ||||
| @@ -818,16 +818,16 @@ function! s:close_tag_list(lists, ldest) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:close_tag_def_list(deflist, ldest) | ||||
| function! s:close_tag_def_list(deflist, ldest) abort | ||||
|   if a:deflist | ||||
|     call insert(a:ldest, "</dl>") | ||||
|     call insert(a:ldest, '</dl>') | ||||
|     return 0 | ||||
|   endif | ||||
|   return a:deflist | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:process_tag_pre(line, pre) | ||||
| function! s:process_tag_pre(line, pre) abort | ||||
|   " pre is the list of [is_in_pre, indent_of_pre] | ||||
|   "XXX always outputs a single line or empty list! | ||||
|   let lines = [] | ||||
| @@ -839,16 +839,16 @@ function! s:process_tag_pre(line, pre) | ||||
|     let class = matchstr(a:line, '{{{\zs.*$') | ||||
|     "FIXME class cannot contain arbitrary strings | ||||
|     let class = substitute(class, '\s\+$', '', 'g') | ||||
|     if class != "" | ||||
|       call add(lines, "<pre ".class.">") | ||||
|     if class !=? '' | ||||
|       call add(lines, '<pre '.class.'>') | ||||
|     else | ||||
|       call add(lines, "<pre>") | ||||
|       call add(lines, '<pre>') | ||||
|     endif | ||||
|     let pre = [1, len(matchstr(a:line, '^\s*\ze{{{'))] | ||||
|     let processed = 1 | ||||
|   elseif pre[0] && a:line =~# '^\s*}}}\s*$' | ||||
|     let pre = [0, 0] | ||||
|     call add(lines, "</pre>") | ||||
|     call add(lines, '</pre>') | ||||
|     let processed = 1 | ||||
|   elseif pre[0] | ||||
|     let processed = 1 | ||||
| @@ -860,7 +860,7 @@ function! s:process_tag_pre(line, pre) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:process_tag_math(line, math) | ||||
| function! s:process_tag_math(line, math) abort | ||||
|   " math is the list of [is_in_math, indent_of_math] | ||||
|   let lines = [] | ||||
|   let math = a:math | ||||
| @@ -872,9 +872,9 @@ function! s:process_tag_math(line, math) | ||||
|     " store the environment name in a global variable in order to close the | ||||
|     " environment properly | ||||
|     let s:current_math_env = matchstr(class, '^%\zs\S\+\ze%') | ||||
|     if s:current_math_env != "" | ||||
|     if s:current_math_env !=? '' | ||||
|       call add(lines, substitute(class, '^%\(\S\+\)%', '\\begin{\1}', '')) | ||||
|     elseif class != "" | ||||
|     elseif class !=? '' | ||||
|       call add(lines, "\\\[".class) | ||||
|     else | ||||
|       call add(lines, "\\\[") | ||||
| @@ -883,8 +883,8 @@ function! s:process_tag_math(line, math) | ||||
|     let processed = 1 | ||||
|   elseif math[0] && a:line =~# '^\s*}}\$\s*$' | ||||
|     let math = [0, 0] | ||||
|     if s:current_math_env != "" | ||||
|       call add(lines, "\\end{".s:current_math_env."}") | ||||
|     if s:current_math_env !=? '' | ||||
|       call add(lines, "\\end{".s:current_math_env.'}') | ||||
|     else | ||||
|       call add(lines, "\\\]") | ||||
|     endif | ||||
| @@ -897,28 +897,28 @@ function! s:process_tag_math(line, math) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:process_tag_quote(line, quote) | ||||
| function! s:process_tag_quote(line, quote) abort | ||||
|   let lines = [] | ||||
|   let quote = a:quote | ||||
|   let processed = 0 | ||||
|   if a:line =~# '^\s\{4,}\S' | ||||
|     if !quote | ||||
|       call add(lines, "<blockquote>") | ||||
|       call add(lines, '<blockquote>') | ||||
|       let quote = 1 | ||||
|     endif | ||||
|     let processed = 1 | ||||
|     call add(lines, substitute(a:line, '^\s*', '', '')) | ||||
|   elseif quote | ||||
|     call add(lines, "</blockquote>") | ||||
|     call add(lines, '</blockquote>') | ||||
|     let quote = 0 | ||||
|   endif | ||||
|   return [processed, lines, quote] | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:process_tag_list(line, lists) | ||||
| function! s:process_tag_list(line, lists) abort | ||||
|  | ||||
|   function! s:add_checkbox(line, rx_list) | ||||
|   function! s:add_checkbox(line, rx_list) abort | ||||
|     let st_tag = '<li>' | ||||
|     let chk = matchlist(a:line, a:rx_list) | ||||
|     if !empty(chk) && len(chk[1]) > 0 | ||||
| @@ -969,7 +969,7 @@ function! s:process_tag_list(line, lists) | ||||
|     let lstRegExp = '' | ||||
|   endif | ||||
|  | ||||
|   if lstSym != '' | ||||
|   if lstSym !=? '' | ||||
|     " To get proper indent level 'retab' the line -- change all tabs | ||||
|     " to spaces*tabstop | ||||
|     let line = substitute(a:line, '\t', repeat(' ', &tabstop), 'g') | ||||
| @@ -1015,55 +1015,55 @@ function! s:process_tag_list(line, lists) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:process_tag_def_list(line, deflist) | ||||
| function! s:process_tag_def_list(line, deflist) abort | ||||
|   let lines = [] | ||||
|   let deflist = a:deflist | ||||
|   let processed = 0 | ||||
|   let matches = matchlist(a:line, '\(^.*\)::\%(\s\|$\)\(.*\)') | ||||
|   if !deflist && len(matches) > 0 | ||||
|     call add(lines, "<dl>") | ||||
|     call add(lines, '<dl>') | ||||
|     let deflist = 1 | ||||
|   endif | ||||
|   if deflist && len(matches) > 0 | ||||
|     if matches[1] != '' | ||||
|       call add(lines, "<dt>".matches[1]."</dt>") | ||||
|     if matches[1] !=? '' | ||||
|       call add(lines, '<dt>'.matches[1].'</dt>') | ||||
|     endif | ||||
|     if matches[2] != '' | ||||
|       call add(lines, "<dd>".matches[2]."</dd>") | ||||
|     if matches[2] !=? '' | ||||
|       call add(lines, '<dd>'.matches[2].'</dd>') | ||||
|     endif | ||||
|     let processed = 1 | ||||
|   elseif deflist | ||||
|     let deflist = 0 | ||||
|     call add(lines, "</dl>") | ||||
|     call add(lines, '</dl>') | ||||
|   endif | ||||
|   return [processed, lines, deflist] | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:process_tag_para(line, para) | ||||
| function! s:process_tag_para(line, para) abort | ||||
|   let lines = [] | ||||
|   let para = a:para | ||||
|   let processed = 0 | ||||
|   if a:line =~# '^\s\{,3}\S' | ||||
|     if !para | ||||
|       call add(lines, "<p>") | ||||
|       call add(lines, '<p>') | ||||
|       let para = 1 | ||||
|     endif | ||||
|     let processed = 1 | ||||
|     if vimwiki#vars#get_global('text_ignore_newline') | ||||
|       call add(lines, a:line) | ||||
|     else | ||||
|       call add(lines, a:line."<br />") | ||||
|       call add(lines, a:line.'<br />') | ||||
|     endif | ||||
|   elseif para && a:line =~# '^\s*$' | ||||
|     call add(lines, "</p>") | ||||
|     call add(lines, '</p>') | ||||
|     let para = 0 | ||||
|   endif | ||||
|   return [processed, lines, para] | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:process_tag_h(line, id) | ||||
| function! s:process_tag_h(line, id) abort | ||||
|   let line = a:line | ||||
|   let processed = 0 | ||||
|   let h_level = 0 | ||||
| @@ -1092,7 +1092,7 @@ function! s:process_tag_h(line, id) | ||||
|  | ||||
|       for l in range(h_level-1) | ||||
|         let h_number .= a:id[l][1].'.' | ||||
|         if a:id[l][0] != '' | ||||
|         if a:id[l][0] !=? '' | ||||
|           let h_complete_id .= a:id[l][0].'-' | ||||
|         endif | ||||
|       endfor | ||||
| @@ -1134,7 +1134,7 @@ function! s:process_tag_h(line, id) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:process_tag_hr(line) | ||||
| function! s:process_tag_hr(line) abort | ||||
|   let line = a:line | ||||
|   let processed = 0 | ||||
|   if a:line =~# '^-----*$' | ||||
| @@ -1145,8 +1145,8 @@ function! s:process_tag_hr(line) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:process_tag_table(line, table, header_ids) | ||||
|   function! s:table_empty_cell(value) | ||||
| function! s:process_tag_table(line, table, header_ids) abort | ||||
|   function! s:table_empty_cell(value) abort | ||||
|     let cell = {} | ||||
|  | ||||
|     if a:value =~# '^\s*\\/\s*$' | ||||
| @@ -1170,7 +1170,7 @@ function! s:process_tag_table(line, table, header_ids) | ||||
|     return cell | ||||
|   endfunction | ||||
|  | ||||
|   function! s:table_add_row(table, line) | ||||
|   function! s:table_add_row(table, line) abort | ||||
|     if empty(a:table) | ||||
|       if a:line =~# '^\s\+' | ||||
|         let row = ['center', []] | ||||
| @@ -1205,7 +1205,7 @@ function! s:process_tag_table(line, table, header_ids) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:parse_line(line, state) | ||||
| function! s:parse_line(line, state) abort | ||||
|   let state = {} | ||||
|   let state.para = a:state.para | ||||
|   let state.quote = a:state.quote | ||||
| @@ -1428,14 +1428,14 @@ function! s:parse_line(line, state) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:use_custom_wiki2html() | ||||
| function! s:use_custom_wiki2html() abort | ||||
|   let custom_wiki2html = vimwiki#vars#get_wikilocal('custom_wiki2html') | ||||
|   return !empty(custom_wiki2html) && | ||||
|         \ (s:file_exists(custom_wiki2html) || s:binary_exists(custom_wiki2html)) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! vimwiki#html#CustomWiki2HTML(path, wikifile, force) | ||||
| function! vimwiki#html#CustomWiki2HTML(path, wikifile, force) abort | ||||
|   call vimwiki#path#mkdir(a:path) | ||||
|   let output = system(vimwiki#vars#get_wikilocal('custom_wiki2html'). ' '. | ||||
|       \ a:force. ' '. | ||||
| @@ -1455,19 +1455,19 @@ function! vimwiki#html#CustomWiki2HTML(path, wikifile, force) | ||||
|       \ (len(vimwiki#vars#get_wikilocal('custom_wiki2html_args')) > 0 ? | ||||
|       \     vimwiki#vars#get_wikilocal('custom_wiki2html_args') : '-')) | ||||
|   " Echo if non void | ||||
|   if output !~ "^\s*$" | ||||
|   if output !~? '^\s*$' | ||||
|     echomsg output | ||||
|   endif | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:convert_file(path_html, wikifile) | ||||
| function! s:convert_file(path_html, wikifile) abort | ||||
|   let done = 0 | ||||
|  | ||||
|   let wikifile = fnamemodify(a:wikifile, ":p") | ||||
|   let wikifile = fnamemodify(a:wikifile, ':p') | ||||
|  | ||||
|   let path_html = expand(a:path_html).vimwiki#vars#get_bufferlocal('subdir') | ||||
|   let htmlfile = fnamemodify(wikifile, ":t:r").'.html' | ||||
|   let htmlfile = fnamemodify(wikifile, ':t:r').'.html' | ||||
|  | ||||
|   " the currently processed file name is needed when processing links | ||||
|   " yeah yeah, shame on me for using (quasi-) global variables | ||||
| @@ -1511,7 +1511,7 @@ function! s:convert_file(path_html, wikifile) | ||||
|     " prepare constants for s:safe_html_line() | ||||
|     let s:lt_pattern = '<' | ||||
|     let s:gt_pattern = '>' | ||||
|     if vimwiki#vars#get_global('valid_html_tags') != '' | ||||
|     if vimwiki#vars#get_global('valid_html_tags') !=? '' | ||||
|       let tags = join(split(vimwiki#vars#get_global('valid_html_tags'), '\s*,\s*'), '\|') | ||||
|       let s:lt_pattern = '\c<\%(/\?\%('.tags.'\)\%(\s\{-1}\S\{-}\)\{-}/\?>\)\@!' | ||||
|       let s:gt_pattern = '\c\%(</\?\%('.tags.'\)\%(\s\{-1}\S\{-}\)\{-}/\?\)\@<!>' | ||||
| @@ -1549,7 +1549,7 @@ function! s:convert_file(path_html, wikifile) | ||||
|  | ||||
|  | ||||
|     if nohtml | ||||
|       echon "\r"."%nohtml placeholder found" | ||||
|       echon "\r".'%nohtml placeholder found' | ||||
|       return '' | ||||
|     endif | ||||
|  | ||||
| @@ -1567,7 +1567,7 @@ function! s:convert_file(path_html, wikifile) | ||||
|     call s:close_tag_table(state.table, lines, state.header_ids) | ||||
|     call extend(ldest, lines) | ||||
|  | ||||
|     let title = s:process_title(placeholders, fnamemodify(a:wikifile, ":t:r")) | ||||
|     let title = s:process_title(placeholders, fnamemodify(a:wikifile, ':t:r')) | ||||
|     let date = s:process_date(placeholders, strftime('%Y-%m-%d')) | ||||
|     let wiki_path = strpart(s:current_wiki_file, strlen(vimwiki#vars#get_wikilocal('path'))) | ||||
|  | ||||
| @@ -1585,7 +1585,7 @@ function! s:convert_file(path_html, wikifile) | ||||
|     call map(html_lines, 'substitute(v:val, "%css%", "'. css_name .'", "g")') | ||||
|  | ||||
|     let enc = &fileencoding | ||||
|     if enc == '' | ||||
|     if enc ==? '' | ||||
|       let enc = &encoding | ||||
|     endif | ||||
|     call map(html_lines, 'substitute(v:val, "%encoding%", "'. enc .'", "g")') | ||||
| @@ -1606,16 +1606,16 @@ function! s:convert_file(path_html, wikifile) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! vimwiki#html#Wiki2HTML(path_html, wikifile) | ||||
| function! vimwiki#html#Wiki2HTML(path_html, wikifile) abort | ||||
|   let result = s:convert_file(a:path_html, a:wikifile) | ||||
|   if result != '' | ||||
|   if result !=? '' | ||||
|     call s:create_default_CSS(a:path_html) | ||||
|   endif | ||||
|   return result | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! vimwiki#html#WikiAll2HTML(path_html, force) | ||||
| function! vimwiki#html#WikiAll2HTML(path_html, force) abort | ||||
|   if !s:syntax_supported() && !s:use_custom_wiki2html() | ||||
|     echomsg 'Vimwiki Error: Conversion to HTML is not supported for this syntax' | ||||
|     return | ||||
| @@ -1623,7 +1623,7 @@ function! vimwiki#html#WikiAll2HTML(path_html, force) | ||||
|  | ||||
|   echomsg 'Vimwiki: Saving Vimwiki files ...' | ||||
|   let save_eventignore = &eventignore | ||||
|   let &eventignore = "all" | ||||
|   let &eventignore = 'all' | ||||
|   try | ||||
|     wall | ||||
|   catch | ||||
| @@ -1650,7 +1650,7 @@ function! vimwiki#html#WikiAll2HTML(path_html, force) | ||||
|   let wikifiles = split(glob(vimwiki#vars#get_wikilocal('path').'**/*'. | ||||
|         \ vimwiki#vars#get_wikilocal('ext')), '\n') | ||||
|   for wikifile in wikifiles | ||||
|     let wikifile = fnamemodify(wikifile, ":p") | ||||
|     let wikifile = fnamemodify(wikifile, ':p') | ||||
|  | ||||
|     " temporarily adjust 'subdir' and 'invsubdir' state variables | ||||
|     let subdir = vimwiki#base#subdir(vimwiki#vars#get_wikilocal('path'), wikifile) | ||||
| @@ -1680,29 +1680,29 @@ function! vimwiki#html#WikiAll2HTML(path_html, force) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:file_exists(fname) | ||||
| function! s:file_exists(fname) abort | ||||
|   return !empty(getftype(expand(a:fname))) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:binary_exists(fname) | ||||
| function! s:binary_exists(fname) abort | ||||
|   return executable(expand(a:fname)) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:get_wikifile_url(wikifile) | ||||
| function! s:get_wikifile_url(wikifile) abort | ||||
|   return vimwiki#vars#get_wikilocal('path_html') . | ||||
|     \ vimwiki#base#subdir(vimwiki#vars#get_wikilocal('path'), a:wikifile). | ||||
|     \ fnamemodify(a:wikifile, ":t:r").'.html' | ||||
|     \ fnamemodify(a:wikifile, ':t:r').'.html' | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! vimwiki#html#PasteUrl(wikifile) | ||||
| function! vimwiki#html#PasteUrl(wikifile) abort | ||||
|   execute 'r !echo file://'.s:get_wikifile_url(a:wikifile) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! vimwiki#html#CatUrl(wikifile) | ||||
| function! vimwiki#html#CatUrl(wikifile) abort | ||||
|   execute '!echo file://'.s:get_wikifile_url(a:wikifile) | ||||
| endfunction | ||||
|  | ||||
|   | ||||
| @@ -4,7 +4,7 @@ | ||||
| " Home: https://github.com/vimwiki/vimwiki/ | ||||
|  | ||||
|  | ||||
| if exists("g:loaded_vimwiki_list_auto") || &cp | ||||
| if exists('g:loaded_vimwiki_list_auto') || &compatible | ||||
|   finish | ||||
| endif | ||||
| let g:loaded_vimwiki_list_auto = 1 | ||||
| @@ -14,12 +14,12 @@ let g:loaded_vimwiki_list_auto = 1 | ||||
| " incrementation functions for the various kinds of numbers | ||||
| " --------------------------------------------------------- | ||||
|  | ||||
| function! s:increment_1(value) | ||||
| function! s:increment_1(value) abort | ||||
|   return eval(a:value) + 1 | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:increment_A(value) | ||||
| function! s:increment_A(value) abort | ||||
|   let list_of_chars = split(a:value, '.\zs') | ||||
|   let done = 0 | ||||
|   for idx in reverse(range(len(list_of_chars))) | ||||
| @@ -39,7 +39,7 @@ function! s:increment_A(value) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:increment_a(value) | ||||
| function! s:increment_a(value) abort | ||||
|   let list_of_chars = split(a:value, '.\zs') | ||||
|   let done = 0 | ||||
|   for idx in reverse(range(len(list_of_chars))) | ||||
| @@ -59,7 +59,7 @@ function! s:increment_a(value) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:increment_I(value) | ||||
| function! s:increment_I(value) abort | ||||
|   let subst_list = [ ['XLVIII$', 'IL'], ['VIII$', 'IX'], ['III$', 'IV'], | ||||
|         \ ['DCCCXCIX$', 'CM'], ['CCCXCIX$', 'CD'], ['LXXXIX$', 'XC'], | ||||
|         \ ['XXXIX$', 'XL'], ['\(I\{1,2\}\)$', '\1I'], ['CDXCIX$', 'D'], | ||||
| @@ -74,7 +74,7 @@ function! s:increment_I(value) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:increment_i(value) | ||||
| function! s:increment_i(value) abort | ||||
|   let subst_list = [ ['xlviii$', 'il'], ['viii$', 'ix'], ['iii$', 'iv'], | ||||
|         \ ['dcccxcix$', 'cm'], ['cccxcix$', 'cd'], ['lxxxix$', 'xc'], | ||||
|         \ ['xxxix$', 'xl'], ['\(i\{1,2\}\)$', '\1i'], ['cdxcix$', 'd'], | ||||
| @@ -93,41 +93,41 @@ endfunction | ||||
| " utility functions | ||||
| " --------------------------------------------------------- | ||||
|  | ||||
| function! s:substitute_rx_in_line(lnum, pattern, new_string) | ||||
| function! s:substitute_rx_in_line(lnum, pattern, new_string) abort | ||||
|   call setline(a:lnum, substitute(getline(a:lnum), a:pattern, a:new_string, '')) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:substitute_string_in_line(lnum, old_string, new_string) | ||||
| function! s:substitute_string_in_line(lnum, old_string, new_string) abort | ||||
|   call s:substitute_rx_in_line(a:lnum, vimwiki#u#escape(a:old_string), a:new_string) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:first_char(string) | ||||
| function! s:first_char(string) abort | ||||
|   return matchstr(a:string, '^.') | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| if exists("*strdisplaywidth") | ||||
|   function! s:string_length(str) | ||||
| if exists('*strdisplaywidth') | ||||
|   function! s:string_length(str) abort | ||||
|     return strdisplaywidth(a:str) | ||||
|   endfunction | ||||
| else | ||||
|   function! s:string_length(str) | ||||
|   function! s:string_length(str) abort | ||||
|     return strlen(substitute(a:str, '.', 'x', 'g')) | ||||
|   endfunction | ||||
| endif | ||||
|  | ||||
|  | ||||
| function! vimwiki#lst#default_symbol() | ||||
| function! vimwiki#lst#default_symbol() abort | ||||
|   return vimwiki#vars#get_syntaxlocal('list_markers')[0] | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! vimwiki#lst#get_list_margin() | ||||
| function! vimwiki#lst#get_list_margin() abort | ||||
|   let list_margin = vimwiki#vars#get_wikilocal('list_margin') | ||||
|   if list_margin < 0 | ||||
|     return &sw | ||||
|     return &shiftwidth | ||||
|   else | ||||
|     return list_margin | ||||
|   endif | ||||
| @@ -136,7 +136,7 @@ endfunction | ||||
|  | ||||
| "Returns: the column where the text of a line starts (possible list item | ||||
| "markers and checkboxes are skipped) | ||||
| function! s:text_begin(lnum) | ||||
| function! s:text_begin(lnum) abort | ||||
|   return s:string_length(matchstr(getline(a:lnum), vimwiki#vars#get_syntaxlocal('rxListItem'))) | ||||
| endfunction | ||||
|  | ||||
| @@ -144,7 +144,7 @@ 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) | ||||
| function! s:line_has_marker(lnum) abort | ||||
|   if getline(a:lnum) =~# vimwiki#vars#get_syntaxlocal('rxListItem').'\s*$' | ||||
|     return 1 | ||||
|   elseif getline(a:lnum) =~# vimwiki#vars#get_syntaxlocal('rxListItem').'\s*\S' | ||||
| @@ -165,7 +165,7 @@ endfunction | ||||
| "type - 1 for bulleted item, 2 for numbered item, 0 for a regular line | ||||
| "mrkr - the concrete marker, e.g. '**' or 'b)' | ||||
| "cb   - the char in the checkbox or '' if there is no checkbox | ||||
| function! s:get_item(lnum) | ||||
| function! s:get_item(lnum) abort | ||||
|   let item = {'lnum': a:lnum} | ||||
|   if a:lnum == 0 || a:lnum > line('$') | ||||
|     let item.type = 0 | ||||
| @@ -174,15 +174,15 @@ function! s:get_item(lnum) | ||||
|  | ||||
|   let matches = matchlist(getline(a:lnum), vimwiki#vars#get_syntaxlocal('rxListItem')) | ||||
|   if matches == [] || | ||||
|         \ (matches[1] == '' && matches[2] == '') || | ||||
|         \ (matches[1] != '' && matches[2] != '') | ||||
|         \ (matches[1] ==? '' && matches[2] ==? '') || | ||||
|         \ (matches[1] !=? '' && matches[2] !=? '') | ||||
|     let item.type = 0 | ||||
|     return item | ||||
|   endif | ||||
|  | ||||
|   let item.cb = matches[3] | ||||
|  | ||||
|   if matches[1] != '' | ||||
|   if matches[1] !=? '' | ||||
|     let item.type = 1 | ||||
|     let item.mrkr = matches[1] | ||||
|   else | ||||
| @@ -194,14 +194,14 @@ function! s:get_item(lnum) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:empty_item() | ||||
| function! s:empty_item() abort | ||||
|   return {'type': 0} | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| "Returns: level of the line | ||||
| "0 is the 'highest' level | ||||
| function! s:get_level(lnum) | ||||
| function! s:get_level(lnum) abort | ||||
|   if getline(a:lnum) =~# '^\s*$' | ||||
|     return 0 | ||||
|   endif | ||||
| @@ -209,7 +209,7 @@ function! s:get_level(lnum) | ||||
|     let level = indent(a:lnum) | ||||
|   else | ||||
|     let level = s:string_length(matchstr(getline(a:lnum), | ||||
|           \ vimwiki#vars#get_syntaxlocal(rx_bullet_chars)))-1 | ||||
|           \ vimwiki#vars#get_syntaxlocal('rx_bullet_chars')))-1 | ||||
|     if level < 0 | ||||
|       let level = (indent(a:lnum) == 0) ? 0 : 9999 | ||||
|     endif | ||||
| @@ -221,7 +221,7 @@ endfunction | ||||
| "Returns: 1, a, i, A, I or '' | ||||
| "If in doubt if alphanumeric character or romanian | ||||
| "numeral, peek in the previous line | ||||
| function! s:guess_kind_of_numbered_item(item) | ||||
| function! s:guess_kind_of_numbered_item(item) abort | ||||
|   if a:item.type != 2 | return '' | endif | ||||
|   let number_chars = a:item.mrkr[:-2] | ||||
|   let divisor = a:item.mrkr[-1:] | ||||
| @@ -282,14 +282,14 @@ function! s:guess_kind_of_numbered_item(item) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:regexp_of_marker(item) | ||||
| function! s:regexp_of_marker(item) abort | ||||
|   if a:item.type == 1 | ||||
|     return vimwiki#u#escape(a:item.mrkr) | ||||
|   elseif a:item.type == 2 | ||||
|     let number_divisors = vimwiki#vars#get_syntaxlocal('number_divisors') | ||||
|     for ki in ['d', 'u', 'l'] | ||||
|       let match = matchstr(a:item.mrkr, '\'.ki.'\+['.number_divisors.']') | ||||
|       if match != '' | ||||
|       if match !=? '' | ||||
|         return '\'.ki.'\+'.vimwiki#u#escape(match[-1:]) | ||||
|       endif | ||||
|     endfor | ||||
| @@ -300,7 +300,7 @@ endfunction | ||||
|  | ||||
|  | ||||
| " Returns: Whether or not the checkbox of a list item is [X] or [-] | ||||
| function! s:is_closed(item) | ||||
| function! s:is_closed(item) abort | ||||
|   let state = a:item.cb | ||||
|   return state ==# vimwiki#vars#get_syntaxlocal('listsyms_list')[-1] | ||||
|         \ || state ==# vimwiki#vars#get_global('listsym_rejected') | ||||
| @@ -312,7 +312,7 @@ endfunction | ||||
|  | ||||
| "Returns: the list item after a:item or an empty item | ||||
| "If a:ignore_kind is 1, the markers can differ | ||||
| function! s:get_next_list_item(item, ignore_kind) | ||||
| function! s:get_next_list_item(item, ignore_kind) abort | ||||
|   let org_lvl = s:get_level(a:item.lnum) | ||||
|   if !a:ignore_kind | ||||
|     let org_regex = s:regexp_of_marker(a:item) | ||||
| @@ -336,7 +336,7 @@ endfunction | ||||
|  | ||||
| "Returns: the list item before a:item or an empty item | ||||
| "If a:ignore_kind is 1, the markers can differ | ||||
| function! s:get_prev_list_item(item, ignore_kind) | ||||
| function! s:get_prev_list_item(item, ignore_kind) abort | ||||
|   let org_lvl = s:get_level(a:item.lnum) | ||||
|   if !a:ignore_kind | ||||
|     let org_regex = s:regexp_of_marker(a:item) | ||||
| @@ -358,7 +358,7 @@ function! s:get_prev_list_item(item, ignore_kind) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:get_item_of_level(cur_ln, cur_lvl, org_lvl, org_regex) | ||||
| function! s:get_item_of_level(cur_ln, cur_lvl, org_lvl, org_regex) abort | ||||
|   let cur_linecontent = getline(a:cur_ln) | ||||
|   if a:cur_lvl == a:org_lvl | ||||
|     if cur_linecontent =~# '^\s*'.a:org_regex.'\s' | ||||
| @@ -372,7 +372,7 @@ function! s:get_item_of_level(cur_ln, cur_lvl, org_lvl, org_regex) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:get_any_item_of_level(cur_ln, cur_lvl, org_lvl) | ||||
| function! s:get_any_item_of_level(cur_ln, cur_lvl, org_lvl) abort | ||||
|   if a:cur_lvl == a:org_lvl | ||||
|     return s:get_item(a:cur_ln) | ||||
|   elseif a:cur_lvl < a:org_lvl | ||||
| @@ -381,7 +381,7 @@ function! s:get_any_item_of_level(cur_ln, cur_lvl, org_lvl) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:get_first_item_in_list(item, ignore_kind) | ||||
| function! s:get_first_item_in_list(item, ignore_kind) abort | ||||
|   let cur_item = a:item | ||||
|   while 1 | ||||
|     let prev_item = s:get_prev_list_item(cur_item, a:ignore_kind) | ||||
| @@ -395,7 +395,7 @@ function! s:get_first_item_in_list(item, ignore_kind) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:get_last_item_in_list(item, ignore_kind) | ||||
| function! s:get_last_item_in_list(item, ignore_kind) abort | ||||
|   let cur_item = a:item | ||||
|   while 1 | ||||
|     let next_item = s:get_next_list_item(cur_item, a:ignore_kind) | ||||
| @@ -413,7 +413,7 @@ endfunction | ||||
| "0 in case of nonvalid line. | ||||
| "If there is no second argument, 0 is returned at a header, otherwise the | ||||
| "header is skipped | ||||
| function! s:get_next_line(lnum, ...) | ||||
| function! s:get_next_line(lnum, ...) abort | ||||
|   if getline(a:lnum) =~# vimwiki#vars#get_syntaxlocal('rxPreStart') | ||||
|     let cur_ln = a:lnum + 1 | ||||
|     while cur_ln <= line('$') && getline(cur_ln) !~# vimwiki#vars#get_syntaxlocal('rxPreEnd') | ||||
| @@ -441,7 +441,7 @@ endfunction | ||||
|  | ||||
| "Returns: lnum-1 in most cases, but skips blank lines and preformatted text | ||||
| "0 in case of nonvalid line and a header, because a header ends every list | ||||
| function! s:get_prev_line(lnum) | ||||
| function! s:get_prev_line(lnum) abort | ||||
|   let cur_ln = a:lnum - 1 | ||||
|  | ||||
|   if getline(cur_ln) =~# vimwiki#vars#get_syntaxlocal('rxPreEnd') | ||||
| @@ -464,7 +464,7 @@ function! s:get_prev_line(lnum) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:get_first_child(item) | ||||
| function! s:get_first_child(item) abort | ||||
|   if a:item.lnum >= line('$') | ||||
|     return s:empty_item() | ||||
|   endif | ||||
| @@ -485,7 +485,7 @@ endfunction | ||||
| "Returns: the next sibling of a:child, given the parent item | ||||
| "Used for iterating over children | ||||
| "Note: child items do not necessarily have the same indent, i.e. level | ||||
| function! s:get_next_child_item(parent, child) | ||||
| function! s:get_next_child_item(parent, child) abort | ||||
|   if a:parent.type == 0 | return s:empty_item() | endif | ||||
|   let parent_lvl = s:get_level(a:parent.lnum) | ||||
|   let cur_ln = s:get_last_line_of_item_incl_children(a:child) | ||||
| @@ -504,7 +504,7 @@ function! s:get_next_child_item(parent, child) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:get_parent(item) | ||||
| function! s:get_parent(item) abort | ||||
|   let parent_line = 0 | ||||
|  | ||||
|   let cur_ln = prevnonblank(a:item.lnum) | ||||
| @@ -532,7 +532,7 @@ endfunction | ||||
|  | ||||
|  | ||||
| "Returns: the item above or the item below or an empty item | ||||
| function! s:get_a_neighbor_item(item) | ||||
| function! s:get_a_neighbor_item(item) abort | ||||
|   let prev_item = s:get_prev_list_item(a:item, 1) | ||||
|   if prev_item.type != 0 | ||||
|     return prev_item | ||||
| @@ -546,7 +546,7 @@ function! s:get_a_neighbor_item(item) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:get_a_neighbor_item_in_column(lnum, column) | ||||
| function! s:get_a_neighbor_item_in_column(lnum, column) abort | ||||
|   let cur_ln = s:get_prev_line(a:lnum) | ||||
|   while cur_ln >= 1 | ||||
|     if s:get_level(cur_ln) <= a:column | ||||
| @@ -560,7 +560,7 @@ endfunction | ||||
|  | ||||
| "Returns: the item if there is one in a:lnum | ||||
| "else the multiline item a:lnum belongs to | ||||
| function! s:get_corresponding_item(lnum) | ||||
| function! s:get_corresponding_item(lnum) abort | ||||
|   let item = s:get_item(a:lnum) | ||||
|   if item.type != 0 | ||||
|     return item | ||||
| @@ -583,7 +583,7 @@ endfunction | ||||
|  | ||||
|  | ||||
| "Returns: the last line of a (possibly multiline) item, including all children | ||||
| function! s:get_last_line_of_item_incl_children(item) | ||||
| function! s:get_last_line_of_item_incl_children(item) abort | ||||
|   let cur_ln = a:item.lnum | ||||
|   let org_lvl = s:get_level(a:item.lnum) | ||||
|   while 1 | ||||
| @@ -598,7 +598,7 @@ endfunction | ||||
|  | ||||
| "Returns: the last line of a (possibly multiline) item | ||||
| "Note: there can be other list items between the first and last line | ||||
| function! s:get_last_line_of_item(item) | ||||
| function! s:get_last_line_of_item(item) abort | ||||
|   if a:item.type == 0 | return 0 | endif | ||||
|   let org_lvl = s:get_level(a:item.lnum) | ||||
|   let last_corresponding_line = a:item.lnum | ||||
| @@ -627,7 +627,7 @@ endfunction | ||||
|  | ||||
| "Renumbers the current list from a:item on downwards | ||||
| "Returns: the last item that was adjusted | ||||
| function! s:adjust_numbered_list_below(item, recursive) | ||||
| function! s:adjust_numbered_list_below(item, recursive) abort | ||||
|   if !(a:item.type == 2 || (a:item.type == 1 && a:recursive)) | ||||
|     return a:item | ||||
|   endif | ||||
| @@ -657,7 +657,7 @@ function! s:adjust_numbered_list_below(item, recursive) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:adjust_items_recursively(parent) | ||||
| function! s:adjust_items_recursively(parent) abort | ||||
|   if a:parent.type == 0 | ||||
|     return s:empty_item() | ||||
|   end | ||||
| @@ -681,7 +681,7 @@ endfunction | ||||
| "If a:ignore_kind == 0, only the items which have the same kind of marker as | ||||
| "a:item are considered, otherwise all items. | ||||
| "Returns: the last item that was adjusted | ||||
| function! s:adjust_numbered_list(item, ignore_kind, recursive) | ||||
| function! s:adjust_numbered_list(item, ignore_kind, recursive) abort | ||||
|   if !(a:item.type == 2 || (a:item.type == 1 && (a:ignore_kind || a:recursive))) | ||||
|     return s:empty_item() | ||||
|   end | ||||
| @@ -708,7 +708,7 @@ endfunction | ||||
|  | ||||
| "Renumbers the list the cursor is in | ||||
| "also update its parents checkbox state | ||||
| function! vimwiki#lst#adjust_numbered_list() | ||||
| function! vimwiki#lst#adjust_numbered_list() abort | ||||
|   let cur_item = s:get_corresponding_item(line('.')) | ||||
|   if cur_item.type == 0 | return | endif | ||||
|   call s:adjust_numbered_list(cur_item, 1, 0) | ||||
| @@ -718,7 +718,7 @@ endfunction | ||||
|  | ||||
| "Renumbers all lists of the buffer | ||||
| "of course, this might take some seconds | ||||
| function! vimwiki#lst#adjust_whole_buffer() | ||||
| function! vimwiki#lst#adjust_whole_buffer() abort | ||||
|   let cur_ln = 1 | ||||
|   while 1 | ||||
|     let cur_item = s:get_item(cur_ln) | ||||
| @@ -738,8 +738,8 @@ endfunction | ||||
| " --------------------------------------------------------- | ||||
|  | ||||
| "Returns: the rate of checkboxed list item in percent | ||||
| function! s:get_rate(item) | ||||
|   if a:item.type == 0 || a:item.cb == '' | ||||
| function! s:get_rate(item) abort | ||||
|   if a:item.type == 0 || a:item.cb ==? '' | ||||
|     return -1 | ||||
|   endif | ||||
|   let state = a:item.cb | ||||
| @@ -753,7 +753,7 @@ endfunction | ||||
|  | ||||
| "Set state of the list item to [ ] or [o] or whatever | ||||
| "Returns: 1 if the state changed, 0 otherwise | ||||
| function! s:set_state(item, new_rate) | ||||
| function! s:set_state(item, new_rate) abort | ||||
|   let new_state = s:rate_to_state(a:new_rate) | ||||
|   let old_state = s:rate_to_state(s:get_rate(a:item)) | ||||
|   if new_state !=# old_state | ||||
| @@ -768,7 +768,7 @@ endfunction | ||||
| " Sets the state of the list item to [ ] or [o] or whatever. Updates the states of its child items. | ||||
| " If the new state should be [X] or [-], the state of the current list item is changed to this | ||||
| " state, but if a child item already has [X] or [-] it is left alone. | ||||
| function! s:set_state_plus_children(item, new_rate, ...) | ||||
| function! s:set_state_plus_children(item, new_rate, ...) abort | ||||
|   let retain_state_if_closed = a:0 > 0 && a:1 > 0 | ||||
|  | ||||
|   if !(retain_state_if_closed && (a:new_rate == 100 || a:new_rate == -1) && s:is_closed(a:item)) | ||||
| @@ -812,7 +812,7 @@ function! s:set_state_plus_children(item, new_rate, ...) | ||||
|     if child_item.type == 0 | ||||
|       break | ||||
|     endif | ||||
|     if child_item.cb != '' | ||||
|     if child_item.cb !=? '' | ||||
|       call s:set_state_plus_children(child_item, a:new_rate, retain_closed_children) | ||||
|     endif | ||||
|     let child_item = s:get_next_child_item(a:item, child_item) | ||||
| @@ -821,7 +821,7 @@ endfunction | ||||
|  | ||||
|  | ||||
| "Returns: the appropriate symbol for a given percent rate | ||||
| function! s:rate_to_state(rate) | ||||
| function! s:rate_to_state(rate) abort | ||||
|   let listsyms_list = vimwiki#vars#get_syntaxlocal('listsyms_list') | ||||
|   let state = '' | ||||
|   let n = len(listsyms_list) | ||||
| @@ -841,8 +841,8 @@ endfunction | ||||
|  | ||||
| "updates the symbol of a checkboxed item according to the symbols of its | ||||
| "children | ||||
| function! s:update_state(item) | ||||
|   if a:item.type == 0 || a:item.cb == '' | ||||
| function! s:update_state(item) abort | ||||
|   if a:item.type == 0 || a:item.cb ==? '' | ||||
|     return | ||||
|   endif | ||||
|  | ||||
| @@ -856,7 +856,7 @@ function! s:update_state(item) | ||||
|     if child_item.type == 0 | ||||
|       break | ||||
|     endif | ||||
|     if child_item.cb != '' | ||||
|     if child_item.cb !=? '' | ||||
|       let rate = s:get_rate(child_item) | ||||
|       if rate == -1 | ||||
|         " for calculating the parent rate, a [-] item counts as much as a [X] item ... | ||||
| @@ -886,7 +886,7 @@ function! s:update_state(item) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:set_state_recursively(item, new_rate) | ||||
| function! s:set_state_recursively(item, new_rate) abort | ||||
|   let state_changed = s:set_state(a:item, a:new_rate) | ||||
|   if state_changed | ||||
|     call s:update_state(s:get_parent(a:item)) | ||||
| @@ -896,8 +896,8 @@ endfunction | ||||
|  | ||||
| "Creates checkbox in a list item. | ||||
| "Returns: 1 if successful | ||||
| function! s:create_cb(item, start_rate) | ||||
|   if a:item.type == 0 || a:item.cb != '' | ||||
| function! s:create_cb(item, start_rate) abort | ||||
|   if a:item.type == 0 || a:item.cb !=? '' | ||||
|     return 0 | ||||
|   endif | ||||
|  | ||||
| @@ -911,9 +911,9 @@ function! s:create_cb(item, start_rate) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:remove_cb(item) | ||||
| function! s:remove_cb(item) abort | ||||
|   let item = a:item | ||||
|   if item.type != 0 && item.cb != '' | ||||
|   if item.type != 0 && item.cb !=? '' | ||||
|     let item.cb = '' | ||||
|     call s:substitute_rx_in_line(item.lnum, '\s\+\[.\]', '') | ||||
|   endif | ||||
| @@ -922,7 +922,7 @@ endfunction | ||||
|  | ||||
|  | ||||
| " Change state of the checkboxes in the lines of the given range | ||||
| function! s:change_cb(from_line, to_line, new_rate) | ||||
| function! s:change_cb(from_line, to_line, new_rate) abort | ||||
|   let from_item = s:get_corresponding_item(a:from_line) | ||||
|   if from_item.type == 0 | ||||
|     return | ||||
| @@ -932,7 +932,7 @@ function! s:change_cb(from_line, to_line, new_rate) | ||||
|  | ||||
|   for cur_ln in range(from_item.lnum, a:to_line) | ||||
|     let cur_item = s:get_item(cur_ln) | ||||
|     if cur_item.type != 0 && cur_item.cb != '' | ||||
|     if cur_item.type != 0 && cur_item.cb !=? '' | ||||
|       call s:set_state_plus_children(cur_item, a:new_rate) | ||||
|       let cur_parent_item = s:get_parent(cur_item) | ||||
|       if index(parent_items_of_lines, cur_parent_item) == -1 | ||||
| @@ -950,13 +950,13 @@ endfunction | ||||
|  | ||||
| " Toggles checkbox between two states in the lines of the given range, creates checkboxes (with | ||||
| " a:start_rate as state) if there aren't any. | ||||
| function! s:toggle_create_cb(from_line, to_line, state1, state2, start_rate) | ||||
| function! s:toggle_create_cb(from_line, to_line, state1, state2, start_rate) abort | ||||
|   let from_item = s:get_corresponding_item(a:from_line) | ||||
|   if from_item.type == 0 | ||||
|     return | ||||
|   endif | ||||
|  | ||||
|   if from_item.cb == '' | ||||
|   if from_item.cb ==? '' | ||||
|  | ||||
|     "if from_line has no CB, make a CB in every selected line | ||||
|     let parent_items_of_lines = [] | ||||
| @@ -991,7 +991,7 @@ endfunction | ||||
|  | ||||
| "Decrement checkbox between [ ] and [X] | ||||
| "in the lines of the given range | ||||
| function! vimwiki#lst#decrement_cb(from_line, to_line) | ||||
| function! vimwiki#lst#decrement_cb(from_line, to_line) abort | ||||
|   let from_item = s:get_corresponding_item(a:from_line) | ||||
|   if from_item.type == 0 | ||||
|     return | ||||
| @@ -1009,7 +1009,7 @@ endfunction | ||||
|  | ||||
| "Increment checkbox between [ ] and [X] | ||||
| "in the lines of the given range | ||||
| function! vimwiki#lst#increment_cb(from_line, to_line) | ||||
| function! vimwiki#lst#increment_cb(from_line, to_line) abort | ||||
|   let from_item = s:get_corresponding_item(a:from_line) | ||||
|   if from_item.type == 0 | ||||
|     return | ||||
| @@ -1027,19 +1027,19 @@ endfunction | ||||
|  | ||||
| "Toggles checkbox between [ ] and [X] or creates one | ||||
| "in the lines of the given range | ||||
| function! vimwiki#lst#toggle_cb(from_line, to_line) | ||||
| function! vimwiki#lst#toggle_cb(from_line, to_line) abort | ||||
|   return s:toggle_create_cb(a:from_line, a:to_line, 100, 0, 0) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| "Toggles checkbox between [ ] and [-] or creates one | ||||
| "in the lines of the given range | ||||
| function! vimwiki#lst#toggle_rejected_cb(from_line, to_line) | ||||
| function! vimwiki#lst#toggle_rejected_cb(from_line, to_line) abort | ||||
|   return s:toggle_create_cb(a:from_line, a:to_line, -1, 0, -1) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! vimwiki#lst#remove_cb(first_line, last_line) | ||||
| function! vimwiki#lst#remove_cb(first_line, last_line) abort | ||||
|   let first_item = s:get_corresponding_item(a:first_line) | ||||
|   let last_item = s:get_corresponding_item(a:last_line) | ||||
|  | ||||
| @@ -1067,7 +1067,7 @@ function! vimwiki#lst#remove_cb(first_line, last_line) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! vimwiki#lst#remove_cb_in_list() | ||||
| function! vimwiki#lst#remove_cb_in_list() abort | ||||
|   let first_item = s:get_first_item_in_list(s:get_corresponding_item(line('.')), 0) | ||||
|  | ||||
|   let cur_item = first_item | ||||
| @@ -1090,7 +1090,7 @@ endfunction | ||||
| " change the level of list items | ||||
| " --------------------------------------------------------- | ||||
|  | ||||
| function! s:set_indent(lnum, new_indent) | ||||
| function! s:set_indent(lnum, new_indent) abort | ||||
|   if &expandtab | ||||
|     let indentstring = repeat(' ', a:new_indent) | ||||
|   else | ||||
| @@ -1100,7 +1100,7 @@ function! s:set_indent(lnum, new_indent) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:decrease_level(item) | ||||
| function! s:decrease_level(item) abort | ||||
|   let removed_indent = 0 | ||||
|   if vimwiki#vars#get_syntaxlocal('recurring_bullets') && a:item.type == 1 && | ||||
|         \ index(vimwiki#vars#get_syntaxlocal('multiple_bullet_chars'), | ||||
| @@ -1123,7 +1123,7 @@ function! s:decrease_level(item) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:increase_level(item) | ||||
| function! s:increase_level(item) abort | ||||
|   let additional_indent = 0 | ||||
|   if vimwiki#vars#get_syntaxlocal('recurring_bullets') && a:item.type == 1 && | ||||
|         \ index(vimwiki#vars#get_syntaxlocal('multiple_bullet_chars'), | ||||
| @@ -1147,7 +1147,7 @@ endfunction | ||||
|  | ||||
| "adds a:indent_by to the current indent | ||||
| "a:indent_by can be negative | ||||
| function! s:indent_line_by(lnum, indent_by) | ||||
| function! s:indent_line_by(lnum, indent_by) abort | ||||
|   let item = s:get_item(a:lnum) | ||||
|   if vimwiki#vars#get_syntaxlocal('recurring_bullets') && item.type == 1 && | ||||
|         \ index(vimwiki#vars#get_syntaxlocal('multiple_bullet_chars'), | ||||
| @@ -1164,7 +1164,7 @@ endfunction | ||||
|  | ||||
|  | ||||
| "changes lvl of lines in selection | ||||
| function! s:change_level(from_line, to_line, direction, plus_children) | ||||
| function! s:change_level(from_line, to_line, direction, plus_children) abort | ||||
|   let from_item = s:get_corresponding_item(a:from_line) | ||||
|   if from_item.type == 0 | ||||
|     if a:direction ==# 'increase' && a:from_line == a:to_line && empty(getline(a:from_line)) | ||||
| @@ -1227,7 +1227,7 @@ function! s:change_level(from_line, to_line, direction, plus_children) | ||||
|   endif | ||||
|   call s:update_state(old_parent) | ||||
|   let from_item = s:get_item(from_item.lnum) | ||||
|   if from_item.cb != '' | ||||
|   if from_item.cb !=? '' | ||||
|     call s:update_state(from_item) | ||||
|     call s:update_state(s:get_parent(from_item)) | ||||
|   endif | ||||
| @@ -1241,7 +1241,7 @@ function! s:change_level(from_line, to_line, direction, plus_children) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! vimwiki#lst#change_level(from_line, to_line, direction, plus_children) | ||||
| function! vimwiki#lst#change_level(from_line, to_line, direction, plus_children) abort | ||||
|   let cur_col = col('$') - col('.') | ||||
|   call s:change_level(a:from_line, a:to_line, a:direction, a:plus_children) | ||||
|   call cursor('.', col('$') - cur_col) | ||||
| @@ -1249,7 +1249,7 @@ endfunction | ||||
|  | ||||
|  | ||||
| "indent line a:lnum to be the continuation of a:prev_item | ||||
| function! s:indent_multiline(prev_item, lnum) | ||||
| function! s:indent_multiline(prev_item, lnum) abort | ||||
|   if a:prev_item.type != 0 | ||||
|     call s:set_indent(a:lnum, s:text_begin(a:prev_item.lnum)) | ||||
|   endif | ||||
| @@ -1261,7 +1261,7 @@ endfunction | ||||
| " --------------------------------------------------------- | ||||
|  | ||||
| "Returns: the position of a marker in g:vimwiki_list_markers | ||||
| function! s:get_idx_list_markers(item) | ||||
| function! s:get_idx_list_markers(item) abort | ||||
|   if a:item.type == 1 | ||||
|     let m = s:first_char(a:item.mrkr) | ||||
|   else | ||||
| @@ -1272,7 +1272,7 @@ endfunction | ||||
|  | ||||
|  | ||||
| "changes the marker of the given item to the next in g:vimwiki_list_markers | ||||
| function! s:get_next_mrkr(item) | ||||
| function! s:get_next_mrkr(item) abort | ||||
|   let markers = vimwiki#vars#get_syntaxlocal('list_markers') | ||||
|   if a:item.type == 0 | ||||
|     let new_mrkr = markers[0] | ||||
| @@ -1285,7 +1285,7 @@ endfunction | ||||
|  | ||||
|  | ||||
| "changes the marker of the given item to the previous in g:vimwiki_list_markers | ||||
| function! s:get_prev_mrkr(item) | ||||
| function! s:get_prev_mrkr(item) abort | ||||
|   let markers = vimwiki#vars#get_syntaxlocal('list_markers') | ||||
|   if a:item.type == 0 | ||||
|     return markers[-1] | ||||
| @@ -1299,7 +1299,7 @@ function! s:get_prev_mrkr(item) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:set_new_mrkr(item, new_mrkr) | ||||
| function! s:set_new_mrkr(item, new_mrkr) abort | ||||
|   if a:item.type == 0 | ||||
|     call s:substitute_rx_in_line(a:item.lnum, '^\s*\zs\ze', a:new_mrkr.' ') | ||||
|     if indent(a:item.lnum) == 0 && !vimwiki#vars#get_syntaxlocal('recurring_bullets') | ||||
| @@ -1311,16 +1311,16 @@ function! s:set_new_mrkr(item, new_mrkr) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! vimwiki#lst#change_marker(from_line, to_line, new_mrkr, mode) | ||||
|   let cur_col_from_eol = col("$") - (a:mode ==# "i" ? col("'^") : col('.')) | ||||
| function! vimwiki#lst#change_marker(from_line, to_line, new_mrkr, mode) abort | ||||
|   let cur_col_from_eol = col('$') - (a:mode ==# 'i' ? col("'^") : col('.')) | ||||
|   let new_mrkr = a:new_mrkr | ||||
|   let cur_ln = a:from_line | ||||
|   while 1 | ||||
|     let cur_item = s:get_item(cur_ln) | ||||
|  | ||||
|     if new_mrkr ==# "next" | ||||
|     if new_mrkr ==# 'next' | ||||
|       let new_mrkr = s:get_next_mrkr(cur_item) | ||||
|     elseif new_mrkr ==# "prev" | ||||
|     elseif new_mrkr ==# 'prev' | ||||
|       let new_mrkr = s:get_prev_mrkr(cur_item) | ||||
|     endif | ||||
|  | ||||
| @@ -1365,7 +1365,7 @@ function! vimwiki#lst#change_marker(from_line, to_line, new_mrkr, mode) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! vimwiki#lst#change_marker_in_list(new_mrkr) | ||||
| function! vimwiki#lst#change_marker_in_list(new_mrkr) abort | ||||
|   let cur_item = s:get_corresponding_item(line('.')) | ||||
|   let first_item = s:get_first_item_in_list(cur_item, 0) | ||||
|   let last_item = s:get_last_item_in_list(cur_item, 0) | ||||
| @@ -1383,7 +1383,7 @@ endfunction | ||||
|  | ||||
|  | ||||
| "sets kind of the item depending on neighbor items and the parent item | ||||
| function! s:adjust_mrkr(item) | ||||
| function! s:adjust_mrkr(item) abort | ||||
|   if a:item.type == 0 || vimwiki#vars#get_syntaxlocal('recurring_bullets') | ||||
|     return | ||||
|   endif | ||||
| @@ -1409,14 +1409,14 @@ function! s:adjust_mrkr(item) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:clone_marker_from_to(from, to) | ||||
| function! s:clone_marker_from_to(from, to) abort | ||||
|   let item_from = s:get_item(a:from) | ||||
|   if item_from.type == 0 | return | endif | ||||
|   let new_mrkr = item_from.mrkr . ' ' | ||||
|   call s:substitute_rx_in_line(a:to, '^\s*', new_mrkr) | ||||
|   let new_indent = ( vimwiki#vars#get_syntaxlocal('recurring_bullets') ? 0 : indent(a:from) ) | ||||
|   call s:set_indent(a:to, new_indent) | ||||
|   if item_from.cb != '' | ||||
|   if item_from.cb !=? '' | ||||
|     call s:create_cb(s:get_item(a:to), 0) | ||||
|     call s:update_state(s:get_parent(s:get_item(a:to))) | ||||
|   endif | ||||
| @@ -1427,9 +1427,9 @@ function! s:clone_marker_from_to(from, to) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:remove_mrkr(item) | ||||
| function! s:remove_mrkr(item) abort | ||||
|   let item = a:item | ||||
|   if item.cb != '' | ||||
|   if item.cb !=? '' | ||||
|     let item = s:remove_cb(item) | ||||
|     let parent_item = s:get_parent(item) | ||||
|   else | ||||
| @@ -1444,7 +1444,7 @@ function! s:remove_mrkr(item) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:create_marker(lnum) | ||||
| function! s:create_marker(lnum) abort | ||||
|   let new_sibling = s:get_corresponding_item(a:lnum) | ||||
|   if new_sibling.type == 0 | ||||
|     let new_sibling = s:get_a_neighbor_item_in_column(a:lnum, virtcol('.')) | ||||
| @@ -1463,7 +1463,7 @@ endfunction | ||||
| " handle keys | ||||
| " --------------------------------------------------------- | ||||
|  | ||||
| function! vimwiki#lst#kbd_o() | ||||
| function! vimwiki#lst#kbd_o() abort | ||||
|   let fold_end = foldclosedend('.') | ||||
|   let lnum = (fold_end == -1) ? line('.') : fold_end | ||||
|   let cur_item = s:get_item(lnum) | ||||
| @@ -1482,7 +1482,7 @@ function! vimwiki#lst#kbd_o() | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! vimwiki#lst#kbd_O() | ||||
| function! vimwiki#lst#kbd_O() abort | ||||
|   exe 'normal!' "Ox\<C-H>" | ||||
|   let cur_ln = line('.') | ||||
|   if !vimwiki#u#is_codeblock(cur_ln) | ||||
| @@ -1496,7 +1496,7 @@ function! vimwiki#lst#kbd_O() | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:cr_on_empty_list_item(lnum, behavior) | ||||
| function! s:cr_on_empty_list_item(lnum, behavior) abort | ||||
|   if a:behavior == 1 | ||||
|     "just make a new list item | ||||
|     exe 'normal!' "gi\<CR>\<ESC>" | ||||
| @@ -1513,7 +1513,7 @@ function! s:cr_on_empty_list_item(lnum, behavior) | ||||
|     let item = s:get_item(a:lnum) | ||||
|     let neighbor_item = s:get_a_neighbor_item(item) | ||||
|     let child_item = s:get_first_child(item) | ||||
|     let parent_item = (item.cb != '') ? s:get_parent(item) : s:empty_item() | ||||
|     let parent_item = (item.cb !=? '') ? s:get_parent(item) : s:empty_item() | ||||
|     normal! "_cc | ||||
|     call s:adjust_numbered_list(neighbor_item, 0, 0) | ||||
|     call s:adjust_numbered_list(child_item, 0, 0) | ||||
| @@ -1525,7 +1525,7 @@ function! s:cr_on_empty_list_item(lnum, behavior) | ||||
|     let item = s:get_item(a:lnum) | ||||
|     let neighbor_item = s:get_a_neighbor_item(item) | ||||
|     let child_item = s:get_first_child(item) | ||||
|     let parent_item = (item.cb != '') ? s:get_parent(item) : s:empty_item() | ||||
|     let parent_item = (item.cb !=? '') ? s:get_parent(item) : s:empty_item() | ||||
|     exe 'normal!' "_cc\<CR>" | ||||
|     call s:adjust_numbered_list(neighbor_item, 0, 0) | ||||
|     call s:adjust_numbered_list(child_item, 0, 0) | ||||
| @@ -1541,7 +1541,7 @@ function! s:cr_on_empty_list_item(lnum, behavior) | ||||
|       let item = s:get_item(a:lnum) | ||||
|       let neighbor_item = s:get_a_neighbor_item(item) | ||||
|       let child_item = s:get_first_child(item) | ||||
|       let parent_item = (item.cb != '') ? s:get_parent(item) : s:empty_item() | ||||
|       let parent_item = (item.cb !=? '') ? s:get_parent(item) : s:empty_item() | ||||
|       normal! "_cc | ||||
|       call s:adjust_numbered_list(neighbor_item, 0, 0) | ||||
|       call s:adjust_numbered_list(child_item, 0, 0) | ||||
| @@ -1552,7 +1552,7 @@ function! s:cr_on_empty_list_item(lnum, behavior) | ||||
|   endif | ||||
| endfunction | ||||
|  | ||||
| function! s:cr_on_empty_line(lnum, behavior) | ||||
| function! s:cr_on_empty_line(lnum, behavior) abort | ||||
|   let lst = s:get_corresponding_item(a:lnum) | ||||
|  | ||||
|   "inserting and deleting the x is necessary | ||||
| @@ -1570,7 +1570,7 @@ function! s:cr_on_empty_line(lnum, behavior) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:cr_on_list_item(lnum, insert_new_marker, not_at_eol) | ||||
| function! s:cr_on_list_item(lnum, insert_new_marker, not_at_eol) abort | ||||
|   if a:insert_new_marker | ||||
|     "the ultimate feature of this script: make new marker on <CR> | ||||
|     exe 'normal!' "gi\<CR>\<ESC>" | ||||
| @@ -1589,7 +1589,7 @@ function! s:cr_on_list_item(lnum, insert_new_marker, not_at_eol) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! vimwiki#lst#kbd_cr(normal, just_mrkr) | ||||
| function! vimwiki#lst#kbd_cr(normal, just_mrkr) abort | ||||
|   let lnum = line('.') | ||||
|   let has_bp = s:line_has_marker(lnum) | ||||
|  | ||||
| @@ -1608,8 +1608,8 @@ function! vimwiki#lst#kbd_cr(normal, just_mrkr) | ||||
|   if getline('.')[col("'^")-1:] =~# '^\s\+$' | ||||
|     let cur_col = 0 | ||||
|   else | ||||
|     let cur_col = col("$") - col("'^") | ||||
|     if getline('.')[col("'^")-1] =~# '\s' && exists("*strdisplaywidth") | ||||
|     let cur_col = col('$') - col("'^") | ||||
|     if getline('.')[col("'^")-1] =~# '\s' && exists('*strdisplaywidth') | ||||
|       let ws_behind_cursor = | ||||
|             \ strdisplaywidth(matchstr(getline('.')[col("'^")-1:], '\s\+'), | ||||
|             \ virtcol("'^")-1) | ||||
| @@ -1628,7 +1628,7 @@ function! vimwiki#lst#kbd_cr(normal, just_mrkr) | ||||
|     call s:cr_on_list_item(lnum, insert_new_marker, cur_col) | ||||
|   endif | ||||
|  | ||||
|   call cursor(lnum+1, col("$") - cur_col) | ||||
|   call cursor(lnum+1, col('$') - cur_col) | ||||
|   if cur_col == 0 | ||||
|     startinsert! | ||||
|   else | ||||
| @@ -1639,8 +1639,8 @@ endfunction | ||||
|  | ||||
|  | ||||
| "creates a list item in the current line or removes it | ||||
| function! vimwiki#lst#toggle_list_item() | ||||
|   let cur_col_from_eol = col("$") - col("'^") | ||||
| function! vimwiki#lst#toggle_list_item() abort | ||||
|   let cur_col_from_eol = col('$') - col("'^") | ||||
|   let cur_item = s:get_item(line('.')) | ||||
|  | ||||
|   if cur_item.type == 0 | ||||
| @@ -1660,7 +1660,7 @@ function! vimwiki#lst#toggle_list_item() | ||||
|   endif | ||||
|  | ||||
|   "set cursor position s.t. it's on the same char as before | ||||
|   let new_cur_col = col("$") - cur_col_from_eol | ||||
|   let new_cur_col = col('$') - cur_col_from_eol | ||||
|   call cursor(cur_item.lnum, new_cur_col >= 1 ? new_cur_col : 1) | ||||
|  | ||||
|   if cur_col_from_eol == 0 || getline(cur_item.lnum) =~# '^\s*$' | ||||
| @@ -1675,7 +1675,7 @@ endfunction | ||||
| " misc stuff | ||||
| " --------------------------------------------------------- | ||||
|  | ||||
| function! vimwiki#lst#TO_list_item(inner, visual) | ||||
| function! vimwiki#lst#TO_list_item(inner, visual) abort | ||||
|   let lnum = prevnonblank('.') | ||||
|   let item = s:get_corresponding_item(lnum) | ||||
|   if item.type == 0 | ||||
| @@ -1694,7 +1694,7 @@ function! vimwiki#lst#TO_list_item(inner, visual) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! vimwiki#lst#fold_level(lnum) | ||||
| function! vimwiki#lst#fold_level(lnum) abort | ||||
|   let cur_item = s:get_item(a:lnum) | ||||
|   if cur_item.type != 0 | ||||
|     let parent_item = s:get_parent(cur_item) | ||||
|   | ||||
| @@ -4,14 +4,14 @@ | ||||
| " Home: https://github.com/vimwiki/vimwiki/ | ||||
|  | ||||
|  | ||||
| function! s:safesubstitute(text, search, replace, mode) | ||||
| function! s:safesubstitute(text, search, replace, mode) abort | ||||
|   " Substitute regexp but do not interpret replace | ||||
|   let escaped = escape(a:replace, '\&') | ||||
|   return substitute(a:text, a:search, escaped, a:mode) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! vimwiki#markdown_base#scan_reflinks() | ||||
| function! vimwiki#markdown_base#scan_reflinks() abort | ||||
|   let mkd_refs = {} | ||||
|   " construct list of references using vimgrep | ||||
|   try | ||||
| @@ -25,7 +25,7 @@ function! vimwiki#markdown_base#scan_reflinks() | ||||
|     let matchline = join(getline(d.lnum, min([d.lnum+1, line('$')])), ' ') | ||||
|     let descr = matchstr(matchline, vimwiki#vars#get_syntaxlocal('rxMkdRefMatchDescr')) | ||||
|     let url = matchstr(matchline, vimwiki#vars#get_syntaxlocal('rxMkdRefMatchUrl')) | ||||
|     if descr != '' && url != '' | ||||
|     if descr !=? '' && url !=? '' | ||||
|       let mkd_refs[descr] = url | ||||
|     endif | ||||
|   endfor | ||||
| @@ -35,7 +35,7 @@ endfunction | ||||
|  | ||||
|  | ||||
| " try markdown reference links | ||||
| function! vimwiki#markdown_base#open_reflink(link) | ||||
| function! vimwiki#markdown_base#open_reflink(link) abort | ||||
|   " echom "vimwiki#markdown_base#open_reflink" | ||||
|   let link = a:link | ||||
|   let mkd_refs = vimwiki#vars#get_bufferlocal('markdown_refs') | ||||
| @@ -49,7 +49,7 @@ function! vimwiki#markdown_base#open_reflink(link) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:normalize_link_syntax_n() | ||||
| function! s:normalize_link_syntax_n() abort | ||||
|   let lnum = line('.') | ||||
|  | ||||
|   " try WikiIncl | ||||
| @@ -97,7 +97,7 @@ function! s:normalize_link_syntax_n() | ||||
|   " normalize_link_syntax_v | ||||
|   let lnk = vimwiki#base#matchstr_at_cursor(vimwiki#vars#get_global('rxWord')) | ||||
|   if !empty(lnk) | ||||
|     if vimwiki#base#is_diary_file(expand("%:p")) | ||||
|     if vimwiki#base#is_diary_file(expand('%:p')) | ||||
|       let sub = vimwiki#base#normalize_link_in_diary(lnk) | ||||
|     else | ||||
|       let sub = vimwiki#base#normalize_link_helper(lnk, | ||||
| @@ -111,7 +111,7 @@ function! s:normalize_link_syntax_n() | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:normalize_link_syntax_v() | ||||
| function! s:normalize_link_syntax_v() abort | ||||
|   let lnum = line('.') | ||||
|   let sel_save = &selection | ||||
|   let &selection = 'old' | ||||
| @@ -147,7 +147,7 @@ function! s:normalize_link_syntax_v() | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! vimwiki#markdown_base#normalize_link(is_visual_mode) | ||||
| function! vimwiki#markdown_base#normalize_link(is_visual_mode) abort | ||||
|   if 0 | ||||
|     " Syntax-specific links | ||||
|   else | ||||
|   | ||||
| @@ -4,25 +4,25 @@ | ||||
| " Home: https://github.com/vimwiki/vimwiki/ | ||||
|  | ||||
|  | ||||
| function! vimwiki#path#chomp_slash(str) | ||||
| function! vimwiki#path#chomp_slash(str) abort | ||||
|   return substitute(a:str, '[/\\]\+$', '', '') | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| " Define path-compare function, either case-sensitive or not, depending on OS. | ||||
| if vimwiki#u#is_windows() | ||||
|   function! vimwiki#path#is_equal(p1, p2) | ||||
|   function! vimwiki#path#is_equal(p1, p2) abort | ||||
|     return a:p1 ==? a:p2 | ||||
|   endfunction | ||||
| else | ||||
|   function! vimwiki#path#is_equal(p1, p2) | ||||
|   function! vimwiki#path#is_equal(p1, p2) abort | ||||
|     return a:p1 ==# a:p2 | ||||
|   endfunction | ||||
| endif | ||||
|  | ||||
|  | ||||
| " collapse sections like /a/b/../c to /a/c | ||||
| function! vimwiki#path#normalize(path) | ||||
| function! vimwiki#path#normalize(path) abort | ||||
|   let path = a:path | ||||
|   while 1 | ||||
|     let result = substitute(path, '/[^/]\+/\.\.', '', '') | ||||
| @@ -35,7 +35,7 @@ function! vimwiki#path#normalize(path) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! vimwiki#path#path_norm(path) | ||||
| function! vimwiki#path#path_norm(path) abort | ||||
|   " /-slashes | ||||
|   if a:path !~# '^scp:' | ||||
|     let path = substitute(a:path, '\', '/', 'g') | ||||
| @@ -49,21 +49,21 @@ function! vimwiki#path#path_norm(path) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! vimwiki#path#is_link_to_dir(link) | ||||
| function! vimwiki#path#is_link_to_dir(link) abort | ||||
|   " Check if link is to a directory. | ||||
|   " It should be ended with \ or /. | ||||
|   return a:link =~# '\m[/\\]$' | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! vimwiki#path#abs_path_of_link(link) | ||||
|   return vimwiki#path#normalize(expand("%:p:h").'/'.a:link) | ||||
| function! vimwiki#path#abs_path_of_link(link) abort | ||||
|   return vimwiki#path#normalize(expand('%:p:h').'/'.a:link) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| " return longest common path prefix of 2 given paths. | ||||
| " '~/home/usrname/wiki', '~/home/usrname/wiki/shmiki' => '~/home/usrname/wiki' | ||||
| function! vimwiki#path#path_common_pfx(path1, path2) | ||||
| function! vimwiki#path#path_common_pfx(path1, path2) abort | ||||
|   let p1 = split(a:path1, '[/\\]', 1) | ||||
|   let p2 = split(a:path2, '[/\\]', 1) | ||||
|  | ||||
| @@ -80,7 +80,7 @@ function! vimwiki#path#path_common_pfx(path1, path2) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! vimwiki#path#wikify_path(path) | ||||
| function! vimwiki#path#wikify_path(path) abort | ||||
|   let result = resolve(fnamemodify(a:path, ':p')) | ||||
|   if vimwiki#u#is_windows() | ||||
|     let result = substitute(result, '\\', '/', 'g') | ||||
| @@ -90,13 +90,13 @@ function! vimwiki#path#wikify_path(path) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! vimwiki#path#current_wiki_file() | ||||
| function! vimwiki#path#current_wiki_file() abort | ||||
|   return vimwiki#path#wikify_path(expand('%:p')) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| " Returns: the relative path from a:dir to a:file | ||||
| function! vimwiki#path#relpath(dir, file) | ||||
| function! vimwiki#path#relpath(dir, file) abort | ||||
|   let result = [] | ||||
|   if vimwiki#u#is_windows() | ||||
|     " TODO temporary fix see #478 | ||||
| @@ -131,12 +131,12 @@ function! vimwiki#path#relpath(dir, file) | ||||
|   if vimwiki#u#is_windows() | ||||
|     " TODO temporary fix see #478 | ||||
|     let result_path = join(result, '\') | ||||
|     if a:file =~ '\m\\$' | ||||
|     if a:file =~? '\m\\$' | ||||
|       let result_path .= '\' | ||||
|     endif | ||||
|   else | ||||
|     let result_path = join(result, '/') | ||||
|     if a:file =~ '\m/$' | ||||
|     if a:file =~? '\m/$' | ||||
|       let result_path .= '/' | ||||
|     endif | ||||
|   endif | ||||
| @@ -147,7 +147,7 @@ endfunction | ||||
| " If the optional argument provided and nonzero, | ||||
| " it will ask before creating a directory | ||||
| " Returns: 1 iff directory exists or successfully created | ||||
| function! vimwiki#path#mkdir(path, ...) | ||||
| function! vimwiki#path#mkdir(path, ...) abort | ||||
|   let path = expand(a:path) | ||||
|  | ||||
|   if path =~# '^scp:' | ||||
| @@ -158,26 +158,26 @@ function! vimwiki#path#mkdir(path, ...) | ||||
|   if isdirectory(path) | ||||
|     return 1 | ||||
|   else | ||||
|     if !exists("*mkdir") | ||||
|     if !exists('*mkdir') | ||||
|       return 0 | ||||
|     endif | ||||
|  | ||||
|     let path = vimwiki#path#chomp_slash(path) | ||||
|     if vimwiki#u#is_windows() && !empty(vimwiki#vars#get_global('w32_dir_enc')) | ||||
|       let path = iconv(path, &enc, vimwiki#vars#get_global('w32_dir_enc')) | ||||
|       let path = iconv(path, &encoding, vimwiki#vars#get_global('w32_dir_enc')) | ||||
|     endif | ||||
|  | ||||
|     if a:0 && a:1 && input("Vimwiki: Make new directory: ".path."\n [y]es/[N]o? ") !~? '^y' | ||||
|     if a:0 && a:1 && input('Vimwiki: Make new directory: '.path."\n [y]es/[N]o? ") !~? '^y' | ||||
|       return 0 | ||||
|     endif | ||||
|  | ||||
|     call mkdir(path, "p") | ||||
|     call mkdir(path, 'p') | ||||
|     return 1 | ||||
|   endif | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! vimwiki#path#is_absolute(path) | ||||
| function! vimwiki#path#is_absolute(path) abort | ||||
|   if vimwiki#u#is_windows() | ||||
|     return a:path =~? '\m^\a:' | ||||
|   else | ||||
| @@ -191,13 +191,13 @@ endfunction | ||||
| " is because on windows ~\vimwiki//.tags is invalid but ~\vimwiki/.tags is a | ||||
| " valid path. | ||||
| if vimwiki#u#is_windows() | ||||
|   function! vimwiki#path#join_path(directory, file) | ||||
|   function! vimwiki#path#join_path(directory, file) abort | ||||
|     let directory = vimwiki#path#chomp_slash(a:directory) | ||||
|     let file = substitute(a:file, '\m^[\\/]\+', '', '') | ||||
|     return directory . '/' . file | ||||
|   endfunction | ||||
| else | ||||
|   function! vimwiki#path#join_path(directory, file) | ||||
|   function! vimwiki#path#join_path(directory, file) abort | ||||
|     let directory = substitute(a:directory, '\m/\+$', '', '') | ||||
|     let file = substitute(a:file, '\m^/\+', '', '') | ||||
|     return directory . '/' . file | ||||
|   | ||||
| @@ -27,8 +27,8 @@ let s:TAGS_METADATA_FILE_NAME = '.vimwiki_tags' | ||||
| "   a:full_rebuild == 1: re-scan entire wiki | ||||
| "   a:full_rebuild == 0: only re-scan current page | ||||
| "   a:all_files == '':   only if the file is newer than .tags | ||||
| function! vimwiki#tags#update_tags(full_rebuild, all_files) | ||||
|   let all_files = a:all_files != '' | ||||
| function! vimwiki#tags#update_tags(full_rebuild, all_files) abort | ||||
|   let all_files = a:all_files !=? '' | ||||
|   if !a:full_rebuild | ||||
|     " Updating for one page (current) | ||||
|     let page_name = vimwiki#vars#get_bufferlocal('subdir') . expand('%:t:r') | ||||
| @@ -61,7 +61,7 @@ function! vimwiki#tags#update_tags(full_rebuild, all_files) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:safesubstitute(text, search, replace, mode) | ||||
| function! s:safesubstitute(text, search, replace, mode) abort | ||||
|   " Substitute regexp but do not interpret replace | ||||
|   let escaped = escape(a:replace, '\&') | ||||
|   return substitute(a:text, a:search, escaped, a:mode) | ||||
| @@ -69,7 +69,7 @@ endfunction | ||||
|  | ||||
|  | ||||
| "   Scans the list of text lines (argument) and produces tags metadata as a list of tag entries. | ||||
| function! s:scan_tags(lines, page_name) | ||||
| function! s:scan_tags(lines, page_name) abort | ||||
|  | ||||
|   let entries = [] | ||||
|  | ||||
| @@ -103,7 +103,7 @@ function! s:scan_tags(lines, page_name) | ||||
|       else | ||||
|         let current_complete_anchor = '' | ||||
|         for l in range(level-1) | ||||
|           if anchor_level[l] != '' | ||||
|           if anchor_level[l] !=? '' | ||||
|             let current_complete_anchor .= anchor_level[l].'#' | ||||
|           endif | ||||
|         endfor | ||||
| @@ -118,7 +118,7 @@ function! s:scan_tags(lines, page_name) | ||||
|     let str = line | ||||
|     while 1 | ||||
|       let tag_group = matchstr(str, rxtag) | ||||
|       if tag_group == '' | ||||
|       if tag_group ==? '' | ||||
|         break | ||||
|       endif | ||||
|       let tagend = matchend(str, rxtag) | ||||
| @@ -162,11 +162,11 @@ function! s:load_tags_metadata() abort | ||||
|   endif | ||||
|   let metadata = {} | ||||
|   for line in readfile(metadata_path) | ||||
|     if line =~ '^!_TAG_FILE_' | ||||
|     if line =~# '^!_TAG_FILE_' | ||||
|       continue | ||||
|     endif | ||||
|     let parts = matchlist(line, '^\(.\{-}\);"\(.*\)$') | ||||
|     if parts[0] == '' || parts[1] == '' || parts[2] == '' | ||||
|     if parts[0] ==? '' || parts[1] ==? '' || parts[2] ==? '' | ||||
|       throw 'VimwikiTags1: Metadata file corrupted' | ||||
|     endif | ||||
|     let std_fields = split(parts[1], '\t') | ||||
| @@ -174,11 +174,11 @@ function! s:load_tags_metadata() abort | ||||
|       throw 'VimwikiTags2: Metadata file corrupted' | ||||
|     endif | ||||
|     let vw_part = parts[2] | ||||
|     if vw_part[0] != "\t" | ||||
|     if vw_part[0] !=? "\t" | ||||
|       throw 'VimwikiTags3: Metadata file corrupted' | ||||
|     endif | ||||
|     let vw_fields = split(vw_part[1:], "\t") | ||||
|     if len(vw_fields) != 1 || vw_fields[0] !~ '^vimwiki:' | ||||
|     if len(vw_fields) != 1 || vw_fields[0] !~# '^vimwiki:' | ||||
|       throw 'VimwikiTags4: Metadata file corrupted' | ||||
|     endif | ||||
|     let vw_data = substitute(vw_fields[0], '^vimwiki:', '', '') | ||||
| @@ -207,7 +207,7 @@ endfunction | ||||
|  | ||||
| "   Removes all entries for given page from metadata in-place.  Returns updated | ||||
| "   metadata (just in case). | ||||
| function! s:remove_page_from_tags(metadata, page_name) | ||||
| function! s:remove_page_from_tags(metadata, page_name) abort | ||||
|   if has_key(a:metadata, a:page_name) | ||||
|     call remove(a:metadata, a:page_name) | ||||
|     return a:metadata | ||||
| @@ -218,7 +218,7 @@ endfunction | ||||
|  | ||||
|  | ||||
| "   Merges metadata of one file into a:metadata | ||||
| function! s:merge_tags(metadata, pagename, file_metadata) | ||||
| function! s:merge_tags(metadata, pagename, file_metadata) abort | ||||
|   let metadata = a:metadata | ||||
|   let metadata[a:pagename] = a:file_metadata | ||||
|   return metadata | ||||
| @@ -234,7 +234,7 @@ endfunction | ||||
| "   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) | ||||
| function! s:tags_entry_cmp(i1, i2) abort | ||||
|   let items = [] | ||||
|   for orig_item in [a:i1, a:i2] | ||||
|     let fields = split(orig_item, "\t") | ||||
| @@ -258,7 +258,7 @@ endfunction | ||||
|  | ||||
|  | ||||
| "   Saves metadata object into a file. Throws exceptions in case of problems. | ||||
| function! s:write_tags_metadata(metadata) | ||||
| function! s:write_tags_metadata(metadata) abort | ||||
|   let metadata_path = vimwiki#tags#metadata_file_path() | ||||
|   let tags = [] | ||||
|   for pagename in keys(a:metadata) | ||||
| @@ -273,18 +273,18 @@ function! s:write_tags_metadata(metadata) | ||||
|             \ . pagename . vimwiki#vars#get_wikilocal('ext') . "\t" | ||||
|             \ . entry.lineno | ||||
|             \ . ';"' | ||||
|             \ . "\t" . "vimwiki:" . entry_data | ||||
|             \ . "\t" . 'vimwiki:' . entry_data | ||||
|             \) | ||||
|     endfor | ||||
|   endfor | ||||
|   call sort(tags, "s:tags_entry_cmp") | ||||
|   call sort(tags, 's:tags_entry_cmp') | ||||
|   call insert(tags, "!_TAG_FILE_SORTED\t1\t") | ||||
|   call writefile(tags, metadata_path) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| "   Returns list of unique tags found in the .tags file | ||||
| function! vimwiki#tags#get_tags() | ||||
| function! vimwiki#tags#get_tags() abort | ||||
|   let metadata = s:load_tags_metadata() | ||||
|   let tags = {} | ||||
|   for entries in values(metadata) | ||||
| @@ -306,7 +306,7 @@ function! vimwiki#tags#generate_tags(create, ...) abort | ||||
|   " use a dictionary function for closure like capability | ||||
|   " copy all local variables into dict (add a: if arguments are needed) | ||||
|   let GeneratorTags = copy(l:) | ||||
|   function! GeneratorTags.f() | ||||
|   function! GeneratorTags.f() abort | ||||
|     let need_all_tags = empty(self.specific_tags) | ||||
|     let metadata = s:load_tags_metadata() | ||||
|  | ||||
| @@ -334,14 +334,14 @@ function! vimwiki#tags#generate_tags(create, ...) abort | ||||
|         let tag_tpl = printf('rxH%d_Template', self.header_level + 1) | ||||
|         call add(lines, s:safesubstitute(vimwiki#vars#get_syntaxlocal(tag_tpl), '__Header__', tagname, '')) | ||||
|  | ||||
|         if vimwiki#vars#get_wikilocal('syntax') == 'markdown' | ||||
|         if vimwiki#vars#get_wikilocal('syntax') ==# 'markdown' | ||||
|           for _ in range(vimwiki#vars#get_global('markdown_header_style')) | ||||
|             call add(lines, '') | ||||
|           endfor | ||||
|         endif | ||||
|  | ||||
|         for taglink in sort(tags_entries[tagname]) | ||||
|           if vimwiki#vars#get_wikilocal('syntax') == 'markdown' | ||||
|           if vimwiki#vars#get_wikilocal('syntax') ==# 'markdown' | ||||
|             let link_tpl = vimwiki#vars#get_syntaxlocal('Weblink3Template') | ||||
|             let link_infos = vimwiki#base#resolve_link(taglink) | ||||
|             if empty(link_infos.anchor) | ||||
|   | ||||
| @@ -9,23 +9,23 @@ | ||||
|  | ||||
|  | ||||
|  | ||||
| if exists("g:loaded_vimwiki_tbl_auto") || &cp | ||||
| if exists('g:loaded_vimwiki_tbl_auto') || &compatible | ||||
|   finish | ||||
| endif | ||||
| let g:loaded_vimwiki_tbl_auto = 1 | ||||
|  | ||||
|  | ||||
| let s:textwidth = &tw | ||||
| let s:textwidth = &textwidth | ||||
|  | ||||
|  | ||||
| function! s:rxSep() | ||||
| function! s:rxSep() abort | ||||
|   return vimwiki#vars#get_syntaxlocal('rxTableSep') | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:wide_len(str) | ||||
| function! s:wide_len(str) abort | ||||
|   " vim73 has new function that gives correct string width. | ||||
|   if exists("*strdisplaywidth") | ||||
|   if exists('*strdisplaywidth') | ||||
|     return strdisplaywidth(a:str) | ||||
|   endif | ||||
|  | ||||
| @@ -36,8 +36,8 @@ function! s:wide_len(str) | ||||
|     let savemodified = &modified | ||||
|     let save_cursor = getpos('.') | ||||
|     exe "norm! o\<esc>" | ||||
|     call setline(line("."), a:str) | ||||
|     let ret = virtcol("$") - 1 | ||||
|     call setline(line('.'), a:str) | ||||
|     let ret = virtcol('$') - 1 | ||||
|     d | ||||
|     call setpos('.', save_cursor) | ||||
|     let &modified = savemodified | ||||
| @@ -46,51 +46,46 @@ function! s:wide_len(str) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:cell_splitter() | ||||
| function! s:cell_splitter() abort | ||||
|   return '\s*'.s:rxSep().'\s*' | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:sep_splitter() | ||||
| function! s:sep_splitter() abort | ||||
|   return '-'.s:rxSep().'-' | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:is_table(line) | ||||
| function! s:is_table(line) abort | ||||
|   return s:is_separator(a:line) || | ||||
|         \ (a:line !~# s:rxSep().s:rxSep() && a:line =~# '^\s*'.s:rxSep().'.\+'.s:rxSep().'\s*$') | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:is_separator(line) | ||||
| function! s:is_separator(line) abort | ||||
|   return a:line =~# '^\s*'.s:rxSep().'\(:\=--\+:\='.s:rxSep().'\)\+\s*$' | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:is_separator_tail(line) | ||||
| function! s:is_separator_tail(line) abort | ||||
|   return a:line =~# '^\{-1}\%(\s*\|-*\)\%('.s:rxSep().'-\+\)\+'.s:rxSep().'\s*$' | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:is_last_column(lnum, cnum) | ||||
|   return a:line =~# '^\{-1}\%(\s*\|-*\)\%('.s:rxSep().'-\+\)\+'.s:rxSep().'\s*$' | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:is_last_column(lnum, cnum) | ||||
| function! s:is_last_column(lnum, cnum) abort | ||||
|   let line = strpart(getline(a:lnum), a:cnum - 1) | ||||
|   return line =~# s:rxSep().'\s*$'  && line !~# s:rxSep().'.*'.s:rxSep().'\s*$' | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:is_first_column(lnum, cnum) | ||||
| function! s:is_first_column(lnum, cnum) abort | ||||
|   let line = strpart(getline(a:lnum), 0, a:cnum - 1) | ||||
|   return line =~# '^\s*$' || | ||||
|         \ (line =~# '^\s*'.s:rxSep() && line !~# '^\s*'.s:rxSep().'.*'.s:rxSep()) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:count_separators_up(lnum) | ||||
| function! s:count_separators_up(lnum) abort | ||||
|   let lnum = a:lnum - 1 | ||||
|   while lnum > 1 | ||||
|     if !s:is_separator(getline(lnum)) | ||||
| @@ -103,7 +98,7 @@ function! s:count_separators_up(lnum) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:count_separators_down(lnum) | ||||
| function! s:count_separators_down(lnum) abort | ||||
|   let lnum = a:lnum + 1 | ||||
|   while lnum < line('$') | ||||
|     if !s:is_separator(getline(lnum)) | ||||
| @@ -116,9 +111,9 @@ function! s:count_separators_down(lnum) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:create_empty_row(cols) | ||||
| function! s:create_empty_row(cols) abort | ||||
|   let row = s:rxSep() | ||||
|   let cell = "   ".s:rxSep() | ||||
|   let cell = '   '.s:rxSep() | ||||
|  | ||||
|   for c in range(a:cols) | ||||
|     let row .= cell | ||||
| @@ -128,9 +123,9 @@ function! s:create_empty_row(cols) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:create_row_sep(cols) | ||||
| function! s:create_row_sep(cols) abort | ||||
|   let row = s:rxSep() | ||||
|   let cell = "---".s:rxSep() | ||||
|   let cell = '---'.s:rxSep() | ||||
|  | ||||
|   for c in range(a:cols) | ||||
|     let row .= cell | ||||
| @@ -140,7 +135,7 @@ function! s:create_row_sep(cols) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! vimwiki#tbl#get_cells(line, ...) | ||||
| function! vimwiki#tbl#get_cells(line, ...) abort | ||||
|   let result = [] | ||||
|   let state = 'NONE' | ||||
|   let cell_start = 0 | ||||
| @@ -148,23 +143,23 @@ function! vimwiki#tbl#get_cells(line, ...) | ||||
|   let len = strlen(a:line) - 1 | ||||
|  | ||||
|   " 'Simple' FSM | ||||
|   while state != 'CELL' | ||||
|     if quote_start != 0 && state != 'CELL' | ||||
|   while state !=# 'CELL' | ||||
|     if quote_start != 0 && state !=# 'CELL' | ||||
|       let state = 'CELL' | ||||
|     endif | ||||
|     for idx in range(quote_start, len) | ||||
|       " The only way I know Vim can do Unicode... | ||||
|       let ch = a:line[idx] | ||||
|       if state ==# 'NONE' | ||||
|         if ch == '|' | ||||
|         if ch ==# '|' | ||||
|           let cell_start = idx + 1 | ||||
|           let state = 'CELL' | ||||
|         endif | ||||
|       elseif state ==# 'CELL' | ||||
|         if ch == '[' || ch == '{' | ||||
|         if ch ==# '[' || ch ==# '{' | ||||
|           let state = 'BEFORE_QUOTE_START' | ||||
|           let quote_start = idx | ||||
|         elseif ch == '|' | ||||
|         elseif ch ==# '|' | ||||
|           let cell = strpart(a:line, cell_start, idx - cell_start) | ||||
|           if a:0 && a:1 | ||||
|             let cell = substitute(cell, '^ \(.*\) $', '\1', '') | ||||
| @@ -175,23 +170,23 @@ function! vimwiki#tbl#get_cells(line, ...) | ||||
|           let cell_start = idx + 1 | ||||
|         endif | ||||
|       elseif state ==# 'BEFORE_QUOTE_START' | ||||
|         if ch == '[' || ch == '{' | ||||
|         if ch ==# '[' || ch ==# '{' | ||||
|           let state = 'QUOTE' | ||||
|           let quote_start = idx | ||||
|         else | ||||
|           let state = 'CELL' | ||||
|         endif | ||||
|       elseif state ==# 'QUOTE' | ||||
|         if ch == ']' || ch == '}' | ||||
|         if ch ==# ']' || ch ==# '}' | ||||
|           let state = 'BEFORE_QUOTE_END' | ||||
|         endif | ||||
|       elseif state ==# 'BEFORE_QUOTE_END' | ||||
|         if ch == ']' || ch == '}' | ||||
|         if ch ==# ']' || ch ==# '}' | ||||
|           let state = 'CELL' | ||||
|         endif | ||||
|       endif | ||||
|     endfor | ||||
|     if state == 'NONE' | ||||
|     if state ==# 'NONE' | ||||
|       break | ||||
|     endif | ||||
|   endwhile | ||||
| @@ -200,12 +195,12 @@ function! vimwiki#tbl#get_cells(line, ...) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:col_count(lnum) | ||||
| function! s:col_count(lnum) abort | ||||
|   return len(vimwiki#tbl#get_cells(getline(a:lnum))) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:get_indent(lnum, depth) | ||||
| function! s:get_indent(lnum, depth) abort | ||||
|   if !s:is_table(getline(a:lnum)) | ||||
|     return | ||||
|   endif | ||||
| @@ -229,7 +224,7 @@ function! s:get_indent(lnum, depth) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:get_rows(lnum, ...) | ||||
| function! s:get_rows(lnum, ...) abort | ||||
|   if !s:is_table(getline(a:lnum)) | ||||
|     return | ||||
|   endif | ||||
| @@ -268,7 +263,7 @@ function! s:get_rows(lnum, ...) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:get_cell_aligns(lnum, ...) | ||||
| function! s:get_cell_aligns(lnum, ...) abort | ||||
|   let aligns = {} | ||||
|   let depth = a:0 > 0 ? a:1 : 0 | ||||
|   for [lnum, row] in s:get_rows(a:lnum, depth) | ||||
| @@ -297,7 +292,7 @@ function! s:get_cell_aligns(lnum, ...) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:get_cell_aligns_fast(rows) | ||||
| function! s:get_cell_aligns_fast(rows) abort | ||||
|   let aligns = {} | ||||
|   let clen = 0 | ||||
|   for [lnum, row] in a:rows | ||||
| @@ -333,7 +328,7 @@ function! s:get_cell_aligns_fast(rows) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:get_cell_max_lens(lnum, ...) | ||||
| function! s:get_cell_max_lens(lnum, ...) abort | ||||
|   let max_lens = {} | ||||
|   let rows = a:0 > 2 ? a:3 : s:get_rows(a:lnum) | ||||
|   for [lnum, row] in rows | ||||
| @@ -354,7 +349,7 @@ function! s:get_cell_max_lens(lnum, ...) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:get_aligned_rows(lnum, col1, col2, depth) | ||||
| function! s:get_aligned_rows(lnum, col1, col2, depth) abort | ||||
|   let rows = [] | ||||
|   let aligns = {} | ||||
|   let startlnum = 0 | ||||
| @@ -423,7 +418,7 @@ endfunction | ||||
|  | ||||
|  | ||||
| " Number of the current column. Starts from 0. | ||||
| function! s:cur_column() | ||||
| function! s:cur_column() abort | ||||
|   let line = getline('.') | ||||
|   if !s:is_table(line) | ||||
|     return -1 | ||||
| @@ -443,16 +438,16 @@ function! s:cur_column() | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:fmt_cell(cell, max_len, align) | ||||
| function! s:fmt_cell(cell, max_len, align) abort | ||||
|   let cell = ' '.a:cell.' ' | ||||
|  | ||||
|   let diff = a:max_len - s:wide_len(a:cell) | ||||
|   if diff == 0 && empty(a:cell) | ||||
|     let diff = 1 | ||||
|   endif | ||||
|   if a:align == 'left' | ||||
|   if a:align ==# 'left' | ||||
|     let cell .= repeat(' ', diff) | ||||
|   elseif a:align == 'right' | ||||
|   elseif a:align ==# 'right' | ||||
|     let cell = repeat(' ',diff).cell | ||||
|   else | ||||
|     let cell = repeat(' ',diff/2).cell.repeat(' ',diff-diff/2) | ||||
| @@ -461,7 +456,7 @@ function! s:fmt_cell(cell, max_len, align) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:fmt_row(cells, max_lens, aligns, col1, col2) | ||||
| function! s:fmt_row(cells, max_lens, aligns, col1, col2) abort | ||||
|   let new_line = s:rxSep() | ||||
|   for idx in range(len(a:cells)) | ||||
|     if idx == a:col1 | ||||
| @@ -482,16 +477,16 @@ function! s:fmt_row(cells, max_lens, aligns, col1, col2) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:fmt_cell_sep(max_len, align) | ||||
| function! s:fmt_cell_sep(max_len, align) abort | ||||
|   let cell = '' | ||||
|   if a:max_len == 0 | ||||
|     let cell .= '-' | ||||
|   else | ||||
|     let cell .= repeat('-', a:max_len) | ||||
|   endif | ||||
|   if a:align == 'right' | ||||
|   if a:align ==# 'right' | ||||
|     return cell.'-:' | ||||
|   elseif a:align == 'left' | ||||
|   elseif a:align ==# 'left' | ||||
|     return cell.'--' | ||||
|   else | ||||
|     return ':'.cell.':' | ||||
| @@ -499,7 +494,7 @@ function! s:fmt_cell_sep(max_len, align) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:fmt_sep(max_lens, aligns, col1, col2) | ||||
| function! s:fmt_sep(max_lens, aligns, col1, col2) abort | ||||
|   let new_line = s:rxSep() | ||||
|   for idx in range(len(a:max_lens)) | ||||
|     if idx == a:col1 | ||||
| @@ -513,42 +508,42 @@ function! s:fmt_sep(max_lens, aligns, col1, col2) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:kbd_create_new_row(cols, goto_first) | ||||
| function! s:kbd_create_new_row(cols, goto_first) abort | ||||
|   let cmd = "\<ESC>o".s:create_empty_row(a:cols) | ||||
|   let cmd .= "\<ESC>:call vimwiki#tbl#format(line('.'), 2)\<CR>" | ||||
|   let cmd .= "\<ESC>0" | ||||
|   if a:goto_first | ||||
|     let cmd .= ":call search('\\(".s:rxSep()."\\)\\zs', 'c', line('.'))\<CR>" | ||||
|   else | ||||
|     let cmd .= (col('.')-1)."l" | ||||
|     let cmd .= (col('.')-1).'l' | ||||
|     let cmd .= ":call search('\\(".s:rxSep()."\\)\\zs', 'bc', line('.'))\<CR>" | ||||
|   endif | ||||
|   let cmd .= "a" | ||||
|   let cmd .= 'a' | ||||
|  | ||||
|   return cmd | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:kbd_goto_next_row() | ||||
| function! s:kbd_goto_next_row() abort | ||||
|   let cmd = "\<ESC>j" | ||||
|   let cmd .= ":call search('.\\(".s:rxSep()."\\)', 'c', line('.'))\<CR>" | ||||
|   let cmd .= ":call search('\\(".s:rxSep()."\\)\\zs', 'bc', line('.'))\<CR>" | ||||
|   let cmd .= "a" | ||||
|   let cmd .= 'a' | ||||
|   return cmd | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:kbd_goto_prev_row() | ||||
| function! s:kbd_goto_prev_row() abort | ||||
|   let cmd = "\<ESC>k" | ||||
|   let cmd .= ":call search('.\\(".s:rxSep()."\\)', 'c', line('.'))\<CR>" | ||||
|   let cmd .= ":call search('\\(".s:rxSep()."\\)\\zs', 'bc', line('.'))\<CR>" | ||||
|   let cmd .= "a" | ||||
|   let cmd .= 'a' | ||||
|   return cmd | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| " Used in s:kbd_goto_next_col | ||||
| function! vimwiki#tbl#goto_next_col() | ||||
| function! vimwiki#tbl#goto_next_col() abort | ||||
|   let curcol = virtcol('.') | ||||
|   let lnum = line('.') | ||||
|   let depth = 2 | ||||
| @@ -571,11 +566,11 @@ function! vimwiki#tbl#goto_next_col() | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:kbd_goto_next_col(jumpdown) | ||||
| function! s:kbd_goto_next_col(jumpdown) abort | ||||
|   let cmd = "\<ESC>" | ||||
|   if a:jumpdown | ||||
|     let seps = s:count_separators_down(line('.')) | ||||
|     let cmd .= seps."j0" | ||||
|     let cmd .= seps.'j0' | ||||
|   endif | ||||
|   let cmd .= ":call vimwiki#tbl#goto_next_col()\<CR>a" | ||||
|   return cmd | ||||
| @@ -583,7 +578,7 @@ endfunction | ||||
|  | ||||
|  | ||||
| " Used in s:kbd_goto_prev_col | ||||
| function! vimwiki#tbl#goto_prev_col() | ||||
| function! vimwiki#tbl#goto_prev_col() abort | ||||
|   let curcol = virtcol('.') | ||||
|   let lnum = line('.') | ||||
|   let depth = 2 | ||||
| @@ -612,12 +607,12 @@ function! vimwiki#tbl#goto_prev_col() | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:kbd_goto_prev_col(jumpup) | ||||
| function! s:kbd_goto_prev_col(jumpup) abort | ||||
|   let cmd = "\<ESC>" | ||||
|   if a:jumpup | ||||
|     let seps = s:count_separators_up(line('.')) | ||||
|     let cmd .= seps."k" | ||||
|     let cmd .= "$" | ||||
|     let cmd .= seps.'k' | ||||
|     let cmd .= '$' | ||||
|   endif | ||||
|   let cmd .= ":call vimwiki#tbl#goto_prev_col()\<CR>a" | ||||
|   " let cmd .= ":call search('\\(".s:rxSep()."\\)\\zs', 'b', line('.'))\<CR>" | ||||
| @@ -627,10 +622,10 @@ function! s:kbd_goto_prev_col(jumpup) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! vimwiki#tbl#kbd_cr() | ||||
| function! vimwiki#tbl#kbd_cr() abort | ||||
|   let lnum = line('.') | ||||
|   if !s:is_table(getline(lnum)) | ||||
|     return "" | ||||
|     return '' | ||||
|   endif | ||||
|  | ||||
|   if s:is_separator(getline(lnum+1)) || !s:is_table(getline(lnum+1)) | ||||
| @@ -642,7 +637,7 @@ function! vimwiki#tbl#kbd_cr() | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! vimwiki#tbl#kbd_tab() | ||||
| function! vimwiki#tbl#kbd_tab() abort | ||||
|   let lnum = line('.') | ||||
|   if !s:is_table(getline(lnum)) | ||||
|     return "\<Tab>" | ||||
| @@ -659,7 +654,7 @@ function! vimwiki#tbl#kbd_tab() | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! vimwiki#tbl#kbd_shift_tab() | ||||
| function! vimwiki#tbl#kbd_shift_tab() abort | ||||
|   let lnum = line('.') | ||||
|   if !s:is_table(getline(lnum)) | ||||
|     return "\<S-Tab>" | ||||
| @@ -669,13 +664,13 @@ function! vimwiki#tbl#kbd_shift_tab() | ||||
|   let is_sep = s:is_separator_tail(getline(lnum)) | ||||
|   "echomsg "DEBUG kbd_tab> ".first | ||||
|   if (is_sep || first) && !s:is_table(getline(lnum-1)) | ||||
|     return "" | ||||
|     return '' | ||||
|   endif | ||||
|   return s:kbd_goto_prev_col(is_sep || first) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! vimwiki#tbl#format(lnum, ...) | ||||
| function! vimwiki#tbl#format(lnum, ...) abort | ||||
|   if !(&filetype ==? 'vimwiki') | ||||
|     return | ||||
|   endif | ||||
| @@ -709,11 +704,11 @@ function! vimwiki#tbl#format(lnum, ...) | ||||
|     endif | ||||
|   endfor | ||||
|  | ||||
|   let &tw = s:textwidth | ||||
|   let &textwidth = s:textwidth | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! vimwiki#tbl#create(...) | ||||
| function! vimwiki#tbl#create(...) abort | ||||
|   if a:0 > 1 | ||||
|     let cols = a:1 | ||||
|     let rows = a:2 | ||||
| @@ -749,7 +744,7 @@ function! vimwiki#tbl#create(...) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! vimwiki#tbl#align_or_cmd(cmd, ...) | ||||
| function! vimwiki#tbl#align_or_cmd(cmd, ...) abort | ||||
|   if s:is_table(getline('.')) | ||||
|     call call('vimwiki#tbl#format', [line('.')] + a:000) | ||||
|   else | ||||
| @@ -758,7 +753,7 @@ function! vimwiki#tbl#align_or_cmd(cmd, ...) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! vimwiki#tbl#reset_tw(lnum) | ||||
| function! vimwiki#tbl#reset_tw(lnum) abort | ||||
|   if !(&filetype ==? 'vimwiki') | ||||
|     return | ||||
|   endif | ||||
| @@ -767,13 +762,13 @@ function! vimwiki#tbl#reset_tw(lnum) | ||||
|     return | ||||
|   endif | ||||
|  | ||||
|   let s:textwidth = &tw | ||||
|   let &tw = 0 | ||||
|   let s:textwidth = &textwidth | ||||
|   let &textwidth = 0 | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| " TODO: move_column_left and move_column_right are good candidates to be refactored. | ||||
| function! vimwiki#tbl#move_column_left() | ||||
| function! vimwiki#tbl#move_column_left() abort | ||||
|  | ||||
|   "echomsg "DEBUG move_column_left: " | ||||
|  | ||||
| @@ -808,7 +803,7 @@ function! vimwiki#tbl#move_column_left() | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! vimwiki#tbl#move_column_right() | ||||
| function! vimwiki#tbl#move_column_right() abort | ||||
|  | ||||
|   let line = getline('.') | ||||
|  | ||||
| @@ -840,27 +835,27 @@ function! vimwiki#tbl#move_column_right() | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! vimwiki#tbl#get_rows(lnum) | ||||
| function! vimwiki#tbl#get_rows(lnum) abort | ||||
|   return s:get_rows(a:lnum) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! vimwiki#tbl#is_table(line) | ||||
| function! vimwiki#tbl#is_table(line) abort | ||||
|   return s:is_table(a:line) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! vimwiki#tbl#is_separator(line) | ||||
| function! vimwiki#tbl#is_separator(line) abort | ||||
|   return s:is_separator(a:line) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! vimwiki#tbl#cell_splitter() | ||||
| function! vimwiki#tbl#cell_splitter() abort | ||||
|   return s:cell_splitter() | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! vimwiki#tbl#sep_splitter() | ||||
| function! vimwiki#tbl#sep_splitter() abort | ||||
|   return s:sep_splitter() | ||||
| endfunction | ||||
|  | ||||
|   | ||||
| @@ -3,7 +3,7 @@ | ||||
| " Description: Utility functions | ||||
| " Home: https://github.com/vimwiki/vimwiki/ | ||||
|  | ||||
| function! vimwiki#u#trim(string, ...) | ||||
| function! vimwiki#u#trim(string, ...) abort | ||||
|   let chars = '' | ||||
|   if a:0 > 0 | ||||
|     let chars = a:1 | ||||
| @@ -15,58 +15,58 @@ endfunction | ||||
|  | ||||
|  | ||||
| " Builtin cursor doesn't work right with unicode characters. | ||||
| function! vimwiki#u#cursor(lnum, cnum) | ||||
| function! vimwiki#u#cursor(lnum, cnum) abort | ||||
|   exe a:lnum | ||||
|   exe 'normal! 0'.a:cnum.'|' | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! vimwiki#u#is_windows() | ||||
|   return has("win32") || has("win64") || has("win95") || has("win16") | ||||
| function! vimwiki#u#is_windows() abort | ||||
|   return has('win32') || has('win64') || has('win95') || has('win16') | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! vimwiki#u#is_macos() | ||||
|   if has("mac") || has("macunix") || has("gui_mac") | ||||
| function! vimwiki#u#is_macos() abort | ||||
|   if has('mac') || has('macunix') || has('gui_mac') | ||||
|     return 1 | ||||
|   endif | ||||
|   " that still doesn't mean we are not on Mac OS | ||||
|   let os = substitute(system('uname'), '\n', '', '') | ||||
|   return os == 'Darwin' || os == 'Mac' | ||||
|   return os ==? 'Darwin' || os ==? 'Mac' | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! vimwiki#u#count_first_sym(line) | ||||
| function! vimwiki#u#count_first_sym(line) abort | ||||
|   let first_sym = matchstr(a:line, '\S') | ||||
|   return len(matchstr(a:line, first_sym.'\+')) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! vimwiki#u#escape(string) | ||||
| function! vimwiki#u#escape(string) abort | ||||
|   return escape(a:string, '~.*[]\^$') | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| " Load concrete Wiki syntax: sets regexes and templates for headers and links | ||||
| function vimwiki#u#reload_regexes() | ||||
| function! vimwiki#u#reload_regexes() abort | ||||
|   execute 'runtime! syntax/vimwiki_'.vimwiki#vars#get_wikilocal('syntax').'.vim' | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| " Load syntax-specific functionality | ||||
| function vimwiki#u#reload_regexes_custom() | ||||
| function! vimwiki#u#reload_regexes_custom() abort | ||||
|   execute 'runtime! syntax/vimwiki_'.vimwiki#vars#get_wikilocal('syntax').'_custom.vim' | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| " Backward compatible version of the built-in function shiftwidth() | ||||
| if exists('*shiftwidth') | ||||
|   func vimwiki#u#sw() | ||||
|   function! vimwiki#u#sw() abort | ||||
|     return shiftwidth() | ||||
|   endfunc | ||||
| else | ||||
|   func vimwiki#u#sw() | ||||
|     return &sw | ||||
|   function! vimwiki#u#sw() abort | ||||
|     return &shiftwidth | ||||
|   endfunc | ||||
| endif | ||||
|  | ||||
| @@ -77,7 +77,7 @@ endif | ||||
| "   if a:1==1 then the hasmapto(<Plug>) check is skipped. | ||||
| "     this can be used to map different keys to the same <Plug> definition | ||||
| "   if a:1==2 then the mapping is not <buffer> specific i.e. it is global | ||||
| function vimwiki#u#map_key(mode, key, plug, ...) | ||||
| function! vimwiki#u#map_key(mode, key, plug, ...) abort | ||||
|   if a:0 && a:1 == 2 | ||||
|     " global mappings | ||||
|     if !hasmapto(a:plug) && maparg(a:key, a:mode) ==# '' | ||||
| @@ -95,7 +95,7 @@ function vimwiki#u#map_key(mode, key, plug, ...) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! vimwiki#u#is_codeblock(lnum) | ||||
| function! vimwiki#u#is_codeblock(lnum) abort | ||||
|   let syn_g = synIDattr(synID(a:lnum,1,1),'name') | ||||
|   if  syn_g =~# 'textSnip.*' | ||||
|         \ || syn_g =~# 'VimwikiPre.*' | ||||
|   | ||||
| @@ -26,7 +26,7 @@ | ||||
| " ------------------------------------------------------------------------------------------------ | ||||
|  | ||||
|  | ||||
| function! s:populate_global_variables() | ||||
| function! s:populate_global_variables() abort | ||||
|  | ||||
|   let g:vimwiki_global_vars = {} | ||||
|  | ||||
| @@ -139,7 +139,7 @@ function! s:populate_global_variables() | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:read_global_settings_from_user() | ||||
| function! s:read_global_settings_from_user() abort | ||||
|   let global_settings = { | ||||
|         \ 'CJK_length': {'type': type(0), 'default': 0, 'min': 0, 'max': 1}, | ||||
|         \ 'auto_chdir': {'type': type(0), 'default': 0, 'min': 0, 'max': 1}, | ||||
| @@ -243,7 +243,7 @@ function! s:read_global_settings_from_user() | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:normalize_global_settings() | ||||
| function! s:normalize_global_settings() abort | ||||
|   let keys = keys(g:vimwiki_global_vars.ext2syntax) | ||||
|   for ext in keys | ||||
|     " for convenience, we also allow the term 'mediawiki' | ||||
| @@ -254,7 +254,7 @@ function! s:normalize_global_settings() | ||||
|     " ensure the file extensions in ext2syntax start with a dot | ||||
|     " make sure this occurs after anything else that tries to access | ||||
|     " the entry using the index 'ext' since this removes that index | ||||
|     if ext[0] != '.' | ||||
|     if ext[0] !=# '.' | ||||
|       let new_ext = '.' . ext | ||||
|       let g:vimwiki_global_vars.ext2syntax[new_ext] = g:vimwiki_global_vars.ext2syntax[ext] | ||||
|       call remove(g:vimwiki_global_vars.ext2syntax, ext) | ||||
| @@ -321,7 +321,7 @@ function! s:normalize_global_settings() | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:populate_wikilocal_options() | ||||
| function! s:populate_wikilocal_options() abort | ||||
|   let default_values = { | ||||
|         \ 'auto_diary_index': {'type': type(0), 'default': 0, 'min': 0, 'max': 1}, | ||||
|         \ 'auto_export': {'type': type(0), 'default': 0, 'min': 0, 'max': 1}, | ||||
| @@ -415,7 +415,7 @@ function! s:populate_wikilocal_options() | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:check_users_value(key, users_value, value_infos, comes_from_global_variable) | ||||
| function! s:check_users_value(key, users_value, value_infos, comes_from_global_variable) abort | ||||
|   let type_code_to_name = { | ||||
|         \ type(0): 'number', | ||||
|         \ type(''): 'string', | ||||
| @@ -473,7 +473,7 @@ function! s:check_users_value(key, users_value, value_infos, comes_from_global_v | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:normalize_wikilocal_settings() | ||||
| function! s:normalize_wikilocal_settings() abort | ||||
|   for wiki_settings in g:vimwiki_wikilocal_vars | ||||
|     let wiki_settings['path'] = s:normalize_path(wiki_settings['path']) | ||||
|  | ||||
| @@ -489,7 +489,7 @@ function! s:normalize_wikilocal_settings() | ||||
|     let wiki_settings['diary_rel_path'] = s:normalize_path(wiki_settings['diary_rel_path']) | ||||
|  | ||||
|     let ext = wiki_settings['ext'] | ||||
|     if !empty(ext) && ext[0] != '.' | ||||
|     if !empty(ext) && ext[0] !=# '.' | ||||
|       let wiki_settings['ext'] = '.' . ext | ||||
|     endif | ||||
|  | ||||
| @@ -501,7 +501,7 @@ function! s:normalize_wikilocal_settings() | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:normalize_path(path) | ||||
| function! s:normalize_path(path) abort | ||||
|   " trim trailing / and \ because otherwise resolve() doesn't work quite right | ||||
|   let path = substitute(a:path, '[/\\]\+$', '', '') | ||||
|   if path !~# '^scp:' | ||||
| @@ -512,7 +512,7 @@ function! s:normalize_path(path) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! vimwiki#vars#populate_syntax_vars(syntax) | ||||
| function! vimwiki#vars#populate_syntax_vars(syntax) abort | ||||
|   if !exists('g:vimwiki_syntax_variables') | ||||
|     let g:vimwiki_syntax_variables = {} | ||||
|   endif | ||||
| @@ -626,7 +626,7 @@ function! vimwiki#vars#populate_syntax_vars(syntax) | ||||
|   if match(vimwiki#vars#get_global('listsyms'), vimwiki#vars#get_global('listsym_rejected')) != -1 | ||||
|     echomsg 'Vimwiki Warning: the value of g:vimwiki_listsym_rejected (''' | ||||
|           \ . vimwiki#vars#get_global('listsym_rejected') | ||||
|           \ . ''') must not be a part of g:vimwiki_listsyms (''' . | ||||
|           \ . ''') must not be a part of g:vimwiki_listsyms (''' | ||||
|           \ . vimwiki#vars#get_global('listsyms') . ''')' | ||||
|   endif | ||||
|   let g:vimwiki_syntax_variables[a:syntax].rxListItemWithoutCB = | ||||
| @@ -698,7 +698,7 @@ function! vimwiki#vars#populate_syntax_vars(syntax) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:populate_extra_markdown_vars() | ||||
| function! s:populate_extra_markdown_vars() abort | ||||
|   let mkd_syntax = g:vimwiki_syntax_variables['markdown'] | ||||
|  | ||||
|   " 0a) match [[URL|DESCRIPTION]] | ||||
| @@ -867,13 +867,13 @@ function! s:populate_extra_markdown_vars() | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! vimwiki#vars#init() | ||||
| function! vimwiki#vars#init() abort | ||||
|   call s:populate_global_variables() | ||||
|   call s:populate_wikilocal_options() | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! vimwiki#vars#get_syntaxlocal(key, ...) | ||||
| function! vimwiki#vars#get_syntaxlocal(key, ...) abort | ||||
|   if a:0 | ||||
|     let syntax = a:1 | ||||
|   else | ||||
| @@ -889,7 +889,7 @@ endfunction | ||||
|  | ||||
| " Get a variable for the buffer we are currently in or for the given buffer (number or name). | ||||
| " Populate the variable, if it doesn't exist. | ||||
| function! vimwiki#vars#get_bufferlocal(key, ...) | ||||
| function! vimwiki#vars#get_bufferlocal(key, ...) abort | ||||
|   let buffer = a:0 ? a:1 : '%' | ||||
|  | ||||
|   " 'get(getbufvar(...' handles vim < v7.3.831 that didn't allow a default value for getbufvar | ||||
| @@ -921,20 +921,20 @@ function! vimwiki#vars#get_bufferlocal(key, ...) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! vimwiki#vars#set_bufferlocal(key, value, ...) | ||||
| function! vimwiki#vars#set_bufferlocal(key, value, ...) abort | ||||
|   let buffer = a:0 ? a:1 : '%' | ||||
|   call setbufvar(buffer, 'vimwiki_' . a:key, a:value) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! vimwiki#vars#get_global(key) | ||||
| function! vimwiki#vars#get_global(key) abort | ||||
|   return g:vimwiki_global_vars[a:key] | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| " the second argument can be a wiki number. When absent, the wiki of the currently active buffer is | ||||
| " used | ||||
| function! vimwiki#vars#get_wikilocal(key, ...) | ||||
| function! vimwiki#vars#get_wikilocal(key, ...) abort | ||||
|   if a:0 | ||||
|     return g:vimwiki_wikilocal_vars[a:1][a:key] | ||||
|   else | ||||
| @@ -943,12 +943,12 @@ function! vimwiki#vars#get_wikilocal(key, ...) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! vimwiki#vars#get_wikilocal_default(key) | ||||
| function! vimwiki#vars#get_wikilocal_default(key) abort | ||||
|   return g:vimwiki_wikilocal_vars[-1][a:key] | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! vimwiki#vars#set_wikilocal(key, value, wiki_nr) | ||||
| function! vimwiki#vars#set_wikilocal(key, value, wiki_nr) abort | ||||
|   if a:wiki_nr == len(g:vimwiki_wikilocal_vars) - 1 | ||||
|     call insert(g:vimwiki_wikilocal_vars, {}, -1) | ||||
|   endif | ||||
| @@ -956,7 +956,7 @@ function! vimwiki#vars#set_wikilocal(key, value, wiki_nr) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! vimwiki#vars#add_temporary_wiki(settings) | ||||
| function! vimwiki#vars#add_temporary_wiki(settings) abort | ||||
|   let new_temp_wiki_settings = copy(g:vimwiki_wikilocal_vars[-1]) | ||||
|   for [key, value] in items(a:settings) | ||||
|     let new_temp_wiki_settings[key] = value | ||||
| @@ -967,6 +967,6 @@ endfunction | ||||
|  | ||||
|  | ||||
| " number of registered wikis + temporary | ||||
| function! vimwiki#vars#number_of_wikis() | ||||
| function! vimwiki#vars#number_of_wikis() abort | ||||
|   return len(g:vimwiki_wikilocal_vars) - 1 | ||||
| endfunction | ||||
|   | ||||
| @@ -2,7 +2,7 @@ | ||||
| " Vimwiki filetype plugin file | ||||
| " Home: https://github.com/vimwiki/vimwiki/ | ||||
|  | ||||
| if exists("b:did_ftplugin") | ||||
| if exists('b:did_ftplugin') | ||||
|   finish | ||||
| endif | ||||
| let b:did_ftplugin = 1  " Don't load another plugin for this buffer | ||||
| @@ -11,7 +11,7 @@ let b:did_ftplugin = 1  " Don't load another plugin for this buffer | ||||
|  | ||||
| setlocal commentstring=%%%s | ||||
|  | ||||
| if vimwiki#vars#get_global('conceallevel') && exists("+conceallevel") | ||||
| if vimwiki#vars#get_global('conceallevel') && exists('+conceallevel') | ||||
|   let &l:conceallevel = vimwiki#vars#get_global('conceallevel') | ||||
| endif | ||||
|  | ||||
| @@ -19,11 +19,11 @@ endif | ||||
| execute 'setlocal suffixesadd='.vimwiki#vars#get_wikilocal('ext') | ||||
| setlocal isfname-=[,] | ||||
|  | ||||
| exe "setlocal tags+=" . escape(vimwiki#tags#metadata_file_path(), ' \|"') | ||||
| exe 'setlocal tags+=' . escape(vimwiki#tags#metadata_file_path(), ' \|"') | ||||
|  | ||||
|  | ||||
|  | ||||
| function! Complete_wikifiles(findstart, base) | ||||
| function! Complete_wikifiles(findstart, base) abort | ||||
|   if a:findstart == 1 | ||||
|     let column = col('.')-2 | ||||
|     let line = getline('.')[:column] | ||||
| @@ -50,14 +50,14 @@ function! Complete_wikifiles(findstart, base) | ||||
|     " Completion works for wikilinks/anchors, and for tags. s:line_content | ||||
|     " tells us which string came before a:base. There seems to be no easier | ||||
|     " solution, because calling col('.') here returns garbage. | ||||
|     if s:line_context == '' | ||||
|     if s:line_context ==? '' | ||||
|       return [] | ||||
|     elseif s:line_context == ':' | ||||
|     elseif s:line_context ==# ':' | ||||
|       " Tags completion | ||||
|       let tags = vimwiki#tags#get_tags() | ||||
|       if a:base != '' | ||||
|       if a:base !=? '' | ||||
|         call filter(tags, | ||||
|             \ "v:val[:" . (len(a:base)-1) . "] == '" . substitute(a:base, "'", "''", '') . "'" ) | ||||
|             \ 'v:val[:' . (len(a:base)-1) . "] == '" . substitute(a:base, "'", "''", '') . "'" ) | ||||
|       endif | ||||
|       return tags | ||||
|     elseif a:base !~# '#' | ||||
| @@ -93,7 +93,7 @@ function! Complete_wikifiles(findstart, base) | ||||
|       " we look for anchors in the given wikifile | ||||
|  | ||||
|       let segments = split(a:base, '#', 1) | ||||
|       let given_wikifile = segments[0] == '' ? expand('%:t:r') : segments[0] | ||||
|       let given_wikifile = segments[0] ==? '' ? expand('%:t:r') : segments[0] | ||||
|       let link_infos = vimwiki#base#resolve_link(given_wikifile.'#') | ||||
|       let wikifile = link_infos.filename | ||||
|       let syntax = vimwiki#vars#get_wikilocal('syntax', link_infos.index) | ||||
| @@ -134,12 +134,12 @@ let &formatlistpat = vimwiki#vars#get_syntaxlocal('rxListItem') | ||||
| " Folding stuff | ||||
| " ------------------------------------------------ | ||||
|  | ||||
| function! VimwikiFoldListLevel(lnum) | ||||
| function! VimwikiFoldListLevel(lnum) abort | ||||
|   return vimwiki#lst#fold_level(a:lnum) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! VimwikiFoldLevel(lnum) | ||||
| function! VimwikiFoldLevel(lnum) abort | ||||
|   let line = getline(a:lnum) | ||||
|  | ||||
|   " Header/section folding... | ||||
| @@ -151,21 +151,21 @@ function! VimwikiFoldLevel(lnum) | ||||
|   elseif line =~# vimwiki#vars#get_syntaxlocal('rxPreEnd') | ||||
|     return 's1' | ||||
|   else | ||||
|     return "=" | ||||
|     return '=' | ||||
|   endif | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| " Constants used by VimwikiFoldText | ||||
| " use \u2026 and \u21b2 (or \u2424) if enc=utf-8 to save screen space | ||||
| let s:ellipsis = (&enc ==? 'utf-8') ? "\u2026" : "..." | ||||
| let s:ellipsis = (&encoding ==? 'utf-8') ? "\u2026" : '...' | ||||
| let s:ell_len = strlen(s:ellipsis) | ||||
| let s:newline = (&enc ==? 'utf-8') ? "\u21b2 " : "  " | ||||
| let s:newline = (&encoding ==? 'utf-8') ? "\u21b2 " : '  ' | ||||
| let s:tolerance = 5 | ||||
|  | ||||
|  | ||||
| " unused | ||||
| function! s:shorten_text_simple(text, len) | ||||
| function! s:shorten_text_simple(text, len) abort | ||||
|   let spare_len = a:len - len(a:text) | ||||
|   return (spare_len>=0) ? [a:text,spare_len] : [a:text[0:a:len].s:ellipsis, -1] | ||||
| endfunction | ||||
| @@ -174,7 +174,7 @@ endfunction | ||||
| " s:shorten_text(text, len) = [string, spare] with "spare" = len-strlen(string) | ||||
| " for long enough "text", the string's length is within s:tolerance of "len" | ||||
| " (so that -s:tolerance <= spare <= s:tolerance, "string" ends with s:ellipsis) | ||||
| function! s:shorten_text(text, len) | ||||
| function! s:shorten_text(text, len) abort | ||||
|   " returns [string, spare] | ||||
|   " strlen() returns lenght in bytes, not in characters, so we'll have to do a | ||||
|   " trick here -- replace all non-spaces with dot, calculate lengths and | ||||
| @@ -192,7 +192,7 @@ function! s:shorten_text(text, len) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! VimwikiFoldText() | ||||
| function! VimwikiFoldText() abort | ||||
|   let line = getline(v:foldstart) | ||||
|   let main_text = substitute(line, '^\s*', repeat(' ',indent(v:foldstart)), '') | ||||
|   let fold_len = v:foldend - v:foldstart + 1 | ||||
| @@ -518,10 +518,10 @@ if str2nr(vimwiki#vars#get_global('key_mappings').lists) | ||||
|   endif | ||||
| endif | ||||
|  | ||||
| function! s:CR(normal, just_mrkr) | ||||
| function! s:CR(normal, just_mrkr) abort | ||||
|   let res = vimwiki#tbl#kbd_cr() | ||||
|   if res != "" | ||||
|     exe "normal! " . res . "\<Right>" | ||||
|   if res !=? '' | ||||
|     exe 'normal! ' . res . "\<Right>" | ||||
|     startinsert | ||||
|     return | ||||
|   endif | ||||
|   | ||||
| @@ -4,7 +4,7 @@ | ||||
| " GetLatestVimScripts: 2226 1 :AutoInstall: vimwiki | ||||
|  | ||||
|  | ||||
| if exists("g:loaded_vimwiki") || &cp | ||||
| if exists('g:loaded_vimwiki') || &compatible | ||||
|   finish | ||||
| endif | ||||
| let g:loaded_vimwiki = 1 | ||||
| @@ -15,8 +15,8 @@ let s:plugin_vers = -1 | ||||
| " Get the directory the script is installed in | ||||
| let s:plugin_dir = expand('<sfile>:p:h:h') | ||||
|  | ||||
| let s:old_cpo = &cpo | ||||
| set cpo&vim | ||||
| let s:old_cpo = &cpoptions | ||||
| set cpoptions&vim | ||||
|  | ||||
|  | ||||
| if exists('g:vimwiki_autowriteall') | ||||
| @@ -27,7 +27,7 @@ endif | ||||
|  | ||||
|  | ||||
| " this is called when the cursor leaves the buffer | ||||
| function! s:setup_buffer_leave() | ||||
| function! s:setup_buffer_leave() abort | ||||
|   " don't do anything if it's not managed by Vimwiki (that is, when it's not in | ||||
|   " a registered wiki and not a temporary wiki) | ||||
|   if vimwiki#vars#get_bufferlocal('wiki_nr') == -1 | ||||
| @@ -43,7 +43,7 @@ endfunction | ||||
|  | ||||
|  | ||||
| " create a new temporary wiki for the current buffer | ||||
| function! s:create_temporary_wiki() | ||||
| function! s:create_temporary_wiki() abort | ||||
|   let path = expand('%:p:h') | ||||
|   let ext = '.'.expand('%:e') | ||||
|  | ||||
| @@ -70,7 +70,7 @@ endfunction | ||||
| " This function is called when Vim opens a new buffer with a known wiki | ||||
| " extension. Both when the buffer has never been opened in this session and | ||||
| " when it has. | ||||
| function! s:setup_new_wiki_buffer() | ||||
| function! s:setup_new_wiki_buffer() abort | ||||
|   let wiki_nr = vimwiki#vars#get_bufferlocal('wiki_nr') | ||||
|   if wiki_nr == -1    " it's not in a known wiki directory | ||||
|     if vimwiki#vars#get_global('global_ext') | ||||
| @@ -95,7 +95,7 @@ endfunction | ||||
|  | ||||
|  | ||||
| " this is called when the cursor enters the buffer | ||||
| function! s:setup_buffer_enter() | ||||
| function! s:setup_buffer_enter() abort | ||||
|   " don't do anything if it's not managed by Vimwiki (that is, when it's not in | ||||
|   " a registered wiki and not a temporary wiki) | ||||
|   if vimwiki#vars#get_bufferlocal('wiki_nr') == -1 | ||||
| @@ -107,14 +107,14 @@ endfunction | ||||
|  | ||||
|  | ||||
| " this is called when the buffer enters a window or when running a  diff | ||||
| function! s:setup_buffer_win_enter() | ||||
| function! s:setup_buffer_win_enter() abort | ||||
|   " don't do anything if it's not managed by Vimwiki (that is, when it's not in | ||||
|   " a registered wiki and not a temporary wiki) | ||||
|   if vimwiki#vars#get_bufferlocal('wiki_nr') == -1 | ||||
|     return | ||||
|   endif | ||||
|  | ||||
|   if &filetype != 'vimwiki' | ||||
|   if &filetype !=# 'vimwiki' | ||||
|     setfiletype vimwiki | ||||
|   endif | ||||
|  | ||||
| @@ -122,7 +122,7 @@ function! s:setup_buffer_win_enter() | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:setup_cleared_syntax() | ||||
| function! s:setup_cleared_syntax() abort | ||||
|   " highlight groups that get cleared | ||||
|   " on colorscheme change because they are not linked to Vim-predefined groups | ||||
|   hi def VimwikiBold term=bold cterm=bold gui=bold | ||||
| @@ -132,15 +132,15 @@ function! s:setup_cleared_syntax() | ||||
|   if vimwiki#vars#get_global('hl_headers') == 1 | ||||
|     for i in range(1,6) | ||||
|       execute 'hi def VimwikiHeader'.i.' guibg=bg guifg=' | ||||
|             \ . vimwiki#vars#get_global('hcolor_guifg_'.&bg)[i-1] | ||||
|             \ .' gui=bold ctermfg='.vimwiki#vars#get_global('hcolor_ctermfg_'.&bg)[i-1] | ||||
|             \ . vimwiki#vars#get_global('hcolor_guifg_'.&background)[i-1] | ||||
|             \ .' gui=bold ctermfg='.vimwiki#vars#get_global('hcolor_ctermfg_'.&background)[i-1] | ||||
|             \ .' term=bold cterm=bold' | ||||
|     endfor | ||||
|   endif | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:vimwiki_get_known_extensions() | ||||
| function! s:vimwiki_get_known_extensions() abort | ||||
|   " Getting all extensions that different wikis could have | ||||
|   let extensions = {} | ||||
|   for idx in range(vimwiki#vars#number_of_wikis()) | ||||
| @@ -158,7 +158,7 @@ endfunction | ||||
| " Set settings which are global for Vim, but should only be executed for | ||||
| " Vimwiki buffers. So they must be set when the cursor enters a Vimwiki buffer | ||||
| " and reset when the cursor leaves the buffer. | ||||
| function! s:set_global_options() | ||||
| function! s:set_global_options() abort | ||||
|   let s:vimwiki_autowriteall_saved = &autowriteall | ||||
|   let &autowriteall = vimwiki#vars#get_global('autowriteall') | ||||
|  | ||||
| @@ -171,7 +171,7 @@ endfunction | ||||
| " Set settings which are local to a window. In a new tab they would be reset to | ||||
| " Vim defaults. So we enforce our settings here when the cursor enters a | ||||
| " Vimwiki buffer. | ||||
| function! s:set_windowlocal_options() | ||||
| function! s:set_windowlocal_options() abort | ||||
|   if !&diff   " if Vim is currently in diff mode, don't interfere with its folding | ||||
|     let foldmethod = vimwiki#vars#get_global('folding') | ||||
|     if foldmethod =~? '^expr.*' | ||||
| @@ -193,7 +193,7 @@ function! s:set_windowlocal_options() | ||||
|     endif | ||||
|   endif | ||||
|  | ||||
|   if vimwiki#vars#get_global('conceallevel') && exists("+conceallevel") | ||||
|   if vimwiki#vars#get_global('conceallevel') && exists('+conceallevel') | ||||
|     let &conceallevel = vimwiki#vars#get_global('conceallevel') | ||||
|   endif | ||||
|  | ||||
| @@ -203,19 +203,19 @@ function! s:set_windowlocal_options() | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:get_version() | ||||
| function! s:get_version() abort | ||||
|   if s:plugin_vers != -1 | ||||
|     echo "Stable version: " . string(s:plugin_vers) | ||||
|     echo 'Stable version: ' . string(s:plugin_vers) | ||||
|   else | ||||
|     let l:plugin_rev    = system("git --git-dir " . s:plugin_dir . "/.git rev-parse --short HEAD") | ||||
|     let l:plugin_branch = system("git --git-dir " . s:plugin_dir . "/.git rev-parse --abbrev-ref HEAD") | ||||
|     let l:plugin_date   = system("git --git-dir " . s:plugin_dir . "/.git show -s --format=%ci") | ||||
|     let l:plugin_rev    = system('git --git-dir ' . s:plugin_dir . '/.git rev-parse --short HEAD') | ||||
|     let l:plugin_branch = system('git --git-dir ' . s:plugin_dir . '/.git rev-parse --abbrev-ref HEAD') | ||||
|     let l:plugin_date   = system('git --git-dir ' . s:plugin_dir . '/.git show -s --format=%ci') | ||||
|     if v:shell_error == 0 | ||||
|       echo "Branch: " . l:plugin_branch | ||||
|       echo "Revision: " . l:plugin_rev | ||||
|       echo "Date: " . l:plugin_date | ||||
|       echo 'Branch: ' . l:plugin_branch | ||||
|       echo 'Revision: ' . l:plugin_rev | ||||
|       echo 'Date: ' . l:plugin_date | ||||
|     else | ||||
|       echo "Unknown version" | ||||
|       echo 'Unknown version' | ||||
|     endif | ||||
|   endif | ||||
| endfunction | ||||
| @@ -229,20 +229,20 @@ call vimwiki#vars#init() | ||||
|  | ||||
|  | ||||
| " Define callback functions which the user can redefine | ||||
| if !exists("*VimwikiLinkHandler") | ||||
| if !exists('*VimwikiLinkHandler') | ||||
|   function VimwikiLinkHandler(url) | ||||
|     return 0 | ||||
|   endfunction | ||||
| endif | ||||
|  | ||||
| if !exists("*VimwikiLinkConverter") | ||||
| if !exists('*VimwikiLinkConverter') | ||||
|   function VimwikiLinkConverter(url, source, target) | ||||
|     " Return the empty string when unable to process link | ||||
|     return '' | ||||
|   endfunction | ||||
| endif | ||||
|  | ||||
| if !exists("*VimwikiWikiIncludeHandler") | ||||
| if !exists('*VimwikiWikiIncludeHandler') | ||||
|   function! VimwikiWikiIncludeHandler(value) | ||||
|     return '' | ||||
|   endfunction | ||||
| @@ -251,7 +251,7 @@ endif | ||||
|  | ||||
| " write a level 1 header to new wiki files | ||||
| " a:fname should be an absolute filepath | ||||
| function! s:create_h1(fname) | ||||
| function! s:create_h1(fname) abort | ||||
|   if vimwiki#vars#get_global('auto_header') | ||||
|     let idx = vimwiki#vars#get_bufferlocal('wiki_nr') | ||||
|  | ||||
| @@ -412,7 +412,7 @@ if str2nr(vimwiki#vars#get_global('key_mappings').global) | ||||
| endif | ||||
|  | ||||
|  | ||||
| function! s:build_menu(topmenu) | ||||
| function! s:build_menu(topmenu) abort | ||||
|   let wnamelist = [] | ||||
|   for idx in range(vimwiki#vars#number_of_wikis()) | ||||
|     let wname = vimwiki#vars#get_wikilocal('name', idx) | ||||
| @@ -440,7 +440,7 @@ function! s:build_menu(topmenu) | ||||
|   endfor | ||||
| endfunction | ||||
|  | ||||
| function! s:build_table_menu(topmenu) | ||||
| function! s:build_table_menu(topmenu) abort | ||||
|   exe 'menu '.a:topmenu.'.-Sep- :' | ||||
|   exe 'menu '.a:topmenu.'.Table.Create\ (enter\ cols\ rows) :VimwikiTable ' | ||||
|   exe 'nmenu '.a:topmenu.'.Table.Format<tab>gqq gqq' | ||||
| @@ -464,4 +464,4 @@ if vimwiki#vars#get_global('use_calendar') | ||||
| endif | ||||
|  | ||||
|  | ||||
| let &cpo = s:old_cpo | ||||
| let &cpoptions = s:old_cpo | ||||
|   | ||||
| @@ -6,7 +6,7 @@ | ||||
| " Quit if syntax file is already loaded | ||||
| if v:version < 600 | ||||
|   syntax clear | ||||
| elseif exists("b:current_syntax") | ||||
| elseif exists('b:current_syntax') | ||||
|   finish | ||||
| endif | ||||
|  | ||||
| @@ -18,7 +18,7 @@ call vimwiki#vars#populate_syntax_vars(s:current_syntax) | ||||
|  | ||||
|  | ||||
| " LINKS: highlighting is complicated due to "nonexistent" links feature | ||||
| function! s:add_target_syntax_ON(target, type) | ||||
| function! s:add_target_syntax_ON(target, type) abort | ||||
|   let prefix0 = 'syntax match '.a:type.' `' | ||||
|   let suffix0 = '` display contains=@NoSpell,VimwikiLinkRest,'.a:type.'Char' | ||||
|   let prefix1 = 'syntax match '.a:type.'T `' | ||||
| @@ -28,7 +28,7 @@ function! s:add_target_syntax_ON(target, type) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:add_target_syntax_OFF(target) | ||||
| function! s:add_target_syntax_OFF(target) abort | ||||
|   let prefix0 = 'syntax match VimwikiNoExistsLink `' | ||||
|   let suffix0 = '` display contains=@NoSpell,VimwikiLinkRest,VimwikiLinkChar' | ||||
|   let prefix1 = 'syntax match VimwikiNoExistsLinkT `' | ||||
| @@ -38,7 +38,7 @@ function! s:add_target_syntax_OFF(target) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:highlight_existing_links() | ||||
| function! s:highlight_existing_links() abort | ||||
|   " Wikilink | ||||
|   " Conditional highlighting that depends on the existence of a wiki file or | ||||
|   "   directory is only available for *schemeless* wiki links | ||||
| @@ -153,7 +153,7 @@ endfor | ||||
|  | ||||
|  | ||||
| " possibly concealed chars | ||||
| let s:conceal = exists("+conceallevel") ? ' conceal' : '' | ||||
| let s:conceal = exists('+conceallevel') ? ' conceal' : '' | ||||
|  | ||||
| if vimwiki#vars#get_global('conceal_onechar_markers') | ||||
|   execute 'syn match VimwikiEqInChar contained /'. | ||||
| @@ -178,13 +178,13 @@ endif | ||||
|  | ||||
|  | ||||
| let s:options = ' contained transparent contains=NONE' | ||||
| if exists("+conceallevel") | ||||
| if exists('+conceallevel') | ||||
|   let s:options .= s:conceal | ||||
| endif | ||||
|  | ||||
| " A shortener for long URLs: LinkRest (a middle part of the URL) is concealed | ||||
| " VimwikiLinkRest group is left undefined if link shortening is not desired | ||||
| if exists("+conceallevel") && vimwiki#vars#get_global('url_maxsave') > 0 | ||||
| if exists('+conceallevel') && vimwiki#vars#get_global('url_maxsave') > 0 | ||||
|   execute 'syn match VimwikiLinkRest `\%(///\=[^/ \t]\+/\)\zs\S\+\ze' | ||||
|         \.'\%([/#?]\w\|\S\{'.vimwiki#vars#get_global('url_maxsave').'}\)`'.' cchar=~'.s:options | ||||
| endif | ||||
| @@ -339,7 +339,7 @@ syntax match VimwikiPlaceholderParam /.*/ contained | ||||
|  | ||||
|  | ||||
| " html tags | ||||
| if vimwiki#vars#get_global('valid_html_tags') != '' | ||||
| if vimwiki#vars#get_global('valid_html_tags') !=? '' | ||||
|   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*/\?>#' | ||||
|   execute 'syntax match VimwikiBold #\c<b>.\{-}</b># contains=VimwikiHTMLTag' | ||||
| @@ -358,7 +358,7 @@ execute 'syntax match VimwikiTag /'.vimwiki#vars#get_syntaxlocal('rxTags').'/' | ||||
| " header groups highlighting | ||||
| if vimwiki#vars#get_global('hl_headers') == 0 | ||||
|   " Strangely in default colorscheme Title group is not set to bold for cterm... | ||||
|   if !exists("g:colors_name") | ||||
|   if !exists('g:colors_name') | ||||
|     hi Title cterm=bold | ||||
|   endif | ||||
|   for s:i in range(1,6) | ||||
| @@ -367,8 +367,8 @@ if vimwiki#vars#get_global('hl_headers') == 0 | ||||
| else | ||||
|   for s:i in range(1,6) | ||||
|     execute 'hi def VimwikiHeader'.s:i.' guibg=bg guifg=' | ||||
|           \ .vimwiki#vars#get_global('hcolor_guifg_'.&bg)[s:i-1].' gui=bold ctermfg=' | ||||
|           \ .vimwiki#vars#get_global('hcolor_ctermfg_'.&bg)[s:i-1].' term=bold cterm=bold' | ||||
|           \ .vimwiki#vars#get_global('hcolor_guifg_'.&background)[s:i-1].' gui=bold ctermfg=' | ||||
|           \ .vimwiki#vars#get_global('hcolor_ctermfg_'.&background)[s:i-1].' term=bold cterm=bold' | ||||
|   endfor | ||||
| endif | ||||
|  | ||||
| @@ -461,13 +461,13 @@ call vimwiki#u#reload_regexes_custom() | ||||
|  | ||||
|  | ||||
| " FIXME it now does not make sense to pretend there is a single syntax "vimwiki" | ||||
| let b:current_syntax="vimwiki" | ||||
| let b:current_syntax='vimwiki' | ||||
|  | ||||
|  | ||||
| " EMBEDDED syntax setup | ||||
| let s:nested = vimwiki#vars#get_wikilocal('nested_syntaxes') | ||||
| if vimwiki#vars#get_wikilocal('automatic_nested_syntaxes') | ||||
|   let s:nested = extend(s:nested, vimwiki#base#detect_nested_syntax(), "keep") | ||||
|   let s:nested = extend(s:nested, vimwiki#base#detect_nested_syntax(), 'keep') | ||||
| endif | ||||
| if !empty(s:nested) | ||||
|   for [s:hl_syntax, s:vim_syntax] in items(s:nested) | ||||
|   | ||||
| @@ -1,10 +1,10 @@ | ||||
| " vim:tabstop=2:shiftwidth=2:expandtab:textwidth=99 | ||||
| " Vimwiki syntax file | ||||
| " Description: Defines markdown custom syntax | ||||
| " Home: https://github.com/vimwiki/vimwiki/ | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| function! s:add_target_syntax_ON(target, type) | ||||
| function! s:add_target_syntax_ON(target, type) abort | ||||
|   let prefix0 = 'syntax match '.a:type.' `' | ||||
|   let suffix0 = '` display contains=@NoSpell,VimwikiLinkRest,'.a:type.'Char' | ||||
|   let prefix1 = 'syntax match '.a:type.'T `' | ||||
| @@ -14,7 +14,7 @@ function! s:add_target_syntax_ON(target, type) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:add_target_syntax_OFF(target, type) | ||||
| function! s:add_target_syntax_OFF(target, type) abort | ||||
|   let prefix0 = 'syntax match VimwikiNoExistsLink `' | ||||
|   let suffix0 = '` display contains=@NoSpell,VimwikiLinkRest,'.a:type.'Char' | ||||
|   let prefix1 = 'syntax match VimwikiNoExistsLinkT `' | ||||
| @@ -24,18 +24,18 @@ function! s:add_target_syntax_OFF(target, type) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:wrap_wikilink1_rx(target) | ||||
| function! s:wrap_wikilink1_rx(target) abort | ||||
|   return vimwiki#vars#get_syntaxlocal('rxWikiLink1InvalidPrefix') . a:target. | ||||
|         \ vimwiki#vars#get_syntaxlocal('rxWikiLink1InvalidSuffix') | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:existing_mkd_refs() | ||||
| function! s:existing_mkd_refs() abort | ||||
|   return keys(vimwiki#markdown_base#scan_reflinks()) | ||||
| endfunction | ||||
|  | ||||
|  | ||||
| function! s:highlight_existing_links() | ||||
| function! s:highlight_existing_links() abort | ||||
|   " Wikilink1 | ||||
|   " Conditional highlighting that depends on the existence of a wiki file or | ||||
|   "   directory is only available for *schemeless* wiki links | ||||
| @@ -134,7 +134,7 @@ endfor | ||||
|  | ||||
|  | ||||
| " concealed chars | ||||
| if exists("+conceallevel") | ||||
| if exists('+conceallevel') | ||||
|   syntax conceal on | ||||
| endif | ||||
|  | ||||
| @@ -165,7 +165,7 @@ execute 'syn match VimwikiImageChar "'. | ||||
| execute 'syn match VimwikiImageChar "'. | ||||
|             \ vimwiki#vars#get_syntaxlocal('rxWeblink1Suffix1').'"'.s:options | ||||
|  | ||||
| if exists("+conceallevel") | ||||
| if exists('+conceallevel') | ||||
|   syntax conceal off | ||||
| endif | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user