Feature: permit blockquote automatic continuation (issue #1274) (fixed)
This commit is contained in:
@@ -1,14 +1,16 @@
|
||||
---
|
||||
# Copied from previous .travis.yml by tinmarino the 2023-03-09
|
||||
|
||||
# Commented out to avoid verbosity on github commit status
|
||||
name: CI
|
||||
#description: Vimwiki CI test bank
|
||||
|
||||
# yamllint disable-line rule:truthy
|
||||
on: [push, pull_request, workflow_dispatch]
|
||||
|
||||
jobs:
|
||||
Typos:
|
||||
# Copyed from: https://github.com/junegunn/fzf/blob/master/.github/workflows/typos.yml
|
||||
# Copied from: https://github.com/junegunn/fzf/blob/master/
|
||||
# -- .github/workflows/typos.yml
|
||||
name: Typos
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
@@ -20,9 +22,23 @@ jobs:
|
||||
config: ./test/resources/typos_config.toml
|
||||
|
||||
|
||||
Yamllint:
|
||||
# Copied from: https://github.com/junegunn/fzf/blob/master/
|
||||
# -- .github/workflows/typos.yml
|
||||
name: Yamllint
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- uses: ibiqlik/action-yamllint@v3
|
||||
with:
|
||||
file_or_dir: .github/workflows/test-vader-action.yml
|
||||
|
||||
|
||||
Vint:
|
||||
# Copyed from: https://github.com/LudvigHz/vint-action
|
||||
# And local test/run_test.sh
|
||||
# Copied from: https://github.com/LudvigHz/vint-action
|
||||
# And local ./test/run_test.sh
|
||||
name: Vint
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
||||
@@ -1,9 +1,18 @@
|
||||
" vim:tabstop=2:shiftwidth=2:expandtab:textwidth=99
|
||||
" Vimwiki autoload plugin file
|
||||
" Description: Everything concerning lists and checkboxes
|
||||
" Title: Vimwiki list functions
|
||||
"
|
||||
" Description:
|
||||
" Everything concerning lists and checkboxes
|
||||
"
|
||||
" Also helpers for blockquotes as this file has intelligence and map (issue #1274)
|
||||
" i <Cr>
|
||||
" n o
|
||||
" n O
|
||||
" Which also got exploited for blocquotes
|
||||
"
|
||||
" Home: https://github.com/vimwiki/vimwiki/
|
||||
|
||||
|
||||
|
||||
if exists('g:loaded_vimwiki_list_auto') || &compatible
|
||||
finish
|
||||
endif
|
||||
@@ -145,11 +154,24 @@ function! s:line_has_marker(lnum) abort
|
||||
" Returns: 2 if there is a marker and text
|
||||
" 1 for a marker and no text
|
||||
" 0 for no marker at all (empty line or only text)
|
||||
if getline(a:lnum) =~# vimwiki#vars#get_wikilocal('rxListItem').'\s*$'
|
||||
|
||||
" Concatenate regex list and blockquote item
|
||||
let rx_list_or_blockquote =
|
||||
\ '\%('
|
||||
\ . vimwiki#vars#get_wikilocal('rxListItem')
|
||||
\ . '\|'
|
||||
\ . vimwiki#vars#get_wikilocal('rxBlockquoteItem')
|
||||
\ . '\)'
|
||||
|
||||
" Search for marker
|
||||
if getline(a:lnum) =~# rx_list_or_blockquote . '\s*$'
|
||||
" Found without text
|
||||
return 1
|
||||
elseif getline(a:lnum) =~# vimwiki#vars#get_wikilocal('rxListItem').'\s*\S'
|
||||
elseif getline(a:lnum) =~# rx_list_or_blockquote . '\s*\S'
|
||||
" Found with text
|
||||
return 2
|
||||
else
|
||||
" Not found
|
||||
return 0
|
||||
endif
|
||||
endfunction
|
||||
@@ -178,12 +200,17 @@ endfunction
|
||||
" ---------------------------------------------------------
|
||||
|
||||
function! s:get_item(lnum) abort
|
||||
" Returns: the mainly used data structure in this file
|
||||
" Return: the mainly used data structure in this file
|
||||
" An item represents a single list item and is a dictionary with the keys
|
||||
" lnum - the line number of the list item
|
||||
" type - 1 for bulleted item, 2 for numbered item, 0 for a regular line (default)
|
||||
" type - the type of marker at current line
|
||||
" - 0 for a regular line (default)
|
||||
" - 1 for bulleted item
|
||||
" - 2 for numbered item
|
||||
" - 3 a blockquote item (see #1274 to add line-continuation trick to blockquotes)
|
||||
" mrkr - the concrete marker, e.g. '**' or 'b)' (default '')
|
||||
" cb - the char in the checkbox or '' if there is no checkbox
|
||||
|
||||
" Init default
|
||||
let item = {'lnum': a:lnum}
|
||||
let item.type = 0
|
||||
@@ -195,7 +222,15 @@ function! s:get_item(lnum) abort
|
||||
return item
|
||||
endif
|
||||
|
||||
" Search for list on current line
|
||||
" Clause: Search for blockquotes (#1274) and return it if found
|
||||
let matches = matchlist(getline(a:lnum), vimwiki#vars#get_wikilocal('rxBlockquoteItem'))
|
||||
if len(matches) >= 1 && matches[1] !=? ''
|
||||
let item.type = 3
|
||||
let item.mrkr = matches[1]
|
||||
return item
|
||||
endif
|
||||
|
||||
" List: Search for list on current line if no blockquotes
|
||||
let matches = matchlist(getline(a:lnum), vimwiki#vars#get_wikilocal('rxListItem'))
|
||||
" Clause: If not on a list line => do not work
|
||||
if matches == [] ||
|
||||
@@ -205,6 +240,7 @@ function! s:get_item(lnum) abort
|
||||
endif
|
||||
|
||||
" Fill item
|
||||
" The checkbox inner is the last match
|
||||
let item.cb = matches[3]
|
||||
if matches[1] !=? ''
|
||||
let item.type = 1
|
||||
@@ -1842,3 +1878,5 @@ function! vimwiki#lst#fold_level(lnum) abort
|
||||
endif
|
||||
return '='
|
||||
endfunction
|
||||
|
||||
" vim:tabstop=2:shiftwidth=2:expandtab:textwidth=99
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
" vim:tabstop=2:shiftwidth=2:expandtab:textwidth=99
|
||||
" Vimwiki autoload plugin file
|
||||
" Description: Vimwiki variable definition and manipulation
|
||||
" Title: Vimwiki variable definition and manipulation functions
|
||||
"
|
||||
" Home: https://github.com/vimwiki/vimwiki/
|
||||
|
||||
" ------------------------------------------------------------------------------------------------
|
||||
@@ -610,6 +609,8 @@ function! s:normalize_wikilocal_settings() abort
|
||||
endif
|
||||
call s:populate_list_vars(wiki_settings)
|
||||
|
||||
call s:populate_blockquote_vars(wiki_settings)
|
||||
|
||||
" Check nested syntax
|
||||
for keyword in keys(wiki_settings.nested_syntaxes)
|
||||
if type(keyword) != type('') || empty(keyword) || type(wiki_settings.nested_syntaxes[keyword]) != type('') ||
|
||||
@@ -834,6 +835,10 @@ function! s:get_common_syntaxlocal() abort
|
||||
let s:rx_inline_math_start = '\%(^\|[^$\\]\)\@<=\$\%($\|[^$[:space:]]\)\@='
|
||||
let s:rx_inline_math_end = '\%(^\|[^$\\[:space:]]\)\@<=\$\%($\|[^$0-9]\)\@='
|
||||
|
||||
" Blockquote marker (#1274)
|
||||
" -- it should not be changed but let's avoid hardcoding
|
||||
let res.blockquote_markers = {'type': type([]), 'default': ['>']}
|
||||
|
||||
return res
|
||||
endfunction
|
||||
|
||||
@@ -1121,6 +1126,22 @@ function! s:populate_list_vars(wiki) abort
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:populate_blockquote_vars(wiki) abort
|
||||
" Populate blockquote variable
|
||||
" Start being more intelligent on blockquote line continuation
|
||||
" See: issue #1274
|
||||
|
||||
" Start of line and spaces
|
||||
let a:wiki.rxBlockquoteItem = '^\s*\('
|
||||
|
||||
" Content
|
||||
let blockquote_markers = vimwiki#vars#get_syntaxlocal('blockquote_markers')
|
||||
let a:wiki.rxBlockquoteItem .= join(blockquote_markers, '\|')
|
||||
|
||||
let a:wiki.rxBlockquoteItem .= '\)'
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:populate_extra_markdown_vars() abort
|
||||
" Populate markdown specific syntax variables
|
||||
let mkd_syntax = g:vimwiki_syntaxlocal_vars['markdown']
|
||||
@@ -1681,3 +1702,4 @@ function! vimwiki#vars#number_of_wikis() abort
|
||||
" Return: number of registered wikis + temporary
|
||||
return len(g:vimwiki_wikilocal_vars) - 1
|
||||
endfunction
|
||||
" vim:tabstop=2:shiftwidth=2:expandtab:textwidth=99
|
||||
|
||||
@@ -2948,6 +2948,14 @@ Where:
|
||||
- `['*', '-', '+']` is the option value
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
*blockquote_markers*
|
||||
|
||||
List of markers to define the blockquote regrion
|
||||
|
||||
Default: ['>']
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
*yaml_metadata_block*
|
||||
|
||||
@@ -4012,6 +4020,9 @@ master is retained as a legacy mirror of the dev branch.
|
||||
This is somewhat experimental, and will probably be refined over time.
|
||||
|
||||
Fixed:~
|
||||
* Issue #1274: Feature: Continue blockquote when <CR>
|
||||
is pressed in insert mode
|
||||
Also add the |blockquote_markers| variable
|
||||
* Issue #1316: Permit tags in heading
|
||||
* Issue #1270: VimwikiAddHeaderLevel map (3=) was broken by a previous
|
||||
refactoring commit
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
# Issue: #1274
|
||||
# Feature: Markdown -- Continue blockquote when <CR> is pressed in insert mode.
|
||||
|
||||
|
||||
Given vimwiki (Blockquote with test {{{1):
|
||||
> Dummy text 1
|
||||
|
||||
|
||||
Execute (Set syntax markdown):
|
||||
call SetSyntax('markdown')
|
||||
|
||||
|
||||
Do (Press insert, enter and type):
|
||||
A
|
||||
\<Cr>
|
||||
Dummy text 2
|
||||
|
||||
|
||||
Expect(Marker added 1):
|
||||
> Dummy text 1
|
||||
> Dummy text 2
|
||||
|
||||
|
||||
Do (Press o and type):
|
||||
o
|
||||
Dummy text 2
|
||||
|
||||
|
||||
Expect(Marker added 2):
|
||||
> Dummy text 1
|
||||
> Dummy text 2
|
||||
|
||||
|
||||
Do (Press O and type):
|
||||
O
|
||||
Dummy text 2
|
||||
|
||||
|
||||
Expect(Marker added 3, above):
|
||||
> Dummy text 2
|
||||
> Dummy text 1
|
||||
|
||||
|
||||
Given vimwiki (Blockquote without test {{{1):
|
||||
>
|
||||
|
||||
|
||||
Do (Press insert, enter and type):
|
||||
A
|
||||
\<Cr>
|
||||
Dummy text 2
|
||||
|
||||
|
||||
Expect(Marker removed):
|
||||
Dummy text 2
|
||||
|
||||
|
||||
Do (Press o):
|
||||
o
|
||||
Dummy text 2
|
||||
|
||||
|
||||
Expect(Marker appended, below):
|
||||
>
|
||||
> Dummy text 2
|
||||
|
||||
|
||||
Do (Press O):
|
||||
O
|
||||
Dummy text 2
|
||||
|
||||
|
||||
Expect(Marker appended, above):
|
||||
> Dummy text 2
|
||||
>
|
||||
@@ -5,13 +5,20 @@ Before(Define function for yaml inspection):
|
||||
function! Issue1287Yaml(line)
|
||||
" The line where the yaml delimiter is: 1 if at top
|
||||
let l = a:line
|
||||
|
||||
Log "1: " . string(GetSyntaxStack(l + 0, 2))
|
||||
AssertEqual 'textSnipYAML', GetSyntaxStack(l + 0, 2)[0]
|
||||
Log '2: ' . string(GetSyntaxStack(l + 0, 2))
|
||||
AssertEqual 'VimwikiPre', GetSyntaxStack(l + 0, 2)[1]
|
||||
|
||||
Log '3: ' . string(GetSyntaxStack(l + 1, 2))
|
||||
AssertEqual 'textSnipYAML', GetSyntaxStack(l + 1, 2)[0]
|
||||
Log '4: ' . string(GetSyntaxStack(l + 2, 2))
|
||||
AssertEqual 'textSnipYAML', GetSyntaxStack(l + 2, 2)[0]
|
||||
Log '5: ' . string(GetSyntaxStack(l + 2, 20))
|
||||
AssertEqual 'textSnipYAML', GetSyntaxStack(l + 2, 20)[0]
|
||||
|
||||
Log '6: ' . string(GetSyntaxStack(l + 3, 2))
|
||||
AssertEqual 'VimwikiPre', GetSyntaxStack(l + 3, 2)[-1]
|
||||
endfunction
|
||||
|
||||
|
||||
Reference in New Issue
Block a user