mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-01-23 13:00:04 +08:00
feat(markdown): use bundle markdown plugin
This commit is contained in:
parent
f0ca1bc6c5
commit
3f14a86e0d
@ -68,7 +68,7 @@ endfunction
|
||||
|
||||
function! SpaceVim#layers#lang#markdown#plugins() abort
|
||||
let plugins = []
|
||||
call add(plugins, ['SpaceVim/vim-markdown',{ 'on_ft' : 'markdown'}])
|
||||
call add(plugins, [g:_spacevim_root_dir . 'bundle/vim-markdown',{ 'on_ft' : 'markdown'}])
|
||||
call add(plugins, ['joker1007/vim-markdown-quote-syntax',{ 'on_ft' : 'markdown'}])
|
||||
call add(plugins, [g:_spacevim_root_dir . 'bundle/vim-markdown-toc', {'merged' : 0}])
|
||||
call add(plugins, ['iamcco/mathjax-support-for-mkdp',{ 'on_ft' : 'markdown'}])
|
||||
|
1
bundle/vim-markdown/.gitignore
vendored
Normal file
1
bundle/vim-markdown/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
tags
|
21
bundle/vim-markdown/LICENSE
vendored
Normal file
21
bundle/vim-markdown/LICENSE
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2017 SpaceVim
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
3
bundle/vim-markdown/README.md
vendored
Normal file
3
bundle/vim-markdown/README.md
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
# Markdown mode for SpaceVim
|
||||
|
||||
This is Markdown plugin for SpaceVim, It is based on SpaceVim API. This plugin include syntax file for Markdown.
|
5
bundle/vim-markdown/addon-info.json
vendored
Normal file
5
bundle/vim-markdown/addon-info.json
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"name": "markdown",
|
||||
"description": "vim markdown syntax and filetype plugin",
|
||||
"author": "wsdjeg"
|
||||
}
|
5
bundle/vim-markdown/after/syntax/markdown.vim
vendored
Normal file
5
bundle/vim-markdown/after/syntax/markdown.vim
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
unlet b:current_syntax
|
||||
syntax include @Yaml syntax/yaml.vim
|
||||
syntax region yamlFrontmatter start=/\%^---$/ end=/^---$/ keepend contains=@Yaml
|
||||
let b:current_syntax = "markdown"
|
||||
|
29
bundle/vim-markdown/doc/markdown.txt
vendored
Normal file
29
bundle/vim-markdown/doc/markdown.txt
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
*markdown.txt* vim markdown syntax and filetype plugin
|
||||
wsdjeg *markdown*
|
||||
|
||||
==============================================================================
|
||||
CONTENTS *markdown-contents*
|
||||
1. Introduction.............................................|markdown-intro|
|
||||
2. Configuration...........................................|markdown-config|
|
||||
|
||||
==============================================================================
|
||||
INTRODUCTION *markdown-intro*
|
||||
|
||||
This is Markdown plugin for SpaceVim, It is based on SpaceVim API. This plugin
|
||||
include syntax file for Markdown.
|
||||
|
||||
==============================================================================
|
||||
CONFIGURATION *markdown-config*
|
||||
|
||||
*g:markdown_default_mappings*
|
||||
Enable/Disable default mappings when edit markdown file, by default it is
|
||||
enabled.
|
||||
|
||||
*g:vim_markdown_auto_insert_bullets*
|
||||
Enable/Disable auto insert bullets, by default it is enabled.
|
||||
|
||||
*g:markdown_hi_error*
|
||||
Enable/Disable highlight for markdown error.
|
||||
|
||||
|
||||
vim:tw=78:ts=8:ft=help:norl:
|
7
bundle/vim-markdown/ftdetect/markdown.vim
vendored
Normal file
7
bundle/vim-markdown/ftdetect/markdown.vim
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
if !has('patch-7.4.480')
|
||||
" Before this patch, vim used modula2 for .md.
|
||||
" https://github.com/vim/vim/commit/7d76c804af900ba6dcc4b1e45373ccab3418c6b2
|
||||
au! filetypedetect BufRead,BufNewFile *.md
|
||||
endif
|
||||
au BufRead,BufNewFile *.{md,mdown,mkd,mkdn,markdown,mdwn} set filetype=markdown
|
||||
au BufRead,BufNewFile *.{md,mdown,mkd,mkdn,markdown,mdwn}.{des3,des,bf,bfa,aes,idea,cast,rc2,rc4,rc5,desx} set filetype=markdown
|
7
bundle/vim-markdown/ftplugin/markdown.vim
vendored
Normal file
7
bundle/vim-markdown/ftplugin/markdown.vim
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
if exists('b:did_ftplugin') | finish | endif
|
||||
|
||||
if g:markdown_default_mappings
|
||||
inoremap <buffer> <C-b> ****<Left><Left>
|
||||
endif
|
||||
|
||||
let b:did_ftplugin = 1
|
75
bundle/vim-markdown/indent/markdown.vim
vendored
Normal file
75
bundle/vim-markdown/indent/markdown.vim
vendored
Normal file
@ -0,0 +1,75 @@
|
||||
if exists("b:did_indent") | finish | endif
|
||||
let b:did_indent = 1
|
||||
|
||||
setlocal indentexpr=GetMarkdownIndent()
|
||||
setlocal nolisp
|
||||
setlocal autoindent
|
||||
|
||||
" Automatically continue blockquote on line break
|
||||
setlocal formatoptions+=r
|
||||
setlocal comments=b:>
|
||||
if g:vim_markdown_auto_insert_bullets
|
||||
" Do not automatically insert bullets when auto-wrapping with text-width
|
||||
setlocal formatoptions-=c
|
||||
" Accept various markers as bullets
|
||||
setlocal comments+=b:*,b:+,b:-
|
||||
endif
|
||||
|
||||
" Only define the function once
|
||||
if exists("*GetMarkdownIndent") | finish | endif
|
||||
|
||||
function! s:IsMkdCode(lnum)
|
||||
let name = synIDattr(synID(a:lnum, 1, 0), 'name')
|
||||
return (name =~ '^mkd\%(Code$\|Snippet\)' || name != '' && name !~ '^\%(mkd\|html\)')
|
||||
endfunction
|
||||
|
||||
function! s:IsLiStart(line)
|
||||
return a:line !~ '^ *\([*-]\)\%( *\1\)\{2}\%( \|\1\)*$' &&
|
||||
\ a:line =~ '^\s*[*+-] \+'
|
||||
endfunction
|
||||
|
||||
function! s:IsHeaderLine(line)
|
||||
return a:line =~ '^\s*#'
|
||||
endfunction
|
||||
|
||||
function! s:IsBlankLine(line)
|
||||
return a:line =~ '^$'
|
||||
endfunction
|
||||
|
||||
function! s:PrevNonBlank(lnum)
|
||||
let i = a:lnum
|
||||
while i > 1 && s:IsBlankLine(getline(i))
|
||||
let i -= 1
|
||||
endwhile
|
||||
return i
|
||||
endfunction
|
||||
|
||||
function GetMarkdownIndent()
|
||||
if v:lnum > 2 && s:IsBlankLine(getline(v:lnum - 1)) && s:IsBlankLine(getline(v:lnum - 2))
|
||||
return 0
|
||||
endif
|
||||
let list_ind = get(g:, "vim_markdown_new_list_item_indent", 4)
|
||||
" Find a non-blank line above the current line.
|
||||
let lnum = s:PrevNonBlank(v:lnum - 1)
|
||||
" At the start of the file use zero indent.
|
||||
if lnum == 0 | return 0 | endif
|
||||
let ind = indent(lnum)
|
||||
let line = getline(lnum) " Last line
|
||||
let cline = getline(v:lnum) " Current line
|
||||
if s:IsLiStart(cline)
|
||||
" Current line is the first line of a list item, do not change indent
|
||||
return indent(v:lnum)
|
||||
elseif s:IsHeaderLine(cline) && !s:IsMkdCode(v:lnum)
|
||||
" Current line is the header, do not indent
|
||||
return 0
|
||||
elseif s:IsLiStart(line)
|
||||
if s:IsMkdCode(lnum)
|
||||
return ind
|
||||
else
|
||||
" Last line is the first line of a list item, increase indent
|
||||
return ind + list_ind
|
||||
end
|
||||
else
|
||||
return ind
|
||||
endif
|
||||
endfunction
|
24
bundle/vim-markdown/plugin/markdown.vim
vendored
Normal file
24
bundle/vim-markdown/plugin/markdown.vim
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
""
|
||||
" @section Introduction, intro
|
||||
" This is Markdown plugin for SpaceVim, It is based on SpaceVim API.
|
||||
" This plugin include syntax file for Markdown.
|
||||
|
||||
if !exists('g:markdown_default_mappings')
|
||||
""
|
||||
" Enable/Disable default mappings when edit markdown file, by default it is
|
||||
" enabled.
|
||||
let g:markdown_default_mappings = 1
|
||||
endif
|
||||
|
||||
if !exists('g:vim_markdown_auto_insert_bullets')
|
||||
""
|
||||
" Enable/Disable auto insert bullets, by default it is enabled.
|
||||
let g:vim_markdown_auto_insert_bullets = 1
|
||||
endif
|
||||
|
||||
if !exists('g:markdown_hi_error')
|
||||
""
|
||||
" Enable/Disable highlight for markdown error.
|
||||
let g:markdown_hi_error = 1
|
||||
endif
|
||||
|
188
bundle/vim-markdown/syntax/markdown.vim
vendored
Normal file
188
bundle/vim-markdown/syntax/markdown.vim
vendored
Normal file
@ -0,0 +1,188 @@
|
||||
" fuck the runtime syntax
|
||||
syntax clear
|
||||
unlet! b:current_syntax
|
||||
|
||||
if exists("b:current_syntax")
|
||||
finish
|
||||
endif
|
||||
|
||||
if !exists('main_syntax')
|
||||
let main_syntax = 'markdown'
|
||||
endif
|
||||
|
||||
runtime! syntax/html.vim
|
||||
unlet! b:current_syntax
|
||||
|
||||
if !exists('g:markdown_nested_languages')
|
||||
let g:markdown_nested_languages = []
|
||||
endif
|
||||
let s:done_include = {}
|
||||
for s:type in map(copy(g:markdown_nested_languages),
|
||||
\ 'matchstr(v:val,"[^=]*$")')
|
||||
if has_key(s:done_include, matchstr(s:type,'[^.]*'))
|
||||
continue
|
||||
endif
|
||||
if s:type =~ '\.'
|
||||
let b:{matchstr(s:type,'[^.]*')}_subtype = matchstr(s:type,'\.\zs.*')
|
||||
endif
|
||||
" add try catch, when no syntax file for fenced language
|
||||
try
|
||||
exe 'syn include @markdownHighlight'
|
||||
\ . substitute(s:type,'\.','','g')
|
||||
\ . ' syntax/'
|
||||
\ . matchstr(s:type,'[^.]*').'.vim'
|
||||
unlet! b:current_syntax
|
||||
catch
|
||||
endtry
|
||||
let s:done_include[matchstr(s:type,'[^.]*')] = 1
|
||||
endfor
|
||||
unlet! s:type
|
||||
unlet! s:done_include
|
||||
|
||||
if !exists('g:markdown_minlines')
|
||||
let g:markdown_minlines = 50
|
||||
endif
|
||||
execute 'syn sync minlines=' . g:markdown_minlines
|
||||
syn case ignore
|
||||
|
||||
syn match markdownValid '[<>]\c[a-z/$!]\@!'
|
||||
syn match markdownValid '&\%(#\=\w*;\)\@!'
|
||||
|
||||
syn match markdownLineStart "^[<@]\@!"
|
||||
\ nextgroup=@markdownBlock,htmlSpecialChar
|
||||
|
||||
syn cluster markdownBlock contains=markdownH1,markdownH2,
|
||||
\ markdownH3,markdownH4,markdownH5,markdownH6,markdownBlockquote,
|
||||
\ markdownListMarker,markdownOrderedListMarker,
|
||||
\ markdownCodeBlock,markdownRule
|
||||
syn cluster markdownInline contains=markdownLineBreak,markdownLinkText,
|
||||
\ markdownItalic,markdownBold,markdownCode,markdownEscape,
|
||||
\ @htmlTop,markdownError
|
||||
|
||||
syn match markdownH1 "^.\+\n=\+$" contained contains=@markdownInline,
|
||||
\ markdownHeadingRule,markdownAutomaticLink
|
||||
syn match markdownH2 "^.\+\n-\+$" contained contains=@markdownInline,
|
||||
\ markdownHeadingRule,markdownAutomaticLink
|
||||
|
||||
syn match markdownHeadingRule "^[=-]\+$" contained
|
||||
|
||||
syn region markdownH1 matchgroup=markdownHeadingDelimiter start="##\@!"
|
||||
\ end="#*\s*$" keepend oneline contains=@markdownInline,
|
||||
\ markdownAutomaticLink contained
|
||||
syn region markdownH2 matchgroup=markdownHeadingDelimiter start="###\@!"
|
||||
\ end="#*\s*$" keepend oneline contains=@markdownInline,
|
||||
\ markdownAutomaticLink contained
|
||||
syn region markdownH3 matchgroup=markdownHeadingDelimiter start="####\@!" end="#*\s*$" keepend oneline contains=@markdownInline,markdownAutomaticLink contained
|
||||
syn region markdownH4 matchgroup=markdownHeadingDelimiter start="#####\@!" end="#*\s*$" keepend oneline contains=@markdownInline,markdownAutomaticLink contained
|
||||
syn region markdownH5 matchgroup=markdownHeadingDelimiter start="######\@!" end="#*\s*$" keepend oneline contains=@markdownInline,markdownAutomaticLink contained
|
||||
syn region markdownH6 matchgroup=markdownHeadingDelimiter start="#######\@!" end="#*\s*$" keepend oneline contains=@markdownInline,markdownAutomaticLink contained
|
||||
|
||||
syn match markdownBlockquote ">\%(\s\|$\)" contained nextgroup=@markdownBlock
|
||||
|
||||
syn region markdownCodeBlock start=" \|\t" end="$" contained
|
||||
|
||||
syn match markdownListMarker
|
||||
\ "\%(\t\| \{0,8\}\)[-*+]\%(\s\+\S\)\@=" contained
|
||||
syn match markdownOrderedListMarker
|
||||
\ "\%(\t\| \{0,8}\)\<\d\+\.\%(\s\+\S\)\@=" contained
|
||||
|
||||
syn match markdownRule "\* *\* *\*[ *]*$" contained
|
||||
syn match markdownRule "- *- *-[ -]*$" contained
|
||||
|
||||
syn match markdownLineBreak " \{2,\}$"
|
||||
|
||||
syn region markdownIdDeclaration matchgroup=markdownLinkDelimiter start="^ \{0,3\}!\=\[" end="\]:" oneline keepend nextgroup=markdownUrl skipwhite
|
||||
syn match markdownUrl "\S\+" nextgroup=markdownUrlTitle skipwhite contained
|
||||
syn region markdownUrl matchgroup=markdownUrlDelimiter start="<" end=">" oneline keepend nextgroup=markdownUrlTitle skipwhite contained
|
||||
syn region markdownUrlTitle matchgroup=markdownUrlTitleDelimiter start=+"+ end=+"+ keepend contained
|
||||
syn region markdownUrlTitle matchgroup=markdownUrlTitleDelimiter start=+'+ end=+'+ keepend contained
|
||||
syn region markdownUrlTitle matchgroup=markdownUrlTitleDelimiter start=+(+ end=+)+ keepend contained
|
||||
|
||||
syn region markdownLinkText matchgroup=markdownLinkTextDelimiter start="!\=\[\%(\_[^]]*]\%( \=[[(]\)\)\@=" end="\]\%( \=[[(]\)\@=" nextgroup=markdownLink,markdownId skipwhite contains=@markdownInline,markdownLineStart
|
||||
syn region markdownLink matchgroup=markdownLinkDelimiter start="(" end=")" contains=markdownUrl keepend contained
|
||||
syn region markdownId matchgroup=markdownIdDelimiter start="\[" end="\]" keepend contained
|
||||
syn region markdownAutomaticLink matchgroup=markdownUrlDelimiter start="<\%(\w\+:\|[[:alnum:]_+-]\+@\)\@=" end=">" keepend oneline
|
||||
|
||||
let s:concealends = ''
|
||||
if has('conceal') && get(g:, 'markdown_syntax_conceal', 1) == 1
|
||||
let s:concealends = ' concealends'
|
||||
endif
|
||||
exe 'syn region markdownItalic matchgroup=markdownItalicDelimiter start="\S\@<=\*\|\*\S\@=" end="\S\@<=\*\|\*\S\@=" keepend contains=markdownLineStart,@Spell' . s:concealends
|
||||
exe 'syn region markdownItalic matchgroup=markdownItalicDelimiter start="\S\@<=_\|_\S\@=" end="\S\@<=_\|_\S\@=" keepend contains=markdownLineStart,@Spell' . s:concealends
|
||||
exe 'syn region markdownBold matchgroup=markdownBoldDelimiter start="\S\@<=\*\*\|\*\*\S\@=" end="\S\@<=\*\*\|\*\*\S\@=" keepend contains=markdownLineStart,markdownItalic,@Spell' . s:concealends
|
||||
exe 'syn region markdownBold matchgroup=markdownBoldDelimiter start="\S\@<=__\|__\S\@=" end="\S\@<=__\|__\S\@=" keepend contains=markdownLineStart,markdownItalic,@Spell' . s:concealends
|
||||
exe 'syn region markdownBoldItalic matchgroup=markdownBoldItalicDelimiter start="\S\@<=\*\*\*\|\*\*\*\S\@=" end="\S\@<=\*\*\*\|\*\*\*\S\@=" keepend contains=markdownLineStart,@Spell' . s:concealends
|
||||
exe 'syn region markdownBoldItalic matchgroup=markdownBoldItalicDelimiter start="\S\@<=___\|___\S\@=" end="\S\@<=___\|___\S\@=" keepend contains=markdownLineStart,@Spell' . s:concealends
|
||||
|
||||
syn region markdownCode matchgroup=markdownCodeDelimiter start="`" end="`" keepend contains=markdownLineStart
|
||||
syn region markdownCode matchgroup=markdownCodeDelimiter start="`` \=" end=" \=``" keepend contains=markdownLineStart
|
||||
syn region markdownCode matchgroup=markdownCodeDelimiter start="^\s*````*.*$" end="^\s*````*\ze\s*$" keepend
|
||||
|
||||
syn match markdownFootnote "\[^[^\]]\+\]"
|
||||
syn match markdownFootnoteDefinition "^\[^[^\]]\+\]:"
|
||||
|
||||
if main_syntax ==# 'markdown'
|
||||
let s:done_include = {}
|
||||
for s:type in g:markdown_nested_languages
|
||||
if has_key(s:done_include, matchstr(s:type,'[^.]*'))
|
||||
continue
|
||||
endif
|
||||
exe 'syn region markdownHighlight'.substitute(matchstr(s:type,'[^=]*$'),'\..*','','').' matchgroup=markdownCodeDelimiter start="^\s*````*\s*'.matchstr(s:type,'[^=]*').'\S\@!.*$" end="^\s*````*\ze\s*$" keepend contains=@markdownHighlight'.substitute(matchstr(s:type,'[^=]*$'),'\.','','g')
|
||||
let s:done_include[matchstr(s:type,'[^.]*')] = 1
|
||||
endfor
|
||||
unlet! s:type
|
||||
unlet! s:done_include
|
||||
endif
|
||||
|
||||
syn match markdownEscape "\\[][\\`*_{}()<>#+.!-]"
|
||||
syn match markdownError "\w\@<=_\w\@="
|
||||
|
||||
hi def link markdownH1 htmlH1
|
||||
hi def link markdownH2 htmlH2
|
||||
hi def link markdownH3 htmlH3
|
||||
hi def link markdownH4 htmlH4
|
||||
hi def link markdownH5 htmlH5
|
||||
hi def link markdownH6 htmlH6
|
||||
hi def link markdownHeadingRule markdownRule
|
||||
hi def link markdownHeadingDelimiter Delimiter
|
||||
hi def link markdownOrderedListMarker markdownListMarker
|
||||
hi def link markdownListMarker htmlTagName
|
||||
hi def link markdownBlockquote Comment
|
||||
hi def link markdownRule PreProc
|
||||
|
||||
hi def link markdownFootnote Typedef
|
||||
hi def link markdownFootnoteDefinition Typedef
|
||||
|
||||
hi def link markdownLinkText htmlLink
|
||||
hi def link markdownIdDeclaration Typedef
|
||||
hi def link markdownId Type
|
||||
hi def link markdownAutomaticLink markdownUrl
|
||||
hi def link markdownUrl Float
|
||||
hi def link markdownUrlTitle String
|
||||
hi def link markdownIdDelimiter markdownLinkDelimiter
|
||||
hi def link markdownUrlDelimiter htmlTag
|
||||
hi def link markdownUrlTitleDelimiter Delimiter
|
||||
|
||||
hi def link markdownItalic htmlItalic
|
||||
hi def link markdownItalicDelimiter markdownItalic
|
||||
hi def link markdownBold htmlBold
|
||||
hi def link markdownBoldDelimiter markdownBold
|
||||
hi def link markdownBoldItalic htmlBoldItalic
|
||||
hi def link markdownBoldItalicDelimiter markdownBoldItalic
|
||||
hi def link markdownCodeDelimiter Delimiter
|
||||
|
||||
hi def link markdownEscape Special
|
||||
if g:markdown_hi_error
|
||||
hi def link markdownError Error
|
||||
else
|
||||
hi! def link markdownError Normal
|
||||
endif
|
||||
|
||||
let b:current_syntax = "markdown"
|
||||
if main_syntax ==# 'markdown'
|
||||
unlet main_syntax
|
||||
endif
|
||||
|
||||
runtime! after/syntax/markdown.vim
|
||||
|
||||
" vim:set sw=2 cc=80:
|
Loading…
Reference in New Issue
Block a user