diff options
Diffstat (limited to 'runtime/autoload')
-rw-r--r-- | runtime/autoload/RstFold.vim | 16 | ||||
-rw-r--r-- | runtime/autoload/dist/ft.vim | 2 | ||||
-rw-r--r-- | runtime/autoload/paste.vim | 46 | ||||
-rw-r--r-- | runtime/autoload/rubycomplete.vim | 57 | ||||
-rw-r--r-- | runtime/autoload/tohtml.vim | 122 | ||||
-rw-r--r-- | runtime/autoload/xmlformat.vim | 16 |
6 files changed, 147 insertions, 112 deletions
diff --git a/runtime/autoload/RstFold.vim b/runtime/autoload/RstFold.vim index 5becb04685..238b1e3537 100644 --- a/runtime/autoload/RstFold.vim +++ b/runtime/autoload/RstFold.vim @@ -1,8 +1,12 @@ " Author: Antony Lee <anntzer.lee@gmail.com> " Description: Helper functions for reStructuredText syntax folding -" Last Modified: 2018-01-07 +" Last Modified: 2018-12-29 function s:CacheRstFold() + if !g:rst_fold_enabled + return + endif + let closure = {'header_types': {}, 'max_level': 0, 'levels': {}} function closure.Process(match) dict let curline = getcurpos()[1] @@ -20,12 +24,18 @@ function s:CacheRstFold() let self.levels[curline] = self.header_types[key] endfunction let save_cursor = getcurpos() + let save_mark = getpos("'[") 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) + call setpos("'[", save_mark) let b:RstFoldCache = closure.levels endfunction function RstFold#GetRstFold() + if !g:rst_fold_enabled + return + endif + if !has_key(b:, 'RstFoldCache') call s:CacheRstFold() endif @@ -37,6 +47,10 @@ function RstFold#GetRstFold() endfunction function RstFold#GetRstFoldText() + if !g:rst_fold_enabled + return + endif + if !has_key(b:, 'RstFoldCache') call s:CacheRstFold() endif diff --git a/runtime/autoload/dist/ft.vim b/runtime/autoload/dist/ft.vim index 6ed39cb9f1..a97bad3b56 100644 --- a/runtime/autoload/dist/ft.vim +++ b/runtime/autoload/dist/ft.vim @@ -126,7 +126,7 @@ endfunc " This function checks if one of the first ten lines start with a '@'. In " that case it is probably a change file. " If the first line starts with # or ! it's probably a ch file. -" If a line has "main", "include", "//" ir "/*" it's probably ch. +" If a line has "main", "include", "//" or "/*" it's probably ch. " Otherwise CHILL is assumed. func dist#ft#FTchange() let lnum = 1 diff --git a/runtime/autoload/paste.vim b/runtime/autoload/paste.vim index dd7b3ae54a..2d787e7a1d 100644 --- a/runtime/autoload/paste.vim +++ b/runtime/autoload/paste.vim @@ -1,35 +1,25 @@ " Vim support file to help with paste mappings and menus " Maintainer: Bram Moolenaar <Bram@vim.org> -" Last Change: 2017 Aug 30 +" Last Change: 2019 Jan 27 " Define the string to use for items that are present both in Edit, Popup and " Toolbar menu. Also used in mswin.vim and macmap.vim. -" Pasting blockwise and linewise selections is not possible in Insert and -" Visual mode without the +virtualedit feature. They are pasted as if they -" were characterwise instead. Add to that some tricks to leave the cursor in -" the right position, also for "gi". -if has("virtualedit") - let paste#paste_cmd = {'n': ":call paste#Paste()<CR>"} - let paste#paste_cmd['v'] = '"-c<Esc>' . paste#paste_cmd['n'] - let paste#paste_cmd['i'] = "\<c-\>\<c-o>\"+gP" +let paste#paste_cmd = {'n': ":call paste#Paste()<CR>"} +let paste#paste_cmd['v'] = '"-c<Esc>' . paste#paste_cmd['n'] +let paste#paste_cmd['i'] = "\<c-\>\<c-o>\"+gP" - func! paste#Paste() - let ove = &ve - set ve=all - normal! `^ - if @+ != '' - normal! "+gP - endif - let c = col(".") - normal! i - if col(".") < c " compensate for i<ESC> moving the cursor left - normal! l - endif - let &ve = ove - endfunc -else - let paste#paste_cmd = {'n': "\"=@+.'xy'<CR>gPFx\"_2x"} - let paste#paste_cmd['v'] = '"-c<Esc>gix<Esc>' . paste#paste_cmd['n'] . '"_x' - let paste#paste_cmd['i'] = 'x<Esc>' . paste#paste_cmd['n'] . '"_s' -endif +func! paste#Paste() + let ove = &ve + set ve=all + normal! `^ + if @+ != '' + normal! "+gP + endif + let c = col(".") + normal! i + if col(".") < c " compensate for i<ESC> moving the cursor left + normal! l + endif + let &ve = ove +endfunc diff --git a/runtime/autoload/rubycomplete.vim b/runtime/autoload/rubycomplete.vim index 40b87f4cbe..ea18470232 100644 --- a/runtime/autoload/rubycomplete.vim +++ b/runtime/autoload/rubycomplete.vim @@ -1,9 +1,9 @@ " Vim completion script -" Language: Ruby -" Maintainer: Mark Guzman <segfault@hasno.info> -" URL: https://github.com/vim-ruby/vim-ruby -" Release Coordinator: Doug Kearns <dougkearns@gmail.com> -" Maintainer Version: 0.8.1 +" Language: Ruby +" Maintainer: Mark Guzman <segfault@hasno.info> +" URL: https://github.com/vim-ruby/vim-ruby +" Release Coordinator: Doug Kearns <dougkearns@gmail.com> +" Last Change: 2019 Jan 06 " ---------------------------------------------------------------------------- " " Ruby IRB/Complete author: Keiju ISHITSUKA(keiju@ishitsuka.com) @@ -103,7 +103,7 @@ function! s:GetBufferRubyEntity( name, type, ... ) endif let curpos = getpos(".") - let [enum,ecol] = searchpairpos( crex, '', '\(end\|}\)', 'wr' ) + let [enum,ecol] = searchpairpos( crex, '', '\(end\|}\)', 'W' ) call cursor(lastpos[1], lastpos[2]) if lnum > enum @@ -253,15 +253,27 @@ class VimRubyCompletion # {{{ buffer analysis magic def load_requires + + custom_paths = VIM::evaluate("get(g:, 'rubycomplete_load_paths', [])") + + if !custom_paths.empty? + $LOAD_PATH.concat(custom_paths).uniq! + end + buf = VIM::Buffer.current enum = buf.line_number nums = Range.new( 1, enum ) nums.each do |x| + ln = buf[x] begin - eval( "require %s" % $1 ) if /.*require\s*(.*)$/.match( ln ) - rescue Exception - #ignore? + if /.*require_relative\s*(.*)$/.match( ln ) + eval( "require %s" % File.expand_path($1) ) + elsif /.*require\s*(["'].*?["'])/.match( ln ) + eval( "require %s" % $1 ) + end + rescue Exception => e + dprint e.inspect end end end @@ -344,8 +356,13 @@ class VimRubyCompletion if x != cur_line next if x == 0 ln = buf[x] - if /^\s*(module|class|def|include)\s+/.match(ln) - clscnt += 1 if $1 == "class" + is_const = false + if /^\s*(module|class|def|include)\s+/.match(ln) || is_const = /^\s*?[A-Z]([A-z]|[1-9])*\s*?[|]{0,2}=\s*?.+\s*?/.match(ln) + clscnt += 1 if /class|module/.match($1) + # We must make sure to load each constant only once to avoid errors + if is_const + ln.gsub!(/\s*?[|]{0,2}=\s*?/, '||=') + end #dprint "\$1$1 classdef += "%s\n" % ln classdef += "end\n" if /def\s+/.match(ln) @@ -423,7 +440,6 @@ class VimRubyCompletion return get_buffer_entity_list( "class" ) end - def load_rails allow_rails = VIM::evaluate("exists('g:rubycomplete_rails') && g:rubycomplete_rails") return if allow_rails.to_i.zero? @@ -529,7 +545,6 @@ class VimRubyCompletion ret += ActiveRecord::ConnectionAdapters::SchemaStatements.methods end - return ret end @@ -587,11 +602,13 @@ class VimRubyCompletion # {{{ main completion code def self.preload_rails a = VimRubyCompletion.new - require 'Thread' - Thread.new(a) do |b| - begin - b.load_rails - rescue + if VIM::evaluate("has('nvim')") == 0 + require 'thread' + Thread.new(a) do |b| + begin + b.load_rails + rescue + end end end a.load_rails @@ -612,7 +629,6 @@ class VimRubyCompletion want_gems = VIM::evaluate("get(g:, 'rubycomplete_load_gemfile')") load_gems unless want_gems.to_i.zero? - input = VIM::Buffer.current.line cpos = VIM::Window.current.cursor[1] - 1 @@ -666,6 +682,7 @@ class VimRubyCompletion message = Regexp.quote($4) dprint "const or cls 2 [recv: \'%s\', msg: \'%s\']" % [ receiver, message ] load_buffer_class( receiver ) + load_buffer_module( receiver ) begin classes = eval("#{receiver}.constants") #methods = eval("#{receiver}.methods") @@ -786,7 +803,6 @@ class VimRubyCompletion methods += Kernel.public_methods end - include_object = VIM::evaluate("exists('g:rubycomplete_include_object') && g:rubycomplete_include_object") methods = clean_sel( methods, message ) methods = (methods-Object.instance_methods) if include_object == "0" @@ -829,5 +845,4 @@ let s:rubycomplete_rails_loaded = 0 call s:DefRuby() "}}} ruby-side code - " vim:tw=78:sw=4:ts=8:et:fdm=marker:ft=vim:norl: diff --git a/runtime/autoload/tohtml.vim b/runtime/autoload/tohtml.vim index d972ad63fe..2d874c690d 100644 --- a/runtime/autoload/tohtml.vim +++ b/runtime/autoload/tohtml.vim @@ -1,6 +1,6 @@ " Vim autoload file for the tohtml plugin. " Maintainer: Ben Fritz <fritzophrenic@gmail.com> -" Last Change: 2013 Sep 03 +" Last Change: 2018 Nov 11 " " Additional contributors: " @@ -544,12 +544,16 @@ func! tohtml#Diff2HTML(win_list, buf_list) "{{{ " add required javascript in reverse order so we can just call append again " and again without adjusting {{{ - " insert script closing tag - call append(style_start, [ - \ '', - \ s:settings.use_xhtml ? '//]]>' : '-->', - \ "</script>" - \ ]) + let s:uses_script = s:settings.dynamic_folds || s:settings.line_ids || !empty(s:settings.prevent_copy) + + " insert script closing tag if needed + if s:uses_script + call append(style_start, [ + \ '', + \ s:settings.use_xhtml ? '//]]>' : '-->', + \ "</script>" + \ ]) + endif " insert script which corrects the size of small input elements in " prevent_copy mode. See 2html.vim for details on why this is needed and how @@ -575,55 +579,61 @@ func! tohtml#Diff2HTML(win_list, buf_list) "{{{ \ '}' \ ]) endif - " + " insert javascript to get IDs from line numbers, and to open a fold before " jumping to any lines contained therein - call append(style_start, [ - \ " /* Always jump to new location even if the line was hidden inside a fold, or", - \ " * we corrected the raw number to a line ID.", - \ " */", - \ " if (lineElem) {", - \ " lineElem.scrollIntoView(true);", - \ " }", - \ " return true;", - \ "}", - \ "if ('onhashchange' in window) {", - \ " window.onhashchange = JumpToLine;", - \ "}" - \ ]) - if s:settings.dynamic_folds + if s:settings.line_ids + call append(style_start, [ + \ " /* Always jump to new location even if the line was hidden inside a fold, or", + \ " * we corrected the raw number to a line ID.", + \ " */", + \ " if (lineElem) {", + \ " lineElem.scrollIntoView(true);", + \ " }", + \ " return true;", + \ "}", + \ "if ('onhashchange' in window) {", + \ " window.onhashchange = JumpToLine;", + \ "}" + \ ]) + + if s:settings.dynamic_folds + call append(style_start, [ + \ "", + \ " /* navigate upwards in the DOM tree to open all folds containing the line */", + \ " var node = lineElem;", + \ " while (node && node.id != 'vimCodeElement".s:settings.id_suffix."')", + \ " {", + \ " if (node.className == 'closed-fold')", + \ " {", + \ " /* toggle open the fold ID (remove window ID) */", + \ " toggleFold(node.id.substr(4));", + \ " }", + \ " node = node.parentNode;", + \ " }", + \ ]) + endif + endif + + if s:settings.line_ids call append(style_start, [ \ "", - \ " /* navigate upwards in the DOM tree to open all folds containing the line */", - \ " var node = lineElem;", - \ " while (node && node.id != 'vimCodeElement".s:settings.id_suffix."')", - \ " {", - \ " if (node.className == 'closed-fold')", - \ " {", - \ " /* toggle open the fold ID (remove window ID) */", - \ " toggleFold(node.id.substr(4));", - \ " }", - \ " node = node.parentNode;", + \ "/* function to open any folds containing a jumped-to line before jumping to it */", + \ "function JumpToLine()", + \ "{", + \ " var lineNum;", + \ " lineNum = window.location.hash;", + \ " lineNum = lineNum.substr(1); /* strip off '#' */", + \ "", + \ " if (lineNum.indexOf('L') == -1) {", + \ " lineNum = 'L'+lineNum;", + \ " }", + \ " if (lineNum.indexOf('W') == -1) {", + \ " lineNum = 'W1'+lineNum;", \ " }", + \ " var lineElem = document.getElementById(lineNum);" \ ]) endif - call append(style_start, [ - \ "", - \ "/* function to open any folds containing a jumped-to line before jumping to it */", - \ "function JumpToLine()", - \ "{", - \ " var lineNum;", - \ " lineNum = window.location.hash;", - \ " lineNum = lineNum.substr(1); /* strip off '#' */", - \ "", - \ " if (lineNum.indexOf('L') == -1) {", - \ " lineNum = 'L'+lineNum;", - \ " }", - \ " if (lineNum.indexOf('W') == -1) {", - \ " lineNum = 'W1'+lineNum;", - \ " }", - \ " lineElem = document.getElementById(lineNum);" - \ ]) " Insert javascript to toggle matching folds open and closed in all windows, " if dynamic folding is active. @@ -648,11 +658,13 @@ func! tohtml#Diff2HTML(win_list, buf_list) "{{{ \ ]) endif - " insert script tag; javascript is always needed for the line number - " normalization for URL hashes - call append(style_start, [ - \ "<script type='text/javascript'>", - \ s:settings.use_xhtml ? '//<![CDATA[' : "<!--"]) + if s:uses_script + " insert script tag; javascript is always needed for the line number + " normalization for URL hashes + call append(style_start, [ + \ "<script type='text/javascript'>", + \ s:settings.use_xhtml ? '//<![CDATA[' : "<!--"]) + endif " Insert styles from all the generated html documents and additional styles " for the table-based layout of the side-by-side diff. The diff should take @@ -767,7 +779,7 @@ func! tohtml#GetUserSettings() "{{{ if user_settings.no_pre == 0 call tohtml#GetOption(user_settings, \ 'expand_tabs', - \ &expandtab || &ts != 8 || user_settings.number_lines || + \ &expandtab || &ts != 8 || &vts != '' || user_settings.number_lines || \ (user_settings.dynamic_folds && !user_settings.no_foldcolumn)) else let user_settings.expand_tabs = 1 diff --git a/runtime/autoload/xmlformat.vim b/runtime/autoload/xmlformat.vim index f227b5ee25..ea89401977 100644 --- a/runtime/autoload/xmlformat.vim +++ b/runtime/autoload/xmlformat.vim @@ -1,9 +1,9 @@ " 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 +" Last Change: Thu, 07 Dec 2018 +" 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 @@ -85,7 +85,11 @@ func! s:Trim(item) endfunc " Check if tag is a new opening tag <tag> {{{1 func! s:StartTag(tag) - return a:tag =~? '^\s*<[^/?]' + let is_comment = s:IsComment(a:tag) + return a:tag =~? '^\s*<[^/?]' && !is_comment +endfunc +func! s:IsComment(tag) + return a:tag =~? '<!--' endfunc " Remove one level of indentation {{{1 func! s:DecreaseIndent() |