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