Fix: Highlight borken with done item rided by code (Issue #971)
This commit is contained in:
parent
fc056cfeca
commit
825870ec1b
@ -436,8 +436,15 @@ function! vimwiki#base#generate_links(create, ...) abort
|
|||||||
let link_caption = link
|
let link_caption = link
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
" Replace Url, Description
|
||||||
let entry = s:safesubstitute(link_tpl, '__LinkUrl__', link, '')
|
let entry = s:safesubstitute(link_tpl, '__LinkUrl__', link, '')
|
||||||
let entry = s:safesubstitute(entry, '__LinkDescription__', link_caption, '')
|
let entry = s:safesubstitute(entry, '__LinkDescription__', link_caption, '')
|
||||||
|
|
||||||
|
" Replace Extension
|
||||||
|
let wiki_nr = vimwiki#vars#get_bufferlocal('wiki_nr')
|
||||||
|
let extension = vimwiki#vars#get_wikilocal('ext', wiki_nr)
|
||||||
|
let entry = substitute(entry, '__FileExtension__', extension, 'g')
|
||||||
|
|
||||||
call add(lines, bullet. entry)
|
call add(lines, bullet. entry)
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
|
@ -219,6 +219,14 @@ function! vimwiki#u#ft_is_vw() abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
" Helper: Getter
|
||||||
|
" :param: syntax <string> to retrive, default to current
|
||||||
|
function! vimwiki#u#get_syntax_dic(...) abort
|
||||||
|
let syntax = a:0 ? a:1 : vimwiki#vars#get_wikilocal('syntax')
|
||||||
|
return g:vimwiki_syntax_variables[syntax]
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
" Helper: Expand regex from reduced typeface delimiters
|
" Helper: Expand regex from reduced typeface delimiters
|
||||||
" :param: list<list,delimiters>> with reduced regex
|
" :param: list<list,delimiters>> with reduced regex
|
||||||
" Return: list with extended regex delimiters (not inside a word)
|
" Return: list with extended regex delimiters (not inside a word)
|
||||||
@ -269,19 +277,19 @@ function! vimwiki#u#hi_typeface(dic) abort
|
|||||||
" Italic must go before, otherwise single * takes precedence over ** and ** is considered as
|
" Italic must go before, otherwise single * takes precedence over ** and ** is considered as
|
||||||
" -- a void italic.
|
" -- a void italic.
|
||||||
" Note:
|
" Note:
|
||||||
" -- The last syntax defined take precedence so that user can change at runtime (:h :syn-define)
|
" The last syntax defined take precedence so that user can change at runtime (:h :syn-define)
|
||||||
" -- Some cases are contained by default:
|
" Some cases are contained by default:
|
||||||
" -- -- ex: VimwikiCodeBoldUnderline is not defined in colorschemes -> VimwikiCode
|
" -- ex: VimwikiCodeBoldUnderline is not defined in colorschemes -> VimwikiCode
|
||||||
" -- -- see: #709 asking for concealing quotes in bold, so it must be higlighted differently
|
" -- see: #709 asking for concealing quotes in bold, so it must be higlighted differently
|
||||||
" -- -- -- for the user to understand what is concealed around
|
" -- -- for the user to understand what is concealed around
|
||||||
|
" VimwikiCheckBoxDone and VimwikiDelText are as their are even when nested in bold or italic
|
||||||
|
" -- This is because it would add a lot of code (as n**2) at startup and is not often used
|
||||||
|
" -- Here n=3 (bold, italic, underline)
|
||||||
" Bold > Italic > Underline
|
" Bold > Italic > Underline
|
||||||
|
|
||||||
" Declare nesting capabilities
|
let nested = vimwiki#u#get_syntax_dic().nested
|
||||||
" -- to be embeded in standard: bold, italic, underline
|
|
||||||
let nested = 'VimwikiCode,VimwikiEqIn,VimwikiDelText,VimwikiSuperScript,VimwikiSubScript'
|
|
||||||
" -- to be embeded in exetended (the one above)
|
|
||||||
let nested .= ',VimwikiBold,VimwikiItalic,VimwikiUmderline'
|
|
||||||
|
|
||||||
|
" Italic
|
||||||
for i in a:dic['italic']
|
for i in a:dic['italic']
|
||||||
" -- Italic 1
|
" -- Italic 1
|
||||||
call vimwiki#u#hi_tag(i[0], i[1], 'VimwikiItalic ', nested .',VimwikiItalicBold,VimwikiItalicUnderline')
|
call vimwiki#u#hi_tag(i[0], i[1], 'VimwikiItalic ', nested .',VimwikiItalicBold,VimwikiItalicUnderline')
|
||||||
@ -295,6 +303,7 @@ function! vimwiki#u#hi_typeface(dic) abort
|
|||||||
call vimwiki#u#hi_tag(i[0], i[1], 'VimwikiUnderlineBoldItalic', nested, 2)
|
call vimwiki#u#hi_tag(i[0], i[1], 'VimwikiUnderlineBoldItalic', nested, 2)
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
|
" Bold
|
||||||
for b in a:dic['bold']
|
for b in a:dic['bold']
|
||||||
" -- Bold 1
|
" -- Bold 1
|
||||||
call vimwiki#u#hi_tag(b[0],b[1], 'VimwikiBold', nested . ',VimwikiBoldUnderline,VimwikiBoldItalic')
|
call vimwiki#u#hi_tag(b[0],b[1], 'VimwikiBold', nested . ',VimwikiBoldUnderline,VimwikiBoldItalic')
|
||||||
@ -308,12 +317,14 @@ function! vimwiki#u#hi_typeface(dic) abort
|
|||||||
call vimwiki#u#hi_tag(b[0], b[1], 'VimwikiUnderlineItalicBold', nested, 2)
|
call vimwiki#u#hi_tag(b[0], b[1], 'VimwikiUnderlineItalicBold', nested, 2)
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
|
" Bold Italic
|
||||||
if has_key(a:dic, 'bold_italic')
|
if has_key(a:dic, 'bold_italic')
|
||||||
for bi in a:dic['bold_italic']
|
for bi in a:dic['bold_italic']
|
||||||
call vimwiki#u#hi_tag(bi[0], bi[1], 'VimwikiBoldItalic', nested . ',VimwikiBoldItalicUnderline')
|
call vimwiki#u#hi_tag(bi[0], bi[1], 'VimwikiBoldItalic', nested . ',VimwikiBoldItalicUnderline')
|
||||||
endfor
|
endfor
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
" Underline
|
||||||
for u in a:dic['underline']
|
for u in a:dic['underline']
|
||||||
" -- Underline 1
|
" -- Underline 1
|
||||||
call vimwiki#u#hi_tag(u[0], u[1], 'VimwikiUnderline', nested . ',VimwikiUnderlineBold,VimwikiUnderlineItalic')
|
call vimwiki#u#hi_tag(u[0], u[1], 'VimwikiUnderline', nested . ',VimwikiUnderlineBold,VimwikiUnderlineItalic')
|
||||||
@ -327,16 +338,17 @@ function! vimwiki#u#hi_typeface(dic) abort
|
|||||||
call vimwiki#u#hi_tag(u[0], u[1], 'VimwikiItalicBoldUnderline', nested, 2)
|
call vimwiki#u#hi_tag(u[0], u[1], 'VimwikiItalicBoldUnderline', nested, 2)
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
|
" Strikethrough
|
||||||
|
" Note: VimwikiBoldDelText Not Implemented (see above)
|
||||||
|
for u in a:dic['del']
|
||||||
|
call vimwiki#u#hi_tag(u[0], u[1], 'VimwikiDelText', nested)
|
||||||
|
endfor
|
||||||
|
|
||||||
"" Code do not contain anything but can be contained very nested
|
"" Code do not contain anything but can be contained very nested
|
||||||
for u in a:dic['code']
|
for u in a:dic['code']
|
||||||
call vimwiki#u#hi_tag(u[0], u[1], 'VimwikiCode', '')
|
call vimwiki#u#hi_tag(u[0], u[1], 'VimwikiCode', '')
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
" Deleted
|
|
||||||
for u in a:dic['del']
|
|
||||||
call vimwiki#u#hi_tag(u[0], u[1], 'VimwikiDelText', nested)
|
|
||||||
endfor
|
|
||||||
|
|
||||||
"" Equation
|
"" Equation
|
||||||
for u in a:dic['eq']
|
for u in a:dic['eq']
|
||||||
call vimwiki#u#hi_tag(u[0], u[1], 'VimwikiEqIn', nested)
|
call vimwiki#u#hi_tag(u[0], u[1], 'VimwikiEqIn', nested)
|
||||||
|
@ -21,9 +21,15 @@ let b:vimwiki_syntax_concealends = has('conceal') ? ' concealends' : ''
|
|||||||
" Populate all syntax vars
|
" Populate all syntax vars
|
||||||
" Include syntax/vimwiki_markdown.vim as "side effect"
|
" Include syntax/vimwiki_markdown.vim as "side effect"
|
||||||
call vimwiki#vars#populate_syntax_vars(s:current_syntax)
|
call vimwiki#vars#populate_syntax_vars(s:current_syntax)
|
||||||
|
|
||||||
let syntax_dic = g:vimwiki_syntax_variables[s:current_syntax]
|
let syntax_dic = g:vimwiki_syntax_variables[s:current_syntax]
|
||||||
|
|
||||||
|
" Declare nesting capabilities
|
||||||
|
" -- to be embeded in standard: bold, italic, underline
|
||||||
|
let syntax_dic.nested_extended = 'VimwikiCode,VimwikiEqIn,VimwikiSuperScript,VimwikiSubScript'
|
||||||
|
" -- to be embeded in exetended (the one above)
|
||||||
|
let syntax_dic.nested_typeface = 'VimwikiBold,VimwikiItalic,VimwikiUmderline,VimwikiDelText'
|
||||||
|
let syntax_dic.nested = syntax_dic.nested_extended . ',' . syntax_dic.nested_typeface
|
||||||
|
|
||||||
" text: `code` or ``code`` only inline
|
" text: `code` or ``code`` only inline
|
||||||
" Note: `\%(^\|[^`]\)\@<=` means after a new line or a non `
|
" Note: `\%(^\|[^`]\)\@<=` means after a new line or a non `
|
||||||
let syntax_dic.dTypeface.code = [
|
let syntax_dic.dTypeface.code = [
|
||||||
@ -264,11 +270,13 @@ execute 'syntax match VimwikiList /'.vimwiki#vars#get_wikilocal('rxListItemWitho
|
|||||||
execute 'syntax match VimwikiList /'.vimwiki#vars#get_syntaxlocal('rxListDefine').'/'
|
execute 'syntax match VimwikiList /'.vimwiki#vars#get_syntaxlocal('rxListDefine').'/'
|
||||||
execute 'syntax match VimwikiListTodo /'.vimwiki#vars#get_wikilocal('rxListItem').'/'
|
execute 'syntax match VimwikiListTodo /'.vimwiki#vars#get_wikilocal('rxListItem').'/'
|
||||||
|
|
||||||
|
" Task list done
|
||||||
if vimwiki#vars#get_global('hl_cb_checked') == 1
|
if vimwiki#vars#get_global('hl_cb_checked') == 1
|
||||||
execute 'syntax match VimwikiCheckBoxDone /'.vimwiki#vars#get_wikilocal('rxListItemWithoutCB')
|
execute 'syntax match VimwikiCheckBoxDone /'.vimwiki#vars#get_wikilocal('rxListItemWithoutCB')
|
||||||
\ . '\s*\[['.vimwiki#vars#get_wikilocal('listsyms_list')[-1]
|
\ . '\s*\[['.vimwiki#vars#get_wikilocal('listsyms_list')[-1]
|
||||||
\ . vimwiki#vars#get_global('listsym_rejected')
|
\ . vimwiki#vars#get_global('listsym_rejected')
|
||||||
\ . ']\]\s.*$/ contains=VimwikiNoExistsLink,VimwikiLink,VimwikiWeblink1,VimwikiWikiLink1,@Spell'
|
\ . ']\]\s\(.*\)$/ '
|
||||||
|
\ . 'contains=' . syntax_dic.nested . ',VimwikiNoExistsLink,VimwikiLink,VimwikiWeblink1,VimwikiWikiLink1,@Spell'
|
||||||
elseif vimwiki#vars#get_global('hl_cb_checked') == 2
|
elseif vimwiki#vars#get_global('hl_cb_checked') == 2
|
||||||
execute 'syntax match VimwikiCheckBoxDone /'
|
execute 'syntax match VimwikiCheckBoxDone /'
|
||||||
\ . vimwiki#vars#get_wikilocal('rxListItemAndChildren')
|
\ . vimwiki#vars#get_wikilocal('rxListItemAndChildren')
|
||||||
@ -332,6 +340,9 @@ endif
|
|||||||
let s:typeface_dic = vimwiki#vars#get_syntaxlocal('dTypeface')
|
let s:typeface_dic = vimwiki#vars#get_syntaxlocal('dTypeface')
|
||||||
call vimwiki#u#hi_typeface(s:typeface_dic)
|
call vimwiki#u#hi_typeface(s:typeface_dic)
|
||||||
|
|
||||||
|
" Link highlighting groups
|
||||||
|
""""""""""""""""""""""""""
|
||||||
|
|
||||||
hi def link VimwikiMarkers Normal
|
hi def link VimwikiMarkers Normal
|
||||||
hi def link VimwikiError Normal
|
hi def link VimwikiError Normal
|
||||||
|
|
||||||
|
@ -4,6 +4,45 @@
|
|||||||
# 1 Typeface {{{1
|
# 1 Typeface {{{1
|
||||||
#################
|
#################
|
||||||
|
|
||||||
|
# With vimwiki_hl_cb_checked {{{2
|
||||||
|
|
||||||
|
Given vimwiki (task list with code):
|
||||||
|
Normal syntax
|
||||||
|
- [X] Lorem __sit__ `sed do eiusmod
|
||||||
|
tempor` incididunt ut labore et dolore magna aliqua
|
||||||
|
Normal syntax
|
||||||
|
|
||||||
|
Execute (let g:vimwiki_hl_cb_checked = 1):
|
||||||
|
let g:vimwiki_hl_cb_checked = 1
|
||||||
|
unlet g:vimwiki_syntax_variables
|
||||||
|
call vimwiki#vars#init()
|
||||||
|
call SetSyntax('markdown')
|
||||||
|
|
||||||
|
Execute (Assert Done Syntax 1):
|
||||||
|
AssertEqual '' , SyntaxAt(1, 7)
|
||||||
|
AssertEqual 'VimwikiCheckBoxDone', SyntaxAt(2, 7)
|
||||||
|
AssertEqual 'VimwikiCode' , SyntaxAt(3, 7)
|
||||||
|
AssertEqual '' , SyntaxAt(4, 7)
|
||||||
|
|
||||||
|
Given vimwiki (task list with code):
|
||||||
|
Normal syntax
|
||||||
|
- [X] Lorem __sit__ `sed do eiusmod
|
||||||
|
tempor` incididunt ut labore et dolore magna aliqua
|
||||||
|
Normal syntax
|
||||||
|
|
||||||
|
Execute (let g:vimwiki_hl_cb_checked = 2):
|
||||||
|
let g:vimwiki_hl_cb_checked = 2
|
||||||
|
unlet g:vimwiki_syntax_variables
|
||||||
|
call vimwiki#vars#init()
|
||||||
|
call SetSyntax('markdown')
|
||||||
|
|
||||||
|
Execute (Assert Done Syntax 2):
|
||||||
|
AssertEqual '' , SyntaxAt(1, 7)
|
||||||
|
AssertEqual 'VimwikiCheckBoxDone', SyntaxAt(2, 7)
|
||||||
|
AssertEqual 'VimwikiCheckBoxDone', SyntaxAt(3, 7)
|
||||||
|
AssertEqual '' , SyntaxAt(4, 7)
|
||||||
|
|
||||||
|
|
||||||
# Extended types {{{2
|
# Extended types {{{2
|
||||||
|
|
||||||
Given vimwiki (Extended Types mono):
|
Given vimwiki (Extended Types mono):
|
||||||
|
Loading…
Reference in New Issue
Block a user