Merge branch 'dev' into dev

This commit is contained in:
Alexey Radkov 2019-03-15 15:38:22 +03:00 committed by GitHub
commit fa6342c454
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 96 additions and 35 deletions

View File

@ -63,7 +63,7 @@ endfunction
function! s:is_separator(line) function! s:is_separator(line)
return a:line =~# '^\s*'.s:rxSep().'\(--\+'.s:rxSep().'\)\+\s*$' return a:line =~# '^\s*'.s:rxSep().'\(:\=--\+:\='.s:rxSep().'\)\+\s*$'
endfunction endfunction
@ -72,6 +72,11 @@ function! s:is_separator_tail(line)
endfunction endfunction
function! s:is_last_column(lnum, cnum)
return a:line =~# '^\{-1}\%(\s*\|-*\)\%('.s:rxSep().'-\+\)\+'.s:rxSep().'\s*$'
endfunction
function! s:is_last_column(lnum, cnum) function! s:is_last_column(lnum, cnum)
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*$'
@ -264,6 +269,35 @@ function! s:get_rows(lnum, ...)
endfunction endfunction
function! s:get_cell_aligns(lnum)
let aligns = {}
for [lnum, row] in s:get_rows(a:lnum)
let found_separator = s:is_separator(row)
if found_separator
let cells = vimwiki#tbl#get_cells(row)
for idx in range(len(cells))
let cell = cells[idx]
if cell =~# '^--\+:'
let aligns[idx] = 'right'
elseif cell =~# '^:--\+:'
let aligns[idx] = 'center'
else
let aligns[idx] = 'left'
endif
endfor
return aligns
endif
endfor
if !found_separator
let cells = vimwiki#tbl#get_cells(row)
for idx in range(len(cells))
let aligns[idx] = 'left'
endfor
endif
return aligns
endfunction
function! s:get_cell_max_lens(lnum, ...) function! s:get_cell_max_lens(lnum, ...)
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)
@ -316,12 +350,13 @@ function! s:get_aligned_rows(lnum, col1, col2, depth)
endfor endfor
let max_lens = s:get_cell_max_lens(a:lnum, cells, startlnum, rows) let max_lens = s:get_cell_max_lens(a:lnum, cells, startlnum, rows)
endif endif
let aligns = s:get_cell_aligns(a:lnum)
let result = [] let result = []
for [lnum, row] in rows for [lnum, row] in rows
if s:is_separator(row) if s:is_separator(row)
let new_row = s:fmt_sep(max_lens, a:col1, a:col2) let new_row = s:fmt_sep(max_lens, aligns, a:col1, a:col2)
else else
let new_row = s:fmt_row(cells[lnum - startlnum], max_lens, a:col1, a:col2) let new_row = s:fmt_row(cells[lnum - startlnum], max_lens, aligns, a:col1, a:col2)
endif endif
call add(result, [lnum, new_row]) call add(result, [lnum, new_row])
endfor endfor
@ -350,20 +385,25 @@ function! s:cur_column()
endfunction endfunction
function! s:fmt_cell(cell, max_len) function! s:fmt_cell(cell, max_len, align)
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'
let cell .= repeat(' ', diff) let cell .= repeat(' ', diff)
elseif a:align == 'right'
let cell = repeat(' ',diff).cell
else
let cell = repeat(' ',diff/2).cell.repeat(' ',diff-diff/2)
endif
return cell return cell
endfunction endfunction
function! s:fmt_row(cells, max_lens, col1, col2) function! s:fmt_row(cells, max_lens, aligns, col1, col2)
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
@ -372,28 +412,36 @@ function! s:fmt_row(cells, max_lens, col1, col2)
let idx = a:col1 let idx = a:col1
endif endif
let value = a:cells[idx] let value = a:cells[idx]
let new_line .= s:fmt_cell(value, a:max_lens[idx]).s:rxSep() let new_line .= s:fmt_cell(value, a:max_lens[idx], a:aligns[idx]).s:rxSep()
endfor endfor
let idx = len(a:cells) let idx = len(a:cells)
while idx < len(a:max_lens) while idx < len(a:max_lens)
let new_line .= s:fmt_cell('', a:max_lens[idx]).s:rxSep() let new_line .= s:fmt_cell('', a:max_lens[idx], a:aligns[idx]).s:rxSep()
let idx += 1 let idx += 1
endwhile endwhile
return new_line return new_line
endfunction endfunction
function! s:fmt_cell_sep(max_len) function! s:fmt_cell_sep(max_len, align)
let cell = ''
if a:max_len == 0 if a:max_len == 0
return repeat('-', 3) let cell .= '-'
else else
return repeat('-', a:max_len+2) let cell .= repeat('-', a:max_len)
endif
if a:align == 'right'
return cell.'-:'
elseif a:align == 'left'
return cell.'--'
else
return ':'.cell.':'
endif endif
endfunction endfunction
function! s:fmt_sep(max_lens, col1, col2) function! s:fmt_sep(max_lens, aligns, col1, col2)
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
@ -401,7 +449,7 @@ function! s:fmt_sep(max_lens, col1, col2)
elseif idx == a:col2 elseif idx == a:col2
let idx = a:col1 let idx = a:col1
endif endif
let new_line .= s:fmt_cell_sep(a:max_lens[idx]).s:rxSep() let new_line .= s:fmt_cell_sep(a:max_lens[idx], a:aligns[idx]).s:rxSep()
endfor endfor
return new_line return new_line
endfunction endfunction

