Refactor: Mutualize messaging (echo)
This commit is contained in:
parent
188ead55db
commit
4b041a606a
@ -328,7 +328,7 @@ function! vimwiki#base#system_open_link(url) abort
|
||||
return
|
||||
endif
|
||||
endtry
|
||||
echomsg 'Vimwiki Error: Default Vimwiki link handler was unable to open the HTML file!'
|
||||
call vimwiki#u#error('Default Vimwiki link handler was unable to open the HTML file!')
|
||||
endfunction
|
||||
|
||||
|
||||
@ -343,12 +343,12 @@ function! vimwiki#base#open_link(cmd, link, ...) abort
|
||||
|
||||
if link_infos.filename ==? ''
|
||||
if link_infos.index == -1
|
||||
echomsg 'Vimwiki Error: No registered wiki ''' . link_infos.scheme . '''.'
|
||||
call vimwiki#u#error('No registered wiki ''' . link_infos.scheme . '''.')
|
||||
elseif link_infos.index == -2
|
||||
" scheme field stores wiki name for this error case
|
||||
echom 'Vimwiki Error: No wiki found with name "' . link_infos.scheme . '"'
|
||||
call vimwiki#u#error('No wiki found with name "' . link_infos.scheme . '"')
|
||||
else
|
||||
echomsg 'Vimwiki Error: Unable to resolve link!'
|
||||
call vimwiki#u#error('Unable to resolve link!')
|
||||
endif
|
||||
return
|
||||
endif
|
||||
@ -509,7 +509,7 @@ function! vimwiki#base#backlinks() abort
|
||||
endfor
|
||||
|
||||
if empty(locations)
|
||||
echomsg 'Vimwiki: No other file links to this file'
|
||||
call vimwiki#u#echo('No other file links to this file')
|
||||
else
|
||||
call setloclist(0, locations, 'r')
|
||||
lopen
|
||||
@ -967,7 +967,7 @@ function! vimwiki#base#check_links(range, line1, line2) abort
|
||||
else
|
||||
let wiki_list = range(a:line1, a:line2)
|
||||
endif
|
||||
echom 'Vimwiki Checking links in wikis ' . string(wiki_list)
|
||||
call vimwiki#u#echo('Checking links in wikis ' . string(wiki_list))
|
||||
|
||||
let anchors_of_files = {}
|
||||
let links_of_files = {}
|
||||
@ -1063,7 +1063,7 @@ function! vimwiki#base#check_links(range, line1, line2) abort
|
||||
|
||||
" Fill: QuickFix list
|
||||
if empty(errors)
|
||||
echomsg 'Vimwiki: All links are OK'
|
||||
call vimwiki#u#echo('All links are OK')
|
||||
else
|
||||
call setqflist(errors, 'r')
|
||||
copen
|
||||
@ -1084,8 +1084,7 @@ function! vimwiki#base#edit_file(command, filename, anchor, ...) abort
|
||||
let ok = vimwiki#path#mkdir(dir, 1)
|
||||
|
||||
if !ok
|
||||
echomsg ' '
|
||||
echomsg 'Vimwiki Error: Unable to edit file in non-existent directory: '.dir
|
||||
call vimwiki#u#error('Unable to edit file in non-existent directory: '.dir)
|
||||
return
|
||||
endif
|
||||
|
||||
@ -1097,11 +1096,11 @@ function! vimwiki#base#edit_file(command, filename, anchor, ...) abort
|
||||
try
|
||||
execute a:command fname
|
||||
catch /E37:/
|
||||
echomsg 'Vimwiki: Can''t leave the current buffer, because it is modified. Hint: Take a look at'
|
||||
\ ''':h g:vimwiki_autowriteall'' to see how to save automatically.'
|
||||
call vimwiki#u#warn('Can''t leave the current buffer, because it is modified. Hint: Take a look at'
|
||||
\ . ''':h g:vimwiki_autowriteall'' to see how to save automatically.')
|
||||
return
|
||||
catch /E325:/
|
||||
echom 'Vimwiki: Vim couldn''t open the file, probably because a swapfile already exists. See :h E325.'
|
||||
call vimwiki#u#warn('Vim couldn''t open the file, probably because a swapfile already exists. See :h E325.')
|
||||
return
|
||||
endtry
|
||||
" If the opened file was not already loaded by Vim, an autocommand is
|
||||
@ -1129,7 +1128,7 @@ endfunction
|
||||
function! vimwiki#base#search_word(wikiRX, flags) abort
|
||||
let match_line = search(a:wikiRX, 's'.a:flags)
|
||||
if match_line == 0
|
||||
echomsg 'Vimwiki: Wiki link not found'
|
||||
call vimwiki#u#echo('Wiki link not found')
|
||||
endif
|
||||
endfunction
|
||||
|
||||
@ -1228,7 +1227,7 @@ endfunction
|
||||
" Param: old: url regex of old path relative to wiki root
|
||||
" Param: new: url string of new path
|
||||
function! s:update_wiki_link(fname, old, new) abort
|
||||
echo 'Updating links in '.a:fname
|
||||
call vimwiki#u#echo('Updating links in '.a:fname)
|
||||
let has_updates = 0
|
||||
let dest = []
|
||||
for line in readfile(a:fname)
|
||||
@ -1701,7 +1700,7 @@ function! vimwiki#base#goto_index(wnum, ...) abort
|
||||
endif
|
||||
|
||||
if a:wnum > vimwiki#vars#number_of_wikis()
|
||||
echomsg 'Vimwiki Error: Wiki '.a:wnum.' is not registered in your Vimwiki settings!'
|
||||
call vimwiki#u#error('Wiki '.a:wnum.' is not registered in your Vimwiki settings!')
|
||||
return
|
||||
endif
|
||||
|
||||
@ -1736,14 +1735,14 @@ function! vimwiki#base#delete_link() abort
|
||||
try
|
||||
call delete(fname)
|
||||
catch /.*/
|
||||
echomsg 'Vimwiki Error: Cannot delete "'.expand('%:t:r').'"!'
|
||||
call vimwiki#u#error('Cannot delete "'.expand('%:t:r').'"!')
|
||||
return
|
||||
endtry
|
||||
|
||||
call vimwiki#base#go_back_link()
|
||||
execute 'bdelete! '.escape(fname, ' ')
|
||||
|
||||
" reread buffer => deleted wiki link should appear as non-existent
|
||||
" Reread buffer => deleted wiki link should appear as non-existent
|
||||
if expand('%:p') !=? ''
|
||||
execute 'e'
|
||||
endif
|
||||
@ -1765,11 +1764,11 @@ function! s:input_rename_link() abort
|
||||
|
||||
" Guard: Check link
|
||||
if new_link =~# '[/\\]'
|
||||
echomsg 'Vimwiki Error: Cannot rename to a filename with path!'
|
||||
call vimwiki#u#error('Cannot rename to a filename with path!')
|
||||
return
|
||||
endif
|
||||
if substitute(new_link, '\s', '', 'g') ==? ''
|
||||
echomsg 'Vimwiki Error: Cannot rename to an empty filename!'
|
||||
call vimwiki#u#error('Cannot rename to an empty filename!')
|
||||
return
|
||||
endif
|
||||
|
||||
@ -1796,8 +1795,8 @@ function! vimwiki#base#rename_link(...) abort
|
||||
|
||||
" Clause: Check if there current buffer is a file (new buffer maybe)
|
||||
if glob(expand('%:p')) ==? ''
|
||||
echomsg 'Vimwiki Error: Cannot rename "'.expand('%:p').
|
||||
\'". Current file does not exist! (New file? Save it before renaming.)'
|
||||
call vimwiki#u#error('Cannot rename "'.expand('%:p')
|
||||
\ . '". Current file does not exist! (New file? Save it before renaming.)')
|
||||
return
|
||||
endif
|
||||
|
||||
@ -1812,7 +1811,7 @@ function! vimwiki#base#rename_link(...) abort
|
||||
" Guard: Do not rename if file with such name exists
|
||||
let fname = glob(new_fname)
|
||||
if fname !=? ''
|
||||
echomsg 'Vimwiki Error: Cannot rename to "'.new_fname.'". File with that name exist!'
|
||||
call vimwiki#u#error('Cannot rename to "'.new_fname.'". File with that name exist!')
|
||||
return
|
||||
endif
|
||||
|
||||
@ -1828,13 +1827,13 @@ function! vimwiki#base#rename_link(...) abort
|
||||
|
||||
" Rename wiki link file
|
||||
try
|
||||
echomsg 'Vimwiki: Renaming '.wikiroot_path.old_fname.' to '.new_fname
|
||||
call vimwiki#u#echo('Renaming '.wikiroot_path.old_fname.' to '.new_fname)
|
||||
let res = rename(expand('%:p'), expand(new_fname))
|
||||
if res != 0
|
||||
throw 'Cannot rename!'
|
||||
end
|
||||
catch /.*/
|
||||
echomsg 'Vimwiki Error: Cannot rename "'.expand('%:t:r').'" to "'.new_fname.'"'
|
||||
call vimwiki#u#error('Cannot rename "'.expand('%:t:r').'" to "'.new_fname.'"')
|
||||
return
|
||||
endtry
|
||||
|
||||
@ -1894,12 +1893,12 @@ function! vimwiki#base#rename_link(...) abort
|
||||
exe 'bwipeout! ' . buf_old_info[2]
|
||||
else
|
||||
" Should not happen
|
||||
echomsg 'Vimwiki Error: New buffer is the same as old, so will not delete: '
|
||||
\ . buf_new_nb . '.Please open an issue if see this messsage'
|
||||
call vimwiki#u#error('New buffer is the same as old, so will not delete: '
|
||||
\ . buf_new_nb . '.Please open an issue if see this messsage')
|
||||
endif
|
||||
|
||||
" Log success
|
||||
echomsg 'Vimwiki: '.old_fname.' is renamed to '.new_fname
|
||||
call vimwiki#u#echo(old_fname.' is renamed to '.new_fname)
|
||||
|
||||
" Restore prompt
|
||||
let &more = more_save
|
||||
@ -2354,7 +2353,7 @@ function! vimwiki#base#goto_parent_header() abort
|
||||
if parent_header >= 0
|
||||
call cursor(headers[parent_header][0], 1)
|
||||
else
|
||||
echo 'Vimwiki: no parent header found'
|
||||
call vimwiki#u#echo('no parent header found')
|
||||
endif
|
||||
endfunction
|
||||
|
||||
@ -2368,7 +2367,7 @@ function! vimwiki#base#goto_next_header() abort
|
||||
elseif current_header_index < 0 && !empty(headers) " we're above the first header
|
||||
call cursor(headers[0][0], 1)
|
||||
else
|
||||
echo 'Vimwiki: no next header found'
|
||||
call vimwiki#u#echo('no next header found')
|
||||
endif
|
||||
endfunction
|
||||
|
||||
@ -2384,7 +2383,7 @@ function! vimwiki#base#goto_prev_header() abort
|
||||
if current_header_index >= 0
|
||||
call cursor(headers[current_header_index][0], 1)
|
||||
else
|
||||
echo 'Vimwiki: no previous header found'
|
||||
call vimwiki#u#echo('no previous header found')
|
||||
endif
|
||||
endfunction
|
||||
|
||||
@ -2399,7 +2398,7 @@ function! vimwiki#base#goto_sibling(direction) abort
|
||||
\ headers[current_header_index][1]
|
||||
call cursor(headers[next_potential_sibling][0], 1)
|
||||
else
|
||||
echo 'Vimwiki: no sibling header found'
|
||||
call vimwiki#u#echo('no sibling header found')
|
||||
endif
|
||||
endfunction
|
||||
|
||||
@ -2804,7 +2803,7 @@ endfunction
|
||||
" Called by commands VimwikiSearch and VWS
|
||||
function! vimwiki#base#search(search_pattern) abort
|
||||
if empty(a:search_pattern)
|
||||
echomsg 'Vimwiki Error: No search pattern given.'
|
||||
call vimwiki#u#error('No search pattern given.')
|
||||
return
|
||||
endif
|
||||
|
||||
@ -2825,18 +2824,11 @@ function! vimwiki#base#search(search_pattern) abort
|
||||
try
|
||||
execute cmd
|
||||
catch
|
||||
echomsg 'VimwikiSearch: No match found.'
|
||||
call vimwiki#u#echo('Search: No match found.')
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
|
||||
" Warn deprecated feature
|
||||
function! vimwiki#base#deprecate(old, new) abort
|
||||
echohl WarningMsg
|
||||
echo a:old 'is deprecated and will be removed in future versions, use' a:new 'instead.'
|
||||
echohl None
|
||||
endfunction
|
||||
|
||||
" -------------------------------------------------------------------------
|
||||
" Load syntax-specific Wiki functionality
|
||||
for s:syn in s:vimwiki_get_known_syntaxes()
|
||||
|
@ -281,7 +281,7 @@ function! vimwiki#diary#make_note(wnum, ...) abort
|
||||
endif
|
||||
|
||||
if wiki_nr >= vimwiki#vars#number_of_wikis()
|
||||
echomsg 'Vimwiki Error: Wiki '.wiki_nr.' is not registered in g:vimwiki_list!'
|
||||
call vimwiki#u#error('Wiki '.wiki_nr.' is not registered in g:vimwiki_list!')
|
||||
return
|
||||
endif
|
||||
|
||||
@ -321,7 +321,7 @@ function! vimwiki#diary#goto_diary_index(wnum) abort
|
||||
endif
|
||||
|
||||
if a:wnum > vimwiki#vars#number_of_wikis()
|
||||
echomsg 'Vimwiki Error: Wiki '.a:wnum.' is not registered in g:vimwiki_list!'
|
||||
call vimwiki#u#error('Wiki '.a:wnum.' is not registered in g:vimwiki_list!')
|
||||
return
|
||||
endif
|
||||
|
||||
@ -471,7 +471,7 @@ function! vimwiki#diary#generate_diary_section() abort
|
||||
\ 1,
|
||||
\ 1)
|
||||
else
|
||||
echomsg 'Vimwiki Error: You can generate diary links only in a diary index page!'
|
||||
call vimwiki#u#error('You can generate diary links only in a diary index page!')
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
@ -145,7 +145,7 @@ function! s:get_html_template(template) abort
|
||||
let lines = readfile(template_name)
|
||||
return lines
|
||||
catch /E484/
|
||||
echomsg 'Vimwiki: HTML template '.template_name. ' does not exist!'
|
||||
call vimwiki#u#echo('HTML template '.template_name. ' does not exist!')
|
||||
endtry
|
||||
endif
|
||||
|
||||
@ -203,7 +203,7 @@ function! s:delete_html_files(path) abort
|
||||
try
|
||||
call delete(fname)
|
||||
catch
|
||||
echomsg 'Vimwiki Error: Cannot delete '.fname
|
||||
call vimwiki#u#error('Cannot delete '.fname)
|
||||
endtry
|
||||
endfor
|
||||
endfunction
|
||||
@ -1640,9 +1640,9 @@ function! vimwiki#html#CustomWiki2HTML(path, wikifile, force) abort
|
||||
\ shellescape(s:root_path(vimwiki#vars#get_bufferlocal('subdir'))) : '-'). ' '.
|
||||
\ (len(vimwiki#vars#get_wikilocal('custom_wiki2html_args')) > 0 ?
|
||||
\ vimwiki#vars#get_wikilocal('custom_wiki2html_args') : '-'))
|
||||
" Echo if non void
|
||||
" Print if non void
|
||||
if output !~? '^\s*$'
|
||||
echomsg output
|
||||
call vimwiki#u#echo(string(output))
|
||||
endif
|
||||
endfunction
|
||||
|
||||
@ -1723,7 +1723,7 @@ function! s:convert_file_to_lines(wikifile, current_html_file) abort
|
||||
|
||||
let result['nohtml'] = nohtml
|
||||
if nohtml
|
||||
echon "\r".'%nohtml placeholder found'
|
||||
call vimwiki#u#echo("\r".'%nohtml placeholder found', '', 'n')
|
||||
return result
|
||||
endif
|
||||
|
||||
@ -1808,7 +1808,7 @@ function! s:convert_file(path_html, wikifile) abort
|
||||
return path_html.htmlfile
|
||||
endif
|
||||
|
||||
echomsg 'Vimwiki Error: Conversion to HTML is not supported for this syntax'
|
||||
call vimwiki#u#error('Conversion to HTML is not supported for this syntax')
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
@ -1824,11 +1824,11 @@ endfunction
|
||||
|
||||
function! vimwiki#html#WikiAll2HTML(path_html, force) abort
|
||||
if !s:syntax_supported() && !s:use_custom_wiki2html()
|
||||
echomsg 'Vimwiki Error: Conversion to HTML is not supported for this syntax'
|
||||
call vimwiki#u#error('Conversion to HTML is not supported for this syntax')
|
||||
return
|
||||
endif
|
||||
|
||||
echomsg 'Vimwiki: Saving Vimwiki files ...'
|
||||
call vimwiki#u#echo('Saving Vimwiki files ...')
|
||||
let save_eventignore = &eventignore
|
||||
let &eventignore = 'all'
|
||||
try
|
||||
@ -1842,12 +1842,12 @@ function! vimwiki#html#WikiAll2HTML(path_html, force) abort
|
||||
call vimwiki#path#mkdir(path_html)
|
||||
|
||||
if !vimwiki#vars#get_wikilocal('html_filename_parameterization')
|
||||
echomsg 'Vimwiki: Deleting non-wiki html files ...'
|
||||
call vimwiki#u#echo('Deleting non-wiki html files ...')
|
||||
call s:delete_html_files(path_html)
|
||||
endif
|
||||
|
||||
echomsg 'Vimwiki: Converting wiki to html files ...'
|
||||
let setting_more = &more
|
||||
call vimwiki#u#echo('Converting wiki to html files ...')
|
||||
setlocal nomore
|
||||
|
||||
" temporarily adjust current_subdir global state variable
|
||||
@ -1865,11 +1865,11 @@ function! vimwiki#html#WikiAll2HTML(path_html, force) abort
|
||||
call vimwiki#vars#set_bufferlocal('invsubdir', vimwiki#base#invsubdir(subdir))
|
||||
|
||||
if a:force || !s:is_html_uptodate(wikifile)
|
||||
echomsg 'Vimwiki: Processing '.wikifile
|
||||
call vimwiki#u#echo('Processing '.wikifile)
|
||||
|
||||
call s:convert_file(path_html, wikifile)
|
||||
else
|
||||
echomsg 'Vimwiki: Skipping '.wikifile
|
||||
call vimwiki#u#echo('Skipping '.wikifile)
|
||||
endif
|
||||
endfor
|
||||
" reset 'subdir' state variable
|
||||
@ -1878,10 +1878,10 @@ function! vimwiki#html#WikiAll2HTML(path_html, force) abort
|
||||
|
||||
let created = s:create_default_CSS(path_html)
|
||||
if created
|
||||
echomsg 'Vimwiki: Default style.css has been created'
|
||||
call vimwiki#u#echo('Default style.css has been created')
|
||||
endif
|
||||
echomsg 'Vimwiki: HTML exported to '.path_html
|
||||
echomsg 'Vimwiki: Done!'
|
||||
call vimwiki#u#echo('HTML exported to '.path_html)
|
||||
call vimwiki#u#echo('Done!')
|
||||
|
||||
let &more = setting_more
|
||||
endfunction
|
||||
@ -1995,7 +1995,7 @@ function! s:generate_rss(path) abort
|
||||
endfunction
|
||||
|
||||
function! vimwiki#html#diary_rss() abort
|
||||
echomsg 'Vimwiki: Saving RSS feed ...'
|
||||
call vimwiki#u#echo('Saving RSS feed ...')
|
||||
let path_html = expand(vimwiki#vars#get_wikilocal('path_html'))
|
||||
call vimwiki#path#mkdir(path_html)
|
||||
call s:generate_rss(path_html)
|
||||
|
@ -36,7 +36,6 @@ endfunction
|
||||
|
||||
" try markdown reference links
|
||||
function! vimwiki#markdown_base#open_reflink(link) abort
|
||||
" echom "vimwiki#markdown_base#open_reflink"
|
||||
let link = a:link
|
||||
let mkd_refs = vimwiki#vars#get_bufferlocal('markdown_refs')
|
||||
if has_key(mkd_refs, link)
|
||||
|
@ -617,7 +617,6 @@ function! s:kbd_goto_prev_col(jumpup) abort
|
||||
let cmd .= ":call vimwiki#tbl#goto_prev_col()\<CR>a"
|
||||
" let cmd .= ":call search('\\(".s:rxSep()."\\)\\zs', 'b', line('.'))\<CR>"
|
||||
" let cmd .= "a"
|
||||
"echomsg "DEBUG kbd_goto_prev_col> ".cmd
|
||||
return cmd
|
||||
endfunction
|
||||
|
||||
@ -645,7 +644,7 @@ function! vimwiki#tbl#kbd_tab() abort
|
||||
|
||||
let last = s:is_last_column(lnum, col('.'))
|
||||
let is_sep = s:is_separator_tail(getline(lnum))
|
||||
"echomsg "DEBUG kbd_tab> last=".last.", is_sep=".is_sep
|
||||
"vimwiki#u#debug("DEBUG kbd_tab> last=".last.", is_sep=".is_sep)
|
||||
if (is_sep || last) && !s:is_table(getline(lnum+1))
|
||||
let cols = len(vimwiki#tbl#get_cells(getline(lnum)))
|
||||
return s:kbd_create_new_row(cols, 1)
|
||||
@ -662,7 +661,7 @@ function! vimwiki#tbl#kbd_shift_tab() abort
|
||||
|
||||
let first = s:is_first_column(lnum, col('.'))
|
||||
let is_sep = s:is_separator_tail(getline(lnum))
|
||||
"echomsg "DEBUG kbd_tab> ".first
|
||||
"vimwiki#u#debug("kbd_tab> ".first)
|
||||
if (is_sep || first) && !s:is_table(getline(lnum-1))
|
||||
return ''
|
||||
endif
|
||||
|
@ -3,6 +3,49 @@
|
||||
" Description: Utility functions
|
||||
" Home: https://github.com/vimwiki/vimwiki/
|
||||
|
||||
" Echo: msg
|
||||
" :param: (1) <string> highlighting group
|
||||
" :param: (2) <string> echo suffix (ex: 'n', 'm'
|
||||
function! vimwiki#u#echo(msg, ...) abort
|
||||
let hl_group = a:0 > 0 ? a:1 : ''
|
||||
let echo_suffix = a:0 > 1 ? a:2 : ''
|
||||
" Start highlighting
|
||||
if hl_group !=# ''
|
||||
exe 'echohl ' . hl_group
|
||||
endif
|
||||
" Print
|
||||
let msg = substitute(a:msg, "'", "''", 'g')
|
||||
exe 'echo'.echo_suffix . " 'Vimwiki: " . msg . "'"
|
||||
" Stop highlighting
|
||||
if hl_group !=# ''
|
||||
echohl None
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Debug: msg
|
||||
" let b:vimwiki_debug to trigger
|
||||
function! vimwiki#u#debug(msg) abort
|
||||
if !exists('b:vimwiki_debug') || b:vimwiki_debug == 0
|
||||
return
|
||||
endif
|
||||
echomsg 'DEBUG: ' . a:msg
|
||||
endfunction
|
||||
|
||||
" Warn: msg
|
||||
function! vimwiki#u#warn(msg) abort
|
||||
call vimwiki#u#echo('Warning: ' . a:msg, 'WarningMsg', '')
|
||||
endfunction
|
||||
|
||||
" Error: msg
|
||||
function! vimwiki#u#error(msg) abort
|
||||
call vimwiki#u#echo('Error: ' . a:msg, 'Error', 'msg')
|
||||
endfunction
|
||||
|
||||
" Warn: deprecated feature: old -> new
|
||||
function! vimwiki#u#deprecate(old, new) abort
|
||||
call vimwiki#u#warn('Deprecated: ' . a:old . ' is deprecated and '
|
||||
\ . 'will be removed in future versions. Use ' . a:new . ' instead.')
|
||||
endfunction
|
||||
|
||||
" Get visual selection text content, optionaly replace its content
|
||||
" :param: Text to replace selection
|
||||
@ -264,7 +307,6 @@ function! vimwiki#u#hi_tag(tag_pre, tag_post, syntax_group, contains, ...) abort
|
||||
\ opt_contains .
|
||||
\ b:vimwiki_syntax_concealends .
|
||||
\ opt_more
|
||||
"echom cmd
|
||||
exe cmd
|
||||
endfunction
|
||||
|
||||
|
@ -239,8 +239,8 @@ function! s:read_global_settings_from_user() abort
|
||||
for month in range(1, 12)
|
||||
if !has_key(users_value, month) || type(users_value[month]) != type('') ||
|
||||
\ empty(users_value[month])
|
||||
echom printf('Vimwiki Error: The provided value ''%s'' of the option ''g:vimwiki_%s'' is'
|
||||
\ . ' invalid. See '':h g:vimwiki_%s''.', string(users_value), key, key)
|
||||
call vimwiki#u#error(printf('The provided value ''%s'' of the option ''g:vimwiki_%s'' is'
|
||||
\ . ' invalid. See '':h g:vimwiki_%s''.', string(users_value), key, key))
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
@ -249,8 +249,8 @@ function! s:read_global_settings_from_user() abort
|
||||
let users_value = g:vimwiki_global_vars[key]
|
||||
for ext in keys(users_value)
|
||||
if empty(ext) || index(['markdown', 'media', 'mediawiki', 'default'], users_value[ext]) == -1
|
||||
echom printf('Vimwiki Error: The provided value ''%s'' of the option ''g:vimwiki_%s'' is'
|
||||
\ . ' invalid. See '':h g:vimwiki_%s''.', string(users_value), key, key)
|
||||
call vimwiki#u#error(printf('The provided value ''%s'' of the option ''g:vimwiki_%s'' is'
|
||||
\ . ' invalid. See '':h g:vimwiki_%s''.', string(users_value), key, key))
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
@ -343,7 +343,7 @@ endfunction
|
||||
" Populate local variable <- user & default
|
||||
" Called: s:vimwiki#vars#init
|
||||
function! s:populate_wikilocal_options() abort
|
||||
" Warning Dev: if type is dict,
|
||||
" Dev: if type is dict,
|
||||
" -- the default dict gets extended and not replaced: keys are not deleted
|
||||
|
||||
" Init local variable container
|
||||
@ -481,8 +481,8 @@ function! s:populate_wikilocal_options() abort
|
||||
for keyword in keys(users_value)
|
||||
if type(keyword) != type('') || empty(keyword) || type(users_value[keyword]) != type('') ||
|
||||
\ empty(users_value[keyword])
|
||||
echom printf('Vimwiki Error: The provided value ''%s'' of the option ''g:vimwiki_%s'' is'
|
||||
\ . ' invalid. See '':h g:vimwiki_%s''.', string(users_value), key, key)
|
||||
call vimwiki#u#error(printf('The provided value ''%s'' of the option ''g:vimwiki_%s'' is'
|
||||
\ . ' invalid. See '':h g:vimwiki_%s''.', string(users_value), key, key))
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
@ -493,7 +493,7 @@ endfunction
|
||||
|
||||
|
||||
" Helper, Check user setting
|
||||
" warn user with echo message if not good type
|
||||
" warn user with message if not good type
|
||||
" Param: 1: key <string>: varaible name
|
||||
" Param: 2: vimwiki_key <obj>: user value
|
||||
" Param: 3: value_infod <dict>: type and default value
|
||||
@ -514,44 +514,44 @@ function! s:check_users_value(key, users_value, value_infos, comes_from_global_v
|
||||
\ 'vimwiki-option-'
|
||||
|
||||
if has_key(a:value_infos, 'type') && type(a:users_value) != a:value_infos.type
|
||||
echom printf('Vimwiki Error: The provided value of the option %s is a %s, ' .
|
||||
call vimwiki#u#error(printf('The provided value of the option %s is a %s, ' .
|
||||
\ 'but expected is a %s. See '':h '.help_text.'%s''.', setting_origin,
|
||||
\ type_code_to_name[type(a:users_value)], type_code_to_name[a:value_infos.type], a:key)
|
||||
\ type_code_to_name[type(a:users_value)], type_code_to_name[a:value_infos.type], a:key))
|
||||
endif
|
||||
|
||||
if a:value_infos.type == type(0) && has_key(a:value_infos, 'min') &&
|
||||
\ a:users_value < a:value_infos.min
|
||||
echom printf('Vimwiki Error: The provided value ''%i'' of the option %s is'
|
||||
call vimwiki#u#error(printf('The provided value ''%i'' of the option %s is'
|
||||
\ . ' too small. The minimum value is %i. See '':h '.help_text.'%s''.', a:users_value,
|
||||
\ setting_origin, a:value_infos.min, a:key)
|
||||
\ setting_origin, a:value_infos.min, a:key))
|
||||
endif
|
||||
|
||||
if a:value_infos.type == type(0) && has_key(a:value_infos, 'max') &&
|
||||
\ a:users_value > a:value_infos.max
|
||||
echom printf('Vimwiki Error: The provided value ''%i'' of the option %s is'
|
||||
call vimwiki#u#error(printf('The provided value ''%i'' of the option %s is'
|
||||
\ . ' too large. The maximum value is %i. See '':h '.help_text.'%s''.', a:users_value,
|
||||
\ setting_origin, a:value_infos.max, a:key)
|
||||
\ setting_origin, a:value_infos.max, a:key))
|
||||
endif
|
||||
|
||||
if has_key(a:value_infos, 'possible_values') &&
|
||||
\ index(a:value_infos.possible_values, a:users_value) == -1
|
||||
echom printf('Vimwiki Error: The provided value ''%s'' of the option %s is'
|
||||
call vimwiki#u#error(printf('The provided value ''%s'' of the option %s is'
|
||||
\ . ' invalid. Allowed values are %s. See '':h '.help_text.'%s''.', a:users_value,
|
||||
\ setting_origin, string(a:value_infos.possible_values), a:key)
|
||||
\ setting_origin, string(a:value_infos.possible_values), a:key))
|
||||
endif
|
||||
|
||||
if a:value_infos.type == type('') && has_key(a:value_infos, 'length') &&
|
||||
\ strwidth(a:users_value) != a:value_infos.length
|
||||
echom printf('Vimwiki Error: The provided value ''%s'' of the option %s must'
|
||||
call vimwiki#u#error(printf('The provided value ''%s'' of the option %s must'
|
||||
\ . ' contain exactly %i character(s) but has %i. See '':h '.help_text.'_%s''.',
|
||||
\ a:users_value, setting_origin, a:value_infos.length, strwidth(a:users_value), a:key)
|
||||
\ a:users_value, setting_origin, a:value_infos.length, strwidth(a:users_value), a:key))
|
||||
endif
|
||||
|
||||
if a:value_infos.type == type('') && has_key(a:value_infos, 'min_length') &&
|
||||
\ strwidth(a:users_value) < a:value_infos.min_length
|
||||
echom printf('Vimwiki Error: The provided value ''%s'' of the option %s must'
|
||||
call vimwiki#u#error(printf('The provided value ''%s'' of the option %s must'
|
||||
\ . ' have at least %d character(s) but has %d. See '':h '.help_text.'%s''.', a:users_value,
|
||||
\ setting_origin, a:value_infos.min_length, strwidth(a:users_value), a:key)
|
||||
\ setting_origin, a:value_infos.min_length, strwidth(a:users_value), a:key))
|
||||
endif
|
||||
endfunction
|
||||
|
||||
@ -851,9 +851,9 @@ function! s:populate_list_vars(wiki) abort
|
||||
|
||||
" Guard: Check if listym_rejected is in listsyms
|
||||
if match(a:wiki.listsyms, '[' . a:wiki.listsym_rejected . ']') != -1
|
||||
echomsg 'Vimwiki Warning: the value of listsym_rejected ('''
|
||||
call vimwiki#u#warn('the value of listsym_rejected ('''
|
||||
\ . a:wiki.listsym_rejected . ''') must not be a part of listsyms ('''
|
||||
\ . a:wiki.listsyms . ''')'
|
||||
\ . a:wiki.listsyms . ''')')
|
||||
endif
|
||||
|
||||
let a:wiki.rxListItemWithoutCB =
|
||||
@ -1121,7 +1121,7 @@ function! vimwiki#vars#get_bufferlocal(key, ...) abort
|
||||
elseif a:key ==# 'markdown_refs'
|
||||
call setbufvar(buffer, 'vimwiki_markdown_refs', vimwiki#markdown_base#scan_reflinks())
|
||||
else
|
||||
echoerr 'Vimwiki Error: unknown buffer variable ' . string(a:key)
|
||||
call vimwiki#u#echo('unknown buffer variable ' . string(a:key))
|
||||
endif
|
||||
|
||||
return getbufvar(buffer, 'vimwiki_'.a:key)
|
||||
|
@ -256,17 +256,19 @@ endfunction
|
||||
command! -buffer Vimwiki2HTML
|
||||
\ if filewritable(expand('%')) | silent noautocmd w | endif
|
||||
\ <bar>
|
||||
\ let res = vimwiki#html#Wiki2HTML(expand(vimwiki#vars#get_wikilocal('path_html')),
|
||||
\ expand('%'))
|
||||
\ let res = vimwiki#html#Wiki2HTML(
|
||||
\ expand(vimwiki#vars#get_wikilocal('path_html')), expand('%'))
|
||||
\ <bar>
|
||||
\ if res != '' | echo 'Vimwiki: HTML conversion is done, output: '
|
||||
\ . expand(vimwiki#vars#get_wikilocal('path_html')) | endif
|
||||
\ if res != '' | call vimwiki#u#echo('HTML conversion is done, output: '
|
||||
\ . expand(vimwiki#vars#get_wikilocal('path_html'))) | endif
|
||||
|
||||
command! -buffer Vimwiki2HTMLBrowse
|
||||
\ if filewritable(expand('%')) | silent noautocmd w | endif
|
||||
\ <bar>
|
||||
\ call vimwiki#base#system_open_link(vimwiki#html#Wiki2HTML(
|
||||
\ expand(vimwiki#vars#get_wikilocal('path_html')),
|
||||
\ expand('%')))
|
||||
|
||||
command! -buffer -bang VimwikiAll2HTML
|
||||
\ call vimwiki#html#WikiAll2HTML(expand(vimwiki#vars#get_wikilocal('path_html')), <bang>0)
|
||||
|
||||
@ -566,7 +568,6 @@ if str2nr(vimwiki#vars#get_global('key_mappings').lists)
|
||||
endif
|
||||
endif
|
||||
|
||||
" Not used
|
||||
function! s:CR(normal, just_mrkr) abort
|
||||
let res = vimwiki#tbl#kbd_cr()
|
||||
if res !=? ''
|
||||
|
Loading…
Reference in New Issue
Block a user