1
0
mirror of https://github.com/amix/vimrc synced 2025-06-30 11:54:59 +08:00

Updated vim plugins

This commit is contained in:
Amir
2022-12-03 11:29:32 +01:00
parent d8db85c663
commit 2b653aa950
32 changed files with 650 additions and 110 deletions

View File

@ -25,7 +25,7 @@ if get(g:, 'vim_markdown_folding_style_pythonic', 0)
let b:fenced_block = 0
endif
" else, if we're caring about front matter
elseif g:vim_markdown_frontmatter == 1
elseif get(g:, 'vim_markdown_frontmatter', 0) == 1
" if we're in front matter and not on line 1
if b:front_matter == 1 && a:lnum > 2
let l0 = getline(a:lnum-1)
@ -111,7 +111,7 @@ else " vim_markdown_folding_style_pythonic == 0
elseif b:fenced_block == 1
let b:fenced_block = 0
endif
elseif g:vim_markdown_frontmatter == 1
elseif get(g:, 'vim_markdown_frontmatter', 0) == 1
if b:front_matter == 1
if l0 ==# '---'
let b:front_matter = 0

View File

@ -494,7 +494,9 @@ endfunction
function! s:SetexToAtx(line1, line2)
let l:originalNumLines = line('$')
execute 'silent! ' . a:line1 . ',' . a:line2 . 'substitute/\v(.*\S.*)\n\=+$/# \1/'
execute 'silent! ' . a:line1 . ',' . a:line2 . 'substitute/\v(.*\S.*)\n-+$/## \1/'
let l:changed = l:originalNumLines - line('$')
execute 'silent! ' . a:line1 . ',' . (a:line2 - l:changed) . 'substitute/\v(.*\S.*)\n-+$/## \1'
return l:originalNumLines - line('$')
endfunction
@ -854,19 +856,23 @@ function! s:SyntaxInclude(filetype)
return grouplistname
endfunction
function! s:IsHighlightSourcesEnabledForBuffer()
" Enable for markdown buffers, and for liquid buffers with markdown format
return &filetype =~# 'markdown' || get(b:, 'liquid_subtype', '') =~# 'markdown'
endfunction
function! s:MarkdownRefreshSyntax(force)
" Use != to compare &syntax's value to use the same logic run on
" $VIMRUNTIME/syntax/synload.vim.
"
" vint: next-line -ProhibitEqualTildeOperator
if &filetype =~# 'markdown' && line('$') > 1 && &syntax != 'OFF'
if s:IsHighlightSourcesEnabledForBuffer() && line('$') > 1 && &syntax != 'OFF'
call s:MarkdownHighlightSources(a:force)
endif
endfunction
function! s:MarkdownClearSyntaxVariables()
if &filetype =~# 'markdown'
if s:IsHighlightSourcesEnabledForBuffer()
unlet! b:mkd_included_filetypes
endif
endfunction

View File