View File

@ -883,6 +883,12 @@ is decorated: >
super^script^ super^script^
sub,,script,, sub,,script,,
For Markdown syntax these variations are used: >
**bold text** or __bold text__
*italic text* or _italic text_
***bold_italic text*** or ___italic_bold text___
Furthermore, there are a number of words which are highlighted extra flashy: Furthermore, there are a number of words which are highlighted extra flashy:
TODO, DONE, STARTED, FIXME, FIXED, XXX. TODO, DONE, STARTED, FIXME, FIXED, XXX.
@ -1721,6 +1727,15 @@ values: >
To indent table indent the first row. Then format it with 'gqq'. To indent table indent the first row. Then format it with 'gqq'.
You can specify the type of horizontal alignment for columns in the separator
using the ':' character. The default is left-align. >
| Date | Item | Price |
|------------|:------:|--------:|
| yest | Coffee | $15.00 |
| 2017-02-13 | Tea | $2.10 |
| 2017-03-14 | Cake | $143.12 |
<
============================================================================== ==============================================================================
10. Diary *vimwiki-diary* 10. Diary *vimwiki-diary*

View File

@ -383,7 +383,7 @@ hi def link VimwikiBoldT VimwikiBold
hi def VimwikiItalic term=italic cterm=italic gui=italic hi def VimwikiItalic term=italic cterm=italic gui=italic
hi def link VimwikiItalicT VimwikiItalic hi def link VimwikiItalicT VimwikiItalic
hi def VimwikiBoldItalic term=bold cterm=bold gui=bold,italic hi def VimwikiBoldItalic term=bold,italic cterm=bold,italic gui=bold,italic
hi def link VimwikiItalicBold VimwikiBoldItalic hi def link VimwikiItalicBold VimwikiBoldItalic
hi def link VimwikiBoldItalicT VimwikiBoldItalic hi def link VimwikiBoldItalicT VimwikiBoldItalic
hi def link VimwikiItalicBoldT VimwikiBoldItalic hi def link VimwikiItalicBoldT VimwikiBoldItalic

View File

