Comment: code and robustify
This commit is contained in:
@ -2,13 +2,14 @@
|
||||
" Vimwiki filetype plugin file
|
||||
" Home: https://github.com/vimwiki/vimwiki/
|
||||
|
||||
|
||||
" Cause: load only onces per buffer
|
||||
if exists('b:did_ftplugin')
|
||||
finish
|
||||
endif
|
||||
let b:did_ftplugin = 1 " Don't load another plugin for this buffer
|
||||
|
||||
|
||||
|
||||
setlocal commentstring=%%%s
|
||||
|
||||
if vimwiki#vars#get_global('conceallevel') && exists('+conceallevel')
|
||||
@ -22,7 +23,7 @@ setlocal isfname-=[,]
|
||||
exe 'setlocal tags+=' . escape(vimwiki#tags#metadata_file_path(), ' \|"')
|
||||
|
||||
|
||||
|
||||
" Help for omnicompletion
|
||||
function! Complete_wikifiles(findstart, base) abort
|
||||
if a:findstart == 1
|
||||
let column = col('.')-2
|
||||
@ -115,8 +116,7 @@ endfunction
|
||||
setlocal omnifunc=Complete_wikifiles
|
||||
|
||||
|
||||
|
||||
" settings necessary for the automatic formatting of lists
|
||||
" Declare settings necessary for the automatic formatting of lists
|
||||
setlocal autoindent
|
||||
setlocal nosmartindent
|
||||
setlocal nocindent
|
||||
@ -134,11 +134,13 @@ let &formatlistpat = vimwiki#vars#get_wikilocal('rxListItem')
|
||||
" Folding stuff
|
||||
" ------------------------------------------------
|
||||
|
||||
" Get fold level for a list
|
||||
function! VimwikiFoldListLevel(lnum) abort
|
||||
return vimwiki#lst#fold_level(a:lnum)
|
||||
endfunction
|
||||
|
||||
|
||||
" Get fold level for 1. line number
|
||||
function! VimwikiFoldLevel(lnum) abort
|
||||
let line = getline(a:lnum)
|
||||
|
||||
@ -156,7 +158,7 @@ function! VimwikiFoldLevel(lnum) abort
|
||||
endfunction
|
||||
|
||||
|
||||
" Constants used by VimwikiFoldText
|
||||
" Declare constants used by VimwikiFoldText
|
||||
" use \u2026 and \u21b2 (or \u2424) if enc=utf-8 to save screen space
|
||||
let s:ellipsis = (&encoding ==? 'utf-8') ? "\u2026" : '...'
|
||||
let s:ell_len = strlen(s:ellipsis)
|
||||
@ -164,18 +166,20 @@ let s:newline = (&encoding ==? 'utf-8') ? "\u21b2 " : ' '
|
||||
let s:tolerance = 5
|
||||
|
||||
|
||||
" unused
|
||||
" unused: too naive
|
||||
function! s:shorten_text_simple(text, len) abort
|
||||
let spare_len = a:len - len(a:text)
|
||||
return (spare_len>=0) ? [a:text,spare_len] : [a:text[0:a:len].s:ellipsis, -1]
|
||||
endfunction
|
||||
|
||||
|
||||
" Shorten text
|
||||
" Called: by VimwikiFoldText
|
||||
" s:shorten_text(text, len) = [string, spare] with "spare" = len-strlen(string)
|
||||
" for long enough "text", the string's length is within s:tolerance of "len"
|
||||
" (so that -s:tolerance <= spare <= s:tolerance, "string" ends with s:ellipsis)
|
||||
" Return: [string, spare]
|
||||
function! s:shorten_text(text, len) abort
|
||||
" returns [string, spare]
|
||||
" strlen() returns lenght in bytes, not in characters, so we'll have to do a
|
||||
" trick here -- replace all non-spaces with dot, calculate lengths and
|
||||
" indexes on it, then use original string to break at selected index.
|
||||
@ -192,6 +196,7 @@ function! s:shorten_text(text, len) abort
|
||||
endfunction
|
||||
|
||||
|
||||
" Fold text chapter
|
||||
function! VimwikiFoldText() abort
|
||||
let line = getline(v:foldstart)
|
||||
let main_text = substitute(line, '^\s*', repeat(' ',indent(v:foldstart)), '')
|
||||
@ -528,6 +533,7 @@ 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 !=? ''
|
||||
|
Reference in New Issue
Block a user