@ -109,8 +109,9 @@ syn region mkdFootnote start="\[^" end="\]"
syn match mkdCode /^\s*\n\(\(\s\{8,}[^ ]\|\t\t\+[^\t]\).*\n\)\+/
syn match mkdCode /\%^\(\(\s\{4,}[^ ]\|\t\+[^\t]\).*\n\)\+/
syn match mkdCode /^\s*\n\(\(\s\{4,}[^ ]\|\t\+[^\t]\).*\n\)\+/ contained
syn match mkdListItem /^\s*\%([-*+]\|\d\+\.\)\ze\s\+/ contained
syn region mkdListItemLine start="^\s*\%([-*+]\|\d\+\.\)\s\+" end="$" oneline contains=@mkdNonListItem,mkdListItem,@Spell
syn match mkdListItem /^\s*\%([-*+]\|\d\+\.\)\ze\s\+/ contained nextgroup=mkdListItemCheckbox
syn match mkdListItemCheckbox /\[[xXoO ]\]\ze\s\+/ contained contains=mkdListItem
syn region mkdListItemLine start="^\s*\%([-*+]\|\d\+\.\)\s\+" end="$" oneline contains=@mkdNonListItem,mkdListItem,mkdListItemCheckbox,@Spell
syn region mkdNonListItemBlock start="\(\%^\(\s*\([-*+]\|\d\+\.\)\s\+\)\@!\|\n\(\_^\_$\|\s\{4,}[^ ]\|\t+[^\t]\)\@!\)" end="^\(\s*\([-*+]\|\d\+\.\)\s\+\)\@=" contains=@mkdNonListItem,@Spell
syn match mkdRule /^\s*\*\s\{0,1}\*\s\{0,1}\*\(\*\|\s\)*$/
syn match mkdRule /^\s*-\s\{0,1}-\s\{0,1}-\(-\|\s\)*$/
@ -158,25 +159,26 @@ endif
syn cluster mkdNonListItem contains=@htmlTop,htmlItalic,htmlBold,htmlBoldItalic,mkdFootnotes,mkdInlineURL,mkdLink,mkdLinkDef,mkdLineBreak,mkdBlockquote,mkdCode,mkdRule,htmlH1,htmlH2,htmlH3,htmlH4,htmlH5,htmlH6,mkdMath,mkdStrike
"highlighting for Markdown groups
HtmlHiLink mkdString String
HtmlHiLink mkdCode String
HtmlHiLink mkdCodeDelimiter String
HtmlHiLink mkdCodeStart String
HtmlHiLink mkdCodeEnd String
HtmlHiLink mkdFootnote Comment
HtmlHiLink mkdBlockquote Comment
HtmlHiLink mkdListItem Identifier
HtmlHiLink mkdRule Identifier
HtmlHiLink mkdLineBreak Visual
HtmlHiLink mkdFootnotes htmlLink
HtmlHiLink mkdLink htmlLink
HtmlHiLink mkdURL htmlString
HtmlHiLink mkdInlineURL htmlLink
HtmlHiLink mkdID Identifier
HtmlHiLink mkdLinkDef mkdID
HtmlHiLink mkdLinkDefTarget mkdURL
HtmlHiLink mkdLinkTitle htmlString
HtmlHiLink mkdDelimiter Delimiter
HtmlHiLink mkdString String
HtmlHiLink mkdCode String
HtmlHiLink mkdCodeDelimiter String
HtmlHiLink mkdCodeStart String
HtmlHiLink mkdCodeEnd String
HtmlHiLink mkdFootnote Comment
HtmlHiLink mkdBlockquote Comment
HtmlHiLink mkdListItem Identifier
HtmlHiLink mkdListItemCheckbox Identifier
HtmlHiLink mkdRule Identifier
HtmlHiLink mkdLineBreak Visual
HtmlHiLink mkdFootnotes htmlLink
HtmlHiLink mkdLink htmlLink
HtmlHiLink mkdURL htmlString
HtmlHiLink mkdInlineURL htmlLink
HtmlHiLink mkdID Identifier
HtmlHiLink mkdLinkDef mkdID
HtmlHiLink mkdLinkDefTarget mkdURL
HtmlHiLink mkdLinkTitle htmlString
HtmlHiLink mkdDelimiter Delimiter
let b:current_syntax = 'mkd'

View File

@ -0,0 +1,116 @@
Given markdown;
# a
## b
### c
#### d
##### e
Execute (HeaderIncrease without forbidden level):
:HeaderIncrease
Expect (increase level of all headers):
## a
### b
#### c
##### d
###### e
Given markdown;
# a
###### b
Execute (HeaderIncrease with forbidden level):
:HeaderIncrease
Expect (no changes):
# a
###### b
Given markdown;
## a
### b
#### c
##### d
###### e
Execute (HeaderDecrease without forbidden level):
:HeaderDecrease
Expect (decrease level of all headers):
# a
## b
### c
#### d
##### e
Given markdown;
# a
## b
### c
#### d
##### e
###### f
Execute (HeaderDecrease with forbidden level):
:HeaderDecrease
Expect (no changes):
# a
## b
### c
#### d
##### e
###### f
Given markdown;
a
=
b
-
Execute (HeaderIncrease with setext headers):
:HeaderIncrease
Expect (convert to atx headers):
## a
### b
Given markdown;
a
-
Execute (HeaderDecrease with setext headers):
:HeaderDecrease
Expect (convert to atx headers):
# a

View File

@ -0,0 +1,48 @@
Given markdown;
# a
a
=
## b
b
-
Execute (SetexToAtx):
:SetexToAtx
Expect (convert setex-style headings to atx):
# a
# a
## b
## b
Given markdown;
a
=
b
=
c
-
d
-
Execute (SetexToAtx with range):
:1,8SetexToAtx
Expect (only convert setex headings in original range):
# a
# b
## c
d
-

View File

@ -2,6 +2,7 @@ Before:
unlet! b:mkd_known_filetypes
unlet! b:mkd_included_filetypes
unlet! g:vim_markdown_math
unlet! b:liquid_subtype
Given markdown;
a **b** c
@ -855,6 +856,17 @@ a
Execute (fenced code block with extended info strings):
AssertEqual SyntaxOf('a'), 'mkdCode'
Given liquid;
```vim
let g:a = 1
```
Execute (fenced code block syntax in liquid file with markdown subtype):
let b:liquid_subtype = 'markdown'
let b:func = Markdown_GetFunc('vim-markdown/ftplugin/markdown.vim', 'MarkdownRefreshSyntax')
call b:func(0)
AssertEqual SyntaxOf('g:a'), 'vimVar'
# Code Blocks in pre and code tag
Given markdown;