@ -13,38 +13,36 @@ let s:markdown_syntax = g:vimwiki_syntax_variables['markdown']
let s:markdown_syntax.rxEqIn = '\$[^$`]\+\$' let s:markdown_syntax.rxEqIn = '\$[^$`]\+\$'
let s:markdown_syntax.char_eqin = '\$' let s:markdown_syntax.char_eqin = '\$'
" text: *strong* " text: **strong** or __strong__
" let s:markdown_syntax.rxBold = '\*[^*]\+\*'
let s:markdown_syntax.rxBold = '\%(^\|\s\|[[:punct:]]\)\@<='. let s:markdown_syntax.rxBold = '\%(^\|\s\|[[:punct:]]\)\@<='.
\'\*'. \'\(\*\|_\)\{2\}'.
\'\%([^*`[:space:]][^*`]*[^*`[:space:]]\|[^*`[:space:]]\)'. \'\%([^*_`[:space:]][^*_`]*[^*_`[:space:]]\|[^*_`[:space:]]\)'.
\'\*'. \'\1\{2\}'.
\'\%([[:punct:]]\|\s\|$\)\@=' \'\%([[:punct:]]\|\s\|$\)\@='
let s:markdown_syntax.char_bold = '*' let s:markdown_syntax.char_bold = '\*\*\|__'
" text: _emphasis_ " text: _emphasis_ or *emphasis*
" let s:markdown_syntax.rxItalic = '_[^_]\+_'
let s:markdown_syntax.rxItalic = '\%(^\|\s\|[[:punct:]]\)\@<='. let s:markdown_syntax.rxItalic = '\%(^\|\s\|[[:punct:]]\)\@<='.
\'_'. \'\(\*\|_\)'.
\'\%([^_`[:space:]][^_`]*[^_`[:space:]]\|[^_`[:space:]]\)'. \'\%([^*_`[:space:]][^*_`]*[^*_`[:space:]]\|[^*_`[:space:]]\)'.
\'_'. \'\1'.
\'\%([[:punct:]]\|\s\|$\)\@=' \'\%([[:punct:]]\|\s\|$\)\@='
let s:markdown_syntax.char_italic = '_' let s:markdown_syntax.char_italic = '\*\|_'
" text: *_bold italic_* or _*italic bold*_ " text: *_bold italic_* or _*italic bold*_
let s:markdown_syntax.rxBoldItalic = '\%(^\|\s\|[[:punct:]]\)\@<='. let s:markdown_syntax.rxBoldItalic = '\%(^\|\s\|[[:punct:]]\)\@<='.
\'\*_'. \'\(\*\)\{3\}'.
\'\%([^*_`[:space:]][^*_`]*[^*_`[:space:]]\|[^*_`[:space:]]\)'. \'\%([^*`[:space:]][^*`]*[^*`[:space:]]\|[^*`[:space:]]\)'.
\'_\*'. \'\1\{3\}'.
\'\%([[:punct:]]\|\s\|$\)\@=' \'\%([[:punct:]]\|\s\|$\)\@='
let s:markdown_syntax.char_bolditalic = '\*_' let s:markdown_syntax.char_bolditalic = '\*\*\*'
let s:markdown_syntax.rxItalicBold = '\%(^\|\s\|[[:punct:]]\)\@<='. let s:markdown_syntax.rxItalicBold = '\%(^\|\s\|[[:punct:]]\)\@<='.
\'_\*'. \'\(_\)\{3\}'.
\'\%([^*_`[:space:]][^*_`]*[^*_`[:space:]]\|[^*_`[:space:]]\)'. \'\%([^_`[:space:]][^_`]*[^_`[:space:]]\|[^_`[:space:]]\)'.
\'\*_'. \'\1\{3\}'.
\'\%([[:punct:]]\|\s\|$\)\@=' \'\%([[:punct:]]\|\s\|$\)\@='
let s:markdown_syntax.char_italicbold = '_\*' let s:markdown_syntax.char_italicbold = '___'
" text: `code` " text: `code`
let s:markdown_syntax.rxCode = '`[^`]\+`' let s:markdown_syntax.rxCode = '`[^`]\+`'