diff --git a/autoload/SpaceVim/layers/lang/markdown.vim b/autoload/SpaceVim/layers/lang/markdown.vim index 284c3c674..985a1ea11 100644 --- a/autoload/SpaceVim/layers/lang/markdown.vim +++ b/autoload/SpaceVim/layers/lang/markdown.vim @@ -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'}]) diff --git a/bundle/vim-markdown/.gitignore b/bundle/vim-markdown/.gitignore new file mode 100644 index 000000000..6e92f57d4 --- /dev/null +++ b/bundle/vim-markdown/.gitignore @@ -0,0 +1 @@ +tags diff --git a/bundle/vim-markdown/LICENSE b/bundle/vim-markdown/LICENSE new file mode 100644 index 000000000..b03826341 --- /dev/null +++ b/bundle/vim-markdown/LICENSE @@ -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. diff --git a/bundle/vim-markdown/README.md b/bundle/vim-markdown/README.md new file mode 100644 index 000000000..0bb95d6ed --- /dev/null +++ b/bundle/vim-markdown/README.md @@ -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. diff --git a/bundle/vim-markdown/addon-info.json b/bundle/vim-markdown/addon-info.json new file mode 100644 index 000000000..c644e5014 --- /dev/null +++ b/bundle/vim-markdown/addon-info.json @@ -0,0 +1,5 @@ +{ + "name": "markdown", + "description": "vim markdown syntax and filetype plugin", + "author": "wsdjeg" +} diff --git a/bundle/vim-markdown/after/syntax/markdown.vim b/bundle/vim-markdown/after/syntax/markdown.vim new file mode 100644 index 000000000..af545e687 --- /dev/null +++ b/bundle/vim-markdown/after/syntax/markdown.vim @@ -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" + diff --git a/bundle/vim-markdown/doc/markdown.txt b/bundle/vim-markdown/doc/markdown.txt new file mode 100644 index 000000000..e3406601c --- /dev/null +++ b/bundle/vim-markdown/doc/markdown.txt @@ -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: diff --git a/bundle/vim-markdown/ftdetect/markdown.vim b/bundle/vim-markdown/ftdetect/markdown.vim new file mode 100644 index 000000000..0a77029c2 --- /dev/null +++ b/bundle/vim-markdown/ftdetect/markdown.vim @@ -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 diff --git a/bundle/vim-markdown/ftplugin/markdown.vim b/bundle/vim-markdown/ftplugin/markdown.vim new file mode 100644 index 000000000..02bbff456 --- /dev/null +++ b/bundle/vim-markdown/ftplugin/markdown.vim @@ -0,0 +1,7 @@ +if exists('b:did_ftplugin') | finish | endif + +if g:markdown_default_mappings + inoremap **** +endif + +let b:did_ftplugin = 1 diff --git a/bundle/vim-markdown/indent/markdown.vim b/bundle/vim-markdown/indent/markdown.vim new file mode 100644 index 000000000..1045a314d --- /dev/null +++ b/bundle/vim-markdown/indent/markdown.vim @@ -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 diff --git a/bundle/vim-markdown/plugin/markdown.vim b/bundle/vim-markdown/plugin/markdown.vim new file mode 100644 index 000000000..24244524f --- /dev/null +++ b/bundle/vim-markdown/plugin/markdown.vim @@ -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 + diff --git a/bundle/vim-markdown/syntax/markdown.vim b/bundle/vim-markdown/syntax/markdown.vim new file mode 100644 index 000000000..eeebac8e2 --- /dev/null +++ b/bundle/vim-markdown/syntax/markdown.vim @@ -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: