diff options
Diffstat (limited to 'runtime/autoload')
-rw-r--r-- | runtime/autoload/RstFold.vim | 48 | ||||
-rw-r--r-- | runtime/autoload/csscomplete.vim | 8 | ||||
-rw-r--r-- | runtime/autoload/dist/ft.vim | 8 | ||||
-rw-r--r-- | runtime/autoload/spellfile.vim | 7 | ||||
-rw-r--r-- | runtime/autoload/xmlformat.vim | 111 |
5 files changed, 174 insertions, 8 deletions
diff --git a/runtime/autoload/RstFold.vim b/runtime/autoload/RstFold.vim new file mode 100644 index 0000000000..5becb04685 --- /dev/null +++ b/runtime/autoload/RstFold.vim @@ -0,0 +1,48 @@ +" Author: Antony Lee <anntzer.lee@gmail.com> +" Description: Helper functions for reStructuredText syntax folding +" Last Modified: 2018-01-07 + +function s:CacheRstFold() + let closure = {'header_types': {}, 'max_level': 0, 'levels': {}} + function closure.Process(match) dict + let curline = getcurpos()[1] + if has_key(self.levels, curline - 1) + " For over+under-lined headers, the regex will match both at the + " overline and at the title itself; in that case, skip the second match. + return + endif + let lines = split(a:match, '\n') + let key = repeat(lines[-1][0], len(lines)) + if !has_key(self.header_types, key) + let self.max_level += 1 + let self.header_types[key] = self.max_level + endif + let self.levels[curline] = self.header_types[key] + endfunction + let save_cursor = getcurpos() + silent keeppatterns %s/\v^%(%(([=`:.'"~^_*+#-])\1+\n)?.{1,2}\n([=`:.'"~^_*+#-])\2+)|%(%(([=`:.''"~^_*+#-])\3{2,}\n)?.{3,}\n([=`:.''"~^_*+#-])\4{2,})$/\=closure.Process(submatch(0))/gn + call setpos('.', save_cursor) + let b:RstFoldCache = closure.levels +endfunction + +function RstFold#GetRstFold() + if !has_key(b:, 'RstFoldCache') + call s:CacheRstFold() + endif + if has_key(b:RstFoldCache, v:lnum) + return '>' . b:RstFoldCache[v:lnum] + else + return '=' + endif +endfunction + +function RstFold#GetRstFoldText() + if !has_key(b:, 'RstFoldCache') + call s:CacheRstFold() + endif + let indent = repeat(' ', b:RstFoldCache[v:foldstart] - 1) + let thisline = getline(v:foldstart) + " For over+under-lined headers, skip the overline. + let text = thisline =~ '^\([=`:.''"~^_*+#-]\)\1\+$' ? getline(v:foldstart + 1) : thisline + return indent . text +endfunction diff --git a/runtime/autoload/csscomplete.vim b/runtime/autoload/csscomplete.vim index 50048a37fd..f6c5a6c391 100644 --- a/runtime/autoload/csscomplete.vim +++ b/runtime/autoload/csscomplete.vim @@ -4,7 +4,7 @@ " plus CSS Speech Module <http://www.w3.org/TR/css3-speech/> " Maintainer: Kao, Wei-Ko(othree) ( othree AT gmail DOT com ) " Original Author: Mikolaj Machowski ( mikmach AT wp DOT pl ) -" Last Change: 2016 Jan 11 +" Last Change: 2018 Jul 02 let s:values = split("all additive-symbols align-content align-items align-self animation animation-delay animation-direction animation-duration animation-fill-mode animation-iteration-count animation-name animation-play-state animation-timing-function backface-visibility background background-attachment background-blend-mode background-clip background-color background-image background-origin background-position background-repeat background-size block-size border border-block-end border-block-end-color border-block-end-style border-block-end-width border-block-start border-block-start-color border-block-start-style border-block-start-width border-bottom border-bottom-color border-bottom-left-radius border-bottom-right-radius border-bottom-style border-bottom-width border-collapse border-color border-image border-image-outset border-image-repeat border-image-slice border-image-source border-image-width border-inline-end border-inline-end-color border-inline-end-style border-inline-end-width border-inline-start border-inline-start-color border-inline-start-style border-inline-start-width border-left border-left-color border-left-style border-left-width border-radius border-right border-right-color border-right-style border-right-width border-spacing border-style border-top border-top-color border-top-left-radius border-top-right-radius border-top-style border-top-width border-width bottom box-decoration-break box-shadow box-sizing break-after break-before break-inside caption-side clear clip clip-path color columns column-count column-fill column-gap column-rule column-rule-color column-rule-style column-rule-width column-span column-width content counter-increment counter-reset cue cue-before cue-after cursor direction display empty-cells fallback filter flex flex-basis flex-direction flex-flow flex-grow flex-shrink flex-wrap float font font-family font-feature-settings font-kerning font-language-override font-size font-size-adjust font-stretch font-style font-synthesis font-variant font-variant-alternates font-variant-caps font-variant-east-asian font-variant-ligatures font-variant-numeric font-variant-position font-weight grid grid-area grid-auto-columns grid-auto-flow grid-auto-position grid-auto-rows grid-column grid-column-start grid-column-end grid-row grid-row-start grid-row-end grid-template grid-template-areas grid-template-rows grid-template-columns height hyphens image-rendering image-resolution image-orientation ime-mode inline-size isolation justify-content left letter-spacing line-break line-height list-style list-style-image list-style-position list-style-type margin margin-block-end margin-block-start margin-bottom margin-inline-end margin-inline-start margin-left margin-right margin-top marks mask mask-type max-block-size max-height max-inline-size max-width max-zoom min-block-size min-height min-inline-size min-width min-zoom mix-blend-mode negative object-fit object-position offset-block-end offset-block-start offset-inline-end offset-inline-start opacity order orientation orphans outline outline-color outline-offset outline-style outline-width overflow overflow-wrap overflow-x overflow-y pad padding padding-block-end padding-block-start padding-bottom padding-inline-end padding-inline-start padding-left padding-right padding-top page-break-after page-break-before page-break-inside pause-before pause-after pause perspective perspective-origin pointer-events position prefix quotes range resize rest rest-before rest-after right ruby-align ruby-merge ruby-position scroll-behavior scroll-snap-coordinate scroll-snap-destination scroll-snap-points-x scroll-snap-points-y scroll-snap-type scroll-snap-type-x scroll-snap-type-y shape-image-threshold shape-margin shape-outside speak speak-as suffix symbols system table-layout tab-size text-align text-align-last text-combine-upright text-decoration text-decoration-color text-decoration-line text-emphasis text-emphasis-color text-emphasis-position text-emphasis-style text-indent text-orientation text-overflow text-rendering text-shadow text-transform text-underline-position top touch-action transform transform-box transform-origin transform-style transition transition-delay transition-duration transition-property transition-timing-function unicode-bidi unicode-range user-zoom vertical-align visibility voice-balance voice-duration voice-family voice-pitch voice-rate voice-range voice-stress voice-volume white-space widows width will-change word-break word-spacing word-wrap writing-mode z-index zoom") @@ -19,7 +19,6 @@ function! csscomplete#CompleteCSS(findstart, base) while start >= 0 && line[start - 1] =~ '\%(\k\|-\)' let start -= 1 endwhile - let b:after = line[compl_begin :] let b:compl_context = line[0:compl_begin] return start endif @@ -37,11 +36,14 @@ function! csscomplete#CompleteCSS(findstart, base) " 5. if @ complete at-rule " 6. if ! complete important if exists("b:compl_context") + let line = getline('.') + let compl_begin = col('.') - 2 + let after = line[compl_begin:] let line = b:compl_context - let after = b:after unlet! b:compl_context else let line = a:base + let after = '' endif let res = [] diff --git a/runtime/autoload/dist/ft.vim b/runtime/autoload/dist/ft.vim index 2603c6822f..81fdc9d956 100644 --- a/runtime/autoload/dist/ft.vim +++ b/runtime/autoload/dist/ft.vim @@ -1,7 +1,7 @@ " Vim functions for file type detection " " Maintainer: Bram Moolenaar <Bram@vim.org> -" Last Change: 2017 Nov 11 +" Last Change: 2017 Dec 05 " These functions are moved here from runtime/filetype.vim to make startup " faster. @@ -618,7 +618,11 @@ func dist#ft#FTperl() setf perl return 1 endif - if search('^use\s\s*\k', 'nc', 30) + let save_cursor = getpos('.') + call cursor(1,1) + let has_use = search('^use\s\s*\k', 'c', 30) + call setpos('.', save_cursor) + if has_use setf perl return 1 endif diff --git a/runtime/autoload/spellfile.vim b/runtime/autoload/spellfile.vim index 84584c6e29..9ec6091218 100644 --- a/runtime/autoload/spellfile.vim +++ b/runtime/autoload/spellfile.vim @@ -20,6 +20,7 @@ function! spellfile#LoadFile(lang) endif return endif + let lang = tolower(a:lang) " If the URL changes we try all files again. if s:spellfile_URL != g:spellfile_URL @@ -28,13 +29,13 @@ function! spellfile#LoadFile(lang) endif " I will say this only once! - if has_key(s:donedict, a:lang . &enc) + if has_key(s:donedict, lang . &enc) if &verbose echomsg 'spellfile#LoadFile(): Tried this language/encoding before.' endif return endif - let s:donedict[a:lang . &enc] = 1 + let s:donedict[lang . &enc] = 1 " Find spell directories we can write in. let [dirlist, dirchoices] = spellfile#GetDirChoices() @@ -94,7 +95,7 @@ function! spellfile#LoadFile(lang) let newbufnr = winbufnr(0) endif - let fname = a:lang . '.ascii.spl' + let fname = lang . '.ascii.spl' echo 'Could not find it, trying ' . fname . '...' call spellfile#Nread(fname) if getline(2) !~ 'VIMspell' diff --git a/runtime/autoload/xmlformat.vim b/runtime/autoload/xmlformat.vim new file mode 100644 index 0000000000..f227b5ee25 --- /dev/null +++ b/runtime/autoload/xmlformat.vim @@ -0,0 +1,111 @@ +" Vim plugin for formatting XML +" Last Change: Thu, 22 May 2018 21:26:55 +0100 +" Version: 0.1 +" Author: Christian Brabandt <cb@256bit.org> +" Repository: https://github.com/chrisbra/vim-xml-ftplugin +" License: VIM License +" Documentation: see :h xmlformat.txt (TODO!) +" --------------------------------------------------------------------- +" Load Once: {{{1 +if exists("g:loaded_xmlformat") || &cp + finish +endif +let g:loaded_xmlformat = 1 +let s:keepcpo = &cpo +set cpo&vim + +" Main function: Format the input {{{1 +func! xmlformat#Format() + " only allow reformatting through the gq command + " (e.g. Vim is in normal mode) + if mode() != 'n' + " do not fall back to internal formatting + return 0 + endif + let sw = shiftwidth() + let prev = prevnonblank(v:lnum-1) + let s:indent = indent(prev)/sw + let result = [] + let lastitem = prev ? getline(prev) : '' + let is_xml_decl = 0 + " split on `<`, but don't split on very first opening < + for item in split(join(getline(v:lnum, (v:lnum + v:count - 1))), '.\@<=[>]\zs') + if s:EndTag(item) + let s:indent = s:DecreaseIndent() + call add(result, s:Indent(item)) + elseif s:EmptyTag(lastitem) + call add(result, s:Indent(item)) + elseif s:StartTag(lastitem) && s:IsTag(item) + let s:indent += 1 + call add(result, s:Indent(item)) + else + if !s:IsTag(item) + " Simply split on '<' + let t=split(item, '.<\@=\zs') + let s:indent+=1 + call add(result, s:Indent(t[0])) + let s:indent = s:DecreaseIndent() + call add(result, s:Indent(t[1])) + else + call add(result, s:Indent(item)) + endif + endif + let lastitem = item + endfor + + if !empty(result) + exe v:lnum. ",". (v:lnum + v:count - 1). 'd' + call append(v:lnum - 1, result) + " Might need to remove the last line, if it became empty because of the + " append() call + let last = v:lnum + len(result) + if getline(last) is '' + exe last. 'd' + endif + endif + + " do not run internal formatter! + return 0 +endfunc +" Check if given tag is XML Declaration header {{{1 +func! s:IsXMLDecl(tag) + return a:tag =~? '^\s*<?xml\s\?\%(version="[^"]*"\)\?\s\?\%(encoding="[^"]*"\)\? ?>\s*$' +endfunc +" Return tag indented by current level {{{1 +func! s:Indent(item) + return repeat(' ', shiftwidth()*s:indent). s:Trim(a:item) +endfu +" Return item trimmed from leading whitespace {{{1 +func! s:Trim(item) + if exists('*trim') + return trim(a:item) + else + return matchstr(a:item, '\S\+.*') + endif +endfunc +" Check if tag is a new opening tag <tag> {{{1 +func! s:StartTag(tag) + return a:tag =~? '^\s*<[^/?]' +endfunc +" Remove one level of indentation {{{1 +func! s:DecreaseIndent() + return (s:indent > 0 ? s:indent - 1 : 0) +endfunc +" Check if tag is a closing tag </tag> {{{1 +func! s:EndTag(tag) + return a:tag =~? '^\s*</' +endfunc +" Check that the tag is actually a tag and not {{{1 +" something like "foobar</foobar>" +func! s:IsTag(tag) + return s:Trim(a:tag)[0] == '<' +endfunc +" Check if tag is empty <tag/> {{{1 +func! s:EmptyTag(tag) + return a:tag =~ '/>\s*$' +endfunc +" Restoration And Modelines: {{{1 +let &cpo= s:keepcpo +unlet s:keepcpo +" Modeline {{{1 +" vim: fdm=marker fdl=0 ts=2 et sw=0 sts=-1 |