Merge #10646 'vim-patch: runtime patches'
This commit is contained in:
commit
87140f234a
|
@ -41,6 +41,7 @@ tags
|
|||
/src/nvim/testdir/X*
|
||||
/src/nvim/testdir/valgrind.*
|
||||
/src/nvim/testdir/.gdbinit
|
||||
/runtime/indent/testdir/*.out
|
||||
|
||||
# Generated by unit tests.
|
||||
/test/includes/post/
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
:" information about the environment of a possible bug in Vim.
|
||||
:"
|
||||
:" Maintainer: Bram Moolenaar <Bram@vim.org>
|
||||
:" Last change: 2005 Jun 12
|
||||
:" Last change: 2019 Jan 27
|
||||
:"
|
||||
:" To use inside Vim:
|
||||
:" :so $VIMRUNTIME/bugreport.vim
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
" Maintainer: Doug Kearns <dougkearns@gmail.com>
|
||||
" URL: https://github.com/vim-ruby/vim-ruby
|
||||
" Release Coordinator: Doug Kearns <dougkearns@gmail.com>
|
||||
" Last Change: 2018 Jan 25
|
||||
|
||||
if exists("current_compiler")
|
||||
finish
|
||||
|
@ -28,8 +29,8 @@ CompilerSet errorformat=
|
|||
\%W%f:%l:\ warning:\ %m,
|
||||
\%E%f:%l:in\ %*[^:]:\ %m,
|
||||
\%E%f:%l:\ %m,
|
||||
\%-C%\tfrom\ %f:%l:in\ %.%#,
|
||||
\%-Z%\tfrom\ %f:%l,
|
||||
\%-C%\t%\\d%#:%#\ %#from\ %f:%l:in\ %.%#,
|
||||
\%-Z%\t%\\d%#:%#\ %#from\ %f:%l,
|
||||
\%-Z%p^,
|
||||
\%-G%.%#
|
||||
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
" Vim Compiler File
|
||||
" Compiler: ocaml
|
||||
" Maintainer: See ftplugin/ocaml.vim (?)
|
||||
" Last Change: June 2013 by Marc Weber
|
||||
" Compiler: ocaml
|
||||
" Maintainer: Markus Mottl <markus.mottl@gmail.com>
|
||||
" URL: https://github.com/rgrinberg/vim-ocaml
|
||||
" Last Change:
|
||||
" 2017 Nov 26 - Improved error format (Markus Mottl)
|
||||
" 2013 Aug 27 - Added a new OCaml error format (Markus Mottl)
|
||||
" 2013 Jun 30 - Initial version (Marc Weber)
|
||||
"
|
||||
" Marc Weber's comments:
|
||||
" Setting makeprg doesn't make sense, because there is ocamlc, ocamlopt,
|
||||
|
@ -17,7 +21,6 @@
|
|||
"
|
||||
" So having it here makes people opt-in
|
||||
|
||||
|
||||
if exists("current_compiler")
|
||||
finish
|
||||
endif
|
||||
|
@ -28,6 +31,7 @@ set cpo&vim
|
|||
|
||||
CompilerSet errorformat =
|
||||
\%EFile\ \"%f\"\\,\ line\ %l\\,\ characters\ %c-%*\\d:,
|
||||
\%EFile\ \"%f\"\\,\ line\ %l\\,\ characters\ %c-%*\\d\ %.%#,
|
||||
\%EFile\ \"%f\"\\,\ line\ %l\\,\ character\ %c:%m,
|
||||
\%+EReference\ to\ unbound\ regexp\ name\ %m,
|
||||
\%Eocamlyacc:\ e\ -\ line\ %l\ of\ \"%f\"\\,\ %m,
|
||||
|
@ -38,6 +42,12 @@ CompilerSet errorformat =
|
|||
\%X%*\\a[%*\\d]:\ Leaving\ directory\ `%f',
|
||||
\%D%*\\a:\ Entering\ directory\ `%f',
|
||||
\%X%*\\a:\ Leaving\ directory\ `%f',
|
||||
\%D%*\\a[%*\\d]:\ Entering\ directory\ '%f',
|
||||
\%X%*\\a[%*\\d]:\ Leaving\ directory\ '%f',
|
||||
\%D%*\\a:\ Entering\ directory\ '%f',
|
||||
\%X%*\\a:\ Leaving\ directory\ '%f',
|
||||
\%DEntering\ directory\ '%f',
|
||||
\%XLeaving\ directory\ '%f',
|
||||
\%DMaking\ %*\\a\ in\ %f
|
||||
|
||||
let &cpo = s:cpo_save
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
" Maintainer: Tim Pope <vimNOSPAM@tpope.org>
|
||||
" URL: https://github.com/vim-ruby/vim-ruby
|
||||
" Release Coordinator: Doug Kearns <dougkearns@gmail.com>
|
||||
" Last Change: 2018 Mar 02
|
||||
|
||||
if exists("current_compiler")
|
||||
finish
|
||||
|
@ -20,12 +21,12 @@ CompilerSet makeprg=rake
|
|||
|
||||
CompilerSet errorformat=
|
||||
\%D(in\ %f),
|
||||
\%\\s%#from\ %f:%l:%m,
|
||||
\%\\s%#from\ %f:%l:,
|
||||
\%\\s%##\ %f:%l:%m,
|
||||
\%\\s%##\ %f:%l,
|
||||
\%\\s%#[%f:%l:\ %#%m,
|
||||
\%\\s%#%f:%l:\ %#%m,
|
||||
\%\\s%#%\\d%#:%#\ %#from\ %f:%l:%m,
|
||||
\%\\s%#%\\d%#:%#\ %#from\ %f:%l:,
|
||||
\%\\s%##\ %f:%l:%m%\\&%.%#%\\D:%\\d%\\+:%.%#,
|
||||
\%\\s%##\ %f:%l%\\&%.%#%\\D:%\\d%\\+,
|
||||
\%\\s%#[%f:%l:\ %#%m%\\&%.%#%\\D:%\\d%\\+:%.%#,
|
||||
\%\\s%#%f:%l:\ %#%m%\\&%.%#%\\D:%\\d%\\+:%.%#,
|
||||
\%\\s%#%f:%l:,
|
||||
\%m\ [%f:%l]:,
|
||||
\%+Erake\ aborted!,
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
" Maintainer: Tim Pope <vimNOSPAM@tpope.org>
|
||||
" URL: https://github.com/vim-ruby/vim-ruby
|
||||
" Release Coordinator: Doug Kearns <dougkearns@gmail.com>
|
||||
" Last Change: 2018 Aug 07
|
||||
|
||||
if exists("current_compiler")
|
||||
finish
|
||||
|
@ -23,7 +24,8 @@ CompilerSet errorformat=
|
|||
\%E%.%#:in\ `load':\ %f:%l:%m,
|
||||
\%E%f:%l:in\ `%*[^']':\ %m,
|
||||
\%-Z\ \ \ \ \ %\\+\#\ %f:%l:%.%#,
|
||||
\%E\ \ %\\d%\\+)%.%#,
|
||||
\%E\ \ \ \ \ Failure/Error:\ %m,
|
||||
\%E\ \ \ \ \ Failure/Error:,
|
||||
\%C\ \ \ \ \ %m,
|
||||
\%C%\\s%#,
|
||||
\%-G%.%#
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
" Maintainer: Tim Pope <vimNOSPAM@tpope.org>
|
||||
" URL: https://github.com/vim-ruby/vim-ruby
|
||||
" Release Coordinator: Doug Kearns <dougkearns@gmail.com>
|
||||
" ----------------------------------------------------------------------------
|
||||
" Last Change: 2019 Jan 06
|
||||
|
||||
if exists("current_compiler")
|
||||
finish
|
||||
|
@ -21,21 +21,21 @@ set cpo-=C
|
|||
" default settings runs script normally
|
||||
" add '-c' switch to run syntax check only:
|
||||
"
|
||||
" CompilerSet makeprg=ruby\ -wc\ $*
|
||||
" CompilerSet makeprg=ruby\ -c
|
||||
"
|
||||
" or add '-c' at :make command line:
|
||||
"
|
||||
" :make -c %<CR>
|
||||
"
|
||||
CompilerSet makeprg=ruby\ -w\ $*
|
||||
CompilerSet makeprg=ruby
|
||||
|
||||
CompilerSet errorformat=
|
||||
\%+E%f:%l:\ parse\ error,
|
||||
\%W%f:%l:\ warning:\ %m,
|
||||
\%E%f:%l:in\ %*[^:]:\ %m,
|
||||
\%E%f:%l:\ %m,
|
||||
\%-C%\tfrom\ %f:%l:in\ %.%#,
|
||||
\%-Z%\tfrom\ %f:%l,
|
||||
\%-C%\t%\\d%#:%#\ %#from\ %f:%l:in\ %.%#,
|
||||
\%-Z%\t%\\d%#:%#\ %#from\ %f:%l,
|
||||
\%-Z%p^,
|
||||
\%-G%.%#
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
" Maintainer: Doug Kearns <dougkearns@gmail.com>
|
||||
" URL: https://github.com/vim-ruby/vim-ruby
|
||||
" Release Coordinator: Doug Kearns <dougkearns@gmail.com>
|
||||
" Last Change: 2014 Mar 23
|
||||
|
||||
if exists("current_compiler")
|
||||
finish
|
||||
|
|
|
@ -305,6 +305,7 @@ Name triggered by ~
|
|||
|FuncUndefined| a user function is used but it isn't defined
|
||||
|SpellFileMissing| a spell file is used but it can't be found
|
||||
|SourcePre| before sourcing a Vim script
|
||||
|SourcePost| after sourcing a Vim script
|
||||
|SourceCmd| before sourcing a Vim script |Cmd-event|
|
||||
|
||||
|VimResized| after the Vim window size changed
|
||||
|
@ -397,8 +398,8 @@ BufFilePost After changing the name of the current buffer
|
|||
BufFilePre Before changing the name of the current buffer
|
||||
with the ":file" or ":saveas" command.
|
||||
*BufHidden*
|
||||
BufHidden Just after a buffer has become hidden. That
|
||||
is, when there are no longer windows that show
|
||||
BufHidden Just before a buffer becomes hidden. That is,
|
||||
when there are no longer windows that show
|
||||
the buffer, but the buffer is not unloaded or
|
||||
deleted. Not used for ":qa" or ":q" when
|
||||
exiting Vim.
|
||||
|
@ -776,13 +777,14 @@ FilterReadPre Before reading a file from a filter command.
|
|||
Not triggered when 'shelltemp' is off.
|
||||
*FilterWritePost*
|
||||
FilterWritePost After writing a file for a filter command or
|
||||
making a diff.
|
||||
making a diff with an external diff (see
|
||||
DiffUpdated for internal diff).
|
||||
Vim checks the pattern against the name of
|
||||
the current buffer as with FilterWritePre.
|
||||
Not triggered when 'shelltemp' is off.
|
||||
*FilterWritePre*
|
||||
FilterWritePre Before writing a file for a filter command or
|
||||
making a diff.
|
||||
making a diff with an external diff.
|
||||
Vim checks the pattern against the name of
|
||||
the current buffer, not the name of the
|
||||
temporary file that is the output of the
|
||||
|
@ -1042,8 +1044,10 @@ TermResponse After the response to t_RV is received from
|
|||
anything else that takes time is involved).
|
||||
*TextChanged*
|
||||
TextChanged After a change was made to the text in the
|
||||
current buffer in Normal mode. That is when
|
||||
|b:changedtick| has changed.
|
||||
current buffer in Normal mode. That is after
|
||||
|b:changedtick| has changed (also when that
|
||||
happened before the TextChanged autocommand
|
||||
was defined).
|
||||
Not triggered when there is typeahead or when
|
||||
an operator is pending.
|
||||
Careful: This is triggered very often, don't
|
||||
|
|
|
@ -800,7 +800,7 @@ the |substitute()| function with the following exceptions:
|
|||
- magic is always set without regard to 'magic'.
|
||||
- A ~ inserts a tilde literally.
|
||||
- <CR> and \r inserts a carriage-return (CTRL-M).
|
||||
- \<CR> does not have a special meaning. it's just one of \x.
|
||||
- \<CR> does not have a special meaning. It's just one of \x.
|
||||
|
||||
Examples: >
|
||||
:s/a\|b/xxx\0xxx/g modifies "a b" to "xxxaxxx xxxbxxx"
|
||||
|
@ -886,9 +886,9 @@ When the result is a |List| then the items are joined with separating line
|
|||
breaks. Thus each item becomes a line, except that they can contain line
|
||||
breaks themselves.
|
||||
|
||||
The whole matched text can be accessed with "submatch(0)". The text matched
|
||||
with the first pair of () with "submatch(1)". Likewise for further
|
||||
sub-matches in ().
|
||||
The |submatch()| function can be used to obtain matched text. The whole
|
||||
matched text can be accessed with "submatch(0)". The text matched with the
|
||||
first pair of () with "submatch(1)". Likewise for further sub-matches in ().
|
||||
|
||||
Be careful: The separation character must not appear in the expression!
|
||||
Consider using a character like "@" or ":". There is no problem if the result
|
||||
|
|
|
@ -499,7 +499,6 @@ that see the '"' as part of their argument:
|
|||
:autocmd
|
||||
:bufdo
|
||||
:cexpr (and the like)
|
||||
:call
|
||||
:cdo (and the like)
|
||||
:command
|
||||
:cscope (and the like)
|
||||
|
|
|
@ -91,11 +91,14 @@ this, you will have to type <BS> e again. To avoid this don't set the
|
|||
|
||||
You may have problems using Vim with characters which have a value above 128.
|
||||
For example: You insert ue (u-umlaut) and the editor echoes \334 in Insert
|
||||
mode. After leaving the Insert mode everything is fine. Note that fmt
|
||||
removes all characters with a value above 128 from the text being formatted.
|
||||
On some Unix systems this means you have to define the environment-variable
|
||||
LC_CTYPE. If you are using csh, then put the following line in your .cshrc: >
|
||||
setenv LC_CTYPE iso_8859_1
|
||||
mode. After leaving the Insert mode everything is fine. On some Unix systems
|
||||
this means you have to define the environment-variable LC_CTYPE. If you are
|
||||
using csh, then put the following line in your .cshrc: >
|
||||
setenv LC_CTYPE en_US.utf8
|
||||
(or similar for a different language or country). The value must be a valid
|
||||
locale on your system, i.e. on Unix-like systems it must be present in the
|
||||
output of >
|
||||
locale -a
|
||||
|
||||
==============================================================================
|
||||
3. Default digraphs *digraphs-default*
|
||||
|
|
|
@ -69,7 +69,7 @@ To force conversion from String to Number, add zero to it: >
|
|||
To avoid a leading zero to cause octal conversion, or for using a different
|
||||
base, use |str2nr()|.
|
||||
|
||||
*TRUE* *FALSE*
|
||||
*TRUE* *FALSE* *Boolean*
|
||||
For boolean operators Numbers are used. Zero is FALSE, non-zero is TRUE.
|
||||
You can also use |v:false| and |v:true|. When TRUE is returned from a
|
||||
function it is the Number one, FALSE is the number zero.
|
||||
|
@ -92,7 +92,8 @@ Note that " " and "0" are also non-empty strings, thus considered to be TRUE.
|
|||
A List, Dictionary or Float is not a Number or String, thus evaluate to FALSE.
|
||||
|
||||
*E745* *E728* *E703* *E729* *E730* *E731*
|
||||
List, Dictionary and Funcref types are not automatically converted.
|
||||
|List|, |Dictionary|, |Funcref|, and |Blob| types are not automatically
|
||||
converted.
|
||||
|
||||
*E805* *E806* *E808*
|
||||
When mixing Number and Float the Number is converted to Float. Otherwise
|
||||
|
@ -147,10 +148,10 @@ function() or funcref(). When calling the function the Dictionary and/or
|
|||
arguments will be passed to the function. Example: >
|
||||
|
||||
let Cb = function('Callback', ['foo'], myDict)
|
||||
call Cb()
|
||||
call Cb('bar')
|
||||
|
||||
This will invoke the function as if using: >
|
||||
call myDict.Callback('foo')
|
||||
call myDict.Callback('foo', 'bar')
|
||||
|
||||
Note that binding a function to a Dictionary also happens when the function is
|
||||
a member of the Dictionary: >
|
||||
|
@ -482,7 +483,7 @@ To loop over the values use the |values()| function: >
|
|||
:endfor
|
||||
|
||||
If you want both the key and the value use the |items()| function. It returns
|
||||
a List in which each item is a List with two items, the key and the value: >
|
||||
a List in which each item is a List with two items, the key and the value: >
|
||||
:for [key, value] in items(mydict)
|
||||
: echo key . ': ' . value
|
||||
:endfor
|
||||
|
@ -1408,7 +1409,9 @@ Note that this means that filetype plugins don't get a different set of script
|
|||
variables for each buffer. Use local buffer variables instead |b:var|.
|
||||
|
||||
|
||||
Predefined Vim variables: *vim-variable* *v:var* *v:*
|
||||
PREDEFINED VIM VARIABLES *vim-variable* *v:var* *v:*
|
||||
*E963*
|
||||
Some variables can be set by the user, but the type cannot be changed.
|
||||
|
||||
*v:beval_col* *beval_col-variable*
|
||||
v:beval_col The number of the column, over which the mouse pointer is.
|
||||
|
@ -4696,7 +4699,7 @@ gettagstack([{nr}]) *gettagstack()*
|
|||
|
||||
getwinpos([{timeout}]) *getwinpos()*
|
||||
The result is a list with two numbers, the result of
|
||||
getwinposx() and getwinposy() combined:
|
||||
getwinposx() and getwinposy() combined:
|
||||
[x-pos, y-pos]
|
||||
{timeout} can be used to specify how long to wait in msec for
|
||||
a response from the terminal. When omitted 100 msec is used.
|
||||
|
@ -5417,6 +5420,7 @@ len({expr}) The result is a Number, which is the length of the argument.
|
|||
used, as with |strlen()|.
|
||||
When {expr} is a |List| the number of items in the |List| is
|
||||
returned.
|
||||
When {expr} is a |Blob| the number of bytes is returned.
|
||||
When {expr} is a |Dictionary| the number of entries in the
|
||||
|Dictionary| is returned.
|
||||
Otherwise an error is given.
|
||||
|
@ -5501,13 +5505,6 @@ line({expr}) The result is a Number, which is the line number of the file
|
|||
line(".") line number of the cursor
|
||||
line("'t") line number of mark t
|
||||
line("'" . marker) line number of mark marker
|
||||
< *last-position-jump*
|
||||
This autocommand jumps to the last known position in a file
|
||||
just after opening it, if the '" mark is set: >
|
||||
:au BufReadPost *
|
||||
\ if line("'\"") > 1 && line("'\"") <= line("$") && &ft !~# 'commit'
|
||||
\ | exe "normal! g`\""
|
||||
\ | endif
|
||||
|
||||
line2byte({lnum}) *line2byte()*
|
||||
Return the byte count from the start of the buffer for line
|
||||
|
@ -7514,9 +7511,9 @@ sign_getplaced([{expr} [, {dict}]]) *sign_getplaced()*
|
|||
list of signs placed in that buffer is returned. For the use
|
||||
of {expr}, see |bufname()|. The optional {dict} can contain
|
||||
the following entries:
|
||||
group select only signs in this group
|
||||
id select sign with this identifier
|
||||
lnum select signs placed in this line. For the use
|
||||
group select only signs in this group
|
||||
id select sign with this identifier
|
||||
lnum select signs placed in this line. For the use
|
||||
of {lnum}, see |line()|.
|
||||
If {group} is '*', then signs in all the groups including the
|
||||
global group are returned. If {group} is not supplied or is an
|
||||
|
@ -7557,11 +7554,11 @@ sign_getplaced([{expr} [, {dict}]]) *sign_getplaced()*
|
|||
echo sign_getplaced("eval.c", {'lnum' : 10})
|
||||
|
||||
" Get sign with identifier 10 placed in a.py
|
||||
echo sign_getplaced("a.py", {'id' : 10'})
|
||||
echo sign_getplaced("a.py", {'id' : 10})
|
||||
|
||||
" Get sign with id 20 in group 'g1' placed in a.py
|
||||
echo sign_getplaced("a.py", {'group' : 'g1',
|
||||
\ 'id' : 20'})
|
||||
\ 'id' : 20})
|
||||
|
||||
" Get a List of all the placed signs
|
||||
echo sign_getplaced()
|
||||
|
@ -7646,7 +7643,7 @@ sign_undefine([{name}]) *sign_undefine()*
|
|||
<
|
||||
sign_unplace({group} [, {dict}]) *sign_unplace()*
|
||||
Remove a previously placed sign in one or more buffers. This
|
||||
is similar to the |:sign-unplace()| command.
|
||||
is similar to the |:sign-unplace| command.
|
||||
|
||||
{group} is the sign group name. To use the global sign group,
|
||||
use an empty string. If {group} is set to '*', then all the
|
||||
|
@ -7936,7 +7933,8 @@ str2float({expr}) *str2float()*
|
|||
as when using a floating point number in an expression, see
|
||||
|floating-point-format|. But it's a bit more permissive.
|
||||
E.g., "1e40" is accepted, while in an expression you need to
|
||||
write "1.0e40".
|
||||
write "1.0e40". The hexadecimal form "0x123" is also
|
||||
accepted, but not others, like binary or octal.
|
||||
Text after the number is silently ignored.
|
||||
The decimal point is always '.', no matter what the locale is
|
||||
set to. A comma ends the number: "12,345.67" is converted to
|
||||
|
@ -8819,7 +8817,7 @@ win_getid([{win} [, {tab}]]) *win_getid()*
|
|||
Get the |window-ID| for the specified window.
|
||||
When {win} is missing use the current window.
|
||||
With {win} this is the window number. The top window has
|
||||
number 1. Use `win_getid(winnr())` for the current window.
|
||||
number 1.
|
||||
Without {tab} use the current tab, otherwise the tab with
|
||||
number {tab}. The first tab has number one.
|
||||
Return zero if the window cannot be found.
|
||||
|
|
|
@ -9,7 +9,7 @@ Close this window: Use ":q<Enter>".
|
|||
|
||||
Jump to a subject: Position the cursor on a tag (e.g. |bars|) and hit CTRL-].
|
||||
With the mouse: Double-click the left mouse button on a tag, e.g. |bars|.
|
||||
Jump back: Type CTRL-T or CTRL-O. Repeat to go further back.
|
||||
Jump back: Type CTRL-O. Repeat to go further back.
|
||||
|
||||
Get specific help: It is possible to go directly to whatever you want help
|
||||
on, by giving an argument to the |:help| command.
|
||||
|
@ -30,13 +30,17 @@ Get specific help: It is possible to go directly to whatever you want help
|
|||
help entries for "word".
|
||||
Or use ":helpgrep word". |:helpgrep|
|
||||
|
||||
Getting started: Do the Vim tutor, a 20 minute interactive training for the
|
||||
basic commands, see |vimtutor|.
|
||||
Read the user manual from start to end: |usr_01.txt|
|
||||
|
||||
Vim stands for Vi IMproved. Most of Vim was made by Bram Moolenaar, but only
|
||||
through the help of many others. See |credits|.
|
||||
------------------------------------------------------------------------------
|
||||
*doc-file-list* *Q_ct*
|
||||
BASIC:
|
||||
|quickref| Overview of the most common commands you will use
|
||||
|tutor| 30 minutes training course for beginners
|
||||
|tutor| 20 minutes training course for beginners
|
||||
|copying| About copyrights
|
||||
|iccf| Helping poor children in Uganda
|
||||
|sponsor| Sponsor Vim development, become a registered Vim user
|
||||
|
@ -106,7 +110,6 @@ Basic editing ~
|
|||
|scroll.txt| scrolling the text in the window
|
||||
|insert.txt| Insert and Replace mode
|
||||
|change.txt| deleting and replacing text
|
||||
|indent.txt| automatic indenting for C and other languages
|
||||
|undo.txt| Undo and Redo
|
||||
|repeat.txt| repeating commands, Vim scripts and debugging
|
||||
|visual.txt| using the Visual mode (selecting a text area)
|
||||
|
@ -119,30 +122,36 @@ Advanced editing ~
|
|||
|pattern.txt| regexp patterns and search commands
|
||||
|map.txt| key mapping and abbreviations
|
||||
|tagsrch.txt| tags and special searches
|
||||
|quickfix.txt| commands for a quick edit-compile-fix cycle
|
||||
|windows.txt| commands for using multiple windows and buffers
|
||||
|tabpage.txt| commands for using multiple tab pages
|
||||
|syntax.txt| syntax highlighting
|
||||
|spell.txt| spell checking
|
||||
|diff.txt| working with two to four versions of the same file
|
||||
|autocmd.txt| automatically executing commands on an event
|
||||
|filetype.txt| settings done specifically for a type of file
|
||||
|eval.txt| expression evaluation, conditional commands
|
||||
|fold.txt| hide (fold) ranges of lines
|
||||
|
||||
Special issues ~
|
||||
|print.txt| printing
|
||||
|remote.txt| using Vim as a server or client
|
||||
|digraph.txt| list of available digraphs
|
||||
|mbyte.txt| multi-byte text support
|
||||
|mlang.txt| non-English language support
|
||||
|arabic.txt| Arabic language support and editing
|
||||
|hebrew.txt| Hebrew language support and editing
|
||||
|russian.txt| Russian language support and editing
|
||||
|
||||
Programming language support ~
|
||||
|indent.txt| automatic indenting for C and other languages
|
||||
|syntax.txt| syntax highlighting
|
||||
|textprop.txt| Attaching properties to text for highlighting or other
|
||||
|filetype.txt| settings done specifically for a type of file
|
||||
|quickfix.txt| commands for a quick edit-compile-fix cycle
|
||||
|ft_ada.txt| Ada (the programming language) support
|
||||
|ft_rust.txt| Filetype plugin for Rust
|
||||
|ft_sql.txt| about the SQL filetype plugin
|
||||
|
||||
Language support ~
|
||||
|digraph.txt| list of available digraphs
|
||||
|mbyte.txt| multi-byte text support
|
||||
|mlang.txt| non-English language support
|
||||
|rileft.txt| right-to-left editing mode
|
||||
|arabic.txt| Arabic language support and editing
|
||||
|hebrew.txt| Hebrew language support and editing
|
||||
|russian.txt| Russian language support and editing
|
||||
|
||||
GUI ~
|
||||
|gui.txt| Graphical User Interface (GUI)
|
||||
|
|
|
@ -585,8 +585,9 @@ The basics for using flexible indenting are explained in section |30.3| of the
|
|||
user manual.
|
||||
|
||||
If you want to write your own indent file, it must set the 'indentexpr'
|
||||
option. Setting the 'indentkeys' option is often useful. See the
|
||||
$VIMRUNTIME/indent directory for examples.
|
||||
option. Setting the 'indentkeys' option is often useful.
|
||||
See the $VIMRUNTIME/indent/README.txt file for hints.
|
||||
See the $VIMRUNTIME/indent directory for examples.
|
||||
|
||||
|
||||
REMARKS ABOUT SPECIFIC INDENT FILES ~
|
||||
|
@ -599,14 +600,14 @@ the use of square and curly brackets, and otherwise by community convention.
|
|||
These conventions are not universally followed, so the Clojure indent script
|
||||
offers a few configurable options, listed below.
|
||||
|
||||
If the current vim does not include searchpairpos(), the indent script falls
|
||||
If the current vim does not include |searchpairpos()|, the indent script falls
|
||||
back to normal 'lisp' indenting, and the following options are ignored.
|
||||
|
||||
*g:clojure_maxlines*
|
||||
|
||||
Set maximum scan distance of searchpairpos(). Larger values trade performance
|
||||
for correctness when dealing with very long forms. A value of 0 will scan
|
||||
without limits.
|
||||
Set maximum scan distance of |searchpairpos()|. Larger values trade
|
||||
performance for correctness when dealing with very long forms. A value of 0
|
||||
will scan without limits.
|
||||
>
|
||||
" Default
|
||||
let g:clojure_maxlines = 100
|
||||
|
@ -932,14 +933,14 @@ given are the defaults. Note that the variables are set to an expression, so
|
|||
that you can change the value of 'shiftwidth' later.
|
||||
|
||||
Indent after an open paren: >
|
||||
let g:pyindent_open_paren = '&sw * 2'
|
||||
let g:pyindent_open_paren = 'shiftwidth() * 2'
|
||||
Indent after a nested paren: >
|
||||
let g:pyindent_nested_paren = '&sw'
|
||||
let g:pyindent_nested_paren = 'shiftwidth()'
|
||||
Indent for a continuation line: >
|
||||
let g:pyindent_continue = '&sw * 2'
|
||||
let g:pyindent_continue = 'shiftwidth() * 2'
|
||||
|
||||
The method uses searchpair() to look back for unclosed parenthesis. This can
|
||||
sometimes be slow, thus it timeouts after 150 msec. If you notice the
|
||||
The method uses |searchpair()| to look back for unclosed parenthesis. This
|
||||
can sometimes be slow, thus it timeouts after 150 msec. If you notice the
|
||||
indenting isn't correct, you can set a larger timeout in msec: >
|
||||
let g:pyindent_searchpair_timeout = 500
|
||||
|
||||
|
@ -1035,7 +1036,7 @@ Furthermore, setting the variable b:verilog_indent_width to change the
|
|||
indenting width (default is 'shiftwidth'): >
|
||||
|
||||
let b:verilog_indent_width = 4
|
||||
let b:verilog_indent_width = &sw * 2
|
||||
let b:verilog_indent_width = shiftwidth() * 2
|
||||
|
||||
In addition, you can turn the verbose mode for debug issue: >
|
||||
|
||||
|
@ -1158,7 +1159,7 @@ VIM *ft-vim-indent*
|
|||
For indenting Vim scripts there is one variable that specifies the amount of
|
||||
indent for a continuation line, a line that starts with a backslash: >
|
||||
|
||||
:let g:vim_indent_cont = &sw * 3
|
||||
:let g:vim_indent_cont = shiftwidth() * 3
|
||||
|
||||
Three times shiftwidth is the default value.
|
||||
|
||||
|
|
|
@ -1429,8 +1429,9 @@ tag command action ~
|
|||
|:recover| :rec[over] recover a file from a swap file
|
||||
|:redo| :red[o] redo one undone change
|
||||
|:redir| :redi[r] redirect messages to a file or register
|
||||
|:redraw| :redr[aw] force a redraw of the display
|
||||
|:redrawstatus| :redraws[tatus] force a redraw of the status line(s)
|
||||
|:redraw| :redr[aw] force a redraw of the display
|
||||
|:redrawstatus| :redraws[tatus] force a redraw of the status line(s)
|
||||
|:redrawtabline| :redrawt[abline] force a redraw of the tabline
|
||||
|:registers| :reg[isters] display the contents of registers
|
||||
|:resize| :res[ize] change current window height
|
||||
|:retab| :ret[ab] change tab size
|
||||
|
|
|
@ -1190,7 +1190,7 @@ reported if any are supplied). However, it is possible to specify that the
|
|||
command can take arguments, using the -nargs attribute. Valid cases are:
|
||||
|
||||
-nargs=0 No arguments are allowed (the default)
|
||||
-nargs=1 Exactly one argument is required, it includes spaces
|
||||
-nargs=1 Exactly one argument is required, it includes spaces
|
||||
-nargs=* Any number of arguments are allowed (0, 1, or many),
|
||||
separated by white space
|
||||
-nargs=? 0 or 1 arguments are allowed
|
||||
|
@ -1213,8 +1213,9 @@ defined, not where it is invoked! Example:
|
|||
Executing script2.vim will result in "None" being echoed. Not what you
|
||||
intended! Calling a function may be an alternative.
|
||||
|
||||
Completion behavior *:command-completion* *E179*
|
||||
*E180* *E181* *:command-complete*
|
||||
Completion behavior ~
|
||||
*:command-completion* *E179* *E180* *E181*
|
||||
*:command-complete*
|
||||
By default, the arguments of user defined commands do not undergo completion.
|
||||
However, by specifying one or the other of the following attributes, argument
|
||||
completion can be enabled:
|
||||
|
@ -1335,12 +1336,13 @@ which by default correspond to the current line, last line and the whole
|
|||
buffer, relate to arguments, (loaded) buffers, windows or tab pages.
|
||||
|
||||
Possible values are:
|
||||
-addr=lines Range of lines (this is the default)
|
||||
-addr=arguments Range for arguments
|
||||
-addr=buffers Range for buffers (also not loaded buffers)
|
||||
-addr=loaded_buffers Range for loaded buffers
|
||||
-addr=windows Range for windows
|
||||
-addr=tabs Range for tab pages
|
||||
-addr=lines Range of lines (this is the default)
|
||||
-addr=arguments Range for arguments
|
||||
-addr=buffers Range for buffers (also not loaded buffers)
|
||||
-addr=loaded_buffers Range for loaded buffers
|
||||
-addr=windows Range for windows
|
||||
-addr=tabs Range for tab pages
|
||||
-addr=other other kind of range
|
||||
|
||||
|
||||
Special cases *:command-bang* *:command-bar*
|
||||
|
|
|
@ -534,14 +534,6 @@ This message is only given when Vim detects a problem when searching for a
|
|||
tag. Sometimes this message is not given, even though the tags file is not
|
||||
properly sorted.
|
||||
|
||||
*E460* >
|
||||
The resource fork would be lost (add ! to override)
|
||||
|
||||
On the Macintosh (classic), when writing a file, Vim attempts to preserve all
|
||||
info about a file, including its resource fork. If this is not possible you
|
||||
get this error message. Append "!" to the command name to write anyway (and
|
||||
lose the info).
|
||||
|
||||
*E424* >
|
||||
Too many different highlighting attributes in use
|
||||
|
||||
|
|
|
@ -107,7 +107,7 @@ This cannot be repeated: >
|
|||
endif<CR>
|
||||
Note that when using ":" any motion becomes characterwise exclusive.
|
||||
|
||||
|
||||
*forced-motion*
|
||||
FORCING A MOTION TO BE LINEWISE, CHARACTERWISE OR BLOCKWISE
|
||||
|
||||
When a motion is not of the type you would like to use, you can force another
|
||||
|
@ -993,7 +993,7 @@ remembered. You can return to that position with the "''" and "``" command,
|
|||
unless the line containing that position was changed or deleted. The
|
||||
following commands are "jump" commands: "'", "`", "G", "/", "?", "n", "N",
|
||||
"%", "(", ")", "[[", "]]", "{", "}", ":s", ":tag", "L", "M", "H" and the
|
||||
commands that start editing a new file.
|
||||
commands that start editing a new file.
|
||||
|
||||
*CTRL-O*
|
||||
CTRL-O Go to [count] Older cursor position in jump list
|
||||
|
|
|
@ -295,12 +295,12 @@ files. You use this command: >
|
|||
:setlocal makeprg=perlmake
|
||||
You can switch back to using the global value by making the local value empty: >
|
||||
:setlocal makeprg=
|
||||
This only works for a string option. For a boolean option you need to use the
|
||||
"<" flag, like this: >
|
||||
This only works for a string option. For a number or boolean option you need
|
||||
to use the "<" flag, like this: >
|
||||
:setlocal autoread<
|
||||
Note that for non-boolean options using "<" copies the global value to the
|
||||
local value, it doesn't switch back to using the global value (that matters
|
||||
when the global value changes later). You can also use: >
|
||||
Note that for non-boolean and non-number options using "<" copies the global
|
||||
value to the local value, it doesn't switch back to using the global value
|
||||
(that matters when the global value changes later). You can also use: >
|
||||
:set path<
|
||||
This will make the local value of 'path' empty, so that the global value is
|
||||
used. Thus it does the same as: >
|
||||
|
@ -1661,7 +1661,10 @@ A jump table for the options with a short description can be found at |Q_op|.
|
|||
deleted only once. Also when repeating "R" with "."
|
||||
and a count.
|
||||
*cpo-y*
|
||||
y A yank command can be redone with ".".
|
||||
y A yank command can be redone with ".". Think twice if
|
||||
you really want to use this, it may break some
|
||||
plugins, since most people expect "." to only repeat a
|
||||
change.
|
||||
*cpo-Z*
|
||||
Z When using "w!" while the 'readonly' option is set,
|
||||
don't reset 'readonly'.
|
||||
|
@ -1935,7 +1938,7 @@ A jump table for the options with a short description can be found at |Q_op|.
|
|||
diff library.
|
||||
|
||||
algorithm:{text} Use the specified diff algorithm with the
|
||||
internal diff engine. Currently supported
|
||||
internal diff engine. Currently supported
|
||||
algorithms are:
|
||||
myers the default algorithm
|
||||
minimal spend extra time to generate the
|
||||
|
@ -5626,8 +5629,8 @@ A jump table for the options with a short description can be found at |Q_op|.
|
|||
|
||||
After this option has been set successfully, Vim will source the files
|
||||
"spell/LANG.vim" in 'runtimepath'. "LANG" is the value of 'spelllang'
|
||||
up to the first character that is not an ASCII letter and not a dash.
|
||||
Also see |set-spc-auto|.
|
||||
up to the first character that is not an ASCII letter or number and
|
||||
not a dash. Also see |set-spc-auto|.
|
||||
|
||||
|
||||
*'spellsuggest'* *'sps'*
|
||||
|
@ -6217,10 +6220,11 @@ A jump table for the options with a short description can be found at |Q_op|.
|
|||
'thesaurus' 'tsr' string (default "")
|
||||
global or local to buffer |global-local|
|
||||
List of file names, separated by commas, that are used to lookup words
|
||||
for thesaurus completion commands |i_CTRL-X_CTRL-T|. Each line in
|
||||
the file should contain words with similar meaning, separated by
|
||||
non-keyword characters (white space is preferred). Maximum line
|
||||
length is 510 bytes.
|
||||
for thesaurus completion commands |i_CTRL-X_CTRL-T|.
|
||||
|
||||
Each line in the file should contain words with similar meaning,
|
||||
separated by non-keyword characters (white space is preferred).
|
||||
Maximum line length is 510 bytes.
|
||||
|
||||
To include a comma in a file name precede it with a backslash. Spaces
|
||||
after a comma are ignored, otherwise spaces are included in the file
|
||||
|
|
|
@ -295,7 +295,7 @@ the "*" is under your right hand middle finger (search to the right and down).
|
|||
|
||||
*E956*
|
||||
In very rare cases a regular expression is used recursively. This can happen
|
||||
when executing a pattern takes a long time and when checkig for messages on
|
||||
when executing a pattern takes a long time and when checking for messages on
|
||||
channels a callback is invoked that also uses a pattern or an autocommand is
|
||||
triggered. In most cases this should be fine, but if a pattern is in use when
|
||||
it's used again it fails. Usually this means there is something wrong with
|
||||
|
@ -398,11 +398,11 @@ Use of "\m" makes the pattern after it be interpreted as if 'magic' is set,
|
|||
ignoring the actual value of the 'magic' option.
|
||||
Use of "\M" makes the pattern after it be interpreted as if 'nomagic' is used.
|
||||
*/\v* */\V*
|
||||
Use of "\v" means that in the pattern after it all ASCII characters except
|
||||
'0'-'9', 'a'-'z', 'A'-'Z' and '_' have a special meaning. "very magic"
|
||||
Use of "\v" means that after it, all ASCII characters except '0'-'9', 'a'-'z',
|
||||
'A'-'Z' and '_' have special meaning: "very magic"
|
||||
|
||||
Use of "\V" means that in the pattern after it only the backslash and the
|
||||
terminating character (/ or ?) has a special meaning. "very nomagic"
|
||||
Use of "\V" means that after it, only a backslash and terminating character
|
||||
(usually / or ?) have special meaning: "very nomagic"
|
||||
|
||||
Examples:
|
||||
after: \v \m \M \V matches ~
|
||||
|
|
|
@ -97,14 +97,14 @@ processing a quickfix or location list command, it will be aborted.
|
|||
:[count]lne[xt][!] Same as ":cnext", except the location list for the
|
||||
current window is used instead of the quickfix list.
|
||||
|
||||
:[count]cN[ext][!] *:cp* *:cprevious* *:cN* *:cNext*
|
||||
:[count]cN[ext][!] *:cp* *:cprevious* *:cprev* *:cN* *:cNext*
|
||||
:[count]cp[revious][!] Display the [count] previous error in the list that
|
||||
includes a file name. If there are no file names at
|
||||
all, go to the [count] previous error. See |:cc| for
|
||||
[!] and 'switchbuf'.
|
||||
|
||||
|
||||
:[count]lN[ext][!] *:lp* *:lprevious* *:lN* *:lNext*
|
||||
:[count]lN[ext][!] *:lp* *:lprevious* *:lprev* *:lN* *:lNext*
|
||||
:[count]lp[revious][!] Same as ":cNext" and ":cprevious", except the location
|
||||
list for the current window is used instead of the
|
||||
quickfix list.
|
||||
|
@ -354,6 +354,23 @@ modify the title of a quickfix and location list respectively. Examples: >
|
|||
echo getqflist({'title' : 1})
|
||||
call setloclist(3, [], 'a', {'title' : 'Cmd output'})
|
||||
echo getloclist(3, {'title' : 1})
|
||||
<
|
||||
*quickfix-index*
|
||||
When you jump to a quickfix/location list entry using any of the quickfix
|
||||
commands (e.g. |:cc|, |:cnext|, |:cprev|, etc.), that entry becomes the
|
||||
currently selected entry. The index of the currently selected entry in a
|
||||
quickfix/location list can be obtained using the getqflist()/getloclist()
|
||||
functions. Examples: >
|
||||
echo getqflist({'idx' : 0}).idx
|
||||
echo getqflist({'id' : qfid, 'idx' : 0}).idx
|
||||
echo getloclist(2, {'idx' : 0}).idx
|
||||
<
|
||||
For a new quickfix list, the first entry is selected and the index is 1. Any
|
||||
entry in any quickfix/location list can be set as the currently selected entry
|
||||
using the setqflist() function. Examples: >
|
||||
call setqflist([], 'a', {'idx' : 12})
|
||||
call setqflist([], 'a', {'id' : qfid, 'idx' : 7})
|
||||
call setloclist(1, [], 'a', {'idx' : 7})
|
||||
<
|
||||
*quickfix-size*
|
||||
You can get the number of entries (size) in a quickfix and a location list
|
||||
|
@ -889,7 +906,7 @@ commands can be combined to create a NewGrep command: >
|
|||
'smartcase' is not used.
|
||||
If {pattern} is empty (e.g. // is specified), the last
|
||||
used search pattern is used. |last-pattern|
|
||||
|
||||
:{count}vim[grep] ...
|
||||
When a number is put before the command this is used
|
||||
as the maximum number of matches to find. Use
|
||||
":1vimgrep pattern file" to find only the first.
|
||||
|
@ -1515,7 +1532,7 @@ The backslashes before the pipe character are required to avoid it to be
|
|||
recognized as a command separator. The backslash before each space is
|
||||
required for the set command.
|
||||
|
||||
*cfilter-plugin* *Cfilter* *Lfilter*
|
||||
*cfilter-plugin* *:Cfilter* *:Lfilter*
|
||||
If you have too many matching messages, you can use the cfilter plugin to
|
||||
reduce the number of entries. Load the plugin with: >
|
||||
packadd cfilter
|
||||
|
|
|
@ -306,7 +306,10 @@ For writing a Vim script, see chapter 41 of the user manual |usr_41.txt|.
|
|||
|<SID>|.
|
||||
|
||||
:scr[iptnames][!] {scriptId} *:script*
|
||||
Edit script {scriptId}. Suggested name is ":script".
|
||||
Edit script {scriptId}. Although ":scriptnames name"
|
||||
works, using ":script name" is recommended.
|
||||
When the current buffer can't be |abandon|ed and the !
|
||||
is not present, the command fails.
|
||||
|
||||
*:fini* *:finish* *E168*
|
||||
:fini[sh] Stop sourcing a script. Can only be used in a Vim
|
||||
|
|
|
@ -37,6 +37,7 @@ There are two steps in using signs:
|
|||
displayed. A defined sign can be placed several times in different lines
|
||||
and files.
|
||||
|
||||
*sign-column*
|
||||
When signs are defined for a file, Vim will automatically add a column of two
|
||||
characters to display them in. When the last sign is unplaced the column
|
||||
disappears again. This behavior can be changed with the 'signcolumn' option.
|
||||
|
@ -49,7 +50,7 @@ Example to set the color: >
|
|||
*sign-identifier*
|
||||
Each placed sign is identified by a number called the sign identifier. This
|
||||
identifier is used to jump to the sign or to remove the sign. The identifier
|
||||
is assigned when placing the sign using the |sign-place| command or the
|
||||
is assigned when placing the sign using the |:sign-place| command or the
|
||||
|sign_place()| function. Each sign identifier should be a unique number. If
|
||||
multiple placed signs use the same identifier, then jumping to or removing a
|
||||
sign becomes unpredictable. To avoid overlapping identifiers, sign groups can
|
||||
|
@ -70,6 +71,10 @@ on the same line, the attributes of the sign with the highest priority is used
|
|||
independent of the sign group. The default priority for a sign is 10. The
|
||||
priority is assigned at the time of placing a sign.
|
||||
|
||||
When the line on which the sign is placed is deleted, the sign is moved to the
|
||||
next line (or the last line of the buffer, if there is no next line). When
|
||||
the delete is undone the sign does not move back.
|
||||
|
||||
==============================================================================
|
||||
2. Commands *sign-commands* *:sig* *:sign*
|
||||
|
||||
|
@ -92,7 +97,7 @@ See |sign_define()| for the equivalent Vim script function.
|
|||
:sign define {name} {argument}...
|
||||
Define a new sign or set attributes for an existing sign.
|
||||
The {name} can either be a number (all digits) or a name
|
||||
starting with a non-digit. Leading digits are ignored, thus
|
||||
starting with a non-digit. Leading zeros are ignored, thus
|
||||
"0012", "012" and "12" are considered the same name.
|
||||
About 120 different signs can be defined.
|
||||
|
||||
|
|
|
@ -558,7 +558,7 @@ When the Myspell files are updated you can merge the differences:
|
|||
nvim -d xx_YY.orig.dic xx_YY.new.dic
|
||||
3. Take over the changes you like in xx_YY.dic.
|
||||
You may also need to change xx_YY.aff.
|
||||
4. Rename xx_YY.new.dic to xx_YY.orig.dic and xx_YY.new.aff to xx_YY.new.aff.
|
||||
4. Rename xx_YY.new.dic to xx_YY.orig.dic and xx_YY.new.aff to xx_YY.orig.aff.
|
||||
|
||||
|
||||
SPELL FILE VERSIONS *E770* *E771* *E772*
|
||||
|
@ -1562,6 +1562,10 @@ CHECKCOMPOUNDTRIPLE (Hunspell) *spell-CHECKCOMPOUNDTRIPLE*
|
|||
Forbid three identical characters when compounding. Not
|
||||
supported.
|
||||
|
||||
CHECKSHARPS (Hunspell)) *spell-CHECKSHARPS*
|
||||
SS letter pair in uppercased (German) words may be upper case
|
||||
sharp s (ß). Not supported.
|
||||
|
||||
COMPLEXPREFIXES (Hunspell) *spell-COMPLEXPREFIXES*
|
||||
Enables using two prefixes. Not supported.
|
||||
|
||||
|
@ -1575,12 +1579,21 @@ COMPOUNDFIRST (Hunspell) *spell-COMPOUNDFIRST*
|
|||
Use COMPOUNDRULE instead. |spell-COMPOUNDRULE|
|
||||
|
||||
COMPOUNDBEGIN (Hunspell) *spell-COMPOUNDBEGIN*
|
||||
Words signed with COMPOUNDBEGIN may be first elements in
|
||||
compound words.
|
||||
Use COMPOUNDRULE instead. |spell-COMPOUNDRULE|
|
||||
|
||||
COMPOUNDLAST (Hunspell) *spell-COMPOUNDLAST*
|
||||
Words signed with COMPOUNDLAST may be last elements in
|
||||
compound words.
|
||||
Use COMPOUNDRULE instead. |spell-COMPOUNDRULE|
|
||||
|
||||
COMPOUNDEND (Hunspell) *spell-COMPOUNDEND*
|
||||
Use COMPOUNDRULE instead. |spell-COMPOUNDRULE|
|
||||
Probably the same as COMPOUNDLAST
|
||||
|
||||
COMPOUNDMIDDLE (Hunspell) *spell-COMPOUNDMIDDLE*
|
||||
Words signed with COMPOUNDMIDDLE may be middle elements in
|
||||
compound words.
|
||||
Use COMPOUNDRULE instead. |spell-COMPOUNDRULE|
|
||||
|
||||
COMPOUNDRULES (Hunspell) *spell-COMPOUNDRULES*
|
||||
|
|
|
@ -346,20 +346,9 @@ Upon loading a file, Vim finds the relevant syntax file as follows:
|
|||
syntax.
|
||||
|
||||
==============================================================================
|
||||
4. Syntax file remarks *:syn-file-remarks*
|
||||
4. Conversion to HTML *2html.vim* *convert-to-HTML*
|
||||
|
||||
*b:current_syntax-variable*
|
||||
Vim stores the name of the syntax that has been loaded in the
|
||||
"b:current_syntax" variable. You can use this if you want to load other
|
||||
settings, depending on which syntax is active. Example: >
|
||||
:au BufReadPost * if b:current_syntax == "csh"
|
||||
:au BufReadPost * do-some-things
|
||||
:au BufReadPost * endif
|
||||
|
||||
|
||||
2HTML *2html.vim* *convert-to-HTML*
|
||||
|
||||
This is not a syntax file itself, but a script that converts the current
|
||||
2html is not a syntax file itself, but a script that converts the current
|
||||
window into HTML. Vim opens a new window in which it builds the HTML file.
|
||||
|
||||
After you save the resulting file, you can view it with any browser. The
|
||||
|
@ -649,12 +638,12 @@ the rendered page generated by 2html.vim.
|
|||
:let g:html_no_pre = 1
|
||||
<
|
||||
*g:html_expand_tabs*
|
||||
Default: 1 if 'tabstop' is 8, 'expandtab' is 0, and no fold column or line
|
||||
numbers occur in the generated HTML;
|
||||
0 otherwise.
|
||||
When 0, <Tab> characters in the buffer text are replaced with an appropriate
|
||||
Default: 0 if 'tabstop' is 8, 'expandtab' is 0, 'vartabstop' is not in use,
|
||||
and no fold column or line numbers occur in the generated HTML;
|
||||
1 otherwise.
|
||||
When 1, <Tab> characters in the buffer text are replaced with an appropriate
|
||||
number of space characters, or references if |g:html_no_pre| is 1.
|
||||
When 1, if |g:html_no_pre| is 0 or unset, <Tab> characters in the buffer text
|
||||
When 0, if |g:html_no_pre| is 0 or unset, <Tab> characters in the buffer text
|
||||
are included as-is in the generated HTML. This is useful for when you want to
|
||||
allow copy and paste from a browser without losing the actual whitespace in
|
||||
the source document. Note that this can easily break text alignment and
|
||||
|
@ -751,6 +740,18 @@ When 1, generate XHTML 1.0 instead (XML compliant HTML).
|
|||
>
|
||||
:let g:html_use_xhtml = 1
|
||||
<
|
||||
==============================================================================
|
||||
5. Syntax file remarks *:syn-file-remarks*
|
||||
|
||||
*b:current_syntax-variable*
|
||||
Vim stores the name of the syntax that has been loaded in the
|
||||
"b:current_syntax" variable. You can use this if you want to load other
|
||||
settings, depending on which syntax is active. Example: >
|
||||
:au BufReadPost * if b:current_syntax == "csh"
|
||||
:au BufReadPost * do-some-things
|
||||
:au BufReadPost * endif
|
||||
|
||||
|
||||
|
||||
ABEL *abel.vim* *ft-abel-syntax*
|
||||
|
||||
|
@ -917,6 +918,9 @@ to the respective variable. Example: >
|
|||
To disable them use ":unlet". Example: >
|
||||
:unlet c_comment_strings
|
||||
|
||||
An alternative is to switch to the C++ highlighting: >
|
||||
:set filetype=cpp
|
||||
|
||||
Variable Highlight ~
|
||||
*c_gnu* GNU gcc specific items
|
||||
*c_comment_strings* strings and numbers inside a comment
|
||||
|
@ -2666,9 +2670,29 @@ later, and part earlier) adds.
|
|||
|
||||
RESTRUCTURED TEXT *rst.vim* *ft-rst-syntax*
|
||||
|
||||
You may set what syntax definitions should be used for code blocks via >
|
||||
Syntax highlighting is enabled for code blocks within the document for a
|
||||
select number of file types. See $VIMRUNTIME/syntax/rst.vim for the default
|
||||
syntax list.
|
||||
|
||||
To set a user-defined list of code block syntax highlighting: >
|
||||
let rst_syntax_code_list = ['vim', 'lisp', ...]
|
||||
<
|
||||
|
||||
To assign multiple code block types to a single syntax, define
|
||||
`rst_syntax_code_list` as a mapping: >
|
||||
let rst_syntax_code_list = {
|
||||
\ 'cpp' = ['cpp', 'c++'],
|
||||
\ 'bash' = ['bash', 'sh'],
|
||||
...
|
||||
}
|
||||
|
||||
To use color highlighting for emphasis text: >
|
||||
let rst_use_emphasis_colors = 1
|
||||
|
||||
To enable folding of sections: >
|
||||
let rst_fold_enabled = 1
|
||||
|
||||
Note that folding can cause performance issues on some platforms.
|
||||
|
||||
|
||||
REXX *rexx.vim* *ft-rexx-syntax*
|
||||
|
||||
|
@ -3437,7 +3461,7 @@ The syntax script for zsh allows for syntax-based folding: >
|
|||
:let g:zsh_fold_enable = 1
|
||||
|
||||
==============================================================================
|
||||
5. Defining a syntax *:syn-define* *E410*
|
||||
6. Defining a syntax *:syn-define* *E410*
|
||||
|
||||
Vim understands three types of syntax items:
|
||||
|
||||
|
@ -3796,7 +3820,7 @@ DEFINING REGIONS *:syn-region* *:syn-start* *:syn-skip* *:syn-end*
|
|||
The maximum number of syntax groups is 19999.
|
||||
|
||||
==============================================================================
|
||||
6. :syntax arguments *:syn-arguments*
|
||||
7. :syntax arguments *:syn-arguments*
|
||||
|
||||
The :syntax commands that define syntax items take a number of arguments.
|
||||
The common ones are explained here. The arguments may be given in any order
|
||||
|
@ -4117,7 +4141,7 @@ IMPLICIT CONCEAL *:syn-conceal-implicit*
|
|||
Show either "syntax conceal on" or "syntax conceal off" (translated).
|
||||
|
||||
==============================================================================
|
||||
7. Syntax patterns *:syn-pattern* *E401* *E402*
|
||||
8. Syntax patterns *:syn-pattern* *E401* *E402*
|
||||
|
||||
In the syntax commands, a pattern must be surrounded by two identical
|
||||
characters. This is like it works for the ":s" command. The most common to
|
||||
|
@ -4295,7 +4319,7 @@ Note that only matches within a single line can be used. Multi-line matches
|
|||
cannot be referred to.
|
||||
|
||||
==============================================================================
|
||||
8. Syntax clusters *:syn-cluster* *E400*
|
||||
9. Syntax clusters *:syn-cluster* *E400*
|
||||
|
||||
:sy[ntax] cluster {cluster-name} [contains={group-name}..]
|
||||
[add={group-name}..]
|
||||
|
@ -4341,7 +4365,7 @@ This also has implications for nested clusters: >
|
|||
The maximum number of clusters is 9767.
|
||||
|
||||
==============================================================================
|
||||
9. Including syntax files *:syn-include* *E397*
|
||||
10. Including syntax files *:syn-include* *E397*
|
||||
|
||||
It is often useful for one language's syntax file to include a syntax file for
|
||||
a related language. Depending on the exact relationship, this can be done in
|
||||
|
@ -4382,7 +4406,7 @@ two different ways:
|
|||
The maximum number of includes is 999.
|
||||
|
||||
==============================================================================
|
||||
10. Synchronizing *:syn-sync* *E403* *E404*
|
||||
11. Synchronizing *:syn-sync* *E403* *E404*
|
||||
|
||||
Vim wants to be able to start redrawing in any position in the document. To
|
||||
make this possible it needs to know the syntax state at the position where
|
||||
|
@ -4574,7 +4598,7 @@ You can clear specific sync patterns with: >
|
|||
:syntax sync clear {sync-group-name} ..
|
||||
|
||||
==============================================================================
|
||||
11. Listing syntax items *:syntax* *:sy* *:syn* *:syn-list*
|
||||
12. Listing syntax items *:syntax* *:sy* *:syn* *:syn-list*
|
||||
|
||||
This command lists all the syntax items: >
|
||||
|
||||
|
@ -5087,7 +5111,7 @@ Without the "default" in the C syntax file, the highlighting would be
|
|||
overruled when the syntax file is loaded.
|
||||
|
||||
==============================================================================
|
||||
14. Cleaning up *:syn-clear* *E391*
|
||||
15. Cleaning up *:syn-clear* *E391*
|
||||
|
||||
If you want to clear the syntax stuff for the current buffer, you can use this
|
||||
command: >
|
||||
|
@ -5177,7 +5201,7 @@ syntax/syncolor.vim files are loaded:
|
|||
them.
|
||||
|
||||
==============================================================================
|
||||
15. Highlighting tags *tag-highlight*
|
||||
16. Highlighting tags *tag-highlight*
|
||||
|
||||
If you want to highlight all the tags in your file, you can use the following
|
||||
mappings.
|
||||
|
@ -5212,7 +5236,7 @@ And put these lines in your vimrc: >
|
|||
autocmd BufRead,BufNewFile *.[ch] endif
|
||||
|
||||
==============================================================================
|
||||
16. Window-local syntax *:ownsyntax*
|
||||
17. Window-local syntax *:ownsyntax*
|
||||
|
||||
Normally all windows on a buffer share the same syntax settings. It is
|
||||
possible, however, to set a particular window on a file to have its own
|
||||
|
|
|
@ -173,8 +173,8 @@ commands explained above the tag stack will look like this:
|
|||
1 1 main 1 harddisk2:text/vim/test
|
||||
2 1 FuncB 59 harddisk2:text/vim/src/main.c
|
||||
|
||||
The gettagstack() function returns the tag stack of a specified window. The
|
||||
settagstack() function modifies the tag stack of a window.
|
||||
The |gettagstack()| function returns the tag stack of a specified window. The
|
||||
|settagstack()| function modifies the tag stack of a window.
|
||||
|
||||
*E73*
|
||||
When you try to use the tag stack while it doesn't contain anything you will
|
||||
|
|
|
@ -11,12 +11,13 @@ Vim's capabilities. Or define your own macros.
|
|||
|
||||
|05.1| The vimrc file
|
||||
|05.2| The example vimrc file explained
|
||||
|05.3| Simple mappings
|
||||
|05.4| Adding a package
|
||||
|05.5| Adding a plugin
|
||||
|05.6| Adding a help file
|
||||
|05.7| The option window
|
||||
|05.8| Often used options
|
||||
|05.3| The defaults.vim file explained
|
||||
|05.4| Simple mappings
|
||||
|05.5| Adding a package
|
||||
|05.6| Adding a plugin
|
||||
|05.7| Adding a help file
|
||||
|05.8| The option window
|
||||
|05.9| Often used options
|
||||
|
||||
Next chapter: |usr_06.txt| Using syntax highlighting
|
||||
Previous chapter: |usr_04.txt| Making small changes
|
||||
|
@ -172,21 +173,12 @@ This switches on three very clever mechanisms:
|
|||
automatically. Vim comes with these indent rules for a number of
|
||||
filetypes. See |:filetype-indent-on| and 'indentexpr'.
|
||||
|
||||
>
|
||||
autocmd FileType text setlocal textwidth=78
|
||||
|
||||
This makes Vim break text to avoid lines getting longer than 78 characters.
|
||||
But only for files that have been detected to be plain text. There are
|
||||
actually two parts here. "autocmd FileType text" is an autocommand. This
|
||||
defines that when the file type is set to "text" the following command is
|
||||
automatically executed. "setlocal textwidth=78" sets the 'textwidth' option
|
||||
to 78, but only locally in one file.
|
||||
|
||||
*restore-cursor* >
|
||||
autocmd BufReadPost *
|
||||
\ if line("'\"") > 1 && line("'\"") <= line("$") |
|
||||
\ exe "normal! g`\"" |
|
||||
\ endif
|
||||
*restore-cursor* *last-position-jump* >
|
||||
autocmd BufReadPost *
|
||||
\ if line("'\"") >= 1 && line("'\"") <= line("$") && &ft !~# 'commit'
|
||||
\ | exe "normal! g`\""
|
||||
\ | endif
|
||||
|
||||
Another autocommand. This time it is used after reading any file. The
|
||||
complicated stuff after it checks if the '" mark is defined, and jumps to it
|
||||
|
@ -195,8 +187,22 @@ from the previous line. That avoids a line getting very long.
|
|||
See |line-continuation|. This only works in a Vim script file, not when
|
||||
typing commands at the command-line.
|
||||
|
||||
>
|
||||
command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis
|
||||
\ | wincmd p | diffthis
|
||||
|
||||
This adds the ":DiffOrig" command. Use this in a modified buffer to see the
|
||||
differences with the file it was loaded from. See |diff|.
|
||||
|
||||
>
|
||||
set nolangremap
|
||||
|
||||
Prevent that the langmap option applies to characters that result from a
|
||||
mapping. If set (default), this may break plugins (but it's backward
|
||||
compatible). See 'langremap'.
|
||||
|
||||
==============================================================================
|
||||
*05.3* Simple mappings
|
||||
*05.4* Simple mappings
|
||||
|
||||
A mapping enables you to bind a set of Vim commands to a single key. Suppose,
|
||||
for example, that you need to surround certain words with curly braces. In
|
||||
|
@ -243,7 +249,7 @@ The ":map" command (with no arguments) lists your current mappings. At
|
|||
least the ones for Normal mode. More about mappings in section |40.1|.
|
||||
|
||||
==============================================================================
|
||||
*05.4* Adding a package *add-package* *vimball-install*
|
||||
*05.5* Adding a package *add-package* *vimball-install*
|
||||
|
||||
A package is a set of files that you can add to Vim. There are two kinds of
|
||||
packages: optional and automatically loaded on startup.
|
||||
|
@ -283,7 +289,7 @@ an archive or as a repository. For an archive you can follow these steps:
|
|||
More information about packages can be found here: |packages|.
|
||||
|
||||
==============================================================================
|
||||
*05.5* Adding a plugin *add-plugin* *plugin*
|
||||
*05.6* Adding a plugin *add-plugin* *plugin*
|
||||
|
||||
Vim's functionality can be extended by adding plugins. A plugin is nothing
|
||||
more than a Vim script file that is loaded automatically when Vim starts. You
|
||||
|
@ -420,7 +426,7 @@ Further reading:
|
|||
|new-filetype| How to detect a new file type.
|
||||
|
||||
==============================================================================
|
||||
*05.6* Adding a help file *add-local-help*
|
||||
*05.7* Adding a help file *add-local-help*
|
||||
|
||||
If you are lucky, the plugin you installed also comes with a help file. We
|
||||
will explain how to install the help file, so that you can easily find help
|
||||
|
@ -453,7 +459,7 @@ them through the tag.
|
|||
For writing a local help file, see |write-local-help|.
|
||||
|
||||
==============================================================================
|
||||
*05.7* The option window
|
||||
*05.8* The option window
|
||||
|
||||
If you are looking for an option that does what you want, you can search in
|
||||
the help files here: |options|. Another way is by using this command: >
|
||||
|
@ -492,7 +498,7 @@ border. This is what the 'scrolloff' option does, it specifies an offset
|
|||
from the window border where scrolling starts.
|
||||
|
||||
==============================================================================
|
||||
*05.8* Often used options
|
||||
*05.9* Often used options
|
||||
|
||||
There are an awful lot of options. Most of them you will hardly ever use.
|
||||
Some of the more useful ones will be mentioned here. Don't forget you can
|
||||
|
|
|
@ -120,7 +120,7 @@ the resulting files if they are what you expected.
|
|||
USING A SPECIFIC SWAP FILE
|
||||
|
||||
If you know which swap file needs to be used, you can recover by giving the
|
||||
swap file name. Vim will then finds out the name of the original file from
|
||||
swap file name. Vim will then find out the name of the original file from
|
||||
the swap file.
|
||||
|
||||
Example: >
|
||||
|
|
|
@ -612,6 +612,7 @@ String manipulation: *string-functions*
|
|||
repeat() repeat a string multiple times
|
||||
eval() evaluate a string expression
|
||||
execute() execute an Ex command and get the output
|
||||
trim() trim characters from a string
|
||||
|
||||
List manipulation: *list-functions*
|
||||
get() get an item without error for wrong index
|
||||
|
@ -769,7 +770,7 @@ System functions and manipulation of files:
|
|||
systemlist() get the result of a shell command as a list
|
||||
hostname() name of the system
|
||||
readfile() read a file into a List of lines
|
||||
writefile() write a List of lines into a file
|
||||
writefile() write a List of lines or Blob into a file
|
||||
|
||||
Date and Time: *date-functions* *time-functions*
|
||||
getftime() get last modification time of a file
|
||||
|
@ -798,6 +799,9 @@ Buffers, windows and the argument list:
|
|||
bufwinnr() get the window number of a specific buffer
|
||||
winbufnr() get the buffer number of a specific window
|
||||
getbufline() get a list of lines from the specified buffer
|
||||
setbufline() replace a line in the specified buffer
|
||||
appendbufline() append a list of lines in the specified buffer
|
||||
deletebufline() delete lines from a specified buffer
|
||||
win_findbuf() find windows containing a buffer
|
||||
win_getid() get window ID of a window
|
||||
win_gotoid() go to window with ID
|
||||
|
@ -808,6 +812,8 @@ Buffers, windows and the argument list:
|
|||
getwininfo() get a list with window information
|
||||
getchangelist() get a list of change list entries
|
||||
getjumplist() get a list of jump list entries
|
||||
swapinfo() information about a swap file
|
||||
swapname() get the swap file path of a buffer
|
||||
|
||||
Command line: *command-line-functions*
|
||||
getcmdline() get the current command line
|
||||
|
@ -906,6 +912,7 @@ Window size and position: *window-size-functions*
|
|||
winheight() get height of a specific window
|
||||
winwidth() get width of a specific window
|
||||
win_screenpos() get screen position of a window
|
||||
winlayout() get layout of windows in a tab page
|
||||
winrestcmd() return command to restore window sizes
|
||||
winsaveview() get view of current window
|
||||
winrestview() restore saved view of current window
|
||||
|
@ -928,6 +935,7 @@ Signs: *sign-functions*
|
|||
|
||||
Testing: *test-functions*
|
||||
assert_equal() assert that two expressions values are equal
|
||||
assert_equalfile() assert that two file contents are equal
|
||||
assert_notequal() assert that two expressions values are not equal
|
||||
assert_inrange() assert that an expression is inside a range
|
||||
assert_match() assert that a pattern matches the value
|
||||
|
@ -940,7 +948,21 @@ Testing: *test-functions*
|
|||
|
||||
Timers: *timer-functions*
|
||||
timer_start() create a timer
|
||||
timer_pause() pause or unpause a timer
|
||||
timer_stop() stop a timer
|
||||
timer_stopall() stop all timers
|
||||
timer_info() get information about timers
|
||||
|
||||
Tags: *tag-functions*
|
||||
taglist() get list of matching tags
|
||||
tagfiles() get a list of tags files
|
||||
gettagstack() get the tag stack of a window
|
||||
settagstack() modify the tag stack of a window
|
||||
|
||||
Prompt Buffer: *promptbuffer-functions*
|
||||
prompt_setcallback() set prompt callback for a buffer
|
||||
prompt_setinterrupt() set interrupt callback for a buffer
|
||||
prompt_setprompt() set the prompt text for a buffer
|
||||
|
||||
Various: *various-functions*
|
||||
mode() get current editing mode
|
||||
|
@ -969,15 +991,11 @@ Various: *various-functions*
|
|||
|
||||
wordcount() get byte/word/char count of buffer
|
||||
|
||||
taglist() get list of matching tags
|
||||
tagfiles() get a list of tags files
|
||||
gettagstack() get the tag stack
|
||||
settagstack() modify the tag stack
|
||||
|
||||
luaeval() evaluate Lua expression
|
||||
py3eval() evaluate Python expression (|+python3|)
|
||||
pyeval() evaluate Python expression (|+python|)
|
||||
pyxeval() evaluate |python_x| expression
|
||||
debugbreak() interrupt a program being debugged
|
||||
|
||||
==============================================================================
|
||||
*41.7* Defining a function
|
||||
|
|
|
@ -64,6 +64,10 @@ the differences.
|
|||
- 'wildmenu' is enabled
|
||||
- 'wildoptions' defaults to "pum,tagfile"
|
||||
|
||||
- The |man.vim| plugin is enabled, to provide the |:Man| command.
|
||||
- The |matchit| plugin is enabled. To disable it in your config: >
|
||||
:let loaded_matchit = 1
|
||||
|
||||
==============================================================================
|
||||
3. New Features *nvim-features*
|
||||
|
||||
|
|
|
@ -64,6 +64,10 @@ will not change within a Vim session. The |win_getid()| and |win_id2tabwin()|
|
|||
functions can be used to convert between the window/tab number and the
|
||||
identifier. There is also the window number, which may change whenever
|
||||
windows are opened or closed, see |winnr()|.
|
||||
The window number is only valid in one specific tab. The window ID is valid
|
||||
across tabs. For most functions that take a window ID or a window number, the
|
||||
window number only applies to the current tab, while the window ID can refer
|
||||
to a window in any tab.
|
||||
|
||||
Each buffer has a unique number and the number will not change within a Vim
|
||||
session. The |bufnr()| and |bufname()| functions can be used to convert
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
" Vim support file to detect file types
|
||||
"
|
||||
" Maintainer: Bram Moolenaar <Bram@vim.org>
|
||||
" Last Change: 2018 Feb 14
|
||||
" Last Change: 2019 Jan 28
|
||||
|
||||
" Listen very carefully, I will say this only once
|
||||
if exists("did_load_filetypes")
|
||||
|
@ -93,6 +93,7 @@ au BufNewFile,BufRead proftpd.conf* call s:StarSetf('apachestyle')
|
|||
|
||||
" Apache config file
|
||||
au BufNewFile,BufRead .htaccess,*/etc/httpd/*.conf setf apache
|
||||
au BufNewFile,BufRead */etc/apache2/sites-*/*.com setf apache
|
||||
|
||||
" XA65 MOS6510 cross assembler
|
||||
au BufNewFile,BufRead *.a65 setf a65
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
" Vim filetype plugin file
|
||||
" Language: bash
|
||||
" Maintainer: Bram Moolenaar
|
||||
" Last Changed: 2019 Jan 12
|
||||
"
|
||||
" This is not a real filetype plugin. It allows for someone to set 'filetype'
|
||||
" to "bash" in the modeline, and gets the effect of filetype "sh" with
|
||||
" b:is_bash set. Idea from Mahmode Al-Qudsi.
|
||||
|
||||
if exists("b:did_ftplugin")
|
||||
finish
|
||||
endif
|
||||
|
||||
let b:is_bash = 1
|
||||
if exists("b:is_sh")
|
||||
unlet b:is_sh
|
||||
endif
|
||||
if exists("b:is_kornshell")
|
||||
unlet b:is_kornshell
|
||||
endif
|
||||
|
||||
" Setting 'filetype' here directly won't work, since we are being invoked
|
||||
" through an autocommand. Do it later, on the BufWinEnter event.
|
||||
augroup bash_filetype
|
||||
au BufWinEnter * call SetBashFt()
|
||||
augroup END
|
||||
|
||||
func SetBashFt()
|
||||
au! bash_filetype
|
||||
set ft=sh
|
||||
endfunc
|
|
@ -0,0 +1,19 @@
|
|||
" Vim filetype plugin file
|
||||
" Language: Configuration File
|
||||
" Maintainer: Christian Brabandt <cb@256bit.org>
|
||||
" Latest Revision: 2018-12-24
|
||||
|
||||
if exists("b:did_ftplugin")
|
||||
finish
|
||||
endif
|
||||
let b:did_ftplugin = 1
|
||||
|
||||
let s:cpo_save = &cpo
|
||||
set cpo&vim
|
||||
|
||||
let b:undo_ftplugin = "setl cms< fo<"
|
||||
|
||||
setlocal commentstring=#\ %s formatoptions-=t formatoptions+=croql
|
||||
|
||||
let &cpo = s:cpo_save
|
||||
unlet s:cpo_save
|
|
@ -0,0 +1,20 @@
|
|||
" Language: Dune buildsystem
|
||||
" Maintainer: Markus Mottl <markus.mottl@gmail.com>
|
||||
" Anton Kochkov <anton.kochkov@gmail.com>
|
||||
" URL: https://github.com/rgrinberg/vim-ocaml
|
||||
" Last Change:
|
||||
" 2018 Nov 3 - Added commentstring (Markus Mottl)
|
||||
" 2017 Sep 6 - Initial version (Etienne Millon)
|
||||
|
||||
if exists("b:did_ftplugin")
|
||||
finish
|
||||
endif
|
||||
let b:did_ftplugin=1
|
||||
|
||||
set lisp
|
||||
|
||||
" Comment string
|
||||
setl commentstring=;\ %s
|
||||
setl comments=:;
|
||||
|
||||
setl iskeyword+=#,?,.,/
|
|
@ -3,6 +3,7 @@
|
|||
" Maintainer: Tim Pope <vimNOSPAM@tpope.org>
|
||||
" URL: https://github.com/vim-ruby/vim-ruby
|
||||
" Release Coordinator: Doug Kearns <dougkearns@gmail.com>
|
||||
" Last Change: 2019 Jan 06
|
||||
|
||||
" Only do this when not done yet for this buffer
|
||||
if exists("b:did_ftplugin")
|
||||
|
@ -27,7 +28,7 @@ elseif !exists("b:eruby_subtype")
|
|||
let s:lines = getline(1)."\n".getline(2)."\n".getline(3)."\n".getline(4)."\n".getline(5)."\n".getline("$")
|
||||
let b:eruby_subtype = matchstr(s:lines,'eruby_subtype=\zs\w\+')
|
||||
if b:eruby_subtype == ''
|
||||
let b:eruby_subtype = matchstr(substitute(expand("%:t"),'\c\%(\.erb\|\.eruby\|\.erubis\)\+$','',''),'\.\zs\w\+\%(\ze+\w\+\)\=$')
|
||||
let b:eruby_subtype = matchstr(substitute(expand("%:t"),'\c\%(\.erb\|\.eruby\|\.erubis\|\.example\)\+$','',''),'\.\zs\w\+\%(\ze+\w\+\)\=$')
|
||||
endif
|
||||
if b:eruby_subtype == 'rhtml'
|
||||
let b:eruby_subtype = 'html'
|
||||
|
@ -45,7 +46,7 @@ elseif !exists("b:eruby_subtype")
|
|||
endif
|
||||
endif
|
||||
|
||||
if exists("b:eruby_subtype") && b:eruby_subtype != ''
|
||||
if exists("b:eruby_subtype") && b:eruby_subtype != '' && b:eruby_subtype !=? 'eruby'
|
||||
exe "runtime! ftplugin/".b:eruby_subtype.".vim ftplugin/".b:eruby_subtype."_*.vim ftplugin/".b:eruby_subtype."/*.vim"
|
||||
else
|
||||
runtime! ftplugin/html.vim ftplugin/html_*.vim ftplugin/html/*.vim
|
||||
|
@ -66,6 +67,21 @@ if exists("b:match_words")
|
|||
unlet b:match_words
|
||||
endif
|
||||
|
||||
let s:cfilemap = v:version >= 704 ? maparg('<Plug><cfile>', 'c', 0, 1) : {}
|
||||
if !get(s:cfilemap, 'buffer') || !s:cfilemap.expr || s:cfilemap.rhs =~# 'ErubyAtCursor()'
|
||||
let s:cfilemap = {}
|
||||
endif
|
||||
if !has_key(s:cfilemap, 'rhs')
|
||||
let s:cfilemap.rhs = "substitute(&l:inex =~# '\\<v:fname\\>' && len(expand('<cfile>')) ? eval(substitute(&l:inex, '\\<v:fname\\>', '\\=string(expand(\"<cfile>\"))', 'g')) : '', '^$', \"\\022\\006\",'')"
|
||||
endif
|
||||
let s:ctagmap = v:version >= 704 ? maparg('<Plug><ctag>', 'c', 0, 1) : {}
|
||||
if !get(s:ctagmap, 'buffer') || !s:ctagmap.expr || s:ctagmap.rhs =~# 'ErubyAtCursor()'
|
||||
let s:ctagmap = {}
|
||||
endif
|
||||
let s:include = &l:include
|
||||
let s:path = &l:path
|
||||
let s:suffixesadd = &l:suffixesadd
|
||||
|
||||
runtime! ftplugin/ruby.vim ftplugin/ruby_*.vim ftplugin/ruby/*.vim
|
||||
let b:did_ftplugin = 1
|
||||
|
||||
|
@ -80,6 +96,15 @@ if exists("b:match_words")
|
|||
let s:match_words = b:match_words . ',' . s:match_words
|
||||
endif
|
||||
|
||||
if len(s:include)
|
||||
let &l:include = s:include
|
||||
endif
|
||||
let &l:path = s:path . (s:path =~# ',$\|^$' ? '' : ',') . &l:path
|
||||
let &l:suffixesadd = s:suffixesadd . (s:suffixesadd =~# ',$\|^$' ? '' : ',') . &l:suffixesadd
|
||||
exe 'cmap <buffer><script><expr> <Plug><cfile> ErubyAtCursor() ? ' . maparg('<Plug><cfile>', 'c') . ' : ' . s:cfilemap.rhs
|
||||
exe 'cmap <buffer><script><expr> <Plug><ctag> ErubyAtCursor() ? ' . maparg('<Plug><ctag>', 'c') . ' : ' . get(s:ctagmap, 'rhs', '"\022\027"')
|
||||
unlet s:cfilemap s:ctagmap s:include s:path s:suffixesadd
|
||||
|
||||
" Change the browse dialog on Win32 to show mainly eRuby-related files
|
||||
if has("gui_win32")
|
||||
let b:browsefilter="eRuby Files (*.erb, *.rhtml)\t*.erb;*.rhtml\n" . s:browsefilter
|
||||
|
@ -99,4 +124,9 @@ let b:undo_ftplugin = "setl cms< "
|
|||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
|
||||
function! ErubyAtCursor() abort
|
||||
let groups = map(['erubyBlock', 'erubyComment', 'erubyExpression', 'erubyOneLiner'], 'hlID(v:val)')
|
||||
return !empty(filter(synstack(line('.'), col('.')), 'index(groups, v:val) >= 0'))
|
||||
endfunction
|
||||
|
||||
" vim: nowrap sw=2 sts=2 ts=8:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
" Vim filetype plugin file
|
||||
" Language: Vim help file
|
||||
" Previous Maintainer: Nikolai Weibull <now@bitwi.se>
|
||||
" Latest Revision: 2008-07-09
|
||||
" Latest Revision: 2018-12-29
|
||||
|
||||
if exists("b:did_ftplugin")
|
||||
finish
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
" Vim filetype plugin file
|
||||
" Language: Logcheck
|
||||
" Maintainer: Debian Vim Maintainers <pkg-vim-maintainers@lists.alioth.debian.org>
|
||||
" Last Change: 2012 Jan 15
|
||||
" Maintainer: Debian Vim Maintainers
|
||||
" Last Change: 2018 Dec 27
|
||||
" License: Vim License
|
||||
" URL: http://hg.debian.org/hg/pkg-vim/vim/file/unstable/runtime/ftplugin/logcheck.vim
|
||||
" URL: https://salsa.debian.org/vim-team/vim-debian/blob/master/ftplugin/logcheck.vim
|
||||
|
||||
if exists("b:did_ftplugin")
|
||||
if exists('b:did_ftplugin')
|
||||
finish
|
||||
endif
|
||||
let b:did_ftplugin = 1
|
||||
|
||||
let b:undo_ftplugin = "setl fo<"
|
||||
let b:undo_ftplugin = 'setl fo<'
|
||||
|
||||
" Do not hard-wrap non-comment lines since each line is a self-contained
|
||||
" regular expression
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
" Vim filetype plugin file
|
||||
" Language: Mathematica
|
||||
" Maintainer: Ian Ford <ianf@wolfram.com>
|
||||
" Last Change: 22 January 2019
|
||||
|
||||
" Only do this when not done yet for this buffer
|
||||
if exists("b:did_ftplugin")
|
||||
finish
|
||||
endif
|
||||
|
||||
" Don't load another plugin for this buffer
|
||||
let b:did_ftplugin = 1
|
||||
|
||||
let b:undo_ftplugin = "setlocal commentstring<"
|
||||
|
||||
setlocal commentstring=\(*%s*\)
|
|
@ -5,12 +5,12 @@
|
|||
" Pierre Vittet <pierre-vittet@pvittet.com>
|
||||
" Stefano Zacchiroli <zack@bononia.it>
|
||||
" Vincent Aravantinos <firstname.name@imag.fr>
|
||||
" URL: http://www.ocaml.info/vim/ftplugin/ocaml.vim
|
||||
" URL: https://github.com/rgrinberg/vim-ocaml
|
||||
" Last Change:
|
||||
" 2013 Oct 27 - Added commentstring (MM)
|
||||
" 2013 Jul 26 - load default compiler settings (MM)
|
||||
" 2013 Jul 24 - removed superfluous efm-setting (MM)
|
||||
" 2013 Jul 22 - applied fixes supplied by Hirotaka Hamada (MM)
|
||||
" 2013 Mar 15 - Improved error format (MM)
|
||||
|
||||
if exists("b:did_ftplugin")
|
||||
finish
|
||||
|
@ -37,6 +37,10 @@ endif
|
|||
let s:cposet=&cpoptions
|
||||
set cpo&vim
|
||||
|
||||
" Comment string
|
||||
setlocal comments=
|
||||
setlocal commentstring=(*%s*)
|
||||
|
||||
" Add mappings, unless the user didn't want this.
|
||||
if !exists("no_plugin_maps") && !exists("no_ocaml_maps")
|
||||
" (un)commenting
|
||||
|
@ -60,16 +64,39 @@ if !exists("no_plugin_maps") && !exists("no_ocaml_maps")
|
|||
endif
|
||||
|
||||
" Let % jump between structure elements (due to Issac Trotts)
|
||||
let b:mw = ''
|
||||
let b:mw = b:mw . ',\<let\>:\<and\>:\(\<in\>\|;;\)'
|
||||
let b:mw = '\<let\>:\<and\>:\(\<in\>\|;;\)'
|
||||
let b:mw = b:mw . ',\<if\>:\<then\>:\<else\>'
|
||||
let b:mw = b:mw . ',\<\(for\|while\)\>:\<do\>:\<done\>,'
|
||||
let b:mw = b:mw . ',\<\(for\|while\)\>:\<do\>:\<done\>'
|
||||
let b:mw = b:mw . ',\<\(object\|sig\|struct\|begin\)\>:\<end\>'
|
||||
let b:mw = b:mw . ',\<\(match\|try\)\>:\<with\>'
|
||||
let b:match_words = b:mw
|
||||
|
||||
let b:match_ignorecase=0
|
||||
|
||||
function! s:OcpGrep(bang,args) abort
|
||||
let grepprg = &l:grepprg
|
||||
let grepformat = &l:grepformat
|
||||
let shellpipe = &shellpipe
|
||||
try
|
||||
let &l:grepprg = "ocp-grep -c never"
|
||||
setlocal grepformat=%f:%l:%m
|
||||
if &shellpipe ==# '2>&1| tee' || &shellpipe ==# '|& tee'
|
||||
let &shellpipe = "| tee"
|
||||
endif
|
||||
execute 'grep! '.a:args
|
||||
if empty(a:bang) && !empty(getqflist())
|
||||
return 'cfirst'
|
||||
else
|
||||
return ''
|
||||
endif
|
||||
finally
|
||||
let &l:grepprg = grepprg
|
||||
let &l:grepformat = grepformat
|
||||
let &shellpipe = shellpipe
|
||||
endtry
|
||||
endfunction
|
||||
command! -bar -bang -complete=file -nargs=+ Ocpgrep exe s:OcpGrep(<q-bang>, <q-args>)
|
||||
|
||||
" switching between interfaces (.mli) and implementations (.ml)
|
||||
if !exists("g:did_ocaml_switch")
|
||||
let g:did_ocaml_switch = 1
|
||||
|
@ -97,15 +124,8 @@ endif
|
|||
" Folding support
|
||||
|
||||
" Get the modeline because folding depends on indentation
|
||||
let s:s = line2byte(line('.'))+col('.')-1
|
||||
if search('^\s*(\*:o\?caml:')
|
||||
let s:modeline = getline(".")
|
||||
else
|
||||
let s:modeline = ""
|
||||
endif
|
||||
if s:s > 0
|
||||
exe 'goto' s:s
|
||||
endif
|
||||
let lnum = search('^\s*(\*:o\?caml:', 'n')
|
||||
let s:modeline = lnum? getline(lnum): ""
|
||||
|
||||
" Get the indentation params
|
||||
let s:m = matchstr(s:modeline,'default\s*=\s*\d\+')
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
" Maintainer: Marshall Ward <marshall.ward@gmail.com>
|
||||
" Original Maintainer: Nikolai Weibull <now@bitwi.se>
|
||||
" Website: https://github.com/marshallward/vim-restructuredtext
|
||||
" Latest Revision: 2018-01-07
|
||||
" Latest Revision: 2018-12-29
|
||||
|
||||
if exists("b:did_ftplugin")
|
||||
finish
|
||||
|
@ -13,6 +13,11 @@ let b:did_ftplugin = 1
|
|||
let s:cpo_save = &cpo
|
||||
set cpo&vim
|
||||
|
||||
"Disable folding
|
||||
if !exists('g:rst_fold_enabled')
|
||||
let g:rst_fold_enabled = 0
|
||||
endif
|
||||
|
||||
let b:undo_ftplugin = "setl com< cms< et< fo<"
|
||||
|
||||
setlocal comments=fb:.. commentstring=..\ %s expandtab
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
" Language: Ruby
|
||||
" Maintainer: Tim Pope <vimNOSPAM@tpope.org>
|
||||
" URL: https://github.com/vim-ruby/vim-ruby
|
||||
" Release Coordinator: Doug Kearns <dougkearns@gmail.com>
|
||||
" ----------------------------------------------------------------------------
|
||||
" Release Coordinator: Doug Kearns <dougkearns@gmail.com>
|
||||
" Last Change: 2019 Jan 06
|
||||
|
||||
if (exists("b:did_ftplugin"))
|
||||
finish
|
||||
|
@ -44,19 +44,12 @@ endif
|
|||
setlocal formatoptions-=t formatoptions+=croql
|
||||
|
||||
setlocal include=^\\s*\\<\\(load\\>\\\|require\\>\\\|autoload\\s*:\\=[\"']\\=\\h\\w*[\"']\\=,\\)
|
||||
setlocal includeexpr=substitute(substitute(v:fname,'::','/','g'),'\%(\.rb\)\=$','.rb','')
|
||||
setlocal suffixesadd=.rb
|
||||
|
||||
if exists("&ofu") && has("ruby")
|
||||
setlocal omnifunc=rubycomplete#Complete
|
||||
endif
|
||||
|
||||
" To activate, :set ballooneval
|
||||
if has('balloon_eval') && exists('+balloonexpr')
|
||||
setlocal balloonexpr=RubyBalloonexpr()
|
||||
endif
|
||||
|
||||
|
||||
" TODO:
|
||||
"setlocal define=^\\s*def
|
||||
|
||||
|
@ -69,7 +62,7 @@ endif
|
|||
|
||||
function! s:query_path(root) abort
|
||||
let code = "print $:.join %q{,}"
|
||||
if &shell =~# 'sh'
|
||||
if &shell =~# 'sh' && empty(&shellxquote)
|
||||
let prefix = 'env PATH='.shellescape($PATH).' '
|
||||
else
|
||||
let prefix = ''
|
||||
|
@ -141,44 +134,54 @@ if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")
|
|||
\ "All Files (*.*)\t*.*\n"
|
||||
endif
|
||||
|
||||
let b:undo_ftplugin = "setl fo< inc< inex< sua< def< com< cms< path< tags< kp<"
|
||||
let b:undo_ftplugin = "setl inc= sua= path= tags= fo< com< cms< kp="
|
||||
\."| unlet! b:browsefilter b:match_ignorecase b:match_words b:match_skip"
|
||||
\."| if exists('&ofu') && has('ruby') | setl ofu< | endif"
|
||||
\."| if has('balloon_eval') && exists('+bexpr') | setl bexpr< | endif"
|
||||
|
||||
if get(g:, 'ruby_recommended_style', 1)
|
||||
setlocal shiftwidth=2 softtabstop=2 expandtab
|
||||
let b:undo_ftplugin .= ' | setl sw< sts< et<'
|
||||
endif
|
||||
|
||||
" To activate, :set ballooneval
|
||||
if exists('+balloonexpr') && get(g:, 'ruby_balloonexpr')
|
||||
setlocal balloonexpr=RubyBalloonexpr()
|
||||
let b:undo_ftplugin .= "| setl bexpr="
|
||||
endif
|
||||
|
||||
function! s:map(mode, flags, map) abort
|
||||
let from = matchstr(a:map, '\S\+')
|
||||
if empty(mapcheck(from, a:mode))
|
||||
exe a:mode.'map' '<buffer>'.(a:0 ? a:1 : '') a:map
|
||||
exe a:mode.'map' '<buffer>' a:map
|
||||
let b:undo_ftplugin .= '|sil! '.a:mode.'unmap <buffer> '.from
|
||||
endif
|
||||
endfunction
|
||||
|
||||
cmap <buffer><script><expr> <Plug><cword> substitute(RubyCursorIdentifier(),'^$',"\022\027",'')
|
||||
cmap <buffer><script><expr> <Plug><ctag> substitute(RubyCursorTag(),'^$',"\022\027",'')
|
||||
cmap <buffer><script><expr> <Plug><cfile> substitute(RubyCursorFile(),'^$',"\022\006",'')
|
||||
let b:undo_ftplugin .= "| sil! cunmap <buffer> <Plug><cword>| sil! cunmap <buffer> <Plug><cfile>"
|
||||
let b:undo_ftplugin .= "| sil! cunmap <buffer> <Plug><ctag>| sil! cunmap <buffer> <Plug><cfile>"
|
||||
|
||||
if !exists("g:no_plugin_maps") && !exists("g:no_ruby_maps")
|
||||
nmap <buffer><script> <SID>: :<C-U>
|
||||
nmap <buffer><script> <SID>c: :<C-U><C-R>=v:count ? v:count : ''<CR>
|
||||
|
||||
nnoremap <silent> <buffer> [m :<C-U>call <SID>searchsyn('\<def\>','rubyDefine','b','n')<CR>
|
||||
nnoremap <silent> <buffer> ]m :<C-U>call <SID>searchsyn('\<def\>','rubyDefine','','n')<CR>
|
||||
nnoremap <silent> <buffer> [M :<C-U>call <SID>searchsyn('\<end\>','rubyDefine','b','n')<CR>
|
||||
nnoremap <silent> <buffer> ]M :<C-U>call <SID>searchsyn('\<end\>','rubyDefine','','n')<CR>
|
||||
xnoremap <silent> <buffer> [m :<C-U>call <SID>searchsyn('\<def\>','rubyDefine','b','v')<CR>
|
||||
xnoremap <silent> <buffer> ]m :<C-U>call <SID>searchsyn('\<def\>','rubyDefine','','v')<CR>
|
||||
xnoremap <silent> <buffer> [M :<C-U>call <SID>searchsyn('\<end\>','rubyDefine','b','v')<CR>
|
||||
xnoremap <silent> <buffer> ]M :<C-U>call <SID>searchsyn('\<end\>','rubyDefine','','v')<CR>
|
||||
nnoremap <silent> <buffer> [m :<C-U>call <SID>searchsyn('\<def\>',['rubyDefine'],'b','n')<CR>
|
||||
nnoremap <silent> <buffer> ]m :<C-U>call <SID>searchsyn('\<def\>',['rubyDefine'],'','n')<CR>
|
||||
nnoremap <silent> <buffer> [M :<C-U>call <SID>searchsyn('\<end\>',['rubyDefine'],'b','n')<CR>
|
||||
nnoremap <silent> <buffer> ]M :<C-U>call <SID>searchsyn('\<end\>',['rubyDefine'],'','n')<CR>
|
||||
xnoremap <silent> <buffer> [m :<C-U>call <SID>searchsyn('\<def\>',['rubyDefine'],'b','v')<CR>
|
||||
xnoremap <silent> <buffer> ]m :<C-U>call <SID>searchsyn('\<def\>',['rubyDefine'],'','v')<CR>
|
||||
xnoremap <silent> <buffer> [M :<C-U>call <SID>searchsyn('\<end\>',['rubyDefine'],'b','v')<CR>
|
||||
xnoremap <silent> <buffer> ]M :<C-U>call <SID>searchsyn('\<end\>',['rubyDefine'],'','v')<CR>
|
||||
|
||||
nnoremap <silent> <buffer> [[ :<C-U>call <SID>searchsyn('\<\%(class\<Bar>module\)\>','rubyModule\<Bar>rubyClass','b','n')<CR>
|
||||
nnoremap <silent> <buffer> ]] :<C-U>call <SID>searchsyn('\<\%(class\<Bar>module\)\>','rubyModule\<Bar>rubyClass','','n')<CR>
|
||||
nnoremap <silent> <buffer> [] :<C-U>call <SID>searchsyn('\<end\>','rubyModule\<Bar>rubyClass','b','n')<CR>
|
||||
nnoremap <silent> <buffer> ][ :<C-U>call <SID>searchsyn('\<end\>','rubyModule\<Bar>rubyClass','','n')<CR>
|
||||
xnoremap <silent> <buffer> [[ :<C-U>call <SID>searchsyn('\<\%(class\<Bar>module\)\>','rubyModule\<Bar>rubyClass','b','v')<CR>
|
||||
xnoremap <silent> <buffer> ]] :<C-U>call <SID>searchsyn('\<\%(class\<Bar>module\)\>','rubyModule\<Bar>rubyClass','','v')<CR>
|
||||
xnoremap <silent> <buffer> [] :<C-U>call <SID>searchsyn('\<end\>','rubyModule\<Bar>rubyClass','b','v')<CR>
|
||||
xnoremap <silent> <buffer> ][ :<C-U>call <SID>searchsyn('\<end\>','rubyModule\<Bar>rubyClass','','v')<CR>
|
||||
nnoremap <silent> <buffer> [[ :<C-U>call <SID>searchsyn('\<\%(class\<Bar>module\)\>',['rubyModule','rubyClass'],'b','n')<CR>
|
||||
nnoremap <silent> <buffer> ]] :<C-U>call <SID>searchsyn('\<\%(class\<Bar>module\)\>',['rubyModule','rubyClass'],'','n')<CR>
|
||||
nnoremap <silent> <buffer> [] :<C-U>call <SID>searchsyn('\<end\>',['rubyModule','rubyClass'],'b','n')<CR>
|
||||
nnoremap <silent> <buffer> ][ :<C-U>call <SID>searchsyn('\<end\>',['rubyModule','rubyClass'],'','n')<CR>
|
||||
xnoremap <silent> <buffer> [[ :<C-U>call <SID>searchsyn('\<\%(class\<Bar>module\)\>',['rubyModule','rubyClass'],'b','v')<CR>
|
||||
xnoremap <silent> <buffer> ]] :<C-U>call <SID>searchsyn('\<\%(class\<Bar>module\)\>',['rubyModule','rubyClass'],'','v')<CR>
|
||||
xnoremap <silent> <buffer> [] :<C-U>call <SID>searchsyn('\<end\>',['rubyModule','rubyClass'],'b','v')<CR>
|
||||
xnoremap <silent> <buffer> ][ :<C-U>call <SID>searchsyn('\<end\>',['rubyModule','rubyClass'],'','v')<CR>
|
||||
|
||||
let b:undo_ftplugin = b:undo_ftplugin
|
||||
\."| sil! exe 'unmap <buffer> [[' | sil! exe 'unmap <buffer> ]]' | sil! exe 'unmap <buffer> []' | sil! exe 'unmap <buffer> ]['"
|
||||
|
@ -204,19 +207,18 @@ if !exists("g:no_plugin_maps") && !exists("g:no_ruby_maps")
|
|||
\."| sil! exe 'xunmap <buffer> iM' | sil! exe 'xunmap <buffer> aM'"
|
||||
endif
|
||||
|
||||
call s:map('c', '', '<C-R><C-W> <Plug><cword>')
|
||||
call s:map('c', '', '<C-R><C-F> <Plug><cfile>')
|
||||
|
||||
cmap <buffer><script><expr> <SID>tagzv &foldopen =~# 'tag' ? '<Bar>norm! zv' : ''
|
||||
call s:map('n', '<silent>', '<C-]> <SID>:exe v:count1."tag <Plug><cword>"<SID>tagzv<CR>')
|
||||
call s:map('n', '<silent>', 'g<C-]> <SID>:exe "tjump <Plug><cword>"<SID>tagzv<CR>')
|
||||
call s:map('n', '<silent>', 'g] <SID>:exe "tselect <Plug><cword>"<SID>tagzv<CR>')
|
||||
call s:map('n', '<silent>', '<C-W>] <SID>:exe v:count1."stag <Plug><cword>"<SID>tagzv<CR>')
|
||||
call s:map('n', '<silent>', '<C-W><C-]> <SID>:exe v:count1."stag <Plug><cword>"<SID>tagzv<CR>')
|
||||
call s:map('n', '<silent>', '<C-W>g<C-]> <SID>:exe "stjump <Plug><cword>"<SID>tagzv<CR>')
|
||||
call s:map('n', '<silent>', '<C-W>g] <SID>:exe "stselect <Plug><cword>"<SID>tagzv<CR>')
|
||||
call s:map('n', '<silent>', '<C-W>} <SID>:exe v:count1."ptag <Plug><cword>"<CR>')
|
||||
call s:map('n', '<silent>', '<C-W>g} <SID>:exe "ptjump <Plug><cword>"<CR>')
|
||||
call s:map('n', '<silent>', '<C-]> <SID>:exe v:count1."tag <Plug><ctag>"<SID>tagzv<CR>')
|
||||
call s:map('n', '<silent>', 'g<C-]> <SID>:exe "tjump <Plug><ctag>"<SID>tagzv<CR>')
|
||||
call s:map('n', '<silent>', 'g] <SID>:exe "tselect <Plug><ctag>"<SID>tagzv<CR>')
|
||||
call s:map('n', '<silent>', '<C-W>] <SID>:exe v:count1."stag <Plug><ctag>"<SID>tagzv<CR>')
|
||||
call s:map('n', '<silent>', '<C-W><C-]> <SID>:exe v:count1."stag <Plug><ctag>"<SID>tagzv<CR>')
|
||||
call s:map('n', '<silent>', '<C-W>g<C-]> <SID>:exe "stjump <Plug><ctag>"<SID>tagzv<CR>')
|
||||
call s:map('n', '<silent>', '<C-W>g] <SID>:exe "stselect <Plug><ctag>"<SID>tagzv<CR>')
|
||||
call s:map('n', '<silent>', '<C-W>} <SID>:exe v:count1."ptag <Plug><ctag>"<CR>')
|
||||
call s:map('n', '<silent>', '<C-W>g} <SID>:exe "ptjump <Plug><ctag>"<CR>')
|
||||
|
||||
call s:map('n', '<silent>', 'gf <SID>c:find <Plug><cfile><CR>')
|
||||
call s:map('n', '<silent>', '<C-W>f <SID>c:sfind <Plug><cfile><CR>')
|
||||
|
@ -288,12 +290,13 @@ function! s:searchsyn(pattern, syn, flags, mode) abort
|
|||
norm! gv
|
||||
endif
|
||||
let i = 0
|
||||
call map(a:syn, 'hlID(v:val)')
|
||||
while i < cnt
|
||||
let i = i + 1
|
||||
let line = line('.')
|
||||
let col = col('.')
|
||||
let pos = search(a:pattern,'W'.a:flags)
|
||||
while pos != 0 && s:synname() !~# a:syn
|
||||
while pos != 0 && index(a:syn, s:synid()) < 0
|
||||
let pos = search(a:pattern,'W'.a:flags)
|
||||
endwhile
|
||||
if pos == 0
|
||||
|
@ -303,8 +306,8 @@ function! s:searchsyn(pattern, syn, flags, mode) abort
|
|||
endwhile
|
||||
endfunction
|
||||
|
||||
function! s:synname() abort
|
||||
return synIDattr(synID(line('.'),col('.'),0),'name')
|
||||
function! s:synid() abort
|
||||
return synID(line('.'),col('.'),0)
|
||||
endfunction
|
||||
|
||||
function! s:wrap_i(back,forward) abort
|
||||
|
@ -349,6 +352,10 @@ function! RubyCursorIdentifier() abort
|
|||
return stripped == '' ? expand("<cword>") : stripped
|
||||
endfunction
|
||||
|
||||
function! RubyCursorTag() abort
|
||||
return substitute(RubyCursorIdentifier(), '^[$@]*', '', '')
|
||||
endfunction
|
||||
|
||||
function! RubyCursorFile() abort
|
||||
let isfname = &isfname
|
||||
try
|
||||
|
@ -360,8 +367,9 @@ function! RubyCursorFile() abort
|
|||
let pre = matchstr(strpart(getline('.'), 0, col('.')-1), '.*\f\@<!')
|
||||
let post = matchstr(strpart(getline('.'), col('.')), '\f\@!.*')
|
||||
let ext = getline('.') =~# '^\s*\%(require\%(_relative\)\=\|autoload\)\>' && cfile !~# '\.rb$' ? '.rb' : ''
|
||||
if s:synname() ==# 'rubyConstant'
|
||||
if s:synid() ==# hlID('rubyConstant')
|
||||
let cfile = substitute(cfile,'\.\w\+[?!=]\=$','','')
|
||||
let cfile = substitute(cfile,'^::','','')
|
||||
let cfile = substitute(cfile,'::','/','g')
|
||||
let cfile = substitute(cfile,'\(\u\+\)\(\u\l\)','\1_\2', 'g')
|
||||
let cfile = substitute(cfile,'\(\l\|\d\)\(\u\)','\1_\2', 'g')
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
" Vim filetype plugin
|
||||
" Language: Text
|
||||
" Maintainer: David Barnett <daviebdawg+vim@gmail.com>
|
||||
" Last Change: 2014 Jul 09
|
||||
" Last Change: 2019 Jan 10
|
||||
|
||||
if exists('b:did_ftplugin')
|
||||
finish
|
||||
|
@ -12,6 +12,7 @@ let b:undo_ftplugin = 'setlocal comments< commentstring<'
|
|||
|
||||
" We intentionally don't set formatoptions-=t since text should wrap as text.
|
||||
|
||||
" Pseudo comment leaders to indent bulleted lists.
|
||||
setlocal comments=fb:-,fb:*
|
||||
" Pseudo comment leaders to indent bulleted lists with '-' and '*'. And allow
|
||||
" for Mail quoted text with '>'.
|
||||
setlocal comments=fb:-,fb:*,n:>
|
||||
setlocal commentstring=
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
" Vim filetype plugin file
|
||||
" Language: xml
|
||||
" Maintainer: Christian Brabandt <cb@256bit.org>
|
||||
" Last Changed: May 08th, 2018
|
||||
" Repository: https://github.com/chrisbra/vim-xml-ftplugin
|
||||
" Language: xml
|
||||
" Maintainer: Christian Brabandt <cb@256bit.org>
|
||||
" Last Changed: Dec 07th, 2018
|
||||
" Repository: https://github.com/chrisbra/vim-xml-ftplugin
|
||||
" Previous Maintainer: Dan Sharp <dwsharp at users dot sourceforge dot net>
|
||||
" URL: http://dwsharp.users.sourceforge.net/vim/ftplugin
|
||||
|
||||
|
|
|
@ -1,15 +1,73 @@
|
|||
" Vim indent file
|
||||
" Language: C#
|
||||
" Maintainer: Johannes Zellner <johannes@zellner.org>
|
||||
" Last Change: Fri, 15 Mar 2002 07:53:54 CET
|
||||
" Language: C#
|
||||
" Maintainer: Nick Jensen <nickspoon@gmail.com>
|
||||
" Former Maintainers: Aquila Deus
|
||||
" Johannes Zellner <johannes@zellner.org>
|
||||
" Last Change: 2018-11-21
|
||||
" Filenames: *.cs
|
||||
" License: Vim (see :h license)
|
||||
" Repository: https://github.com/nickspoons/vim-cs
|
||||
"
|
||||
|
||||
" Only load this indent file when no other was loaded.
|
||||
if exists("b:did_indent")
|
||||
finish
|
||||
if exists('b:did_indent')
|
||||
finish
|
||||
endif
|
||||
let b:did_indent = 1
|
||||
|
||||
" C# is like indenting C
|
||||
setlocal cindent
|
||||
let s:save_cpo = &cpoptions
|
||||
set cpoptions&vim
|
||||
|
||||
let b:undo_indent = "setl cin<"
|
||||
|
||||
setlocal indentexpr=GetCSIndent(v:lnum)
|
||||
|
||||
function! s:IsCompilerDirective(line)
|
||||
return a:line =~? '^\s*#'
|
||||
endf
|
||||
|
||||
function! s:IsAttributeLine(line)
|
||||
return a:line =~? '^\s*\[[A-Za-z]' && a:line =~? '\]$'
|
||||
endf
|
||||
|
||||
function! s:FindPreviousNonCompilerDirectiveLine(start_lnum)
|
||||
for delta in range(0, a:start_lnum)
|
||||
let lnum = a:start_lnum - delta
|
||||
let line = getline(lnum)
|
||||
let is_directive = s:IsCompilerDirective(line)
|
||||
if !is_directive
|
||||
return lnum
|
||||
endif
|
||||
endfor
|
||||
return 0
|
||||
endf
|
||||
|
||||
function! GetCSIndent(lnum) abort
|
||||
" Hit the start of the file, use zero indent.
|
||||
if a:lnum == 0
|
||||
return 0
|
||||
endif
|
||||
|
||||
let this_line = getline(a:lnum)
|
||||
|
||||
" Compiler directives use zero indent if so configured.
|
||||
let is_first_col_macro = s:IsCompilerDirective(this_line) && stridx(&l:cinkeys, '0#') >= 0
|
||||
if is_first_col_macro
|
||||
return cindent(a:lnum)
|
||||
endif
|
||||
|
||||
let lnum = s:FindPreviousNonCompilerDirectiveLine(a:lnum - 1)
|
||||
let previous_code_line = getline(lnum)
|
||||
if s:IsAttributeLine(previous_code_line)
|
||||
let ind = indent(lnum)
|
||||
return ind
|
||||
else
|
||||
return cindent(a:lnum)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
let b:undo_indent = 'setlocal indentexpr<'
|
||||
|
||||
let &cpoptions = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
|
||||
" vim:et:sw=2:sts=2
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
" Maintainer: Tim Pope <vimNOSPAM@tpope.org>
|
||||
" URL: https://github.com/vim-ruby/vim-ruby
|
||||
" Release Coordinator: Doug Kearns <dougkearns@gmail.com>
|
||||
" Last Change: 2019 Jan 06
|
||||
|
||||
if exists("b:did_indent")
|
||||
finish
|
||||
|
@ -12,7 +13,7 @@ runtime! indent/ruby.vim
|
|||
unlet! b:did_indent
|
||||
setlocal indentexpr=
|
||||
|
||||
if exists("b:eruby_subtype")
|
||||
if exists("b:eruby_subtype") && b:eruby_subtype != '' && b:eruby_subtype !=# 'eruby'
|
||||
exe "runtime! indent/".b:eruby_subtype.".vim"
|
||||
else
|
||||
runtime! indent/html.vim
|
||||
|
@ -47,7 +48,11 @@ set cpo&vim
|
|||
|
||||
function! GetErubyIndent(...)
|
||||
" The value of a single shift-width
|
||||
let sw = shiftwidth()
|
||||
if exists('*shiftwidth')
|
||||
let sw = shiftwidth()
|
||||
else
|
||||
let sw = &sw
|
||||
endif
|
||||
|
||||
if a:0 && a:1 == '.'
|
||||
let v:lnum = line('.')
|
||||
|
@ -91,6 +96,7 @@ function! GetErubyIndent(...)
|
|||
let ind = ind + sw
|
||||
endif
|
||||
if line !~# '^\s*<%' && line =~# '%>\s*$' && line !~# '^\s*end\>'
|
||||
\ && synID(v:lnum, match(cline, '\S') + 1, 1) != hlID('htmlEndTag')
|
||||
let ind = ind - sw
|
||||
endif
|
||||
if cline =~# '^\s*[-=]\=%>\s*$'
|
||||
|
|
|
@ -368,7 +368,7 @@ function FalconGetIndent(...)
|
|||
return indent('.')
|
||||
endif
|
||||
else
|
||||
call cursor(clnum, vcol)
|
||||
call cursor(clnum, 0) " FIXME: column was vcol
|
||||
end
|
||||
endif
|
||||
|
||||
|
|
|
@ -216,8 +216,9 @@ endfunc "}}}
|
|||
" Add known tag pairs.
|
||||
" Self-closing tags and tags that are sometimes {{{
|
||||
" self-closing (e.g., <p>) are not here (when encountering </p> we can find
|
||||
" the matching <p>, but not the other way around). Known self-closing tags:
|
||||
" 'p', 'img', 'source'.
|
||||
" the matching <p>, but not the other way around).
|
||||
" Known self-closing tags: " 'p', 'img', 'source', 'area', 'keygen', 'track',
|
||||
" 'wbr'.
|
||||
" Old HTML tags:
|
||||
call s:AddITags(s:indent_tags, [
|
||||
\ 'a', 'abbr', 'acronym', 'address', 'b', 'bdo', 'big',
|
||||
|
@ -232,11 +233,11 @@ call s:AddITags(s:indent_tags, [
|
|||
|
||||
" New HTML5 elements:
|
||||
call s:AddITags(s:indent_tags, [
|
||||
\ 'area', 'article', 'aside', 'audio', 'bdi', 'canvas',
|
||||
\ 'command', 'data', 'datalist', 'details', 'embed', 'figcaption',
|
||||
\ 'figure', 'footer', 'header', 'keygen', 'main', 'mark', 'meter',
|
||||
\ 'nav', 'output', 'picture', 'progress', 'rp', 'rt', 'ruby', 'section',
|
||||
\ 'summary', 'svg', 'time', 'track', 'video', 'wbr'])
|
||||
\ 'article', 'aside', 'audio', 'bdi', 'canvas', 'command', 'data',
|
||||
\ 'datalist', 'details', 'dialog', 'embed', 'figcaption', 'figure',
|
||||
\ 'footer', 'header', 'hgroup', 'main', 'mark', 'meter', 'nav', 'output',
|
||||
\ 'picture', 'progress', 'rp', 'rt', 'ruby', 'section', 'summary',
|
||||
\ 'svg', 'time', 'video'])
|
||||
|
||||
" Tags added for web components:
|
||||
call s:AddITags(s:indent_tags, [
|
||||
|
@ -625,7 +626,7 @@ func! s:CSSIndent()
|
|||
return eval(b:hi_css1indent)
|
||||
endif
|
||||
|
||||
" If the current line starts with "}" align with it's match.
|
||||
" If the current line starts with "}" align with its match.
|
||||
if curtext =~ '^\s*}'
|
||||
call cursor(v:lnum, 1)
|
||||
try
|
||||
|
@ -934,7 +935,7 @@ func! s:InsideTag(foundHtmlString)
|
|||
let idx = match(text, '<' . s:tagname . '\s\+\zs\w')
|
||||
endif
|
||||
if idx == -1
|
||||
" after just <tag indent one level more
|
||||
" after just "<tag" indent one level more
|
||||
let idx = match(text, '<' . s:tagname . '$')
|
||||
if idx >= 0
|
||||
call cursor(lnum, idx)
|
||||
|
|
|
@ -1,74 +1,121 @@
|
|||
" Matlab indent file
|
||||
" Language: Matlab
|
||||
" Maintainer: Christophe Poucet <christophe.poucet@pandora.be>
|
||||
" Last Change: 6 January, 2001
|
||||
" Vim indent file
|
||||
" Language: MATLAB
|
||||
" Maintainer: Axel Forsman <axelsfor@gmail.com>
|
||||
" Previous maintainer: Christophe Poucet <christophe.poucet@pandora.be>
|
||||
|
||||
" Only load this indent file when no other was loaded.
|
||||
if exists("b:did_indent")
|
||||
finish
|
||||
endif
|
||||
" Only load if no other indent file is loaded
|
||||
if exists('b:did_indent') | finish | endif
|
||||
let b:did_indent = 1
|
||||
|
||||
" Some preliminary setting
|
||||
setlocal indentkeys=!,o,O=end,=case,=else,=elseif,=otherwise,=catch
|
||||
setlocal indentexpr=GetMatlabIndent()
|
||||
setlocal indentkeys=!,o,O,e,0=end,0=elseif,0=case,0=otherwise,0=catch,0=function,0=elsei
|
||||
|
||||
" The value of the Function indenting format in
|
||||
" MATLAB Editor/Debugger Language Preferences.
|
||||
" The possible values are 0 for Classic, 1 for Indent nested functions
|
||||
" and 2 for Indent all functions (default).
|
||||
let b:MATLAB_function_indent = get(g:, 'MATLAB_function_indent', 2)
|
||||
" The previous value of b:changedtick
|
||||
let b:MATLAB_lasttick = -1
|
||||
" The previously indented line
|
||||
let b:MATLAB_lastline = -1
|
||||
" Whether the line above was a line continuation
|
||||
let b:MATLAB_waslc = 0
|
||||
let b:MATLAB_bracketlevel = 0
|
||||
|
||||
setlocal indentexpr=GetMatlabIndent(v:lnum)
|
||||
" Only define the function once
|
||||
if exists("*GetMatlabIndent") | finish | endif
|
||||
|
||||
" Only define the function once.
|
||||
if exists("*GetMatlabIndent")
|
||||
finish
|
||||
endif
|
||||
let s:keepcpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
function GetMatlabIndent(lnum)
|
||||
" Give up if this line is explicitly joined.
|
||||
if getline(a:lnum - 1) =~ '\\$'
|
||||
return -1
|
||||
endif
|
||||
let s:end = '\<end\>\%([^(]*)\)\@!' " Array indexing heuristic
|
||||
let s:open_pat = 'for\|if\|parfor\|spmd\|switch\|try\|while\|classdef\|properties\|methods\|events\|enumeration'
|
||||
let s:dedent_pat = '\C^\s*\zs\<\%(end\|else\|elseif\|catch\|\(case\|otherwise\|function\)\)\>'
|
||||
let s:start_pat = '\C\<\%(function\|' . s:open_pat . '\)\>'
|
||||
let s:bracket_pair_pat = '\(\[\|{\)\|\(\]\|}\)'
|
||||
let s:zflag = has('patch-7.4.984') ? 'z' : ''
|
||||
|
||||
" Search backwards for the first non-empty line.
|
||||
let plnum = a:lnum - 1
|
||||
while plnum > 0 && getline(plnum) =~ '^\s*$'
|
||||
let plnum = plnum - 1
|
||||
endwhile
|
||||
|
||||
if plnum == 0
|
||||
" This is the first non-empty line, use zero indent.
|
||||
return 0
|
||||
endif
|
||||
|
||||
let curind = indent(plnum)
|
||||
|
||||
" If the current line is a stop-block statement...
|
||||
if getline(v:lnum) =~ '^\s*\(end\|else\|elseif\|case\|otherwise\|catch\)\>'
|
||||
" See if this line does not follow the line right after an openblock
|
||||
if getline(plnum) =~ '^\s*\(for\|if\|else\|elseif\|case\|while\|switch\|try\|otherwise\|catch\)\>'
|
||||
" See if the user has already dedented
|
||||
elseif indent(v:lnum) > curind - shiftwidth()
|
||||
" If not, recommend one dedent
|
||||
let curind = curind - shiftwidth()
|
||||
else
|
||||
" Otherwise, trust the user
|
||||
return -1
|
||||
endif
|
||||
" endif
|
||||
|
||||
" If the previous line opened a block
|
||||
elseif getline(plnum) =~ '^\s*\(for\|if\|else\|elseif\|case\|while\|switch\|try\|otherwise\|catch\)\>'
|
||||
" See if the user has already indented
|
||||
if indent(v:lnum) < curind + shiftwidth()
|
||||
"If not, recommend indent
|
||||
let curind = curind + shiftwidth()
|
||||
else
|
||||
" Otherwise, trust the user
|
||||
return -1
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
|
||||
" If we got to here, it means that the user takes the standardversion, so we return it
|
||||
return curind
|
||||
" Returns whether a comment or string envelops the specified column.
|
||||
function! s:IsCommentOrString(lnum, col)
|
||||
return synIDattr(synID(a:lnum, a:col, 1), "name") =~# 'matlabComment\|matlabMultilineComment\|matlabString'
|
||||
endfunction
|
||||
|
||||
" vim:sw=2
|
||||
" Returns whether the specified line continues on the next line.
|
||||
function! s:IsLineContinuation(lnum)
|
||||
let l = getline(a:lnum) | let c = -3
|
||||
while 1
|
||||
let c = match(l, '\.\{3}', c + 3)
|
||||
if c == -1 | return 0
|
||||
elseif !s:IsCommentOrString(a:lnum, c) | return 1 | endif
|
||||
endwhile
|
||||
endfunction
|
||||
|
||||
function! s:SubmatchCount(lnum, pattern, ...)
|
||||
let endcol = a:0 >= 1 ? a:1 : 1 / 0 | let x = [0, 0, 0, 0]
|
||||
call cursor(a:lnum, 1)
|
||||
while 1
|
||||
let [lnum, c, submatch] = searchpos(a:pattern, 'cpe' . s:zflag, a:lnum)
|
||||
if !submatch || c >= endcol | break | endif
|
||||
if !s:IsCommentOrString(lnum, c) | let x[submatch - 2] += 1 | endif
|
||||
if cursor(0, c + 1) == -1 || col('.') == c | break | endif
|
||||
endwhile
|
||||
return x
|
||||
endfunction
|
||||
|
||||
function! s:GetOpenCloseCount(lnum, pattern, ...)
|
||||
let counts = call('s:SubmatchCount', [a:lnum, a:pattern] + a:000)
|
||||
return counts[0] - counts[1]
|
||||
endfunction
|
||||
|
||||
function! GetMatlabIndent()
|
||||
let prevlnum = prevnonblank(v:lnum - 1)
|
||||
|
||||
if b:MATLAB_lasttick != b:changedtick || b:MATLAB_lastline != prevlnum
|
||||
" Recalculate bracket count (only have to check same block and line above)
|
||||
let b:MATLAB_bracketlevel = 0
|
||||
let previndent = indent(prevlnum) | let l = prevlnum
|
||||
while 1
|
||||
let l = prevnonblank(l - 1) | let indent = indent(l)
|
||||
if l <= 0 || previndent < indent | break | endif
|
||||
let b:MATLAB_bracketlevel += s:GetOpenCloseCount(l, s:bracket_pair_pat)
|
||||
if previndent != indent | break | endif
|
||||
endwhile
|
||||
|
||||
let b:MATLAB_waslc = s:IsLineContinuation(prevlnum - 1)
|
||||
endif
|
||||
" If line above was blank it can impossibly have been a LC
|
||||
let above_lc = b:MATLAB_lasttick == b:changedtick && prevlnum != v:lnum - 1 && b:MATLAB_lastline == prevlnum ? 0 : s:IsLineContinuation(v:lnum - 1)
|
||||
|
||||
let pair_pat = '\C\<\(' . s:open_pat . '\|'
|
||||
\ . (b:MATLAB_function_indent == 1 ? '^\@<!' : '')
|
||||
\ . (b:MATLAB_function_indent >= 1 ? 'function\|' : '')
|
||||
\ . '\|\%(^\s*\)\@<=\%(else\|elseif\|case\|otherwise\|catch\)\)\>'
|
||||
\ . '\|\S\s*\zs\(' . s:end . '\)'
|
||||
let [open, close, b_open, b_close] = prevlnum ? s:SubmatchCount(prevlnum,
|
||||
\ pair_pat . '\|' . s:bracket_pair_pat) : [0, 0, 0, 0]
|
||||
let curbracketlevel = b:MATLAB_bracketlevel + b_open - b_close
|
||||
|
||||
call cursor(v:lnum, 1)
|
||||
let submatch = search(s:dedent_pat, 'cp' . s:zflag, v:lnum)
|
||||
if submatch && !s:IsCommentOrString(v:lnum, col('.'))
|
||||
" Align end, et cetera with start of block
|
||||
let [lnum, col] = searchpairpos(s:start_pat, '', '\C' . s:end, 'bW', 's:IsCommentOrString(line("."), col("."))')
|
||||
let result = lnum ? indent(lnum) + shiftwidth() * (s:GetOpenCloseCount(lnum, pair_pat, col) + submatch == 2) : 0
|
||||
else
|
||||
" Count how many blocks the previous line opens/closes
|
||||
" Line continuations/brackets indent once per statement
|
||||
let result = indent(prevlnum) + shiftwidth() * (open - close
|
||||
\ + (b:MATLAB_bracketlevel ? -!curbracketlevel : !!curbracketlevel)
|
||||
\ + (curbracketlevel <= 0) * (above_lc - b:MATLAB_waslc))
|
||||
endif
|
||||
|
||||
let b:MATLAB_waslc = above_lc
|
||||
let b:MATLAB_bracketlevel = curbracketlevel
|
||||
let b:MATLAB_lasttick = b:changedtick
|
||||
let b:MATLAB_lastline = v:lnum
|
||||
return result
|
||||
endfunction
|
||||
|
||||
let &cpo = s:keepcpo
|
||||
unlet s:keepcpo
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
" Vim indent file
|
||||
" Language: RAML (RESTful API Modeling Language)
|
||||
" Maintainer: mucheng <leisurelicht@gmail.com>
|
||||
" License: VIM LICENSE
|
||||
" Latest Revision: 2018-11-03
|
||||
|
||||
if exists("b:did_indent")
|
||||
finish
|
||||
endif
|
||||
|
||||
" Same as yaml indenting.
|
||||
runtime! indent/yaml.vim
|
|
@ -1,8 +1,10 @@
|
|||
" Vim indent file
|
||||
" Language: Ruby
|
||||
" Maintainer: Nikolai Weibull <now at bitwi.se>
|
||||
" Maintainer: Andrew Radev <andrey.radev@gmail.com>
|
||||
" Previous Maintainer: Nikolai Weibull <now at bitwi.se>
|
||||
" URL: https://github.com/vim-ruby/vim-ruby
|
||||
" Release Coordinator: Doug Kearns <dougkearns@gmail.com>
|
||||
" Last Change: 2019 Jan 06
|
||||
|
||||
" 0. Initialization {{{1
|
||||
" =================
|
||||
|
@ -18,6 +20,11 @@ if !exists('g:ruby_indent_access_modifier_style')
|
|||
let g:ruby_indent_access_modifier_style = 'normal'
|
||||
endif
|
||||
|
||||
if !exists('g:ruby_indent_assignment_style')
|
||||
" Possible values: "variable", "hanging"
|
||||
let g:ruby_indent_assignment_style = 'hanging'
|
||||
endif
|
||||
|
||||
if !exists('g:ruby_indent_block_style')
|
||||
" Possible values: "expression", "do"
|
||||
let g:ruby_indent_block_style = 'expression'
|
||||
|
@ -42,28 +49,27 @@ set cpo&vim
|
|||
" 1. Variables {{{1
|
||||
" ============
|
||||
|
||||
" Regex of syntax group names that are or delimit strings/symbols or are comments.
|
||||
let s:syng_strcom = '\<ruby\%(Regexp\|RegexpDelimiter\|RegexpEscape' .
|
||||
\ '\|Symbol\|String\|StringDelimiter\|StringEscape\|ASCIICode' .
|
||||
\ '\|Interpolation\|InterpolationDelimiter\|NoInterpolation\|Comment\|Documentation\)\>'
|
||||
|
||||
" Regex of syntax group names that are strings.
|
||||
" Syntax group names that are strings.
|
||||
let s:syng_string =
|
||||
\ '\<ruby\%(String\|Interpolation\|NoInterpolation\|StringEscape\)\>'
|
||||
\ ['String', 'Interpolation', 'InterpolationDelimiter', 'NoInterpolation', 'StringEscape']
|
||||
|
||||
" Regex of syntax group names that are strings or documentation.
|
||||
let s:syng_stringdoc =
|
||||
\'\<ruby\%(String\|Interpolation\|NoInterpolation\|StringEscape\|Documentation\)\>'
|
||||
" Syntax group names that are strings or documentation.
|
||||
let s:syng_stringdoc = s:syng_string + ['Documentation']
|
||||
|
||||
" Syntax group names that are or delimit strings/symbols/regexes or are comments.
|
||||
let s:syng_strcom = s:syng_stringdoc +
|
||||
\ ['Regexp', 'RegexpDelimiter', 'RegexpEscape',
|
||||
\ 'Symbol', 'StringDelimiter', 'ASCIICode', 'Comment']
|
||||
|
||||
" Expression used to check whether we should skip a match with searchpair().
|
||||
let s:skip_expr =
|
||||
\ "synIDattr(synID(line('.'),col('.'),1),'name') =~ '".s:syng_strcom."'"
|
||||
\ 'index(map('.string(s:syng_strcom).',"hlID(''ruby''.v:val)"), synID(line("."),col("."),1)) >= 0'
|
||||
|
||||
" Regex used for words that, at the start of a line, add a level of indent.
|
||||
let s:ruby_indent_keywords =
|
||||
\ '^\s*\zs\<\%(module\|class\|if\|for' .
|
||||
\ '\|while\|until\|else\|elsif\|case\|when\|unless\|begin\|ensure\|rescue' .
|
||||
\ '\|\%(public\|protected\|private\)\=\s*def\):\@!\>' .
|
||||
\ '\|\%(\K\k*[!?]\?\)\=\s*def\):\@!\>' .
|
||||
\ '\|\%([=,*/%+-]\|<<\|>>\|:\s\)\s*\zs' .
|
||||
\ '\<\%(if\|for\|while\|until\|case\|unless\|begin\):\@!\>'
|
||||
|
||||
|
@ -77,7 +83,7 @@ let s:ruby_deindent_keywords =
|
|||
let s:end_start_regex =
|
||||
\ '\C\%(^\s*\|[=,*/%+\-|;{]\|<<\|>>\|:\s\)\s*\zs' .
|
||||
\ '\<\%(module\|class\|if\|for\|while\|until\|case\|unless\|begin' .
|
||||
\ '\|\%(public\|protected\|private\)\=\s*def\):\@!\>' .
|
||||
\ '\|\%(\K\k*[!?]\?\)\=\s*def\):\@!\>' .
|
||||
\ '\|\%(^\|[^.:@$]\)\@<=\<do:\@!\>'
|
||||
|
||||
" Regex that defines the middle-match for the 'end' keyword.
|
||||
|
@ -142,31 +148,562 @@ let s:block_continuation_regex = '^\s*[^])}\t ].*'.s:block_regex
|
|||
" Regex that describes a leading operator (only a method call's dot for now)
|
||||
let s:leading_operator_regex = '^\s*[.]'
|
||||
|
||||
" 2. Auxiliary Functions {{{1
|
||||
" 2. GetRubyIndent Function {{{1
|
||||
" =========================
|
||||
|
||||
function! GetRubyIndent(...) abort
|
||||
" 2.1. Setup {{{2
|
||||
" ----------
|
||||
|
||||
let indent_info = {}
|
||||
|
||||
" The value of a single shift-width
|
||||
if exists('*shiftwidth')
|
||||
let indent_info.sw = shiftwidth()
|
||||
else
|
||||
let indent_info.sw = &sw
|
||||
endif
|
||||
|
||||
" For the current line, use the first argument if given, else v:lnum
|
||||
let indent_info.clnum = a:0 ? a:1 : v:lnum
|
||||
let indent_info.cline = getline(indent_info.clnum)
|
||||
|
||||
" Set up variables for restoring position in file. Could use clnum here.
|
||||
let indent_info.col = col('.')
|
||||
|
||||
" 2.2. Work on the current line {{{2
|
||||
" -----------------------------
|
||||
let indent_callback_names = [
|
||||
\ 's:AccessModifier',
|
||||
\ 's:ClosingBracketOnEmptyLine',
|
||||
\ 's:BlockComment',
|
||||
\ 's:DeindentingKeyword',
|
||||
\ 's:MultilineStringOrLineComment',
|
||||
\ 's:ClosingHeredocDelimiter',
|
||||
\ 's:LeadingOperator',
|
||||
\ ]
|
||||
|
||||
for callback_name in indent_callback_names
|
||||
" Decho "Running: ".callback_name
|
||||
let indent = call(function(callback_name), [indent_info])
|
||||
|
||||
if indent >= 0
|
||||
" Decho "Match: ".callback_name." indent=".indent." info=".string(indent_info)
|
||||
return indent
|
||||
endif
|
||||
endfor
|
||||
|
||||
" 2.3. Work on the previous line. {{{2
|
||||
" -------------------------------
|
||||
|
||||
" Special case: we don't need the real s:PrevNonBlankNonString for an empty
|
||||
" line inside a string. And that call can be quite expensive in that
|
||||
" particular situation.
|
||||
let indent_callback_names = [
|
||||
\ 's:EmptyInsideString',
|
||||
\ ]
|
||||
|
||||
for callback_name in indent_callback_names
|
||||
" Decho "Running: ".callback_name
|
||||
let indent = call(function(callback_name), [indent_info])
|
||||
|
||||
if indent >= 0
|
||||
" Decho "Match: ".callback_name." indent=".indent." info=".string(indent_info)
|
||||
return indent
|
||||
endif
|
||||
endfor
|
||||
|
||||
" Previous line number
|
||||
let indent_info.plnum = s:PrevNonBlankNonString(indent_info.clnum - 1)
|
||||
let indent_info.pline = getline(indent_info.plnum)
|
||||
|
||||
let indent_callback_names = [
|
||||
\ 's:StartOfFile',
|
||||
\ 's:AfterAccessModifier',
|
||||
\ 's:ContinuedLine',
|
||||
\ 's:AfterBlockOpening',
|
||||
\ 's:AfterHangingSplat',
|
||||
\ 's:AfterUnbalancedBracket',
|
||||
\ 's:AfterLeadingOperator',
|
||||
\ 's:AfterEndKeyword',
|
||||
\ 's:AfterIndentKeyword',
|
||||
\ ]
|
||||
|
||||
for callback_name in indent_callback_names
|
||||
" Decho "Running: ".callback_name
|
||||
let indent = call(function(callback_name), [indent_info])
|
||||
|
||||
if indent >= 0
|
||||
" Decho "Match: ".callback_name." indent=".indent." info=".string(indent_info)
|
||||
return indent
|
||||
endif
|
||||
endfor
|
||||
|
||||
" 2.4. Work on the MSL line. {{{2
|
||||
" --------------------------
|
||||
let indent_callback_names = [
|
||||
\ 's:PreviousNotMSL',
|
||||
\ 's:IndentingKeywordInMSL',
|
||||
\ 's:ContinuedHangingOperator',
|
||||
\ ]
|
||||
|
||||
" Most Significant line based on the previous one -- in case it's a
|
||||
" contination of something above
|
||||
let indent_info.plnum_msl = s:GetMSL(indent_info.plnum)
|
||||
|
||||
for callback_name in indent_callback_names
|
||||
" Decho "Running: ".callback_name
|
||||
let indent = call(function(callback_name), [indent_info])
|
||||
|
||||
if indent >= 0
|
||||
" Decho "Match: ".callback_name." indent=".indent." info=".string(indent_info)
|
||||
return indent
|
||||
endif
|
||||
endfor
|
||||
|
||||
" }}}2
|
||||
|
||||
" By default, just return the previous line's indent
|
||||
" Decho "Default case matched"
|
||||
return indent(indent_info.plnum)
|
||||
endfunction
|
||||
|
||||
" 3. Indenting Logic Callbacks {{{1
|
||||
" ============================
|
||||
|
||||
function! s:AccessModifier(cline_info) abort
|
||||
let info = a:cline_info
|
||||
|
||||
" If this line is an access modifier keyword, align according to the closest
|
||||
" class declaration.
|
||||
if g:ruby_indent_access_modifier_style == 'indent'
|
||||
if s:Match(info.clnum, s:access_modifier_regex)
|
||||
let class_lnum = s:FindContainingClass()
|
||||
if class_lnum > 0
|
||||
return indent(class_lnum) + info.sw
|
||||
endif
|
||||
endif
|
||||
elseif g:ruby_indent_access_modifier_style == 'outdent'
|
||||
if s:Match(info.clnum, s:access_modifier_regex)
|
||||
let class_lnum = s:FindContainingClass()
|
||||
if class_lnum > 0
|
||||
return indent(class_lnum)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
return -1
|
||||
endfunction
|
||||
|
||||
function! s:ClosingBracketOnEmptyLine(cline_info) abort
|
||||
let info = a:cline_info
|
||||
|
||||
" If we got a closing bracket on an empty line, find its match and indent
|
||||
" according to it. For parentheses we indent to its column - 1, for the
|
||||
" others we indent to the containing line's MSL's level. Return -1 if fail.
|
||||
let col = matchend(info.cline, '^\s*[]})]')
|
||||
|
||||
if col > 0 && !s:IsInStringOrComment(info.clnum, col)
|
||||
call cursor(info.clnum, col)
|
||||
let closing_bracket = info.cline[col - 1]
|
||||
let bracket_pair = strpart('(){}[]', stridx(')}]', closing_bracket) * 2, 2)
|
||||
|
||||
if searchpair(escape(bracket_pair[0], '\['), '', bracket_pair[1], 'bW', s:skip_expr) > 0
|
||||
if closing_bracket == ')' && col('.') != col('$') - 1
|
||||
let ind = virtcol('.') - 1
|
||||
elseif g:ruby_indent_block_style == 'do'
|
||||
let ind = indent(line('.'))
|
||||
else " g:ruby_indent_block_style == 'expression'
|
||||
let ind = indent(s:GetMSL(line('.')))
|
||||
endif
|
||||
endif
|
||||
|
||||
return ind
|
||||
endif
|
||||
|
||||
return -1
|
||||
endfunction
|
||||
|
||||
function! s:BlockComment(cline_info) abort
|
||||
" If we have a =begin or =end set indent to first column.
|
||||
if match(a:cline_info.cline, '^\s*\%(=begin\|=end\)$') != -1
|
||||
return 0
|
||||
endif
|
||||
return -1
|
||||
endfunction
|
||||
|
||||
function! s:DeindentingKeyword(cline_info) abort
|
||||
let info = a:cline_info
|
||||
|
||||
" If we have a deindenting keyword, find its match and indent to its level.
|
||||
" TODO: this is messy
|
||||
if s:Match(info.clnum, s:ruby_deindent_keywords)
|
||||
call cursor(info.clnum, 1)
|
||||
|
||||
if searchpair(s:end_start_regex, s:end_middle_regex, s:end_end_regex, 'bW',
|
||||
\ s:end_skip_expr) > 0
|
||||
let msl = s:GetMSL(line('.'))
|
||||
let line = getline(line('.'))
|
||||
|
||||
if s:IsAssignment(line, col('.')) &&
|
||||
\ strpart(line, col('.') - 1, 2) !~ 'do'
|
||||
" assignment to case/begin/etc, on the same line
|
||||
if g:ruby_indent_assignment_style == 'hanging'
|
||||
" hanging indent
|
||||
let ind = virtcol('.') - 1
|
||||
else
|
||||
" align with variable
|
||||
let ind = indent(line('.'))
|
||||
endif
|
||||
elseif g:ruby_indent_block_style == 'do'
|
||||
" align to line of the "do", not to the MSL
|
||||
let ind = indent(line('.'))
|
||||
elseif getline(msl) =~ '=\s*\(#.*\)\=$'
|
||||
" in the case of assignment to the MSL, align to the starting line,
|
||||
" not to the MSL
|
||||
let ind = indent(line('.'))
|
||||
else
|
||||
" align to the MSL
|
||||
let ind = indent(msl)
|
||||
endif
|
||||
endif
|
||||
return ind
|
||||
endif
|
||||
|
||||
return -1
|
||||
endfunction
|
||||
|
||||
function! s:MultilineStringOrLineComment(cline_info) abort
|
||||
let info = a:cline_info
|
||||
|
||||
" If we are in a multi-line string or line-comment, don't do anything to it.
|
||||
if s:IsInStringOrDocumentation(info.clnum, matchend(info.cline, '^\s*') + 1)
|
||||
return indent(info.clnum)
|
||||
endif
|
||||
return -1
|
||||
endfunction
|
||||
|
||||
function! s:ClosingHeredocDelimiter(cline_info) abort
|
||||
let info = a:cline_info
|
||||
|
||||
" If we are at the closing delimiter of a "<<" heredoc-style string, set the
|
||||
" indent to 0.
|
||||
if info.cline =~ '^\k\+\s*$'
|
||||
\ && s:IsInStringDelimiter(info.clnum, 1)
|
||||
\ && search('\V<<'.info.cline, 'nbW') > 0
|
||||
return 0
|
||||
endif
|
||||
|
||||
return -1
|
||||
endfunction
|
||||
|
||||
function! s:LeadingOperator(cline_info) abort
|
||||
" If the current line starts with a leading operator, add a level of indent.
|
||||
if s:Match(a:cline_info.clnum, s:leading_operator_regex)
|
||||
return indent(s:GetMSL(a:cline_info.clnum)) + a:cline_info.sw
|
||||
endif
|
||||
return -1
|
||||
endfunction
|
||||
|
||||
function! s:EmptyInsideString(pline_info) abort
|
||||
" If the line is empty and inside a string (the previous line is a string,
|
||||
" too), use the previous line's indent
|
||||
let info = a:pline_info
|
||||
|
||||
let plnum = prevnonblank(info.clnum - 1)
|
||||
let pline = getline(plnum)
|
||||
|
||||
if info.cline =~ '^\s*$'
|
||||
\ && s:IsInStringOrComment(plnum, 1)
|
||||
\ && s:IsInStringOrComment(plnum, strlen(pline))
|
||||
return indent(plnum)
|
||||
endif
|
||||
return -1
|
||||
endfunction
|
||||
|
||||
function! s:StartOfFile(pline_info) abort
|
||||
" At the start of the file use zero indent.
|
||||
if a:pline_info.plnum == 0
|
||||
return 0
|
||||
endif
|
||||
return -1
|
||||
endfunction
|
||||
|
||||
function! s:AfterAccessModifier(pline_info) abort
|
||||
let info = a:pline_info
|
||||
|
||||
if g:ruby_indent_access_modifier_style == 'indent'
|
||||
" If the previous line was a private/protected keyword, add a
|
||||
" level of indent.
|
||||
if s:Match(info.plnum, s:indent_access_modifier_regex)
|
||||
return indent(info.plnum) + info.sw
|
||||
endif
|
||||
elseif g:ruby_indent_access_modifier_style == 'outdent'
|
||||
" If the previous line was a private/protected/public keyword, add
|
||||
" a level of indent, since the keyword has been out-dented.
|
||||
if s:Match(info.plnum, s:access_modifier_regex)
|
||||
return indent(info.plnum) + info.sw
|
||||
endif
|
||||
endif
|
||||
return -1
|
||||
endfunction
|
||||
|
||||
" Example:
|
||||
"
|
||||
" if foo || bar ||
|
||||
" baz || bing
|
||||
" puts "foo"
|
||||
" end
|
||||
"
|
||||
function! s:ContinuedLine(pline_info) abort
|
||||
let info = a:pline_info
|
||||
|
||||
let col = s:Match(info.plnum, s:ruby_indent_keywords)
|
||||
if s:Match(info.plnum, s:continuable_regex) &&
|
||||
\ s:Match(info.plnum, s:continuation_regex)
|
||||
if col > 0 && s:IsAssignment(info.pline, col)
|
||||
if g:ruby_indent_assignment_style == 'hanging'
|
||||
" hanging indent
|
||||
let ind = col - 1
|
||||
else
|
||||
" align with variable
|
||||
let ind = indent(info.plnum)
|
||||
endif
|
||||
else
|
||||
let ind = indent(s:GetMSL(info.plnum))
|
||||
endif
|
||||
return ind + info.sw + info.sw
|
||||
endif
|
||||
return -1
|
||||
endfunction
|
||||
|
||||
function! s:AfterBlockOpening(pline_info) abort
|
||||
let info = a:pline_info
|
||||
|
||||
" If the previous line ended with a block opening, add a level of indent.
|
||||
if s:Match(info.plnum, s:block_regex)
|
||||
if g:ruby_indent_block_style == 'do'
|
||||
" don't align to the msl, align to the "do"
|
||||
let ind = indent(info.plnum) + info.sw
|
||||
else
|
||||
let plnum_msl = s:GetMSL(info.plnum)
|
||||
|
||||
if getline(plnum_msl) =~ '=\s*\(#.*\)\=$'
|
||||
" in the case of assignment to the msl, align to the starting line,
|
||||
" not to the msl
|
||||
let ind = indent(info.plnum) + info.sw
|
||||
else
|
||||
let ind = indent(plnum_msl) + info.sw
|
||||
endif
|
||||
endif
|
||||
|
||||
return ind
|
||||
endif
|
||||
|
||||
return -1
|
||||
endfunction
|
||||
|
||||
function! s:AfterLeadingOperator(pline_info) abort
|
||||
" If the previous line started with a leading operator, use its MSL's level
|
||||
" of indent
|
||||
if s:Match(a:pline_info.plnum, s:leading_operator_regex)
|
||||
return indent(s:GetMSL(a:pline_info.plnum))
|
||||
endif
|
||||
return -1
|
||||
endfunction
|
||||
|
||||
function! s:AfterHangingSplat(pline_info) abort
|
||||
let info = a:pline_info
|
||||
|
||||
" If the previous line ended with the "*" of a splat, add a level of indent
|
||||
if info.pline =~ s:splat_regex
|
||||
return indent(info.plnum) + info.sw
|
||||
endif
|
||||
return -1
|
||||
endfunction
|
||||
|
||||
function! s:AfterUnbalancedBracket(pline_info) abort
|
||||
let info = a:pline_info
|
||||
|
||||
" If the previous line contained unclosed opening brackets and we are still
|
||||
" in them, find the rightmost one and add indent depending on the bracket
|
||||
" type.
|
||||
"
|
||||
" If it contained hanging closing brackets, find the rightmost one, find its
|
||||
" match and indent according to that.
|
||||
if info.pline =~ '[[({]' || info.pline =~ '[])}]\s*\%(#.*\)\=$'
|
||||
let [opening, closing] = s:ExtraBrackets(info.plnum)
|
||||
|
||||
if opening.pos != -1
|
||||
if opening.type == '(' && searchpair('(', '', ')', 'bW', s:skip_expr) > 0
|
||||
if col('.') + 1 == col('$')
|
||||
return indent(info.plnum) + info.sw
|
||||
else
|
||||
return virtcol('.')
|
||||
endif
|
||||
else
|
||||
let nonspace = matchend(info.pline, '\S', opening.pos + 1) - 1
|
||||
return nonspace > 0 ? nonspace : indent(info.plnum) + info.sw
|
||||
endif
|
||||
elseif closing.pos != -1
|
||||
call cursor(info.plnum, closing.pos + 1)
|
||||
normal! %
|
||||
|
||||
if s:Match(line('.'), s:ruby_indent_keywords)
|
||||
return indent('.') + info.sw
|
||||
else
|
||||
return indent(s:GetMSL(line('.')))
|
||||
endif
|
||||
else
|
||||
call cursor(info.clnum, info.col)
|
||||
end
|
||||
endif
|
||||
|
||||
return -1
|
||||
endfunction
|
||||
|
||||
function! s:AfterEndKeyword(pline_info) abort
|
||||
let info = a:pline_info
|
||||
" If the previous line ended with an "end", match that "end"s beginning's
|
||||
" indent.
|
||||
let col = s:Match(info.plnum, '\%(^\|[^.:@$]\)\<end\>\s*\%(#.*\)\=$')
|
||||
if col > 0
|
||||
call cursor(info.plnum, col)
|
||||
if searchpair(s:end_start_regex, '', s:end_end_regex, 'bW',
|
||||
\ s:end_skip_expr) > 0
|
||||
let n = line('.')
|
||||
let ind = indent('.')
|
||||
let msl = s:GetMSL(n)
|
||||
if msl != n
|
||||
let ind = indent(msl)
|
||||
end
|
||||
return ind
|
||||
endif
|
||||
end
|
||||
return -1
|
||||
endfunction
|
||||
|
||||
function! s:AfterIndentKeyword(pline_info) abort
|
||||
let info = a:pline_info
|
||||
let col = s:Match(info.plnum, s:ruby_indent_keywords)
|
||||
|
||||
if col > 0
|
||||
call cursor(info.plnum, col)
|
||||
let ind = virtcol('.') - 1 + info.sw
|
||||
" TODO: make this better (we need to count them) (or, if a searchpair
|
||||
" fails, we know that something is lacking an end and thus we indent a
|
||||
" level
|
||||
if s:Match(info.plnum, s:end_end_regex)
|
||||
let ind = indent('.')
|
||||
elseif s:IsAssignment(info.pline, col)
|
||||
if g:ruby_indent_assignment_style == 'hanging'
|
||||
" hanging indent
|
||||
let ind = col + info.sw - 1
|
||||
else
|
||||
" align with variable
|
||||
let ind = indent(info.plnum) + info.sw
|
||||
endif
|
||||
endif
|
||||
return ind
|
||||
endif
|
||||
|
||||
return -1
|
||||
endfunction
|
||||
|
||||
function! s:PreviousNotMSL(msl_info) abort
|
||||
let info = a:msl_info
|
||||
|
||||
" If the previous line wasn't a MSL
|
||||
if info.plnum != info.plnum_msl
|
||||
" If previous line ends bracket and begins non-bracket continuation decrease indent by 1.
|
||||
if s:Match(info.plnum, s:bracket_switch_continuation_regex)
|
||||
" TODO (2016-10-07) Wrong/unused? How could it be "1"?
|
||||
return indent(info.plnum) - 1
|
||||
" If previous line is a continuation return its indent.
|
||||
" TODO: the || s:IsInString() thing worries me a bit.
|
||||
elseif s:Match(info.plnum, s:non_bracket_continuation_regex) || s:IsInString(info.plnum, strlen(line))
|
||||
return indent(info.plnum)
|
||||
endif
|
||||
endif
|
||||
|
||||
return -1
|
||||
endfunction
|
||||
|
||||
function! s:IndentingKeywordInMSL(msl_info) abort
|
||||
let info = a:msl_info
|
||||
" If the MSL line had an indenting keyword in it, add a level of indent.
|
||||
" TODO: this does not take into account contrived things such as
|
||||
" module Foo; class Bar; end
|
||||
let col = s:Match(info.plnum_msl, s:ruby_indent_keywords)
|
||||
if col > 0
|
||||
let ind = indent(info.plnum_msl) + info.sw
|
||||
if s:Match(info.plnum_msl, s:end_end_regex)
|
||||
let ind = ind - info.sw
|
||||
elseif s:IsAssignment(getline(info.plnum_msl), col)
|
||||
if g:ruby_indent_assignment_style == 'hanging'
|
||||
" hanging indent
|
||||
let ind = col + info.sw - 1
|
||||
else
|
||||
" align with variable
|
||||
let ind = indent(info.plnum_msl) + info.sw
|
||||
endif
|
||||
endif
|
||||
return ind
|
||||
endif
|
||||
return -1
|
||||
endfunction
|
||||
|
||||
function! s:ContinuedHangingOperator(msl_info) abort
|
||||
let info = a:msl_info
|
||||
|
||||
" If the previous line ended with [*+/.,-=], but wasn't a block ending or a
|
||||
" closing bracket, indent one extra level.
|
||||
if s:Match(info.plnum_msl, s:non_bracket_continuation_regex) && !s:Match(info.plnum_msl, '^\s*\([\])}]\|end\)')
|
||||
if info.plnum_msl == info.plnum
|
||||
let ind = indent(info.plnum_msl) + info.sw
|
||||
else
|
||||
let ind = indent(info.plnum_msl)
|
||||
endif
|
||||
return ind
|
||||
endif
|
||||
|
||||
return -1
|
||||
endfunction
|
||||
|
||||
" 4. Auxiliary Functions {{{1
|
||||
" ======================
|
||||
|
||||
function! s:IsInRubyGroup(groups, lnum, col) abort
|
||||
let ids = map(copy(a:groups), 'hlID("ruby".v:val)')
|
||||
return index(ids, synID(a:lnum, a:col, 1)) >= 0
|
||||
endfunction
|
||||
|
||||
" Check if the character at lnum:col is inside a string, comment, or is ascii.
|
||||
function s:IsInStringOrComment(lnum, col)
|
||||
return synIDattr(synID(a:lnum, a:col, 1), 'name') =~ s:syng_strcom
|
||||
function! s:IsInStringOrComment(lnum, col) abort
|
||||
return s:IsInRubyGroup(s:syng_strcom, a:lnum, a:col)
|
||||
endfunction
|
||||
|
||||
" Check if the character at lnum:col is inside a string.
|
||||
function s:IsInString(lnum, col)
|
||||
return synIDattr(synID(a:lnum, a:col, 1), 'name') =~ s:syng_string
|
||||
function! s:IsInString(lnum, col) abort
|
||||
return s:IsInRubyGroup(s:syng_string, a:lnum, a:col)
|
||||
endfunction
|
||||
|
||||
" Check if the character at lnum:col is inside a string or documentation.
|
||||
function s:IsInStringOrDocumentation(lnum, col)
|
||||
return synIDattr(synID(a:lnum, a:col, 1), 'name') =~ s:syng_stringdoc
|
||||
function! s:IsInStringOrDocumentation(lnum, col) abort
|
||||
return s:IsInRubyGroup(s:syng_stringdoc, a:lnum, a:col)
|
||||
endfunction
|
||||
|
||||
" Check if the character at lnum:col is inside a string delimiter
|
||||
function s:IsInStringDelimiter(lnum, col)
|
||||
return synIDattr(synID(a:lnum, a:col, 1), 'name') == 'rubyStringDelimiter'
|
||||
function! s:IsInStringDelimiter(lnum, col) abort
|
||||
return s:IsInRubyGroup(['StringDelimiter'], a:lnum, a:col)
|
||||
endfunction
|
||||
|
||||
function! s:IsAssignment(str, pos) abort
|
||||
return strpart(a:str, 0, a:pos - 1) =~ '=\s*$'
|
||||
endfunction
|
||||
|
||||
" Find line above 'lnum' that isn't empty, in a comment, or in a string.
|
||||
function s:PrevNonBlankNonString(lnum)
|
||||
function! s:PrevNonBlankNonString(lnum) abort
|
||||
let in_block = 0
|
||||
let lnum = prevnonblank(a:lnum)
|
||||
while lnum > 0
|
||||
|
@ -191,10 +728,9 @@ function s:PrevNonBlankNonString(lnum)
|
|||
endfunction
|
||||
|
||||
" Find line above 'lnum' that started the continuation 'lnum' may be part of.
|
||||
function s:GetMSL(lnum)
|
||||
function! s:GetMSL(lnum) abort
|
||||
" Start on the line we're at and use its indent.
|
||||
let msl = a:lnum
|
||||
let msl_body = getline(msl)
|
||||
let lnum = s:PrevNonBlankNonString(a:lnum - 1)
|
||||
while lnum > 0
|
||||
" If we have a continuation line, or we're in a string, use line as MSL.
|
||||
|
@ -291,14 +827,13 @@ function s:GetMSL(lnum)
|
|||
endif
|
||||
endif
|
||||
|
||||
let msl_body = getline(msl)
|
||||
let lnum = s:PrevNonBlankNonString(lnum - 1)
|
||||
endwhile
|
||||
return msl
|
||||
endfunction
|
||||
|
||||
" Check if line 'lnum' has more opening brackets than closing ones.
|
||||
function s:ExtraBrackets(lnum)
|
||||
function! s:ExtraBrackets(lnum) abort
|
||||
let opening = {'parentheses': [], 'braces': [], 'brackets': []}
|
||||
let closing = {'parentheses': [], 'braces': [], 'brackets': []}
|
||||
|
||||
|
@ -360,7 +895,7 @@ function s:ExtraBrackets(lnum)
|
|||
return [rightmost_opening, rightmost_closing]
|
||||
endfunction
|
||||
|
||||
function s:Match(lnum, regex)
|
||||
function! s:Match(lnum, regex) abort
|
||||
let line = getline(a:lnum)
|
||||
let offset = match(line, '\C'.a:regex)
|
||||
let col = offset + 1
|
||||
|
@ -380,7 +915,7 @@ endfunction
|
|||
" Locates the containing class/module's definition line, ignoring nested classes
|
||||
" along the way.
|
||||
"
|
||||
function! s:FindContainingClass()
|
||||
function! s:FindContainingClass() abort
|
||||
let saved_position = getpos('.')
|
||||
|
||||
while searchpair(s:end_start_regex, s:end_middle_regex, s:end_end_regex, 'bW',
|
||||
|
@ -396,297 +931,6 @@ function! s:FindContainingClass()
|
|||
return 0
|
||||
endfunction
|
||||
|
||||
" 3. GetRubyIndent Function {{{1
|
||||
" =========================
|
||||
|
||||
function GetRubyIndent(...)
|
||||
" 3.1. Setup {{{2
|
||||
" ----------
|
||||
|
||||
" The value of a single shift-width
|
||||
let sw = shiftwidth()
|
||||
|
||||
" For the current line, use the first argument if given, else v:lnum
|
||||
let clnum = a:0 ? a:1 : v:lnum
|
||||
|
||||
" Set up variables for restoring position in file. Could use clnum here.
|
||||
let vcol = col('.')
|
||||
|
||||
" 3.2. Work on the current line {{{2
|
||||
" -----------------------------
|
||||
|
||||
" Get the current line.
|
||||
let line = getline(clnum)
|
||||
let ind = -1
|
||||
|
||||
" If this line is an access modifier keyword, align according to the closest
|
||||
" class declaration.
|
||||
if g:ruby_indent_access_modifier_style == 'indent'
|
||||
if s:Match(clnum, s:access_modifier_regex)
|
||||
let class_line = s:FindContainingClass()
|
||||
if class_line > 0
|
||||
return indent(class_line) + sw
|
||||
endif
|
||||
endif
|
||||
elseif g:ruby_indent_access_modifier_style == 'outdent'
|
||||
if s:Match(clnum, s:access_modifier_regex)
|
||||
let class_line = s:FindContainingClass()
|
||||
if class_line > 0
|
||||
return indent(class_line)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
" If we got a closing bracket on an empty line, find its match and indent
|
||||
" according to it. For parentheses we indent to its column - 1, for the
|
||||
" others we indent to the containing line's MSL's level. Return -1 if fail.
|
||||
let col = matchend(line, '^\s*[]})]')
|
||||
if col > 0 && !s:IsInStringOrComment(clnum, col)
|
||||
call cursor(clnum, col)
|
||||
let bs = strpart('(){}[]', stridx(')}]', line[col - 1]) * 2, 2)
|
||||
if searchpair(escape(bs[0], '\['), '', bs[1], 'bW', s:skip_expr) > 0
|
||||
if line[col-1]==')' && col('.') != col('$') - 1
|
||||
let ind = virtcol('.') - 1
|
||||
elseif g:ruby_indent_block_style == 'do'
|
||||
let ind = indent(line('.'))
|
||||
else " g:ruby_indent_block_style == 'expression'
|
||||
let ind = indent(s:GetMSL(line('.')))
|
||||
endif
|
||||
endif
|
||||
return ind
|
||||
endif
|
||||
|
||||
" If we have a =begin or =end set indent to first column.
|
||||
if match(line, '^\s*\%(=begin\|=end\)$') != -1
|
||||
return 0
|
||||
endif
|
||||
|
||||
" If we have a deindenting keyword, find its match and indent to its level.
|
||||
" TODO: this is messy
|
||||
if s:Match(clnum, s:ruby_deindent_keywords)
|
||||
call cursor(clnum, 1)
|
||||
if searchpair(s:end_start_regex, s:end_middle_regex, s:end_end_regex, 'bW',
|
||||
\ s:end_skip_expr) > 0
|
||||
let msl = s:GetMSL(line('.'))
|
||||
let line = getline(line('.'))
|
||||
|
||||
if strpart(line, 0, col('.') - 1) =~ '=\s*$' &&
|
||||
\ strpart(line, col('.') - 1, 2) !~ 'do'
|
||||
" assignment to case/begin/etc, on the same line, hanging indent
|
||||
let ind = virtcol('.') - 1
|
||||
elseif g:ruby_indent_block_style == 'do'
|
||||
" align to line of the "do", not to the MSL
|
||||
let ind = indent(line('.'))
|
||||
elseif getline(msl) =~ '=\s*\(#.*\)\=$'
|
||||
" in the case of assignment to the MSL, align to the starting line,
|
||||
" not to the MSL
|
||||
let ind = indent(line('.'))
|
||||
else
|
||||
" align to the MSL
|
||||
let ind = indent(msl)
|
||||
endif
|
||||
endif
|
||||
return ind
|
||||
endif
|
||||
|
||||
" If we are in a multi-line string or line-comment, don't do anything to it.
|
||||
if s:IsInStringOrDocumentation(clnum, matchend(line, '^\s*') + 1)
|
||||
return indent('.')
|
||||
endif
|
||||
|
||||
" If we are at the closing delimiter of a "<<" heredoc-style string, set the
|
||||
" indent to 0.
|
||||
if line =~ '^\k\+\s*$'
|
||||
\ && s:IsInStringDelimiter(clnum, 1)
|
||||
\ && search('\V<<'.line, 'nbW') > 0
|
||||
return 0
|
||||
endif
|
||||
|
||||
" If the current line starts with a leading operator, add a level of indent.
|
||||
if s:Match(clnum, s:leading_operator_regex)
|
||||
return indent(s:GetMSL(clnum)) + sw
|
||||
endif
|
||||
|
||||
" 3.3. Work on the previous line. {{{2
|
||||
" -------------------------------
|
||||
|
||||
" Find a non-blank, non-multi-line string line above the current line.
|
||||
let lnum = s:PrevNonBlankNonString(clnum - 1)
|
||||
|
||||
" If the line is empty and inside a string, use the previous line.
|
||||
if line =~ '^\s*$' && lnum != prevnonblank(clnum - 1)
|
||||
return indent(prevnonblank(clnum))
|
||||
endif
|
||||
|
||||
" At the start of the file use zero indent.
|
||||
if lnum == 0
|
||||
return 0
|
||||
endif
|
||||
|
||||
" Set up variables for the previous line.
|
||||
let line = getline(lnum)
|
||||
let ind = indent(lnum)
|
||||
|
||||
if g:ruby_indent_access_modifier_style == 'indent'
|
||||
" If the previous line was a private/protected keyword, add a
|
||||
" level of indent.
|
||||
if s:Match(lnum, s:indent_access_modifier_regex)
|
||||
return indent(lnum) + sw
|
||||
endif
|
||||
elseif g:ruby_indent_access_modifier_style == 'outdent'
|
||||
" If the previous line was a private/protected/public keyword, add
|
||||
" a level of indent, since the keyword has been out-dented.
|
||||
if s:Match(lnum, s:access_modifier_regex)
|
||||
return indent(lnum) + sw
|
||||
endif
|
||||
endif
|
||||
|
||||
if s:Match(lnum, s:continuable_regex) && s:Match(lnum, s:continuation_regex)
|
||||
return indent(s:GetMSL(lnum)) + sw + sw
|
||||
endif
|
||||
|
||||
" If the previous line ended with a block opening, add a level of indent.
|
||||
if s:Match(lnum, s:block_regex)
|
||||
let msl = s:GetMSL(lnum)
|
||||
|
||||
if g:ruby_indent_block_style == 'do'
|
||||
" don't align to the msl, align to the "do"
|
||||
let ind = indent(lnum) + sw
|
||||
elseif getline(msl) =~ '=\s*\(#.*\)\=$'
|
||||
" in the case of assignment to the msl, align to the starting line,
|
||||
" not to the msl
|
||||
let ind = indent(lnum) + sw
|
||||
else
|
||||
let ind = indent(msl) + sw
|
||||
endif
|
||||
return ind
|
||||
endif
|
||||
|
||||
" If the previous line started with a leading operator, use its MSL's level
|
||||
" of indent
|
||||
if s:Match(lnum, s:leading_operator_regex)
|
||||
return indent(s:GetMSL(lnum))
|
||||
endif
|
||||
|
||||
" If the previous line ended with the "*" of a splat, add a level of indent
|
||||
if line =~ s:splat_regex
|
||||
return indent(lnum) + sw
|
||||
endif
|
||||
|
||||
" If the previous line contained unclosed opening brackets and we are still
|
||||
" in them, find the rightmost one and add indent depending on the bracket
|
||||
" type.
|
||||
"
|
||||
" If it contained hanging closing brackets, find the rightmost one, find its
|
||||
" match and indent according to that.
|
||||
if line =~ '[[({]' || line =~ '[])}]\s*\%(#.*\)\=$'
|
||||
let [opening, closing] = s:ExtraBrackets(lnum)
|
||||
|
||||
if opening.pos != -1
|
||||
if opening.type == '(' && searchpair('(', '', ')', 'bW', s:skip_expr) > 0
|
||||
if col('.') + 1 == col('$')
|
||||
return ind + sw
|
||||
else
|
||||
return virtcol('.')
|
||||
endif
|
||||
else
|
||||
let nonspace = matchend(line, '\S', opening.pos + 1) - 1
|
||||
return nonspace > 0 ? nonspace : ind + sw
|
||||
endif
|
||||
elseif closing.pos != -1
|
||||
call cursor(lnum, closing.pos + 1)
|
||||
normal! %
|
||||
|
||||
if s:Match(line('.'), s:ruby_indent_keywords)
|
||||
return indent('.') + sw
|
||||
else
|
||||
return indent(s:GetMSL(line('.')))
|
||||
endif
|
||||
else
|
||||
call cursor(clnum, vcol)
|
||||
end
|
||||
endif
|
||||
|
||||
" If the previous line ended with an "end", match that "end"s beginning's
|
||||
" indent.
|
||||
let col = s:Match(lnum, '\%(^\|[^.:@$]\)\<end\>\s*\%(#.*\)\=$')
|
||||
if col > 0
|
||||
call cursor(lnum, col)
|
||||
if searchpair(s:end_start_regex, '', s:end_end_regex, 'bW',
|
||||
\ s:end_skip_expr) > 0
|
||||
let n = line('.')
|
||||
let ind = indent('.')
|
||||
let msl = s:GetMSL(n)
|
||||
if msl != n
|
||||
let ind = indent(msl)
|
||||
end
|
||||
return ind
|
||||
endif
|
||||
end
|
||||
|
||||
let col = s:Match(lnum, s:ruby_indent_keywords)
|
||||
if col > 0
|
||||
call cursor(lnum, col)
|
||||
let ind = virtcol('.') - 1 + sw
|
||||
" TODO: make this better (we need to count them) (or, if a searchpair
|
||||
" fails, we know that something is lacking an end and thus we indent a
|
||||
" level
|
||||
if s:Match(lnum, s:end_end_regex)
|
||||
let ind = indent('.')
|
||||
endif
|
||||
return ind
|
||||
endif
|
||||
|
||||
" 3.4. Work on the MSL line. {{{2
|
||||
" --------------------------
|
||||
|
||||
" Set up variables to use and search for MSL to the previous line.
|
||||
let p_lnum = lnum
|
||||
let lnum = s:GetMSL(lnum)
|
||||
|
||||
" If the previous line wasn't a MSL.
|
||||
if p_lnum != lnum
|
||||
" If previous line ends bracket and begins non-bracket continuation decrease indent by 1.
|
||||
if s:Match(p_lnum, s:bracket_switch_continuation_regex)
|
||||
return ind - 1
|
||||
" If previous line is a continuation return its indent.
|
||||
" TODO: the || s:IsInString() thing worries me a bit.
|
||||
elseif s:Match(p_lnum, s:non_bracket_continuation_regex) || s:IsInString(p_lnum,strlen(line))
|
||||
return ind
|
||||
endif
|
||||
endif
|
||||
|
||||
" Set up more variables, now that we know we wasn't continuation bound.
|
||||
let line = getline(lnum)
|
||||
let msl_ind = indent(lnum)
|
||||
|
||||
" If the MSL line had an indenting keyword in it, add a level of indent.
|
||||
" TODO: this does not take into account contrived things such as
|
||||
" module Foo; class Bar; end
|
||||
if s:Match(lnum, s:ruby_indent_keywords)
|
||||
let ind = msl_ind + sw
|
||||
if s:Match(lnum, s:end_end_regex)
|
||||
let ind = ind - sw
|
||||
endif
|
||||
return ind
|
||||
endif
|
||||
|
||||
" If the previous line ended with [*+/.,-=], but wasn't a block ending or a
|
||||
" closing bracket, indent one extra level.
|
||||
if s:Match(lnum, s:non_bracket_continuation_regex) && !s:Match(lnum, '^\s*\([\])}]\|end\)')
|
||||
if lnum == p_lnum
|
||||
let ind = msl_ind + sw
|
||||
else
|
||||
let ind = msl_ind
|
||||
endif
|
||||
return ind
|
||||
endif
|
||||
|
||||
" }}}2
|
||||
|
||||
return ind
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
|
||||
let &cpo = s:cpo_save
|
||||
|
|
|
@ -3,10 +3,11 @@
|
|||
" Maintainer: Christian Brabandt <cb@256bit.org>
|
||||
" Original Author: Nikolai Weibull <now@bitwi.se>
|
||||
" Previous Maintainer: Peter Aronoff <telemachus@arpinum.org>
|
||||
" Latest Revision: 2018-03-26
|
||||
" Latest Revision: 2019-02-02
|
||||
" License: Vim (see :h license)
|
||||
" Repository: https://github.com/chrisbra/vim-sh-indent
|
||||
" Changelog:
|
||||
" 20190201 - Better check for closing if sections
|
||||
" 20180724 - make check for zsh syntax more rigid (needs word-boundaries)
|
||||
" 20180326 - better support for line continuation
|
||||
" 20180325 - better detection of function definitions
|
||||
|
@ -59,6 +60,7 @@ function! s:indent_value(option)
|
|||
endfunction
|
||||
|
||||
function! GetShIndent()
|
||||
let curline = getline(v:lnum)
|
||||
let lnum = prevnonblank(v:lnum - 1)
|
||||
if lnum == 0
|
||||
return 0
|
||||
|
@ -72,7 +74,7 @@ function! GetShIndent()
|
|||
" Check contents of previous lines
|
||||
if line =~ '^\s*\%(if\|then\|do\|else\|elif\|case\|while\|until\|for\|select\|foreach\)\>' ||
|
||||
\ (&ft is# 'zsh' && line =~ '\<\%(if\|then\|do\|else\|elif\|case\|while\|until\|for\|select\|foreach\)\>')
|
||||
if line !~ '\<\%(fi\|esac\|done\|end\)\>\s*\%(#.*\)\=$'
|
||||
if !s:is_end_expression(line)
|
||||
let ind += s:indent_value('default')
|
||||
endif
|
||||
elseif s:is_case_label(line, pnum)
|
||||
|
@ -90,7 +92,10 @@ function! GetShIndent()
|
|||
endif
|
||||
elseif s:end_block(line) && !s:start_block(line)
|
||||
let ind -= s:indent_value('default')
|
||||
elseif pnum != 0 && s:is_continuation_line(pline) && !s:end_block(getline(v:lnum))
|
||||
elseif pnum != 0 &&
|
||||
\ s:is_continuation_line(pline) &&
|
||||
\ !s:end_block(curline) &&
|
||||
\ !s:is_end_expression(curline)
|
||||
" only add indent, if line and pline is in the same block
|
||||
let i = v:lnum
|
||||
let ind2 = indent(s:find_continued_lnum(pnum))
|
||||
|
@ -106,8 +111,15 @@ function! GetShIndent()
|
|||
|
||||
let pine = line
|
||||
" Check content of current line
|
||||
let line = getline(v:lnum)
|
||||
if line =~ '^\s*\%(then\|do\|else\|elif\|fi\|done\|end\)\>' || s:end_block(line)
|
||||
let line = curline
|
||||
" Current line is a endif line, so get indent from start of "if condition" line
|
||||
" TODO: should we do the same for other "end" lines?
|
||||
if curline =~ '^\s*\%(fi\)\s*\%(#.*\)\=$'
|
||||
let previous_line = search('if.\{-\};\s*then\s*\%(#.*\)\=$', 'bnW')
|
||||
if previous_line > 0
|
||||
let ind = indent(previous_line)
|
||||
endif
|
||||
elseif line =~ '^\s*\%(then\|do\|else\|elif\|done\|end\)\>' || s:end_block(line)
|
||||
let ind -= s:indent_value('default')
|
||||
elseif line =~ '^\s*esac\>' && s:is_case_empty(getline(v:lnum - 1))
|
||||
let ind -= s:indent_value('default')
|
||||
|
@ -210,8 +222,8 @@ endfunction
|
|||
|
||||
function! s:is_here_doc(line)
|
||||
if a:line =~ '^\w\+$'
|
||||
let here_pat = '<<-\?'. s:escape(a:line). '\$'
|
||||
return search(here_pat, 'bnW') > 0
|
||||
let here_pat = '<<-\?'. s:escape(a:line). '\$'
|
||||
return search(here_pat, 'bnW') > 0
|
||||
endif
|
||||
return 0
|
||||
endfunction
|
||||
|
@ -256,5 +268,9 @@ function! s:is_comment(line)
|
|||
return a:line =~ '^\s*#'
|
||||
endfunction
|
||||
|
||||
function! s:is_end_expression(line)
|
||||
return a:line =~ '\<\%(fi\|esac\|done\|end\)\>\s*\%(#.*\)\=$'
|
||||
endfunction
|
||||
|
||||
let &cpo = s:cpo_save
|
||||
unlet s:cpo_save
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
" Vim indent file
|
||||
" Language: Tcl
|
||||
" Maintainer: Nikolai Weibull <now@bitwi.se>
|
||||
" Latest Revision: 2006-12-20
|
||||
" Language: Tcl
|
||||
" Previous Maintainer: Nikolai Weibull <now@bitwi.se>
|
||||
" Latest Update: Chris Heithoff <chrisheithoff@gmail.com>
|
||||
" Latest Revision: 2018-12-05
|
||||
|
||||
if exists("b:did_indent")
|
||||
finish
|
||||
|
@ -28,6 +29,15 @@ function s:prevnonblanknoncomment(lnum)
|
|||
return lnum
|
||||
endfunction
|
||||
|
||||
function s:ends_with_backslash(lnum)
|
||||
let line = getline(a:lnum)
|
||||
if line =~ '\\\s*$'
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function s:count_braces(lnum, count_open)
|
||||
let n_open = 0
|
||||
let n_close = 0
|
||||
|
@ -53,23 +63,39 @@ endfunction
|
|||
|
||||
function GetTclIndent()
|
||||
let line = getline(v:lnum)
|
||||
if line =~ '^\s*\*'
|
||||
return cindent(v:lnum)
|
||||
elseif line =~ '^\s*}'
|
||||
return indent(v:lnum) - shiftwidth()
|
||||
endif
|
||||
|
||||
" Get the line number of the previous non-blank or non-comment line.
|
||||
let pnum = s:prevnonblanknoncomment(v:lnum - 1)
|
||||
if pnum == 0
|
||||
return 0
|
||||
endif
|
||||
|
||||
let ind = indent(pnum) + s:count_braces(pnum, 1) * shiftwidth()
|
||||
" ..and the previous line before the previous line.
|
||||
let pnum2 = s:prevnonblanknoncomment(pnum-1)
|
||||
|
||||
let pline = getline(pnum)
|
||||
if pline =~ '}\s*$'
|
||||
let ind -= (s:count_braces(pnum, 0) - (pline =~ '^\s*}' ? 1 : 0)) * shiftwidth()
|
||||
" Default indentation is to preserve the previous indentation.
|
||||
let ind = indent(pnum)
|
||||
|
||||
" ...but if previous line introduces an open brace, then increase current line's indentation
|
||||
if s:count_braces(pnum, 1) > 0
|
||||
let ind += shiftwidth()
|
||||
else
|
||||
" Look for backslash line continuation on the previous two lines.
|
||||
let slash1 = s:ends_with_backslash(pnum)
|
||||
let slash2 = s:ends_with_backslash(pnum2)
|
||||
if slash1 && !slash2
|
||||
" If the previous line begins a line continuation.
|
||||
let ind += shiftwidth()
|
||||
elseif !slash1 && slash2
|
||||
" If two lines ago was the end of a line continuation group of lines.
|
||||
let ind -= shiftwidth()
|
||||
endif
|
||||
endif
|
||||
|
||||
" If the current line begins with a closed brace, then decrease the indentation by one.
|
||||
if line =~ '^\s*}'
|
||||
let ind -= shiftwidth()
|
||||
endif
|
||||
|
||||
return ind
|
||||
endfunction
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
" vim: set ft=html sw=4 :
|
||||
|
||||
|
||||
" START_INDENT
|
||||
<div>
|
||||
<div>
|
||||
text
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="foo bar">
|
||||
text
|
||||
</div>
|
||||
|
||||
<div class="foo bar"
|
||||
data="something">
|
||||
text
|
||||
</div>
|
||||
|
||||
<div class="foo
|
||||
bar">
|
||||
text
|
||||
</div>
|
||||
|
||||
" END_INDENT
|
|
@ -0,0 +1,26 @@
|
|||
" vim: set ft=html sw=4 :
|
||||
|
||||
|
||||
" START_INDENT
|
||||
<div>
|
||||
<div>
|
||||
text
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="foo bar">
|
||||
text
|
||||
</div>
|
||||
|
||||
<div class="foo bar"
|
||||
data="something">
|
||||
text
|
||||
</div>
|
||||
|
||||
<div class="foo
|
||||
bar">
|
||||
text
|
||||
</div>
|
||||
|
||||
" END_INDENT
|
|
@ -0,0 +1,80 @@
|
|||
% vim: set ft=matlab sw=4 :
|
||||
|
||||
% START_INDENT
|
||||
if true
|
||||
disp foo
|
||||
elseif false
|
||||
disp bar
|
||||
end
|
||||
% END_INDENT
|
||||
|
||||
% START_INDENT
|
||||
try
|
||||
statements
|
||||
catch exception
|
||||
statements
|
||||
end
|
||||
% END_INDENT
|
||||
|
||||
% START_INDENT
|
||||
if true, ...
|
||||
if true
|
||||
disp hello
|
||||
end
|
||||
end
|
||||
% END_INDENT
|
||||
|
||||
% START_INDENT
|
||||
switch a
|
||||
case expr
|
||||
if true, foo; end
|
||||
disp hello
|
||||
otherwise
|
||||
disp bar
|
||||
end
|
||||
% END_INDENT
|
||||
|
||||
% START_INDENT
|
||||
if true
|
||||
A(1:end - 1)
|
||||
disp foo
|
||||
end
|
||||
% END_INDENT
|
||||
|
||||
% START_INDENT
|
||||
A = [{
|
||||
}
|
||||
] ...
|
||||
disp foo
|
||||
disp bar
|
||||
% END_INDENT
|
||||
|
||||
% START_INDENT
|
||||
% INDENT_EXE let b:MATLAB_function_indent = 0
|
||||
function foo
|
||||
disp foo
|
||||
function nested
|
||||
disp bar
|
||||
end
|
||||
end
|
||||
% END_INDENT
|
||||
|
||||
% START_INDENT
|
||||
% INDENT_EXE let b:MATLAB_function_indent = 1
|
||||
function foo
|
||||
disp foo
|
||||
function nested
|
||||
disp bar
|
||||
end
|
||||
end
|
||||
% END_INDENT
|
||||
|
||||
% START_INDENT
|
||||
% INDENT_EXE let b:MATLAB_function_indent = 2
|
||||
function foo
|
||||
disp foo
|
||||
function nested
|
||||
disp bar
|
||||
end
|
||||
end
|
||||
% END_INDENT
|
|
@ -0,0 +1,80 @@
|
|||
% vim: set ft=matlab sw=4 :
|
||||
|
||||
% START_INDENT
|
||||
if true
|
||||
disp foo
|
||||
elseif false
|
||||
disp bar
|
||||
end
|
||||
% END_INDENT
|
||||
|
||||
% START_INDENT
|
||||
try
|
||||
statements
|
||||
catch exception
|
||||
statements
|
||||
end
|
||||
% END_INDENT
|
||||
|
||||
% START_INDENT
|
||||
if true, ...
|
||||
if true
|
||||
disp hello
|
||||
end
|
||||
end
|
||||
% END_INDENT
|
||||
|
||||
% START_INDENT
|
||||
switch a
|
||||
case expr
|
||||
if true, foo; end
|
||||
disp hello
|
||||
otherwise
|
||||
disp bar
|
||||
end
|
||||
% END_INDENT
|
||||
|
||||
% START_INDENT
|
||||
if true
|
||||
A(1:end - 1)
|
||||
disp foo
|
||||
end
|
||||
% END_INDENT
|
||||
|
||||
% START_INDENT
|
||||
A = [{
|
||||
}
|
||||
] ...
|
||||
disp foo
|
||||
disp bar
|
||||
% END_INDENT
|
||||
|
||||
% START_INDENT
|
||||
% INDENT_EXE let b:MATLAB_function_indent = 0
|
||||
function foo
|
||||
disp foo
|
||||
function nested
|
||||
disp bar
|
||||
end
|
||||
end
|
||||
% END_INDENT
|
||||
|
||||
% START_INDENT
|
||||
% INDENT_EXE let b:MATLAB_function_indent = 1
|
||||
function foo
|
||||
disp foo
|
||||
function nested
|
||||
disp bar
|
||||
end
|
||||
end
|
||||
% END_INDENT
|
||||
|
||||
% START_INDENT
|
||||
% INDENT_EXE let b:MATLAB_function_indent = 2
|
||||
function foo
|
||||
disp foo
|
||||
function nested
|
||||
disp bar
|
||||
end
|
||||
end
|
||||
% END_INDENT
|
|
@ -0,0 +1,19 @@
|
|||
# vim: set filetype=tcl shiftwidth=4 tabstop=8 expandtab :
|
||||
|
||||
# START_INDENT
|
||||
proc abc {} {
|
||||
set a 5
|
||||
if {[some_cmd]==1} {
|
||||
foreach i [list {1 2 3}] {
|
||||
# Does this comment affect anything?
|
||||
puts $i
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
command_with_a_long_time -arg1 "First" \
|
||||
-arg2 "Second" \
|
||||
-arg3 "Third"
|
||||
|
||||
puts "Move indent back after line continuation is complete"
|
||||
# END_INDENT
|
|
@ -0,0 +1,19 @@
|
|||
# vim: set filetype=tcl shiftwidth=4 tabstop=8 expandtab :
|
||||
|
||||
# START_INDENT
|
||||
proc abc {} {
|
||||
set a 5
|
||||
if {[some_cmd]==1} {
|
||||
foreach i [list {1 2 3}] {
|
||||
# Does this comment affect anything?
|
||||
puts $i
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
command_with_a_long_time -arg1 "First" \
|
||||
-arg2 "Second" \
|
||||
-arg3 "Third"
|
||||
|
||||
puts "Move indent back after line continuation is complete"
|
||||
# END_INDENT
|
|
@ -0,0 +1,32 @@
|
|||
<!-- vim: set ft=xml ts=8 sw=0 sts=-1 et : -->
|
||||
<!-- START_INDENT -->
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<tag0>
|
||||
<tag1>
|
||||
<!-- comment -->
|
||||
<tag2>
|
||||
<tag3/>
|
||||
</tag2>
|
||||
<!-- text comment -->
|
||||
|
||||
<!--
|
||||
text comment
|
||||
-->
|
||||
</tag1>
|
||||
<!--
|
||||
text comment
|
||||
end coment -->
|
||||
</tag0>
|
||||
<!-- END_INDENT -->
|
||||
|
||||
<!-- START_INDENT -->
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<tag0>
|
||||
<tag1>
|
||||
<!-- comment -->
|
||||
<tag2>
|
||||
<tag3/>
|
||||
</tag2>
|
||||
</tag1>
|
||||
</tag0>
|
||||
<!-- END_INDENT -->
|
|
@ -0,0 +1,32 @@
|
|||
<!-- vim: set ft=xml ts=8 sw=0 sts=-1 et : -->
|
||||
<!-- START_INDENT -->
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<tag0>
|
||||
<tag1>
|
||||
<!-- comment -->
|
||||
<tag2>
|
||||
<tag3/>
|
||||
</tag2>
|
||||
<!-- text comment -->
|
||||
|
||||
<!--
|
||||
text comment
|
||||
-->
|
||||
</tag1>
|
||||
<!--
|
||||
text comment
|
||||
end coment -->
|
||||
</tag0>
|
||||
<!-- END_INDENT -->
|
||||
|
||||
<!-- START_INDENT -->
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<tag0>
|
||||
<tag1>
|
||||
<!-- comment -->
|
||||
<tag2>
|
||||
<tag3/>
|
||||
</tag2>
|
||||
</tag1>
|
||||
</tag0>
|
||||
<!-- END_INDENT -->
|
|
@ -1,13 +1,23 @@
|
|||
" Language: xml
|
||||
" Repository: https://github.com/chrisbra/vim-xml-ftplugin
|
||||
" Maintainer: Christian Brabandt <cb@256bit.org>
|
||||
" Previous Maintainer: Johannes Zellner <johannes@zellner.org>
|
||||
" Last Change: 20180724 - Correctly indent xml comments https://github.com/vim/vim/issues/3200
|
||||
" Notes: 1) does not indent pure non-xml code (e.g. embedded scripts)
|
||||
" 2) will be confused by unbalanced tags in comments
|
||||
" or CDATA sections.
|
||||
" 2009-05-26 patch by Nikolai Weibull
|
||||
" TODO: implement pre-like tags, see xml_indent_open / xml_indent_close
|
||||
" Language: xml
|
||||
" Repository: https://github.com/chrisbra/vim-xml-ftplugin
|
||||
" Last Changed: Jan 28, 2019
|
||||
" Maintainer: Christian Brabandt <cb@256bit.org>
|
||||
" Previous Maintainer: Johannes Zellner <johannes@zellner.org>
|
||||
" Last Change:
|
||||
" 20190128 - Make sure to find previous tag
|
||||
" https://github.com/chrisbra/vim-xml-ftplugin/issues/4
|
||||
" 20181116 - Fix indentation when tags start with a colon or an underscore
|
||||
" https://github.com/vim/vim/pull/926
|
||||
" 20181022 - Do not overwrite indentkeys setting
|
||||
" https://github.com/chrisbra/vim-xml-ftplugin/issues/1
|
||||
" 20180724 - Correctly indent xml comments https://github.com/vim/vim/issues/3200
|
||||
"
|
||||
" Notes:
|
||||
" 1) does not indent pure non-xml code (e.g. embedded scripts)
|
||||
" 2) will be confused by unbalanced tags in comments
|
||||
" or CDATA sections.
|
||||
" 2009-05-26 patch by Nikolai Weibull
|
||||
" TODO: implement pre-like tags, see xml_indent_open / xml_indent_close
|
||||
|
||||
" Only load this indent file when no other was loaded.
|
||||
if exists("b:did_indent")
|
||||
|
@ -18,11 +28,12 @@ let s:keepcpo= &cpo
|
|||
set cpo&vim
|
||||
|
||||
" [-- local settings (must come before aborting the script) --]
|
||||
" Attention: Parameter use_syntax_check is used by the docbk.vim indent script
|
||||
setlocal indentexpr=XmlIndentGet(v:lnum,1)
|
||||
setlocal indentkeys=o,O,*<Return>,<>>,<<>,/,{,}
|
||||
setlocal indentkeys=o,O,*<Return>,<>>,<<>,/,{,},!^F
|
||||
|
||||
if !exists('b:xml_indent_open')
|
||||
let b:xml_indent_open = '.\{-}<\a'
|
||||
let b:xml_indent_open = '.\{-}<[:A-Z_a-z]'
|
||||
" pre tag, e.g. <address>
|
||||
" let b:xml_indent_open = '.\{-}<[/]\@!\(address\)\@!'
|
||||
endif
|
||||
|
@ -38,7 +49,7 @@ unlet s:keepcpo
|
|||
|
||||
" [-- finish, if the function already exists --]
|
||||
if exists('*XmlIndentGet')
|
||||
finish
|
||||
finish
|
||||
endif
|
||||
|
||||
let s:keepcpo= &cpo
|
||||
|
@ -51,13 +62,13 @@ endfun
|
|||
|
||||
" [-- check if it's xml --]
|
||||
fun! <SID>XmlIndentSynCheck(lnum)
|
||||
if '' != &syntax
|
||||
let syn1 = synIDattr(synID(a:lnum, 1, 1), 'name')
|
||||
let syn2 = synIDattr(synID(a:lnum, strlen(getline(a:lnum)) - 1, 1), 'name')
|
||||
if '' != syn1 && syn1 !~ 'xml' && '' != syn2 && syn2 !~ 'xml'
|
||||
" don't indent pure non-xml code
|
||||
return 0
|
||||
endif
|
||||
if &syntax != ''
|
||||
let syn1 = synIDattr(synID(a:lnum, 1, 1), 'name')
|
||||
let syn2 = synIDattr(synID(a:lnum, strlen(getline(a:lnum)) - 1, 1), 'name')
|
||||
if syn1 != '' && syn1 !~ 'xml' && syn2 != '' && syn2 !~ 'xml'
|
||||
" don't indent pure non-xml code
|
||||
return 0
|
||||
endif
|
||||
endif
|
||||
return 1
|
||||
endfun
|
||||
|
@ -66,41 +77,73 @@ endfun
|
|||
fun! <SID>XmlIndentSum(lnum, style, add)
|
||||
let line = getline(a:lnum)
|
||||
if a:style == match(line, '^\s*</')
|
||||
return (shiftwidth() *
|
||||
\ (<SID>XmlIndentWithPattern(line, b:xml_indent_open)
|
||||
\ - <SID>XmlIndentWithPattern(line, b:xml_indent_close)
|
||||
\ - <SID>XmlIndentWithPattern(line, '.\{-}/>'))) + a:add
|
||||
return (shiftwidth() *
|
||||
\ (<SID>XmlIndentWithPattern(line, b:xml_indent_open)
|
||||
\ - <SID>XmlIndentWithPattern(line, b:xml_indent_close)
|
||||
\ - <SID>XmlIndentWithPattern(line, '.\{-}/>'))) + a:add
|
||||
else
|
||||
return a:add
|
||||
return a:add
|
||||
endif
|
||||
endfun
|
||||
|
||||
" Main indent function
|
||||
fun! XmlIndentGet(lnum, use_syntax_check)
|
||||
" Find a non-empty line above the current line.
|
||||
let lnum = prevnonblank(a:lnum - 1)
|
||||
|
||||
let plnum = prevnonblank(a:lnum - 1)
|
||||
" Hit the start of the file, use zero indent.
|
||||
if lnum == 0
|
||||
return 0
|
||||
if plnum == 0
|
||||
return 0
|
||||
endif
|
||||
" Find previous line with a tag (regardless whether open or closed,
|
||||
" but always start restrict the match to a line before the current one
|
||||
let ptag_pattern = '\%(.\{-}<[/:A-Z_a-z]\)'. '\%(\&\%<'. line('.').'l\)'
|
||||
let ptag = search(ptag_pattern, 'bnw')
|
||||
|
||||
let syn_name = ''
|
||||
if a:use_syntax_check
|
||||
let check_lnum = <SID>XmlIndentSynCheck(lnum)
|
||||
let check_alnum = <SID>XmlIndentSynCheck(a:lnum)
|
||||
if 0 == check_lnum || 0 == check_alnum
|
||||
return indent(a:lnum)
|
||||
elseif -1 == check_lnum || -1 == check_alnum
|
||||
return -1
|
||||
endif
|
||||
let check_lnum = <SID>XmlIndentSynCheck(plnum)
|
||||
let check_alnum = <SID>XmlIndentSynCheck(a:lnum)
|
||||
if check_lnum == 0 || check_alnum == 0
|
||||
return indent(a:lnum)
|
||||
endif
|
||||
let syn_name = synIDattr(synID(a:lnum, strlen(getline(a:lnum)) - 1, 1), 'name')
|
||||
endif
|
||||
|
||||
let ind = <SID>XmlIndentSum(lnum, -1, indent(lnum))
|
||||
let ind = <SID>XmlIndentSum(a:lnum, 0, ind)
|
||||
if syn_name =~ 'Comment'
|
||||
return <SID>XmlIndentComment(a:lnum)
|
||||
endif
|
||||
|
||||
" Get indent from previous tag line
|
||||
let ind = <SID>XmlIndentSum(ptag, -1, indent(ptag))
|
||||
" Determine indent from current line
|
||||
let ind = <SID>XmlIndentSum(a:lnum, 0, ind)
|
||||
return ind
|
||||
endfun
|
||||
|
||||
" return indent for a commented line,
|
||||
" the middle part might be indented on additional level
|
||||
func! <SID>XmlIndentComment(lnum)
|
||||
let ptagopen = search(b:xml_indent_open, 'bnw')
|
||||
let ptagclose = search(b:xml_indent_close, 'bnw')
|
||||
if getline(a:lnum) =~ '<!--'
|
||||
" if previous tag was a closing tag, do not add
|
||||
" one additional level of indent
|
||||
if ptagclose > ptagopen && a:lnum > ptagclose
|
||||
return indent(ptagclose)
|
||||
else
|
||||
" start of comment, add one indentation level
|
||||
return indent(ptagopen) + shiftwidth()
|
||||
endif
|
||||
elseif getline(a:lnum) =~ '-->'
|
||||
" end of comment, same as start of comment
|
||||
return indent(search('<!--', 'bnw'))
|
||||
else
|
||||
" middle part of comment, add one additional level
|
||||
return indent(search('<!--', 'bnw')) + shiftwidth()
|
||||
endif
|
||||
endfunc
|
||||
|
||||
let &cpo = s:keepcpo
|
||||
unlet s:keepcpo
|
||||
|
||||
" vim:ts=8
|
||||
" vim:ts=4 et sts=-1 sw=0
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
" You can also use this as a start for your own set of menus.
|
||||
"
|
||||
" Maintainer: Bram Moolenaar <Bram@vim.org>
|
||||
" Last Change: 2018 May 17
|
||||
" Last Change: 2019 Jan 27
|
||||
|
||||
" Note that ":an" (short for ":anoremenu") is often used to make a menu work
|
||||
" in all modes and avoid side effects from mappings defined by the user.
|
||||
|
@ -853,17 +853,15 @@ an 70.300 &Window.&New<Tab>^Wn <C-W>n
|
|||
an 70.310 &Window.S&plit<Tab>^Ws <C-W>s
|
||||
an 70.320 &Window.Sp&lit\ To\ #<Tab>^W^^ <C-W><C-^>
|
||||
an 70.330 &Window.Split\ &Vertically<Tab>^Wv <C-W>v
|
||||
if has("vertsplit")
|
||||
an <silent> 70.332 &Window.Split\ File\ E&xplorer :call MenuExplOpen()<CR>
|
||||
if !exists("*MenuExplOpen")
|
||||
fun MenuExplOpen()
|
||||
if @% == ""
|
||||
20vsp .
|
||||
else
|
||||
exe "20vsp " . s:FnameEscape(expand("%:p:h"))
|
||||
endif
|
||||
endfun
|
||||
endif
|
||||
an <silent> 70.332 &Window.Split\ File\ E&xplorer :call MenuExplOpen()<CR>
|
||||
if !exists("*MenuExplOpen")
|
||||
fun MenuExplOpen()
|
||||
if @% == ""
|
||||
20vsp .
|
||||
else
|
||||
exe "20vsp " . s:FnameEscape(expand("%:p:h"))
|
||||
endif
|
||||
endfun
|
||||
endif
|
||||
an 70.335 &Window.-SEP1- <Nop>
|
||||
an 70.340 &Window.&Close<Tab>^Wc :confirm close<CR>
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
" Set options and add mapping such that Vim behaves a lot like MS-Windows
|
||||
"
|
||||
" Maintainer: Bram Moolenaar <Bram@vim.org>
|
||||
" Last change: 2017 Oct 28
|
||||
" Last Change: 2018 Dec 07
|
||||
|
||||
" bail out if this isn't wanted (mrsvim.vim uses this).
|
||||
" Bail out if this isn't wanted.
|
||||
if exists("g:skip_loading_mswin") && g:skip_loading_mswin
|
||||
finish
|
||||
endif
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
" These commands create the option window.
|
||||
"
|
||||
" Maintainer: Bram Moolenaar <Bram@vim.org>
|
||||
" Last Change: 2018 May 15
|
||||
" Last Change: 2019 Jan 27
|
||||
|
||||
" If there already is an option window, jump to that one.
|
||||
let buf = bufnr('option-window')
|
||||
|
@ -395,11 +395,9 @@ endif
|
|||
call <SID>Header("syntax, highlighting and spelling")
|
||||
call append("$", "background\t\"dark\" or \"light\"; the background color brightness")
|
||||
call <SID>OptionG("bg", &bg)
|
||||
if has("autocmd")
|
||||
call append("$", "filetype\ttype of file; triggers the FileType event when set")
|
||||
call append("$", "\t(local to buffer)")
|
||||
call <SID>OptionL("ft")
|
||||
endif
|
||||
call append("$", "filetype\ttype of file; triggers the FileType event when set")
|
||||
call append("$", "\t(local to buffer)")
|
||||
call <SID>OptionL("ft")
|
||||
if has("syntax")
|
||||
call append("$", "syntax\tname of syntax highlighting used")
|
||||
call append("$", "\t(local to buffer)")
|
||||
|
@ -454,10 +452,8 @@ if has("statusline")
|
|||
endif
|
||||
call append("$", "equalalways\tmake all windows the same size when adding/removing windows")
|
||||
call <SID>BinOptionG("ea", &ea)
|
||||
if has("vertsplit")
|
||||
call append("$", "eadirection\tin which direction 'equalalways' works: \"ver\", \"hor\" or \"both\"")
|
||||
call <SID>OptionG("ead", &ead)
|
||||
endif
|
||||
call append("$", "eadirection\tin which direction 'equalalways' works: \"ver\", \"hor\" or \"both\"")
|
||||
call <SID>OptionG("ead", &ead)
|
||||
call append("$", "winheight\tminimal number of lines used for the current window")
|
||||
call append("$", " \tset wh=" . &wh)
|
||||
call append("$", "winminheight\tminimal number of lines used for any window")
|
||||
|
@ -465,15 +461,13 @@ call append("$", " \tset wmh=" . &wmh)
|
|||
call append("$", "winfixheight\tkeep the height of the window")
|
||||
call append("$", "\t(local to window)")
|
||||
call <SID>BinOptionL("wfh")
|
||||
if has("vertsplit")
|
||||
call append("$", "winfixwidth\tkeep the width of the window")
|
||||
call append("$", "\t(local to window)")
|
||||
call <SID>BinOptionL("wfw")
|
||||
call append("$", "winwidth\tminimal number of columns used for the current window")
|
||||
call append("$", " \tset wiw=" . &wiw)
|
||||
call append("$", "winminwidth\tminimal number of columns used for any window")
|
||||
call append("$", " \tset wmw=" . &wmw)
|
||||
endif
|
||||
call append("$", "winwidth\tminimal number of columns used for the current window")
|
||||
call append("$", " \tset wiw=" . &wiw)
|
||||
call append("$", "winminwidth\tminimal number of columns used for any window")
|
||||
call append("$", " \tset wmw=" . &wmw)
|
||||
call append("$", "helpheight\tinitial height of the help window")
|
||||
call append("$", " \tset hh=" . &hh)
|
||||
if has("quickfix")
|
||||
|
@ -490,22 +484,16 @@ call append("$", "\tto a buffer")
|
|||
call <SID>OptionG("swb", &swb)
|
||||
call append("$", "splitbelow\ta new window is put below the current one")
|
||||
call <SID>BinOptionG("sb", &sb)
|
||||
if has("vertsplit")
|
||||
call append("$", "splitright\ta new window is put right of the current one")
|
||||
call <SID>BinOptionG("spr", &spr)
|
||||
endif
|
||||
if has("scrollbind")
|
||||
call append("$", "scrollbind\tthis window scrolls together with other bound windows")
|
||||
call append("$", "\t(local to window)")
|
||||
call <SID>BinOptionL("scb")
|
||||
call append("$", "scrollopt\t\"ver\", \"hor\" and/or \"jump\"; list of options for 'scrollbind'")
|
||||
call <SID>OptionG("sbo", &sbo)
|
||||
endif
|
||||
if has("cursorbind")
|
||||
call append("$", "cursorbind\tthis window's cursor moves together with other bound windows")
|
||||
call append("$", "\t(local to window)")
|
||||
call <SID>BinOptionL("crb")
|
||||
endif
|
||||
call append("$", "splitright\ta new window is put right of the current one")
|
||||
call <SID>BinOptionG("spr", &spr)
|
||||
call append("$", "scrollbind\tthis window scrolls together with other bound windows")
|
||||
call append("$", "\t(local to window)")
|
||||
call <SID>BinOptionL("scb")
|
||||
call append("$", "scrollopt\t\"ver\", \"hor\" and/or \"jump\"; list of options for 'scrollbind'")
|
||||
call <SID>OptionG("sbo", &sbo)
|
||||
call append("$", "cursorbind\tthis window's cursor moves together with other bound windows")
|
||||
call append("$", "\t(local to window)")
|
||||
call <SID>BinOptionL("crb")
|
||||
if has("terminal")
|
||||
call append("$", "termsize\tsize of a terminal window")
|
||||
call append("$", "\t(local to window)")
|
||||
|
@ -1040,12 +1028,10 @@ if has("wildmenu")
|
|||
call append("$", "wildmenu\tcommand-line completion shows a list of matches")
|
||||
call <SID>BinOptionG("wmnu", &wmnu)
|
||||
endif
|
||||
if has("vertsplit")
|
||||
call append("$", "cedit\tkey used to open the command-line window")
|
||||
call <SID>OptionG("cedit", &cedit)
|
||||
call append("$", "cmdwinheight\theight of the command-line window")
|
||||
call <SID>OptionG("cwh", &cwh)
|
||||
endif
|
||||
call append("$", "cedit\tkey used to open the command-line window")
|
||||
call <SID>OptionG("cedit", &cedit)
|
||||
call append("$", "cmdwinheight\theight of the command-line window")
|
||||
call <SID>OptionG("cwh", &cwh)
|
||||
|
||||
|
||||
call <SID>Header("executing external commands")
|
||||
|
@ -1208,14 +1194,10 @@ endif
|
|||
|
||||
|
||||
call <SID>Header("various")
|
||||
if has("virtualedit")
|
||||
call append("$", "virtualedit\twhen to use virtual editing: \"block\", \"insert\" and/or \"all\"")
|
||||
call <SID>OptionG("ve", &ve)
|
||||
endif
|
||||
if has("autocmd")
|
||||
call append("$", "eventignore\tlist of autocommand events which are to be ignored")
|
||||
call <SID>OptionG("ei", &ei)
|
||||
endif
|
||||
call append("$", "virtualedit\twhen to use virtual editing: \"block\", \"insert\" and/or \"all\"")
|
||||
call <SID>OptionG("ve", &ve)
|
||||
call append("$", "eventignore\tlist of autocommand events which are to be ignored")
|
||||
call <SID>OptionG("ei", &ei)
|
||||
call append("$", "loadplugins\tload plugin scripts when starting up")
|
||||
call <SID>BinOptionG("lpl", &lpl)
|
||||
call append("$", "exrc\tenable reading .vimrc/.exrc/.gvimrc in the current directory")
|
||||
|
|
|
@ -0,0 +1,754 @@
|
|||
" matchit.vim: (global plugin) Extended "%" matching
|
||||
" autload script of matchit plugin, see ../plugin/matchit.vim
|
||||
" Last Change: 2019 Jan 28
|
||||
|
||||
let s:last_mps = ""
|
||||
let s:last_words = ":"
|
||||
let s:patBR = ""
|
||||
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
" Auto-complete mappings: (not yet "ready for prime time")
|
||||
" TODO Read :help write-plugin for the "right" way to let the user
|
||||
" specify a key binding.
|
||||
" let g:match_auto = '<C-]>'
|
||||
" let g:match_autoCR = '<C-CR>'
|
||||
" if exists("g:match_auto")
|
||||
" execute "inoremap " . g:match_auto . ' x<Esc>"=<SID>Autocomplete()<CR>Pls'
|
||||
" endif
|
||||
" if exists("g:match_autoCR")
|
||||
" execute "inoremap " . g:match_autoCR . ' <CR><C-R>=<SID>Autocomplete()<CR>'
|
||||
" endif
|
||||
" if exists("g:match_gthhoh")
|
||||
" execute "inoremap " . g:match_gthhoh . ' <C-O>:call <SID>Gthhoh()<CR>'
|
||||
" endif " gthhoh = "Get the heck out of here!"
|
||||
|
||||
let s:notslash = '\\\@1<!\%(\\\\\)*'
|
||||
|
||||
function s:RestoreOptions()
|
||||
" In s:CleanUp(), :execute "set" restore_options .
|
||||
let restore_options = ""
|
||||
if get(b:, 'match_ignorecase', &ic) != &ic
|
||||
let restore_options .= (&ic ? " " : " no") . "ignorecase"
|
||||
let &ignorecase = b:match_ignorecase
|
||||
endif
|
||||
if &ve != ''
|
||||
let restore_options = " ve=" . &ve . restore_options
|
||||
set ve=
|
||||
endif
|
||||
return restore_options
|
||||
endfunction
|
||||
|
||||
function matchit#Match_wrapper(word, forward, mode) range
|
||||
let restore_options = s:RestoreOptions()
|
||||
" If this function was called from Visual mode, make sure that the cursor
|
||||
" is at the correct end of the Visual range:
|
||||
if a:mode == "v"
|
||||
execute "normal! gv\<Esc>"
|
||||
elseif a:mode == "o" && mode(1) !~# '[vV]'
|
||||
exe "norm! v"
|
||||
endif
|
||||
" In s:CleanUp(), we may need to check whether the cursor moved forward.
|
||||
let startpos = [line("."), col(".")]
|
||||
" Use default behavior if called with a count.
|
||||
if v:count
|
||||
exe "normal! " . v:count . "%"
|
||||
return s:CleanUp(restore_options, a:mode, startpos)
|
||||
end
|
||||
|
||||
" First step: if not already done, set the script variables
|
||||
" s:do_BR flag for whether there are backrefs
|
||||
" s:pat parsed version of b:match_words
|
||||
" s:all regexp based on s:pat and the default groups
|
||||
if !exists("b:match_words") || b:match_words == ""
|
||||
let match_words = ""
|
||||
elseif b:match_words =~ ":"
|
||||
let match_words = b:match_words
|
||||
else
|
||||
" Allow b:match_words = "GetVimMatchWords()" .
|
||||
execute "let match_words =" b:match_words
|
||||
endif
|
||||
" Thanks to Preben "Peppe" Guldberg and Bram Moolenaar for this suggestion!
|
||||
if (match_words != s:last_words) || (&mps != s:last_mps)
|
||||
\ || exists("b:match_debug")
|
||||
let s:last_mps = &mps
|
||||
" quote the special chars in 'matchpairs', replace [,:] with \| and then
|
||||
" append the builtin pairs (/*, */, #if, #ifdef, #ifndef, #else, #elif,
|
||||
" #endif)
|
||||
let default = escape(&mps, '[$^.*~\\/?]') . (strlen(&mps) ? "," : "") .
|
||||
\ '\/\*:\*\/,#\s*if\%(n\=def\)\=:#\s*else\>:#\s*elif\>:#\s*endif\>'
|
||||
" s:all = pattern with all the keywords
|
||||
let match_words = match_words . (strlen(match_words) ? "," : "") . default
|
||||
let s:last_words = match_words
|
||||
if match_words !~ s:notslash . '\\\d'
|
||||
let s:do_BR = 0
|
||||
let s:pat = match_words
|
||||
else
|
||||
let s:do_BR = 1
|
||||
let s:pat = s:ParseWords(match_words)
|
||||
endif
|
||||
let s:all = substitute(s:pat, s:notslash . '\zs[,:]\+', '\\|', 'g')
|
||||
" Just in case there are too many '\(...)' groups inside the pattern, make
|
||||
" sure to use \%(...) groups, so that error E872 can be avoided
|
||||
let s:all = substitute(s:all, '\\(', '\\%(', 'g')
|
||||
let s:all = '\%(' . s:all . '\)'
|
||||
if exists("b:match_debug")
|
||||
let b:match_pat = s:pat
|
||||
endif
|
||||
" Reconstruct the version with unresolved backrefs.
|
||||
let s:patBR = substitute(match_words.',',
|
||||
\ s:notslash.'\zs[,:]*,[,:]*', ',', 'g')
|
||||
let s:patBR = substitute(s:patBR, s:notslash.'\zs:\{2,}', ':', 'g')
|
||||
endif
|
||||
|
||||
" Second step: set the following local variables:
|
||||
" matchline = line on which the cursor started
|
||||
" curcol = number of characters before match
|
||||
" prefix = regexp for start of line to start of match
|
||||
" suffix = regexp for end of match to end of line
|
||||
" Require match to end on or after the cursor and prefer it to
|
||||
" start on or before the cursor.
|
||||
let matchline = getline(startpos[0])
|
||||
if a:word != ''
|
||||
" word given
|
||||
if a:word !~ s:all
|
||||
echohl WarningMsg|echo 'Missing rule for word:"'.a:word.'"'|echohl NONE
|
||||
return s:CleanUp(restore_options, a:mode, startpos)
|
||||
endif
|
||||
let matchline = a:word
|
||||
let curcol = 0
|
||||
let prefix = '^\%('
|
||||
let suffix = '\)$'
|
||||
" Now the case when "word" is not given
|
||||
else " Find the match that ends on or after the cursor and set curcol.
|
||||
let regexp = s:Wholematch(matchline, s:all, startpos[1]-1)
|
||||
let curcol = match(matchline, regexp)
|
||||
" If there is no match, give up.
|
||||
if curcol == -1
|
||||
return s:CleanUp(restore_options, a:mode, startpos)
|
||||
endif
|
||||
let endcol = matchend(matchline, regexp)
|
||||
let suf = strlen(matchline) - endcol
|
||||
let prefix = (curcol ? '^.*\%' . (curcol + 1) . 'c\%(' : '^\%(')
|
||||
let suffix = (suf ? '\)\%' . (endcol + 1) . 'c.*$' : '\)$')
|
||||
endif
|
||||
if exists("b:match_debug")
|
||||
let b:match_match = matchstr(matchline, regexp)
|
||||
let b:match_col = curcol+1
|
||||
endif
|
||||
|
||||
" Third step: Find the group and single word that match, and the original
|
||||
" (backref) versions of these. Then, resolve the backrefs.
|
||||
" Set the following local variable:
|
||||
" group = colon-separated list of patterns, one of which matches
|
||||
" = ini:mid:fin or ini:fin
|
||||
"
|
||||
" Now, set group and groupBR to the matching group: 'if:endif' or
|
||||
" 'while:endwhile' or whatever. A bit of a kluge: s:Choose() returns
|
||||
" group . "," . groupBR, and we pick it apart.
|
||||
let group = s:Choose(s:pat, matchline, ",", ":", prefix, suffix, s:patBR)
|
||||
let i = matchend(group, s:notslash . ",")
|
||||
let groupBR = strpart(group, i)
|
||||
let group = strpart(group, 0, i-1)
|
||||
" Now, matchline =~ prefix . substitute(group,':','\|','g') . suffix
|
||||
if s:do_BR " Do the hard part: resolve those backrefs!
|
||||
let group = s:InsertRefs(groupBR, prefix, group, suffix, matchline)
|
||||
endif
|
||||
if exists("b:match_debug")
|
||||
let b:match_wholeBR = groupBR
|
||||
let i = matchend(groupBR, s:notslash . ":")
|
||||
let b:match_iniBR = strpart(groupBR, 0, i-1)
|
||||
endif
|
||||
|
||||
" Fourth step: Set the arguments for searchpair().
|
||||
let i = matchend(group, s:notslash . ":")
|
||||
let j = matchend(group, '.*' . s:notslash . ":")
|
||||
let ini = strpart(group, 0, i-1)
|
||||
let mid = substitute(strpart(group, i,j-i-1), s:notslash.'\zs:', '\\|', 'g')
|
||||
let fin = strpart(group, j)
|
||||
"Un-escape the remaining , and : characters.
|
||||
let ini = substitute(ini, s:notslash . '\zs\\\(:\|,\)', '\1', 'g')
|
||||
let mid = substitute(mid, s:notslash . '\zs\\\(:\|,\)', '\1', 'g')
|
||||
let fin = substitute(fin, s:notslash . '\zs\\\(:\|,\)', '\1', 'g')
|
||||
" searchpair() requires that these patterns avoid \(\) groups.
|
||||
let ini = substitute(ini, s:notslash . '\zs\\(', '\\%(', 'g')
|
||||
let mid = substitute(mid, s:notslash . '\zs\\(', '\\%(', 'g')
|
||||
let fin = substitute(fin, s:notslash . '\zs\\(', '\\%(', 'g')
|
||||
" Set mid. This is optimized for readability, not micro-efficiency!
|
||||
if a:forward && matchline =~ prefix . fin . suffix
|
||||
\ || !a:forward && matchline =~ prefix . ini . suffix
|
||||
let mid = ""
|
||||
endif
|
||||
" Set flag. This is optimized for readability, not micro-efficiency!
|
||||
if a:forward && matchline =~ prefix . fin . suffix
|
||||
\ || !a:forward && matchline !~ prefix . ini . suffix
|
||||
let flag = "bW"
|
||||
else
|
||||
let flag = "W"
|
||||
endif
|
||||
" Set skip.
|
||||
if exists("b:match_skip")
|
||||
let skip = b:match_skip
|
||||
elseif exists("b:match_comment") " backwards compatibility and testing!
|
||||
let skip = "r:" . b:match_comment
|
||||
else
|
||||
let skip = 's:comment\|string'
|
||||
endif
|
||||
let skip = s:ParseSkip(skip)
|
||||
if exists("b:match_debug")
|
||||
let b:match_ini = ini
|
||||
let b:match_tail = (strlen(mid) ? mid.'\|' : '') . fin
|
||||
endif
|
||||
|
||||
" Fifth step: actually start moving the cursor and call searchpair().
|
||||
" Later, :execute restore_cursor to get to the original screen.
|
||||
let view = winsaveview()
|
||||
call cursor(0, curcol + 1)
|
||||
if skip =~ 'synID' && !(has("syntax") && exists("g:syntax_on"))
|
||||
let skip = "0"
|
||||
else
|
||||
execute "if " . skip . "| let skip = '0' | endif"
|
||||
endif
|
||||
let sp_return = searchpair(ini, mid, fin, flag, skip)
|
||||
let final_position = "call cursor(" . line(".") . "," . col(".") . ")"
|
||||
" Restore cursor position and original screen.
|
||||
call winrestview(view)
|
||||
normal! m'
|
||||
if sp_return > 0
|
||||
execute final_position
|
||||
endif
|
||||
return s:CleanUp(restore_options, a:mode, startpos, mid.'\|'.fin)
|
||||
endfun
|
||||
|
||||
" Restore options and do some special handling for Operator-pending mode.
|
||||
" The optional argument is the tail of the matching group.
|
||||
fun! s:CleanUp(options, mode, startpos, ...)
|
||||
if strlen(a:options)
|
||||
execute "set" a:options
|
||||
endif
|
||||
" Open folds, if appropriate.
|
||||
if a:mode != "o"
|
||||
if &foldopen =~ "percent"
|
||||
normal! zv
|
||||
endif
|
||||
" In Operator-pending mode, we want to include the whole match
|
||||
" (for example, d%).
|
||||
" This is only a problem if we end up moving in the forward direction.
|
||||
elseif (a:startpos[0] < line(".")) ||
|
||||
\ (a:startpos[0] == line(".") && a:startpos[1] < col("."))
|
||||
if a:0
|
||||
" Check whether the match is a single character. If not, move to the
|
||||
" end of the match.
|
||||
let matchline = getline(".")
|
||||
let currcol = col(".")
|
||||
let regexp = s:Wholematch(matchline, a:1, currcol-1)
|
||||
let endcol = matchend(matchline, regexp)
|
||||
if endcol > currcol " This is NOT off by one!
|
||||
call cursor(0, endcol)
|
||||
endif
|
||||
endif " a:0
|
||||
endif " a:mode != "o" && etc.
|
||||
return 0
|
||||
endfun
|
||||
|
||||
" Example (simplified HTML patterns): if
|
||||
" a:groupBR = '<\(\k\+\)>:</\1>'
|
||||
" a:prefix = '^.\{3}\('
|
||||
" a:group = '<\(\k\+\)>:</\(\k\+\)>'
|
||||
" a:suffix = '\).\{2}$'
|
||||
" a:matchline = "123<tag>12" or "123</tag>12"
|
||||
" then extract "tag" from a:matchline and return "<tag>:</tag>" .
|
||||
fun! s:InsertRefs(groupBR, prefix, group, suffix, matchline)
|
||||
if a:matchline !~ a:prefix .
|
||||
\ substitute(a:group, s:notslash . '\zs:', '\\|', 'g') . a:suffix
|
||||
return a:group
|
||||
endif
|
||||
let i = matchend(a:groupBR, s:notslash . ':')
|
||||
let ini = strpart(a:groupBR, 0, i-1)
|
||||
let tailBR = strpart(a:groupBR, i)
|
||||
let word = s:Choose(a:group, a:matchline, ":", "", a:prefix, a:suffix,
|
||||
\ a:groupBR)
|
||||
let i = matchend(word, s:notslash . ":")
|
||||
let wordBR = strpart(word, i)
|
||||
let word = strpart(word, 0, i-1)
|
||||
" Now, a:matchline =~ a:prefix . word . a:suffix
|
||||
if wordBR != ini
|
||||
let table = s:Resolve(ini, wordBR, "table")
|
||||
else
|
||||
let table = ""
|
||||
let d = 0
|
||||
while d < 10
|
||||
if tailBR =~ s:notslash . '\\' . d
|
||||
let table = table . d
|
||||
else
|
||||
let table = table . "-"
|
||||
endif
|
||||
let d = d + 1
|
||||
endwhile
|
||||
endif
|
||||
let d = 9
|
||||
while d
|
||||
if table[d] != "-"
|
||||
let backref = substitute(a:matchline, a:prefix.word.a:suffix,
|
||||
\ '\'.table[d], "")
|
||||
" Are there any other characters that should be escaped?
|
||||
let backref = escape(backref, '*,:')
|
||||
execute s:Ref(ini, d, "start", "len")
|
||||
let ini = strpart(ini, 0, start) . backref . strpart(ini, start+len)
|
||||
let tailBR = substitute(tailBR, s:notslash . '\zs\\' . d,
|
||||
\ escape(backref, '\\&'), 'g')
|
||||
endif
|
||||
let d = d-1
|
||||
endwhile
|
||||
if exists("b:match_debug")
|
||||
if s:do_BR
|
||||
let b:match_table = table
|
||||
let b:match_word = word
|
||||
else
|
||||
let b:match_table = ""
|
||||
let b:match_word = ""
|
||||
endif
|
||||
endif
|
||||
return ini . ":" . tailBR
|
||||
endfun
|
||||
|
||||
" Input a comma-separated list of groups with backrefs, such as
|
||||
" a:groups = '\(foo\):end\1,\(bar\):end\1'
|
||||
" and return a comma-separated list of groups with backrefs replaced:
|
||||
" return '\(foo\):end\(foo\),\(bar\):end\(bar\)'
|
||||
fun! s:ParseWords(groups)
|
||||
let groups = substitute(a:groups.",", s:notslash.'\zs[,:]*,[,:]*', ',', 'g')
|
||||
let groups = substitute(groups, s:notslash . '\zs:\{2,}', ':', 'g')
|
||||
let parsed = ""
|
||||
while groups =~ '[^,:]'
|
||||
let i = matchend(groups, s:notslash . ':')
|
||||
let j = matchend(groups, s:notslash . ',')
|
||||
let ini = strpart(groups, 0, i-1)
|
||||
let tail = strpart(groups, i, j-i-1) . ":"
|
||||
let groups = strpart(groups, j)
|
||||
let parsed = parsed . ini
|
||||
let i = matchend(tail, s:notslash . ':')
|
||||
while i != -1
|
||||
" In 'if:else:endif', ini='if' and word='else' and then word='endif'.
|
||||
let word = strpart(tail, 0, i-1)
|
||||
let tail = strpart(tail, i)
|
||||
let i = matchend(tail, s:notslash . ':')
|
||||
let parsed = parsed . ":" . s:Resolve(ini, word, "word")
|
||||
endwhile " Now, tail has been used up.
|
||||
let parsed = parsed . ","
|
||||
endwhile " groups =~ '[^,:]'
|
||||
let parsed = substitute(parsed, ',$', '', '')
|
||||
return parsed
|
||||
endfun
|
||||
|
||||
" TODO I think this can be simplified and/or made more efficient.
|
||||
" TODO What should I do if a:start is out of range?
|
||||
" Return a regexp that matches all of a:string, such that
|
||||
" matchstr(a:string, regexp) represents the match for a:pat that starts
|
||||
" as close to a:start as possible, before being preferred to after, and
|
||||
" ends after a:start .
|
||||
" Usage:
|
||||
" let regexp = s:Wholematch(getline("."), 'foo\|bar', col(".")-1)
|
||||
" let i = match(getline("."), regexp)
|
||||
" let j = matchend(getline("."), regexp)
|
||||
" let match = matchstr(getline("."), regexp)
|
||||
fun! s:Wholematch(string, pat, start)
|
||||
let group = '\%(' . a:pat . '\)'
|
||||
let prefix = (a:start ? '\(^.*\%<' . (a:start + 2) . 'c\)\zs' : '^')
|
||||
let len = strlen(a:string)
|
||||
let suffix = (a:start+1 < len ? '\(\%>'.(a:start+1).'c.*$\)\@=' : '$')
|
||||
if a:string !~ prefix . group . suffix
|
||||
let prefix = ''
|
||||
endif
|
||||
return prefix . group . suffix
|
||||
endfun
|
||||
|
||||
" No extra arguments: s:Ref(string, d) will
|
||||
" find the d'th occurrence of '\(' and return it, along with everything up
|
||||
" to and including the matching '\)'.
|
||||
" One argument: s:Ref(string, d, "start") returns the index of the start
|
||||
" of the d'th '\(' and any other argument returns the length of the group.
|
||||
" Two arguments: s:Ref(string, d, "foo", "bar") returns a string to be
|
||||
" executed, having the effect of
|
||||
" :let foo = s:Ref(string, d, "start")
|
||||
" :let bar = s:Ref(string, d, "len")
|
||||
fun! s:Ref(string, d, ...)
|
||||
let len = strlen(a:string)
|
||||
if a:d == 0
|
||||
let start = 0
|
||||
else
|
||||
let cnt = a:d
|
||||
let match = a:string
|
||||
while cnt
|
||||
let cnt = cnt - 1
|
||||
let index = matchend(match, s:notslash . '\\(')
|
||||
if index == -1
|
||||
return ""
|
||||
endif
|
||||
let match = strpart(match, index)
|
||||
endwhile
|
||||
let start = len - strlen(match)
|
||||
if a:0 == 1 && a:1 == "start"
|
||||
return start - 2
|
||||
endif
|
||||
let cnt = 1
|
||||
while cnt
|
||||
let index = matchend(match, s:notslash . '\\(\|\\)') - 1
|
||||
if index == -2
|
||||
return ""
|
||||
endif
|
||||
" Increment if an open, decrement if a ')':
|
||||
let cnt = cnt + (match[index]=="(" ? 1 : -1) " ')'
|
||||
let match = strpart(match, index+1)
|
||||
endwhile
|
||||
let start = start - 2
|
||||
let len = len - start - strlen(match)
|
||||
endif
|
||||
if a:0 == 1
|
||||
return len
|
||||
elseif a:0 == 2
|
||||
return "let " . a:1 . "=" . start . "| let " . a:2 . "=" . len
|
||||
else
|
||||
return strpart(a:string, start, len)
|
||||
endif
|
||||
endfun
|
||||
|
||||
" Count the number of disjoint copies of pattern in string.
|
||||
" If the pattern is a literal string and contains no '0' or '1' characters
|
||||
" then s:Count(string, pattern, '0', '1') should be faster than
|
||||
" s:Count(string, pattern).
|
||||
fun! s:Count(string, pattern, ...)
|
||||
let pat = escape(a:pattern, '\\')
|
||||
if a:0 > 1
|
||||
let foo = substitute(a:string, '[^'.a:pattern.']', "a:1", "g")
|
||||
let foo = substitute(a:string, pat, a:2, "g")
|
||||
let foo = substitute(foo, '[^' . a:2 . ']', "", "g")
|
||||
return strlen(foo)
|
||||
endif
|
||||
let result = 0
|
||||
let foo = a:string
|
||||
let index = matchend(foo, pat)
|
||||
while index != -1
|
||||
let result = result + 1
|
||||
let foo = strpart(foo, index)
|
||||
let index = matchend(foo, pat)
|
||||
endwhile
|
||||
return result
|
||||
endfun
|
||||
|
||||
" s:Resolve('\(a\)\(b\)', '\(c\)\2\1\1\2') should return table.word, where
|
||||
" word = '\(c\)\(b\)\(a\)\3\2' and table = '-32-------'. That is, the first
|
||||
" '\1' in target is replaced by '\(a\)' in word, table[1] = 3, and this
|
||||
" indicates that all other instances of '\1' in target are to be replaced
|
||||
" by '\3'. The hard part is dealing with nesting...
|
||||
" Note that ":" is an illegal character for source and target,
|
||||
" unless it is preceded by "\".
|
||||
fun! s:Resolve(source, target, output)
|
||||
let word = a:target
|
||||
let i = matchend(word, s:notslash . '\\\d') - 1
|
||||
let table = "----------"
|
||||
while i != -2 " There are back references to be replaced.
|
||||
let d = word[i]
|
||||
let backref = s:Ref(a:source, d)
|
||||
" The idea is to replace '\d' with backref. Before we do this,
|
||||
" replace any \(\) groups in backref with :1, :2, ... if they
|
||||
" correspond to the first, second, ... group already inserted
|
||||
" into backref. Later, replace :1 with \1 and so on. The group
|
||||
" number w+b within backref corresponds to the group number
|
||||
" s within a:source.
|
||||
" w = number of '\(' in word before the current one
|
||||
let w = s:Count(
|
||||
\ substitute(strpart(word, 0, i-1), '\\\\', '', 'g'), '\(', '1')
|
||||
let b = 1 " number of the current '\(' in backref
|
||||
let s = d " number of the current '\(' in a:source
|
||||
while b <= s:Count(substitute(backref, '\\\\', '', 'g'), '\(', '1')
|
||||
\ && s < 10
|
||||
if table[s] == "-"
|
||||
if w + b < 10
|
||||
" let table[s] = w + b
|
||||
let table = strpart(table, 0, s) . (w+b) . strpart(table, s+1)
|
||||
endif
|
||||
let b = b + 1
|
||||
let s = s + 1
|
||||
else
|
||||
execute s:Ref(backref, b, "start", "len")
|
||||
let ref = strpart(backref, start, len)
|
||||
let backref = strpart(backref, 0, start) . ":". table[s]
|
||||
\ . strpart(backref, start+len)
|
||||
let s = s + s:Count(substitute(ref, '\\\\', '', 'g'), '\(', '1')
|
||||
endif
|
||||
endwhile
|
||||
let word = strpart(word, 0, i-1) . backref . strpart(word, i+1)
|
||||
let i = matchend(word, s:notslash . '\\\d') - 1
|
||||
endwhile
|
||||
let word = substitute(word, s:notslash . '\zs:', '\\', 'g')
|
||||
if a:output == "table"
|
||||
return table
|
||||
elseif a:output == "word"
|
||||
return word
|
||||
else
|
||||
return table . word
|
||||
endif
|
||||
endfun
|
||||
|
||||
" Assume a:comma = ",". Then the format for a:patterns and a:1 is
|
||||
" a:patterns = "<pat1>,<pat2>,..."
|
||||
" a:1 = "<alt1>,<alt2>,..."
|
||||
" If <patn> is the first pattern that matches a:string then return <patn>
|
||||
" if no optional arguments are given; return <patn>,<altn> if a:1 is given.
|
||||
fun! s:Choose(patterns, string, comma, branch, prefix, suffix, ...)
|
||||
let tail = (a:patterns =~ a:comma."$" ? a:patterns : a:patterns . a:comma)
|
||||
let i = matchend(tail, s:notslash . a:comma)
|
||||
if a:0
|
||||
let alttail = (a:1 =~ a:comma."$" ? a:1 : a:1 . a:comma)
|
||||
let j = matchend(alttail, s:notslash . a:comma)
|
||||
endif
|
||||
let current = strpart(tail, 0, i-1)
|
||||
if a:branch == ""
|
||||
let currpat = current
|
||||
else
|
||||
let currpat = substitute(current, s:notslash . a:branch, '\\|', 'g')
|
||||
endif
|
||||
while a:string !~ a:prefix . currpat . a:suffix
|
||||
let tail = strpart(tail, i)
|
||||
let i = matchend(tail, s:notslash . a:comma)
|
||||
if i == -1
|
||||
return -1
|
||||
endif
|
||||
let current = strpart(tail, 0, i-1)
|
||||
if a:branch == ""
|
||||
let currpat = current
|
||||
else
|
||||
let currpat = substitute(current, s:notslash . a:branch, '\\|', 'g')
|
||||
endif
|
||||
if a:0
|
||||
let alttail = strpart(alttail, j)
|
||||
let j = matchend(alttail, s:notslash . a:comma)
|
||||
endif
|
||||
endwhile
|
||||
if a:0
|
||||
let current = current . a:comma . strpart(alttail, 0, j-1)
|
||||
endif
|
||||
return current
|
||||
endfun
|
||||
|
||||
fun! matchit#Match_debug()
|
||||
let b:match_debug = 1 " Save debugging information.
|
||||
" pat = all of b:match_words with backrefs parsed
|
||||
amenu &Matchit.&pat :echo b:match_pat<CR>
|
||||
" match = bit of text that is recognized as a match
|
||||
amenu &Matchit.&match :echo b:match_match<CR>
|
||||
" curcol = cursor column of the start of the matching text
|
||||
amenu &Matchit.&curcol :echo b:match_col<CR>
|
||||
" wholeBR = matching group, original version
|
||||
amenu &Matchit.wh&oleBR :echo b:match_wholeBR<CR>
|
||||
" iniBR = 'if' piece, original version
|
||||
amenu &Matchit.ini&BR :echo b:match_iniBR<CR>
|
||||
" ini = 'if' piece, with all backrefs resolved from match
|
||||
amenu &Matchit.&ini :echo b:match_ini<CR>
|
||||
" tail = 'else\|endif' piece, with all backrefs resolved from match
|
||||
amenu &Matchit.&tail :echo b:match_tail<CR>
|
||||
" fin = 'endif' piece, with all backrefs resolved from match
|
||||
amenu &Matchit.&word :echo b:match_word<CR>
|
||||
" '\'.d in ini refers to the same thing as '\'.table[d] in word.
|
||||
amenu &Matchit.t&able :echo '0:' . b:match_table . ':9'<CR>
|
||||
endfun
|
||||
|
||||
" Jump to the nearest unmatched "(" or "if" or "<tag>" if a:spflag == "bW"
|
||||
" or the nearest unmatched "</tag>" or "endif" or ")" if a:spflag == "W".
|
||||
" Return a "mark" for the original position, so that
|
||||
" let m = MultiMatch("bW", "n") ... call winrestview(m)
|
||||
" will return to the original position. If there is a problem, do not
|
||||
" move the cursor and return {}, unless a count is given, in which case
|
||||
" go up or down as many levels as possible and again return {}.
|
||||
" TODO This relies on the same patterns as % matching. It might be a good
|
||||
" idea to give it its own matching patterns.
|
||||
fun! matchit#MultiMatch(spflag, mode)
|
||||
let restore_options = s:RestoreOptions()
|
||||
let startpos = [line("."), col(".")]
|
||||
" save v:count1 variable, might be reset from the restore_cursor command
|
||||
let level = v:count1
|
||||
if a:mode == "o" && mode(1) !~# '[vV]'
|
||||
exe "norm! v"
|
||||
endif
|
||||
|
||||
" First step: if not already done, set the script variables
|
||||
" s:do_BR flag for whether there are backrefs
|
||||
" s:pat parsed version of b:match_words
|
||||
" s:all regexp based on s:pat and the default groups
|
||||
" This part is copied and slightly modified from matchit#Match_wrapper().
|
||||
if !exists("b:match_words") || b:match_words == ""
|
||||
let match_words = ""
|
||||
" Allow b:match_words = "GetVimMatchWords()" .
|
||||
elseif b:match_words =~ ":"
|
||||
let match_words = b:match_words
|
||||
else
|
||||
execute "let match_words =" b:match_words
|
||||
endif
|
||||
if (match_words != s:last_words) || (&mps != s:last_mps) ||
|
||||
\ exists("b:match_debug")
|
||||
let default = escape(&mps, '[$^.*~\\/?]') . (strlen(&mps) ? "," : "") .
|
||||
\ '\/\*:\*\/,#\s*if\%(n\=def\)\=:#\s*else\>:#\s*elif\>:#\s*endif\>'
|
||||
let s:last_mps = &mps
|
||||
let match_words = match_words . (strlen(match_words) ? "," : "") . default
|
||||
let s:last_words = match_words
|
||||
if match_words !~ s:notslash . '\\\d'
|
||||
let s:do_BR = 0
|
||||
let s:pat = match_words
|
||||
else
|
||||
let s:do_BR = 1
|
||||
let s:pat = s:ParseWords(match_words)
|
||||
endif
|
||||
let s:all = '\%(' . substitute(s:pat, '[,:]\+', '\\|', 'g') . '\)'
|
||||
if exists("b:match_debug")
|
||||
let b:match_pat = s:pat
|
||||
endif
|
||||
" Reconstruct the version with unresolved backrefs.
|
||||
let s:patBR = substitute(match_words.',',
|
||||
\ s:notslash.'\zs[,:]*,[,:]*', ',', 'g')
|
||||
let s:patBR = substitute(s:patBR, s:notslash.'\zs:\{2,}', ':', 'g')
|
||||
endif
|
||||
|
||||
" Second step: figure out the patterns for searchpair()
|
||||
" and save the screen, cursor position, and 'ignorecase'.
|
||||
" - TODO: A lot of this is copied from matchit#Match_wrapper().
|
||||
" - maybe even more functionality should be split off
|
||||
" - into separate functions!
|
||||
let openlist = split(s:pat . ',', s:notslash . '\zs:.\{-}' . s:notslash . ',')
|
||||
let midclolist = split(',' . s:pat, s:notslash . '\zs,.\{-}' . s:notslash . ':')
|
||||
call map(midclolist, {-> split(v:val, s:notslash . ':')})
|
||||
let closelist = []
|
||||
let middlelist = []
|
||||
call map(midclolist, {i,v -> [extend(closelist, v[-1 : -1]),
|
||||
\ extend(middlelist, v[0 : -2])]})
|
||||
call map(openlist, {i,v -> v =~# s:notslash . '\\|' ? '\%(' . v . '\)' : v})
|
||||
call map(middlelist, {i,v -> v =~# s:notslash . '\\|' ? '\%(' . v . '\)' : v})
|
||||
call map(closelist, {i,v -> v =~# s:notslash . '\\|' ? '\%(' . v . '\)' : v})
|
||||
let open = join(openlist, ',')
|
||||
let middle = join(middlelist, ',')
|
||||
let close = join(closelist, ',')
|
||||
if exists("b:match_skip")
|
||||
let skip = b:match_skip
|
||||
elseif exists("b:match_comment") " backwards compatibility and testing!
|
||||
let skip = "r:" . b:match_comment
|
||||
else
|
||||
let skip = 's:comment\|string'
|
||||
endif
|
||||
let skip = s:ParseSkip(skip)
|
||||
let view = winsaveview()
|
||||
|
||||
" Third step: call searchpair().
|
||||
" Replace '\('--but not '\\('--with '\%(' and ',' with '\|'.
|
||||
let openpat = substitute(open, '\%(' . s:notslash . '\)\@<=\\(', '\\%(', 'g')
|
||||
let openpat = substitute(openpat, ',', '\\|', 'g')
|
||||
let closepat = substitute(close, '\%(' . s:notslash . '\)\@<=\\(', '\\%(', 'g')
|
||||
let closepat = substitute(closepat, ',', '\\|', 'g')
|
||||
let middlepat = substitute(middle, '\%(' . s:notslash . '\)\@<=\\(', '\\%(', 'g')
|
||||
let middlepat = substitute(middlepat, ',', '\\|', 'g')
|
||||
|
||||
if skip =~ 'synID' && !(has("syntax") && exists("g:syntax_on"))
|
||||
let skip = '0'
|
||||
else
|
||||
try
|
||||
execute "if " . skip . "| let skip = '0' | endif"
|
||||
catch /^Vim\%((\a\+)\)\=:E363/
|
||||
" We won't find anything, so skip searching, should keep Vim responsive.
|
||||
return {}
|
||||
endtry
|
||||
endif
|
||||
mark '
|
||||
while level
|
||||
if searchpair(openpat, middlepat, closepat, a:spflag, skip) < 1
|
||||
call s:CleanUp(restore_options, a:mode, startpos)
|
||||
return {}
|
||||
endif
|
||||
let level = level - 1
|
||||
endwhile
|
||||
|
||||
" Restore options and return a string to restore the original position.
|
||||
call s:CleanUp(restore_options, a:mode, startpos)
|
||||
return view
|
||||
endfun
|
||||
|
||||
" Search backwards for "if" or "while" or "<tag>" or ...
|
||||
" and return "endif" or "endwhile" or "</tag>" or ... .
|
||||
" For now, this uses b:match_words and the same script variables
|
||||
" as matchit#Match_wrapper() . Later, it may get its own patterns,
|
||||
" either from a buffer variable or passed as arguments.
|
||||
" fun! s:Autocomplete()
|
||||
" echo "autocomplete not yet implemented :-("
|
||||
" if !exists("b:match_words") || b:match_words == ""
|
||||
" return ""
|
||||
" end
|
||||
" let startpos = matchit#MultiMatch("bW")
|
||||
"
|
||||
" if startpos == ""
|
||||
" return ""
|
||||
" endif
|
||||
" " - TODO: figure out whether 'if' or '<tag>' matched, and construct
|
||||
" " - the appropriate closing.
|
||||
" let matchline = getline(".")
|
||||
" let curcol = col(".") - 1
|
||||
" " - TODO: Change the s:all argument if there is a new set of match pats.
|
||||
" let regexp = s:Wholematch(matchline, s:all, curcol)
|
||||
" let suf = strlen(matchline) - matchend(matchline, regexp)
|
||||
" let prefix = (curcol ? '^.\{' . curcol . '}\%(' : '^\%(')
|
||||
" let suffix = (suf ? '\).\{' . suf . '}$' : '\)$')
|
||||
" " Reconstruct the version with unresolved backrefs.
|
||||
" let patBR = substitute(b:match_words.',', '[,:]*,[,:]*', ',', 'g')
|
||||
" let patBR = substitute(patBR, ':\{2,}', ':', "g")
|
||||
" " Now, set group and groupBR to the matching group: 'if:endif' or
|
||||
" " 'while:endwhile' or whatever.
|
||||
" let group = s:Choose(s:pat, matchline, ",", ":", prefix, suffix, patBR)
|
||||
" let i = matchend(group, s:notslash . ",")
|
||||
" let groupBR = strpart(group, i)
|
||||
" let group = strpart(group, 0, i-1)
|
||||
" " Now, matchline =~ prefix . substitute(group,':','\|','g') . suffix
|
||||
" if s:do_BR
|
||||
" let group = s:InsertRefs(groupBR, prefix, group, suffix, matchline)
|
||||
" endif
|
||||
" " let g:group = group
|
||||
"
|
||||
" " - TODO: Construct the closing from group.
|
||||
" let fake = "end" . expand("<cword>")
|
||||
" execute startpos
|
||||
" return fake
|
||||
" endfun
|
||||
|
||||
" Close all open structures. "Get the heck out of here!"
|
||||
" fun! s:Gthhoh()
|
||||
" let close = s:Autocomplete()
|
||||
" while strlen(close)
|
||||
" put=close
|
||||
" let close = s:Autocomplete()
|
||||
" endwhile
|
||||
" endfun
|
||||
|
||||
" Parse special strings as typical skip arguments for searchpair():
|
||||
" s:foo becomes (current syntax item) =~ foo
|
||||
" S:foo becomes (current syntax item) !~ foo
|
||||
" r:foo becomes (line before cursor) =~ foo
|
||||
" R:foo becomes (line before cursor) !~ foo
|
||||
fun! s:ParseSkip(str)
|
||||
let skip = a:str
|
||||
if skip[1] == ":"
|
||||
if skip[0] == "s"
|
||||
let skip = "synIDattr(synID(line('.'),col('.'),1),'name') =~? '" .
|
||||
\ strpart(skip,2) . "'"
|
||||
elseif skip[0] == "S"
|
||||
let skip = "synIDattr(synID(line('.'),col('.'),1),'name') !~? '" .
|
||||
\ strpart(skip,2) . "'"
|
||||
elseif skip[0] == "r"
|
||||
let skip = "strpart(getline('.'),0,col('.'))=~'" . strpart(skip,2). "'"
|
||||
elseif skip[0] == "R"
|
||||
let skip = "strpart(getline('.'),0,col('.'))!~'" . strpart(skip,2). "'"
|
||||
endif
|
||||
endif
|
||||
return skip
|
||||
endfun
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
|
||||
" vim:sts=2:sw=2:et:
|
|
@ -1,6 +1,13 @@
|
|||
*pi_matchit.txt* Extended "%" matching
|
||||
*matchit.txt* Extended "%" matching
|
||||
|
||||
For Vim version 6.3. Last change: 2017 May 14
|
||||
For instructions on installing this file, type
|
||||
`:help matchit-install`
|
||||
inside Vim.
|
||||
|
||||
For Vim version 8.1. Last change: 2019 May 05
|
||||
|
||||
|
||||
VIM REFERENCE MANUAL by Benji Fisher et al
|
||||
|
||||
*matchit* *matchit.vim*
|
||||
|
||||
|
@ -34,7 +41,7 @@ g% Cycle backwards through matching groups, as specified by
|
|||
]% Go to [count] next unmatched group, as specified by
|
||||
|b:match_words|. Similar to |]}|.
|
||||
|
||||
*a%* *v_a%*
|
||||
*v_a%*
|
||||
a% In Visual mode, select the matching group, as specified by
|
||||
|b:match_words|, containing the cursor. Similar to |v_a[|.
|
||||
A [count] is ignored, and only the first character of the closing
|
||||
|
@ -62,12 +69,8 @@ for how to specify matching patterns.
|
|||
|
||||
MODES: *matchit-modes* *matchit-v_%* *matchit-o_%*
|
||||
|
||||
Mostly, % and related motions (|g%| and |[%| and |]%|) work just like built-in
|
||||
motion commands in |Operator-pending| and |Visual| modes. However, you
|
||||
cannot make these motions |linewise| or |characterwise|, since the |:omap|s
|
||||
that define them start with "v" in order to make the default behavior
|
||||
inclusive. (See |o_v|.) In other words, "dV%" will not work. The
|
||||
work-around is to go through Visual mode: "V%d" will work.
|
||||
Mostly, % and related motions (|g%| and |[%| and |]%|) should just work like built-in
|
||||
|motion| commands in |Operator-pending| and |Visual| modes (as of 8.1.648)
|
||||
|
||||
LANGUAGES: *matchit-languages*
|
||||
|
||||
|
@ -81,9 +84,9 @@ To support a new language, see |matchit-newlang| below.
|
|||
DETAILS: *matchit-details* *matchit-parse*
|
||||
|
||||
Here is an outline of what matchit.vim does each time you hit the "%" key. If
|
||||
there are backrefs in |b:match_words| then the first step is to produce a
|
||||
there are |backref|s in |b:match_words| then the first step is to produce a
|
||||
version in which these back references have been eliminated; if there are no
|
||||
backrefs then this step is skipped. This step is called parsing. For
|
||||
|backref|s then this step is skipped. This step is called parsing. For
|
||||
example, "\(foo\|bar\):end\1" is parsed to yield
|
||||
"\(foo\|bar\):end\(foo\|bar\)". This can get tricky, especially if there are
|
||||
nested groups. If debugging is turned on, the parsed version is saved as
|
||||
|
@ -128,9 +131,9 @@ column of the start of the match is saved as |b:match_col|.
|
|||
Next, the script looks through |b:match_words| (original and parsed versions)
|
||||
for the group and pattern that match. If debugging is turned on, the group is
|
||||
saved as |b:match_ini| (the first pattern) and |b:match_tail| (the rest). If
|
||||
there are backrefs then, in addition, the matching pattern is saved as
|
||||
there are |backref|s then, in addition, the matching pattern is saved as
|
||||
|b:match_word| and a table of translations is saved as |b:match_table|. If
|
||||
there are backrefs, these are determined from the matching pattern and
|
||||
there are |backref|s, these are determined from the matching pattern and
|
||||
|b:match_match| and substituted into each pattern in the matching group.
|
||||
|
||||
The script decides whether to search forwards or backwards and chooses
|
||||
|
@ -142,11 +145,32 @@ setting |b:match_skip|.
|
|||
==============================================================================
|
||||
2. Activation *matchit-activate*
|
||||
|
||||
For a new language, you can add a line such as >
|
||||
To use the matchit plugin add this line to your |vimrc|: >
|
||||
packadd! matchit
|
||||
|
||||
The script should start working the next time you start Vim.
|
||||
|
||||
(Earlier versions of the script did nothing unless a |buffer-variable| named
|
||||
|b:match_words| was defined. Even earlier versions contained autocommands
|
||||
that set this variable for various file types. Now, |b:match_words| is
|
||||
defined in many of the default |filetype-plugin|s instead.)
|
||||
|
||||
For a new language, you can add autocommands to the script or to your vimrc
|
||||
file, but the recommended method is to add a line such as >
|
||||
let b:match_words = '\<foo\>:\<bar\>'
|
||||
to the corresponding |filetype-plugin|. See |b:match_words| below for how
|
||||
to the |filetype-plugin| for your language. See |b:match_words| below for how
|
||||
this variable is interpreted.
|
||||
|
||||
TROUBLESHOOTING *matchit-troubleshoot*
|
||||
|
||||
The script should work in most installations of Vim. It may not work if Vim
|
||||
was compiled with a minimal feature set, for example if the |+syntax| option
|
||||
was not enabled. If your Vim has support for syntax compiled in, but you do
|
||||
not have |syntax| highlighting turned on, matchit.vim should work, but it may
|
||||
fail to skip matching groups in comments and strings. If the |filetype|
|
||||
mechanism is turned off, the |b:match_words| variable will probably not be
|
||||
defined automatically.
|
||||
|
||||
==============================================================================
|
||||
3. Configuration *matchit-configure*
|
||||
|
||||
|
@ -235,7 +259,7 @@ have only one group; the effect is undefined if a group has only one pattern.
|
|||
A simple example is >
|
||||
:let b:match_words = '\<if\>:\<endif\>,'
|
||||
\ . '\<while\>:\<continue\>:\<break\>:\<endwhile\>'
|
||||
(In Vim regular expressions, |/\<| and |/\>| denote word boundaries. Thus "if"
|
||||
(In Vim regular expressions, |\<| and |\>| denote word boundaries. Thus "if"
|
||||
matches the end of "endif" but "\<if\>" does not.) Then banging on the "%"
|
||||
key will bounce the cursor between "if" and the matching "endif"; and from
|
||||
"while" to any matching "continue" or "break", then to the matching "endwhile"
|
||||
|
@ -256,7 +280,7 @@ definition to a |filetype-plugin| file.
|
|||
Tips: Be careful that your initial pattern does not match your final pattern.
|
||||
See the example above for the use of word-boundary expressions. It is usually
|
||||
better to use ".\{-}" (as many as necessary) instead of ".*" (as many as
|
||||
possible). See |/\{-|. For example, in the string "<tag>label</tag>", "<.*>"
|
||||
possible). See |\{-|. For example, in the string "<tag>label</tag>", "<.*>"
|
||||
matches the whole string whereas "<.\{-}>" and "<[^>]*>" match "<tag>" and
|
||||
"</tag>".
|
||||
|
||||
|
@ -275,18 +299,18 @@ if keywords are only recognized after the start of a line or after a
|
|||
semicolon (;), with optional white space.
|
||||
|
||||
*matchit-backref* *matchit-\1*
|
||||
In any group, the expressions `\1`, `\2`, ..., `\9` (see |/\1|) refer to parts of the
|
||||
INITIAL pattern enclosed in escaped parentheses. These are referred to as
|
||||
back references, or backrefs. For example, >
|
||||
In any group, the expressions |\1|, |\2|, ..., |\9| refer to parts of the
|
||||
INITIAL pattern enclosed in |\(|escaped parentheses|\)|. These are referred
|
||||
to as back references, or backrefs. For example, >
|
||||
:let b:match_words = '\<b\(o\+\)\>:\(h\)\1\>'
|
||||
means that "bo" pairs with "ho" and "boo" pairs with "hoo" and so on. Note
|
||||
that "\1" does not refer to the "\(h\)" in this example. If you have
|
||||
"\(nested \(parentheses\)\) then "\d" refers to the d-th "\(" and everything
|
||||
up to and including the matching "\)": in "\(nested\(parentheses\)\)", "\1"
|
||||
refers to everything and "\2" refers to "\(parentheses\)". If you use a
|
||||
variable such as `s:notend` or `s:sol` in the previous paragraph then remember
|
||||
variable such as |s:notend| or |s:sol| in the previous paragraph then remember
|
||||
to count any "\(" patterns in this variable. You do not have to count groups
|
||||
defined by |/\%(\)|.
|
||||
defined by |\%(\)|.
|
||||
|
||||
It should be possible to resolve back references from any pattern in the
|
||||
group. For example, >
|
||||
|
@ -297,7 +321,7 @@ cannot be determined from "andbar". On the other hand, >
|
|||
should work (and have the same effect as "foobar:barfoo:endfoobar"), although
|
||||
this has not been thoroughly tested.
|
||||
|
||||
You can use |/zero-width| patterns such as |/\@<=| and |/\zs|. (The latter has
|
||||
You can use |zero-width| patterns such as |\@<=| and |\zs|. (The latter has
|
||||
not been thouroughly tested in matchit.vim.) For example, if the keyword "if"
|
||||
must occur at the start of the line, with optional white space, you might use
|
||||
the pattern "\(^\s*\)\@<=if" so that the cursor will end on the "i" instead of
|
||||
|
@ -305,7 +329,7 @@ at the start of the line. For another example, if HTML had only one tag then
|
|||
one could >
|
||||
:let b:match_words = '<:>,<\@<=tag>:<\@<=/tag>'
|
||||
so that "%" can bounce between matching "<" and ">" pairs or (starting on
|
||||
"tag" or "/tag") between matching tags. Without the |/\@<=|, the script would
|
||||
"tag" or "/tag") between matching tags. Without the |\@<=|, the script would
|
||||
bounce from "tag" to the "<" in "</tag>", and another "%" would not take you
|
||||
back to where you started.
|
||||
|
||||
|
@ -322,10 +346,10 @@ the variables described below. You will probably also want to read
|
|||
|
||||
Defining the variable |b:match_debug| causes the script to set the following
|
||||
variables, each time you hit the "%" key. Several of these are only defined
|
||||
if |b:match_words| includes backrefs.
|
||||
if |b:match_words| includes |backref|s.
|
||||
|
||||
*b:match_pat*
|
||||
The b:match_pat variable is set to |b:match_words| with backrefs parsed.
|
||||
The b:match_pat variable is set to |b:match_words| with |backref|s parsed.
|
||||
*b:match_match*
|
||||
The b:match_match variable is set to the bit of text that is recognized as a
|
||||
match.
|
||||
|
@ -334,15 +358,15 @@ The b:match_col variable is set to the cursor column of the start of the
|
|||
matching text.
|
||||
*b:match_wholeBR*
|
||||
The b:match_wholeBR variable is set to the comma-separated group of patterns
|
||||
that matches, with backrefs unparsed.
|
||||
that matches, with |backref|s unparsed.
|
||||
*b:match_iniBR*
|
||||
The b:match_iniBR variable is set to the first pattern in |b:match_wholeBR|.
|
||||
*b:match_ini*
|
||||
The b:match_ini variable is set to the first pattern in |b:match_wholeBR|,
|
||||
with backrefs resolved from |b:match_match|.
|
||||
with |backref|s resolved from |b:match_match|.
|
||||
*b:match_tail*
|
||||
The b:match_tail variable is set to the remaining patterns in
|
||||
|b:match_wholeBR|, with backrefs resolved from |b:match_match|.
|
||||
|b:match_wholeBR|, with |backref|s resolved from |b:match_match|.
|
||||
*b:match_word*
|
||||
The b:match_word variable is set to the pattern from |b:match_wholeBR| that
|
||||
matches |b:match_match|.
|
||||
|
@ -353,14 +377,15 @@ The back reference '\'.d refers to the same thing as '\'.b:match_table[d] in
|
|||
==============================================================================
|
||||
5. Known Bugs and Limitations *matchit-bugs*
|
||||
|
||||
The various |:vmap|s defined in the script (%, |g%|, |[%|, |]%|, |a%|) may
|
||||
have undesired effects in Select mode |Select-mode-mapping|. At least, if you
|
||||
want to replace the selection with any character in "ag%[]" there will be a
|
||||
pause of |'updatetime'| first. E.g., "yV%" would normally work linewise, but
|
||||
the plugin mapping makes it characterwise.
|
||||
Just because I know about a bug does not mean that it is on my todo list. I
|
||||
try to respond to reports of bugs that cause real problems. If it does not
|
||||
cause serious problems, or if there is a work-around, a bug may sit there for
|
||||
a while. Moral: if a bug (known or not) bothers you, let me know.
|
||||
|
||||
It would be nice if "\0" were recognized as the entire pattern. That is, it
|
||||
would be nice if "foo:\end\0" had the same effect as "\(foo\):\end\1".
|
||||
would be nice if "foo:\end\0" had the same effect as "\(foo\):\end\1". I may
|
||||
try to implement this in a future version. (This is not so easy to arrange as
|
||||
you might think!)
|
||||
|
||||
==============================================================================
|
||||
vim:tw=78:ts=8:noet:ft=help:norl:
|
||||
vim:tw=78:fo=tcq2:ft=help:
|
|
@ -0,0 +1,92 @@
|
|||
" matchit.vim: (global plugin) Extended "%" matching
|
||||
" Maintainer: Christian Brabandt
|
||||
" Version: 1.15
|
||||
" Last Change: 2019 Jan 28
|
||||
" Repository: https://github.com/chrisbra/matchit
|
||||
" Previous URL:http://www.vim.org/script.php?script_id=39
|
||||
" Previous Maintainer: Benji Fisher PhD <benji@member.AMS.org>
|
||||
|
||||
" Documentation:
|
||||
" The documentation is in a separate file: ../doc/matchit.txt .
|
||||
|
||||
" Credits:
|
||||
" Vim editor by Bram Moolenaar (Thanks, Bram!)
|
||||
" Original script and design by Raul Segura Acevedo
|
||||
" Support for comments by Douglas Potts
|
||||
" Support for back references and other improvements by Benji Fisher
|
||||
" Support for many languages by Johannes Zellner
|
||||
" Suggestions for improvement, bug reports, and support for additional
|
||||
" languages by Jordi-Albert Batalla, Neil Bird, Servatius Brandt, Mark
|
||||
" Collett, Stephen Wall, Dany St-Amant, Yuheng Xie, and Johannes Zellner.
|
||||
|
||||
" Debugging:
|
||||
" If you'd like to try the built-in debugging commands...
|
||||
" :MatchDebug to activate debugging for the current buffer
|
||||
" This saves the values of several key script variables as buffer-local
|
||||
" variables. See the MatchDebug() function, below, for details.
|
||||
|
||||
" TODO: I should think about multi-line patterns for b:match_words.
|
||||
" This would require an option: how many lines to scan (default 1).
|
||||
" This would be useful for Python, maybe also for *ML.
|
||||
" TODO: Maybe I should add a menu so that people will actually use some of
|
||||
" the features that I have implemented.
|
||||
" TODO: Eliminate the MultiMatch function. Add yet another argument to
|
||||
" Match_wrapper() instead.
|
||||
" TODO: Allow :let b:match_words = '\(\(foo\)\(bar\)\):\3\2:end\1'
|
||||
" TODO: Make backrefs safer by using '\V' (very no-magic).
|
||||
" TODO: Add a level of indirection, so that custom % scripts can use my
|
||||
" work but extend it.
|
||||
|
||||
" Allow user to prevent loading and prevent duplicate loading.
|
||||
if exists("g:loaded_matchit") || &cp
|
||||
finish
|
||||
endif
|
||||
let g:loaded_matchit = 1
|
||||
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
nnoremap <silent> <Plug>(MatchitNormalForward) :<C-U>call matchit#Match_wrapper('',1,'n')<CR>
|
||||
nnoremap <silent> <Plug>(MatchitNormalBackward) :<C-U>call matchit#Match_wrapper('',0,'n')<CR>
|
||||
vnoremap <silent> <Plug>(MatchitVisualForward) :<C-U>call matchit#Match_wrapper('',1,'v')<CR>m'gv``
|
||||
vnoremap <silent> <Plug>(MatchitVisualBackward) :<C-U>call matchit#Match_wrapper('',0,'v')<CR>m'gv``
|
||||
onoremap <silent> <Plug>(MatchitOperationForward) :<C-U>call matchit#Match_wrapper('',1,'o')<CR>
|
||||
onoremap <silent> <Plug>(MatchitOperationBackward) :<C-U>call matchit#Match_wrapper('',0,'o')<CR>
|
||||
|
||||
nmap <silent> % <Plug>(MatchitNormalForward)
|
||||
nmap <silent> g% <Plug>(MatchitNormalBackward)
|
||||
xmap <silent> % <Plug>(MatchitVisualForward)
|
||||
xmap <silent> g% <Plug>(MatchitVisualBackward)
|
||||
omap <silent> % <Plug>(MatchitOperationForward)
|
||||
omap <silent> g% <Plug>(MatchitOperationBackward)
|
||||
|
||||
" Analogues of [{ and ]} using matching patterns:
|
||||
nnoremap <silent> <Plug>(MatchitNormalMultiBackward) :<C-U>call matchit#MultiMatch("bW", "n")<CR>
|
||||
nnoremap <silent> <Plug>(MatchitNormalMultiForward) :<C-U>call matchit#MultiMatch("W", "n")<CR>
|
||||
vnoremap <silent> <Plug>(MatchitVisualMultiBackward) :<C-U>call matchit#MultiMatch("bW", "n")<CR>m'gv``
|
||||
vnoremap <silent> <Plug>(MatchitVisualMultiForward) :<C-U>call matchit#MultiMatch("W", "n")<CR>m'gv``
|
||||
onoremap <silent> <Plug>(MatchitOperationMultiBackward) :<C-U>call matchit#MultiMatch("bW", "o")<CR>
|
||||
onoremap <silent> <Plug>(MatchitOperationMultiForward) :<C-U>call matchit#MultiMatch("W", "o")<CR>
|
||||
|
||||
nmap <silent> [% <Plug>(MatchitNormalMultiBackward)
|
||||
nmap <silent> ]% <Plug>(MatchitNormalMultiForward)
|
||||
xmap <silent> [% <Plug>(MatchitVisualMultiBackward)
|
||||
xmap <silent> ]% <Plug>(MatchitVisualMultiForward)
|
||||
omap <silent> [% <Plug>(MatchitOperationMultiBackward)
|
||||
omap <silent> ]% <Plug>(MatchitOperationMultiForward)
|
||||
|
||||
" text object:
|
||||
vmap <silent> <Plug>(MatchitVisualTextObject) <Plug>(MatchitVisualMultiBackward)o<Plug>(MatchitVisualMultiForward)
|
||||
xmap a% <Plug>(MatchitVisualTextObject)
|
||||
|
||||
" Call this function to turn on debugging information. Every time the main
|
||||
" script is run, buffer variables will be saved. These can be used directly
|
||||
" or viewed using the menu items below.
|
||||
if !exists(":MatchDebug")
|
||||
command! -nargs=0 MatchDebug call matchit#Match_debug()
|
||||
endif
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
|
||||
" vim:sts=2:sw=2:et:
|
|
@ -1,817 +1,2 @@
|
|||
" matchit.vim: (global plugin) Extended "%" matching
|
||||
" Last Change: 2018 Jul 3 by Christian Brabandt
|
||||
" Maintainer: Benji Fisher PhD <benji@member.AMS.org>
|
||||
" Version: 1.13.3, for Vim 6.3+
|
||||
" Fix from Tommy Allen included.
|
||||
" Fix from Fernando Torres included.
|
||||
" Improvement from Ken Takata included.
|
||||
" URL: http://www.vim.org/script.php?script_id=39
|
||||
|
||||
" Documentation:
|
||||
" The documentation is in a separate file, matchit.txt .
|
||||
|
||||
" Credits:
|
||||
" Vim editor by Bram Moolenaar (Thanks, Bram!)
|
||||
" Original script and design by Raul Segura Acevedo
|
||||
" Support for comments by Douglas Potts
|
||||
" Support for back references and other improvements by Benji Fisher
|
||||
" Support for many languages by Johannes Zellner
|
||||
" Suggestions for improvement, bug reports, and support for additional
|
||||
" languages by Jordi-Albert Batalla, Neil Bird, Servatius Brandt, Mark
|
||||
" Collett, Stephen Wall, Dany St-Amant, Yuheng Xie, and Johannes Zellner.
|
||||
|
||||
" Debugging:
|
||||
" If you'd like to try the built-in debugging commands...
|
||||
" :MatchDebug to activate debugging for the current buffer
|
||||
" This saves the values of several key script variables as buffer-local
|
||||
" variables. See the MatchDebug() function, below, for details.
|
||||
|
||||
" TODO: I should think about multi-line patterns for b:match_words.
|
||||
" This would require an option: how many lines to scan (default 1).
|
||||
" This would be useful for Python, maybe also for *ML.
|
||||
" TODO: Maybe I should add a menu so that people will actually use some of
|
||||
" the features that I have implemented.
|
||||
" TODO: Eliminate the MultiMatch function. Add yet another argument to
|
||||
" Match_wrapper() instead.
|
||||
" TODO: Allow :let b:match_words = '\(\(foo\)\(bar\)\):\3\2:end\1'
|
||||
" TODO: Make backrefs safer by using '\V' (very no-magic).
|
||||
" TODO: Add a level of indirection, so that custom % scripts can use my
|
||||
" work but extend it.
|
||||
|
||||
" allow user to prevent loading
|
||||
" and prevent duplicate loading
|
||||
if exists("loaded_matchit") || &cp
|
||||
finish
|
||||
endif
|
||||
let loaded_matchit = 1
|
||||
let s:last_mps = ""
|
||||
let s:last_words = ":"
|
||||
let s:patBR = ""
|
||||
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
nnoremap <silent> % :<C-U>call <SID>Match_wrapper('',1,'n') <CR>
|
||||
nnoremap <silent> g% :<C-U>call <SID>Match_wrapper('',0,'n') <CR>
|
||||
vnoremap <silent> % :<C-U>call <SID>Match_wrapper('',1,'v') <CR>m'gv``
|
||||
vnoremap <silent> g% :<C-U>call <SID>Match_wrapper('',0,'v') <CR>m'gv``
|
||||
onoremap <silent> % v:<C-U>call <SID>Match_wrapper('',1,'o') <CR>
|
||||
onoremap <silent> g% v:<C-U>call <SID>Match_wrapper('',0,'o') <CR>
|
||||
|
||||
" Analogues of [{ and ]} using matching patterns:
|
||||
nnoremap <silent> [% :<C-U>call <SID>MultiMatch("bW", "n") <CR>
|
||||
nnoremap <silent> ]% :<C-U>call <SID>MultiMatch("W", "n") <CR>
|
||||
vmap [% <Esc>[%m'gv``
|
||||
vmap ]% <Esc>]%m'gv``
|
||||
" vnoremap <silent> [% :<C-U>call <SID>MultiMatch("bW", "v") <CR>m'gv``
|
||||
" vnoremap <silent> ]% :<C-U>call <SID>MultiMatch("W", "v") <CR>m'gv``
|
||||
onoremap <silent> [% v:<C-U>call <SID>MultiMatch("bW", "o") <CR>
|
||||
onoremap <silent> ]% v:<C-U>call <SID>MultiMatch("W", "o") <CR>
|
||||
|
||||
" text object:
|
||||
vmap a% <Esc>[%v]%
|
||||
|
||||
" Auto-complete mappings: (not yet "ready for prime time")
|
||||
" TODO Read :help write-plugin for the "right" way to let the user
|
||||
" specify a key binding.
|
||||
" let g:match_auto = '<C-]>'
|
||||
" let g:match_autoCR = '<C-CR>'
|
||||
" if exists("g:match_auto")
|
||||
" execute "inoremap " . g:match_auto . ' x<Esc>"=<SID>Autocomplete()<CR>Pls'
|
||||
" endif
|
||||
" if exists("g:match_autoCR")
|
||||
" execute "inoremap " . g:match_autoCR . ' <CR><C-R>=<SID>Autocomplete()<CR>'
|
||||
" endif
|
||||
" if exists("g:match_gthhoh")
|
||||
" execute "inoremap " . g:match_gthhoh . ' <C-O>:call <SID>Gthhoh()<CR>'
|
||||
" endif " gthhoh = "Get the heck out of here!"
|
||||
|
||||
let s:notslash = '\\\@<!\%(\\\\\)*'
|
||||
|
||||
function! s:Match_wrapper(word, forward, mode) range
|
||||
" In s:CleanUp(), :execute "set" restore_options .
|
||||
let restore_options = ""
|
||||
if exists("b:match_ignorecase") && b:match_ignorecase != &ic
|
||||
let restore_options .= (&ic ? " " : " no") . "ignorecase"
|
||||
let &ignorecase = b:match_ignorecase
|
||||
endif
|
||||
if &ve != ''
|
||||
let restore_options = " ve=" . &ve . restore_options
|
||||
set ve=
|
||||
endif
|
||||
" If this function was called from Visual mode, make sure that the cursor
|
||||
" is at the correct end of the Visual range:
|
||||
if a:mode == "v"
|
||||
execute "normal! gv\<Esc>"
|
||||
endif
|
||||
" In s:CleanUp(), we may need to check whether the cursor moved forward.
|
||||
let startline = line(".")
|
||||
let startcol = col(".")
|
||||
" Use default behavior if called with a count.
|
||||
if v:count
|
||||
exe "normal! " . v:count . "%"
|
||||
return s:CleanUp(restore_options, a:mode, startline, startcol)
|
||||
end
|
||||
|
||||
" First step: if not already done, set the script variables
|
||||
" s:do_BR flag for whether there are backrefs
|
||||
" s:pat parsed version of b:match_words
|
||||
" s:all regexp based on s:pat and the default groups
|
||||
"
|
||||
if !exists("b:match_words") || b:match_words == ""
|
||||
let match_words = ""
|
||||
" Allow b:match_words = "GetVimMatchWords()" .
|
||||
elseif b:match_words =~ ":"
|
||||
let match_words = b:match_words
|
||||
else
|
||||
execute "let match_words =" b:match_words
|
||||
endif
|
||||
" Thanks to Preben "Peppe" Guldberg and Bram Moolenaar for this suggestion!
|
||||
if (match_words != s:last_words) || (&mps != s:last_mps)
|
||||
\ || exists("b:match_debug")
|
||||
let s:last_mps = &mps
|
||||
" The next several lines were here before
|
||||
" BF started messing with this script.
|
||||
" quote the special chars in 'matchpairs', replace [,:] with \| and then
|
||||
" append the builtin pairs (/*, */, #if, #ifdef, #else, #elif, #endif)
|
||||
" let default = substitute(escape(&mps, '[$^.*~\\/?]'), '[,:]\+',
|
||||
" \ '\\|', 'g').'\|\/\*\|\*\/\|#if\>\|#ifdef\>\|#else\>\|#elif\>\|#endif\>'
|
||||
let default = escape(&mps, '[$^.*~\\/?]') . (strlen(&mps) ? "," : "") .
|
||||
\ '\/\*:\*\/,#\s*if\%(def\)\=:#\s*else\>:#\s*elif\>:#\s*endif\>'
|
||||
" s:all = pattern with all the keywords
|
||||
let match_words = match_words . (strlen(match_words) ? "," : "") . default
|
||||
let s:last_words = match_words
|
||||
if match_words !~ s:notslash . '\\\d'
|
||||
let s:do_BR = 0
|
||||
let s:pat = match_words
|
||||
else
|
||||
let s:do_BR = 1
|
||||
let s:pat = s:ParseWords(match_words)
|
||||
endif
|
||||
let s:all = substitute(s:pat, s:notslash . '\zs[,:]\+', '\\|', 'g')
|
||||
let s:all = '\%(' . s:all . '\)'
|
||||
" let s:all = '\%(' . substitute(s:all, '\\\ze[,:]', '', 'g') . '\)'
|
||||
if exists("b:match_debug")
|
||||
let b:match_pat = s:pat
|
||||
endif
|
||||
" Reconstruct the version with unresolved backrefs.
|
||||
let s:patBR = substitute(match_words.',',
|
||||
\ s:notslash.'\zs[,:]*,[,:]*', ',', 'g')
|
||||
let s:patBR = substitute(s:patBR, s:notslash.'\zs:\{2,}', ':', 'g')
|
||||
endif
|
||||
|
||||
" Second step: set the following local variables:
|
||||
" matchline = line on which the cursor started
|
||||
" curcol = number of characters before match
|
||||
" prefix = regexp for start of line to start of match
|
||||
" suffix = regexp for end of match to end of line
|
||||
" Require match to end on or after the cursor and prefer it to
|
||||
" start on or before the cursor.
|
||||
let matchline = getline(startline)
|
||||
if a:word != ''
|
||||
" word given
|
||||
if a:word !~ s:all
|
||||
echohl WarningMsg|echo 'Missing rule for word:"'.a:word.'"'|echohl NONE
|
||||
return s:CleanUp(restore_options, a:mode, startline, startcol)
|
||||
endif
|
||||
let matchline = a:word
|
||||
let curcol = 0
|
||||
let prefix = '^\%('
|
||||
let suffix = '\)$'
|
||||
" Now the case when "word" is not given
|
||||
else " Find the match that ends on or after the cursor and set curcol.
|
||||
let regexp = s:Wholematch(matchline, s:all, startcol-1)
|
||||
let curcol = match(matchline, regexp)
|
||||
" If there is no match, give up.
|
||||
if curcol == -1
|
||||
return s:CleanUp(restore_options, a:mode, startline, startcol)
|
||||
endif
|
||||
let endcol = matchend(matchline, regexp)
|
||||
let suf = strlen(matchline) - endcol
|
||||
let prefix = (curcol ? '^.*\%' . (curcol + 1) . 'c\%(' : '^\%(')
|
||||
let suffix = (suf ? '\)\%' . (endcol + 1) . 'c.*$' : '\)$')
|
||||
endif
|
||||
if exists("b:match_debug")
|
||||
let b:match_match = matchstr(matchline, regexp)
|
||||
let b:match_col = curcol+1
|
||||
endif
|
||||
|
||||
" Third step: Find the group and single word that match, and the original
|
||||
" (backref) versions of these. Then, resolve the backrefs.
|
||||
" Set the following local variable:
|
||||
" group = colon-separated list of patterns, one of which matches
|
||||
" = ini:mid:fin or ini:fin
|
||||
"
|
||||
" Now, set group and groupBR to the matching group: 'if:endif' or
|
||||
" 'while:endwhile' or whatever. A bit of a kluge: s:Choose() returns
|
||||
" group . "," . groupBR, and we pick it apart.
|
||||
let group = s:Choose(s:pat, matchline, ",", ":", prefix, suffix, s:patBR)
|
||||
let i = matchend(group, s:notslash . ",")
|
||||
let groupBR = strpart(group, i)
|
||||
let group = strpart(group, 0, i-1)
|
||||
" Now, matchline =~ prefix . substitute(group,':','\|','g') . suffix
|
||||
if s:do_BR " Do the hard part: resolve those backrefs!
|
||||
let group = s:InsertRefs(groupBR, prefix, group, suffix, matchline)
|
||||
endif
|
||||
if exists("b:match_debug")
|
||||
let b:match_wholeBR = groupBR
|
||||
let i = matchend(groupBR, s:notslash . ":")
|
||||
let b:match_iniBR = strpart(groupBR, 0, i-1)
|
||||
endif
|
||||
|
||||
" Fourth step: Set the arguments for searchpair().
|
||||
let i = matchend(group, s:notslash . ":")
|
||||
let j = matchend(group, '.*' . s:notslash . ":")
|
||||
let ini = strpart(group, 0, i-1)
|
||||
let mid = substitute(strpart(group, i,j-i-1), s:notslash.'\zs:', '\\|', 'g')
|
||||
let fin = strpart(group, j)
|
||||
"Un-escape the remaining , and : characters.
|
||||
let ini = substitute(ini, s:notslash . '\zs\\\(:\|,\)', '\1', 'g')
|
||||
let mid = substitute(mid, s:notslash . '\zs\\\(:\|,\)', '\1', 'g')
|
||||
let fin = substitute(fin, s:notslash . '\zs\\\(:\|,\)', '\1', 'g')
|
||||
" searchpair() requires that these patterns avoid \(\) groups.
|
||||
let ini = substitute(ini, s:notslash . '\zs\\(', '\\%(', 'g')
|
||||
let mid = substitute(mid, s:notslash . '\zs\\(', '\\%(', 'g')
|
||||
let fin = substitute(fin, s:notslash . '\zs\\(', '\\%(', 'g')
|
||||
" Set mid. This is optimized for readability, not micro-efficiency!
|
||||
if a:forward && matchline =~ prefix . fin . suffix
|
||||
\ || !a:forward && matchline =~ prefix . ini . suffix
|
||||
let mid = ""
|
||||
endif
|
||||
" Set flag. This is optimized for readability, not micro-efficiency!
|
||||
if a:forward && matchline =~ prefix . fin . suffix
|
||||
\ || !a:forward && matchline !~ prefix . ini . suffix
|
||||
let flag = "bW"
|
||||
else
|
||||
let flag = "W"
|
||||
endif
|
||||
" Set skip.
|
||||
if exists("b:match_skip")
|
||||
let skip = b:match_skip
|
||||
elseif exists("b:match_comment") " backwards compatibility and testing!
|
||||
let skip = "r:" . b:match_comment
|
||||
else
|
||||
let skip = 's:comment\|string'
|
||||
endif
|
||||
let skip = s:ParseSkip(skip)
|
||||
if exists("b:match_debug")
|
||||
let b:match_ini = ini
|
||||
let b:match_tail = (strlen(mid) ? mid.'\|' : '') . fin
|
||||
endif
|
||||
|
||||
" Fifth step: actually start moving the cursor and call searchpair().
|
||||
" Later, :execute restore_cursor to get to the original screen.
|
||||
let view = winsaveview()
|
||||
call cursor(0, curcol + 1)
|
||||
" normal! 0
|
||||
" if curcol
|
||||
" execute "normal!" . curcol . "l"
|
||||
" endif
|
||||
if skip =~ 'synID' && !(has("syntax") && exists("g:syntax_on"))
|
||||
let skip = '0'
|
||||
else
|
||||
execute "if " . skip . "| let skip = '0' | endif"
|
||||
endif
|
||||
let sp_return = searchpair(ini, mid, fin, flag, skip)
|
||||
let final_position = "call cursor(" . line(".") . "," . col(".") . ")"
|
||||
" Restore cursor position and original screen.
|
||||
call winrestview(view)
|
||||
normal! m'
|
||||
if sp_return > 0
|
||||
execute final_position
|
||||
endif
|
||||
return s:CleanUp(restore_options, a:mode, startline, startcol, mid.'\|'.fin)
|
||||
endfun
|
||||
|
||||
" Restore options and do some special handling for Operator-pending mode.
|
||||
" The optional argument is the tail of the matching group.
|
||||
fun! s:CleanUp(options, mode, startline, startcol, ...)
|
||||
if strlen(a:options)
|
||||
execute "set" a:options
|
||||
endif
|
||||
" Open folds, if appropriate.
|
||||
if a:mode != "o"
|
||||
if &foldopen =~ "percent"
|
||||
normal! zv
|
||||
endif
|
||||
" In Operator-pending mode, we want to include the whole match
|
||||
" (for example, d%).
|
||||
" This is only a problem if we end up moving in the forward direction.
|
||||
elseif (a:startline < line(".")) ||
|
||||
\ (a:startline == line(".") && a:startcol < col("."))
|
||||
if a:0
|
||||
" Check whether the match is a single character. If not, move to the
|
||||
" end of the match.
|
||||
let matchline = getline(".")
|
||||
let currcol = col(".")
|
||||
let regexp = s:Wholematch(matchline, a:1, currcol-1)
|
||||
let endcol = matchend(matchline, regexp)
|
||||
if endcol > currcol " This is NOT off by one!
|
||||
call cursor(0, endcol)
|
||||
endif
|
||||
endif " a:0
|
||||
endif " a:mode != "o" && etc.
|
||||
return 0
|
||||
endfun
|
||||
|
||||
" Example (simplified HTML patterns): if
|
||||
" a:groupBR = '<\(\k\+\)>:</\1>'
|
||||
" a:prefix = '^.\{3}\('
|
||||
" a:group = '<\(\k\+\)>:</\(\k\+\)>'
|
||||
" a:suffix = '\).\{2}$'
|
||||
" a:matchline = "123<tag>12" or "123</tag>12"
|
||||
" then extract "tag" from a:matchline and return "<tag>:</tag>" .
|
||||
fun! s:InsertRefs(groupBR, prefix, group, suffix, matchline)
|
||||
if a:matchline !~ a:prefix .
|
||||
\ substitute(a:group, s:notslash . '\zs:', '\\|', 'g') . a:suffix
|
||||
return a:group
|
||||
endif
|
||||
let i = matchend(a:groupBR, s:notslash . ':')
|
||||
let ini = strpart(a:groupBR, 0, i-1)
|
||||
let tailBR = strpart(a:groupBR, i)
|
||||
let word = s:Choose(a:group, a:matchline, ":", "", a:prefix, a:suffix,
|
||||
\ a:groupBR)
|
||||
let i = matchend(word, s:notslash . ":")
|
||||
let wordBR = strpart(word, i)
|
||||
let word = strpart(word, 0, i-1)
|
||||
" Now, a:matchline =~ a:prefix . word . a:suffix
|
||||
if wordBR != ini
|
||||
let table = s:Resolve(ini, wordBR, "table")
|
||||
else
|
||||
" let table = "----------"
|
||||
let table = ""
|
||||
let d = 0
|
||||
while d < 10
|
||||
if tailBR =~ s:notslash . '\\' . d
|
||||
" let table[d] = d
|
||||
let table = table . d
|
||||
else
|
||||
let table = table . "-"
|
||||
endif
|
||||
let d = d + 1
|
||||
endwhile
|
||||
endif
|
||||
let d = 9
|
||||
while d
|
||||
if table[d] != "-"
|
||||
let backref = substitute(a:matchline, a:prefix.word.a:suffix,
|
||||
\ '\'.table[d], "")
|
||||
" Are there any other characters that should be escaped?
|
||||
let backref = escape(backref, '*,:')
|
||||
execute s:Ref(ini, d, "start", "len")
|
||||
let ini = strpart(ini, 0, start) . backref . strpart(ini, start+len)
|
||||
let tailBR = substitute(tailBR, s:notslash . '\zs\\' . d,
|
||||
\ escape(backref, '\\&'), 'g')
|
||||
endif
|
||||
let d = d-1
|
||||
endwhile
|
||||
if exists("b:match_debug")
|
||||
if s:do_BR
|
||||
let b:match_table = table
|
||||
let b:match_word = word
|
||||
else
|
||||
let b:match_table = ""
|
||||
let b:match_word = ""
|
||||
endif
|
||||
endif
|
||||
return ini . ":" . tailBR
|
||||
endfun
|
||||
|
||||
" Input a comma-separated list of groups with backrefs, such as
|
||||
" a:groups = '\(foo\):end\1,\(bar\):end\1'
|
||||
" and return a comma-separated list of groups with backrefs replaced:
|
||||
" return '\(foo\):end\(foo\),\(bar\):end\(bar\)'
|
||||
fun! s:ParseWords(groups)
|
||||
let groups = substitute(a:groups.",", s:notslash.'\zs[,:]*,[,:]*', ',', 'g')
|
||||
let groups = substitute(groups, s:notslash . '\zs:\{2,}', ':', 'g')
|
||||
let parsed = ""
|
||||
while groups =~ '[^,:]'
|
||||
let i = matchend(groups, s:notslash . ':')
|
||||
let j = matchend(groups, s:notslash . ',')
|
||||
let ini = strpart(groups, 0, i-1)
|
||||
let tail = strpart(groups, i, j-i-1) . ":"
|
||||
let groups = strpart(groups, j)
|
||||
let parsed = parsed . ini
|
||||
let i = matchend(tail, s:notslash . ':')
|
||||
while i != -1
|
||||
" In 'if:else:endif', ini='if' and word='else' and then word='endif'.
|
||||
let word = strpart(tail, 0, i-1)
|
||||
let tail = strpart(tail, i)
|
||||
let i = matchend(tail, s:notslash . ':')
|
||||
let parsed = parsed . ":" . s:Resolve(ini, word, "word")
|
||||
endwhile " Now, tail has been used up.
|
||||
let parsed = parsed . ","
|
||||
endwhile " groups =~ '[^,:]'
|
||||
let parsed = substitute(parsed, ',$', '', '')
|
||||
return parsed
|
||||
endfun
|
||||
|
||||
" TODO I think this can be simplified and/or made more efficient.
|
||||
" TODO What should I do if a:start is out of range?
|
||||
" Return a regexp that matches all of a:string, such that
|
||||
" matchstr(a:string, regexp) represents the match for a:pat that starts
|
||||
" as close to a:start as possible, before being preferred to after, and
|
||||
" ends after a:start .
|
||||
" Usage:
|
||||
" let regexp = s:Wholematch(getline("."), 'foo\|bar', col(".")-1)
|
||||
" let i = match(getline("."), regexp)
|
||||
" let j = matchend(getline("."), regexp)
|
||||
" let match = matchstr(getline("."), regexp)
|
||||
fun! s:Wholematch(string, pat, start)
|
||||
let group = '\%(' . a:pat . '\)'
|
||||
let prefix = (a:start ? '\(^.*\%<' . (a:start + 2) . 'c\)\zs' : '^')
|
||||
let len = strlen(a:string)
|
||||
let suffix = (a:start+1 < len ? '\(\%>'.(a:start+1).'c.*$\)\@=' : '$')
|
||||
if a:string !~ prefix . group . suffix
|
||||
let prefix = ''
|
||||
endif
|
||||
return prefix . group . suffix
|
||||
endfun
|
||||
|
||||
" No extra arguments: s:Ref(string, d) will
|
||||
" find the d'th occurrence of '\(' and return it, along with everything up
|
||||
" to and including the matching '\)'.
|
||||
" One argument: s:Ref(string, d, "start") returns the index of the start
|
||||
" of the d'th '\(' and any other argument returns the length of the group.
|
||||
" Two arguments: s:Ref(string, d, "foo", "bar") returns a string to be
|
||||
" executed, having the effect of
|
||||
" :let foo = s:Ref(string, d, "start")
|
||||
" :let bar = s:Ref(string, d, "len")
|
||||
fun! s:Ref(string, d, ...)
|
||||
let len = strlen(a:string)
|
||||
if a:d == 0
|
||||
let start = 0
|
||||
else
|
||||
let cnt = a:d
|
||||
let match = a:string
|
||||
while cnt
|
||||
let cnt = cnt - 1
|
||||
let index = matchend(match, s:notslash . '\\(')
|
||||
if index == -1
|
||||
return ""
|
||||
endif
|
||||
let match = strpart(match, index)
|
||||
endwhile
|
||||
let start = len - strlen(match)
|
||||
if a:0 == 1 && a:1 == "start"
|
||||
return start - 2
|
||||
endif
|
||||
let cnt = 1
|
||||
while cnt
|
||||
let index = matchend(match, s:notslash . '\\(\|\\)') - 1
|
||||
if index == -2
|
||||
return ""
|
||||
endif
|
||||
" Increment if an open, decrement if a ')':
|
||||
let cnt = cnt + (match[index]=="(" ? 1 : -1) " ')'
|
||||
" let cnt = stridx('0(', match[index]) + cnt
|
||||
let match = strpart(match, index+1)
|
||||
endwhile
|
||||
let start = start - 2
|
||||
let len = len - start - strlen(match)
|
||||
endif
|
||||
if a:0 == 1
|
||||
return len
|
||||
elseif a:0 == 2
|
||||
return "let " . a:1 . "=" . start . "| let " . a:2 . "=" . len
|
||||
else
|
||||
return strpart(a:string, start, len)
|
||||
endif
|
||||
endfun
|
||||
|
||||
" Count the number of disjoint copies of pattern in string.
|
||||
" If the pattern is a literal string and contains no '0' or '1' characters
|
||||
" then s:Count(string, pattern, '0', '1') should be faster than
|
||||
" s:Count(string, pattern).
|
||||
fun! s:Count(string, pattern, ...)
|
||||
let pat = escape(a:pattern, '\\')
|
||||
if a:0 > 1
|
||||
let foo = substitute(a:string, '[^'.a:pattern.']', "a:1", "g")
|
||||
let foo = substitute(a:string, pat, a:2, "g")
|
||||
let foo = substitute(foo, '[^' . a:2 . ']', "", "g")
|
||||
return strlen(foo)
|
||||
endif
|
||||
let result = 0
|
||||
let foo = a:string
|
||||
let index = matchend(foo, pat)
|
||||
while index != -1
|
||||
let result = result + 1
|
||||
let foo = strpart(foo, index)
|
||||
let index = matchend(foo, pat)
|
||||
endwhile
|
||||
return result
|
||||
endfun
|
||||
|
||||
" s:Resolve('\(a\)\(b\)', '\(c\)\2\1\1\2') should return table.word, where
|
||||
" word = '\(c\)\(b\)\(a\)\3\2' and table = '-32-------'. That is, the first
|
||||
" '\1' in target is replaced by '\(a\)' in word, table[1] = 3, and this
|
||||
" indicates that all other instances of '\1' in target are to be replaced
|
||||
" by '\3'. The hard part is dealing with nesting...
|
||||
" Note that ":" is an illegal character for source and target,
|
||||
" unless it is preceded by "\".
|
||||
fun! s:Resolve(source, target, output)
|
||||
let word = a:target
|
||||
let i = matchend(word, s:notslash . '\\\d') - 1
|
||||
let table = "----------"
|
||||
while i != -2 " There are back references to be replaced.
|
||||
let d = word[i]
|
||||
let backref = s:Ref(a:source, d)
|
||||
" The idea is to replace '\d' with backref. Before we do this,
|
||||
" replace any \(\) groups in backref with :1, :2, ... if they
|
||||
" correspond to the first, second, ... group already inserted
|
||||
" into backref. Later, replace :1 with \1 and so on. The group
|
||||
" number w+b within backref corresponds to the group number
|
||||
" s within a:source.
|
||||
" w = number of '\(' in word before the current one
|
||||
let w = s:Count(
|
||||
\ substitute(strpart(word, 0, i-1), '\\\\', '', 'g'), '\(', '1')
|
||||
let b = 1 " number of the current '\(' in backref
|
||||
let s = d " number of the current '\(' in a:source
|
||||
while b <= s:Count(substitute(backref, '\\\\', '', 'g'), '\(', '1')
|
||||
\ && s < 10
|
||||
if table[s] == "-"
|
||||
if w + b < 10
|
||||
" let table[s] = w + b
|
||||
let table = strpart(table, 0, s) . (w+b) . strpart(table, s+1)
|
||||
endif
|
||||
let b = b + 1
|
||||
let s = s + 1
|
||||
else
|
||||
execute s:Ref(backref, b, "start", "len")
|
||||
let ref = strpart(backref, start, len)
|
||||
let backref = strpart(backref, 0, start) . ":". table[s]
|
||||
\ . strpart(backref, start+len)
|
||||
let s = s + s:Count(substitute(ref, '\\\\', '', 'g'), '\(', '1')
|
||||
endif
|
||||
endwhile
|
||||
let word = strpart(word, 0, i-1) . backref . strpart(word, i+1)
|
||||
let i = matchend(word, s:notslash . '\\\d') - 1
|
||||
endwhile
|
||||
let word = substitute(word, s:notslash . '\zs:', '\\', 'g')
|
||||
if a:output == "table"
|
||||
return table
|
||||
elseif a:output == "word"
|
||||
return word
|
||||
else
|
||||
return table . word
|
||||
endif
|
||||
endfun
|
||||
|
||||
" Assume a:comma = ",". Then the format for a:patterns and a:1 is
|
||||
" a:patterns = "<pat1>,<pat2>,..."
|
||||
" a:1 = "<alt1>,<alt2>,..."
|
||||
" If <patn> is the first pattern that matches a:string then return <patn>
|
||||
" if no optional arguments are given; return <patn>,<altn> if a:1 is given.
|
||||
fun! s:Choose(patterns, string, comma, branch, prefix, suffix, ...)
|
||||
let tail = (a:patterns =~ a:comma."$" ? a:patterns : a:patterns . a:comma)
|
||||
let i = matchend(tail, s:notslash . a:comma)
|
||||
if a:0
|
||||
let alttail = (a:1 =~ a:comma."$" ? a:1 : a:1 . a:comma)
|
||||
let j = matchend(alttail, s:notslash . a:comma)
|
||||
endif
|
||||
let current = strpart(tail, 0, i-1)
|
||||
if a:branch == ""
|
||||
let currpat = current
|
||||
else
|
||||
let currpat = substitute(current, s:notslash . a:branch, '\\|', 'g')
|
||||
endif
|
||||
while a:string !~ a:prefix . currpat . a:suffix
|
||||
let tail = strpart(tail, i)
|
||||
let i = matchend(tail, s:notslash . a:comma)
|
||||
if i == -1
|
||||
return -1
|
||||
endif
|
||||
let current = strpart(tail, 0, i-1)
|
||||
if a:branch == ""
|
||||
let currpat = current
|
||||
else
|
||||
let currpat = substitute(current, s:notslash . a:branch, '\\|', 'g')
|
||||
endif
|
||||
if a:0
|
||||
let alttail = strpart(alttail, j)
|
||||
let j = matchend(alttail, s:notslash . a:comma)
|
||||
endif
|
||||
endwhile
|
||||
if a:0
|
||||
let current = current . a:comma . strpart(alttail, 0, j-1)
|
||||
endif
|
||||
return current
|
||||
endfun
|
||||
|
||||
" Call this function to turn on debugging information. Every time the main
|
||||
" script is run, buffer variables will be saved. These can be used directly
|
||||
" or viewed using the menu items below.
|
||||
if !exists(":MatchDebug")
|
||||
command! -nargs=0 MatchDebug call s:Match_debug()
|
||||
endif
|
||||
|
||||
fun! s:Match_debug()
|
||||
let b:match_debug = 1 " Save debugging information.
|
||||
" pat = all of b:match_words with backrefs parsed
|
||||
amenu &Matchit.&pat :echo b:match_pat<CR>
|
||||
" match = bit of text that is recognized as a match
|
||||
amenu &Matchit.&match :echo b:match_match<CR>
|
||||
" curcol = cursor column of the start of the matching text
|
||||
amenu &Matchit.&curcol :echo b:match_col<CR>
|
||||
" wholeBR = matching group, original version
|
||||
amenu &Matchit.wh&oleBR :echo b:match_wholeBR<CR>
|
||||
" iniBR = 'if' piece, original version
|
||||
amenu &Matchit.ini&BR :echo b:match_iniBR<CR>
|
||||
" ini = 'if' piece, with all backrefs resolved from match
|
||||
amenu &Matchit.&ini :echo b:match_ini<CR>
|
||||
" tail = 'else\|endif' piece, with all backrefs resolved from match
|
||||
amenu &Matchit.&tail :echo b:match_tail<CR>
|
||||
" fin = 'endif' piece, with all backrefs resolved from match
|
||||
amenu &Matchit.&word :echo b:match_word<CR>
|
||||
" '\'.d in ini refers to the same thing as '\'.table[d] in word.
|
||||
amenu &Matchit.t&able :echo '0:' . b:match_table . ':9'<CR>
|
||||
endfun
|
||||
|
||||
" Jump to the nearest unmatched "(" or "if" or "<tag>" if a:spflag == "bW"
|
||||
" or the nearest unmatched "</tag>" or "endif" or ")" if a:spflag == "W".
|
||||
" Return a "mark" for the original position, so that
|
||||
" let m = MultiMatch("bW", "n") ... execute m
|
||||
" will return to the original position. If there is a problem, do not
|
||||
" move the cursor and return "", unless a count is given, in which case
|
||||
" go up or down as many levels as possible and again return "".
|
||||
" TODO This relies on the same patterns as % matching. It might be a good
|
||||
" idea to give it its own matching patterns.
|
||||
fun! s:MultiMatch(spflag, mode)
|
||||
if !exists("b:match_words") || b:match_words == ""
|
||||
return {}
|
||||
end
|
||||
let restore_options = ""
|
||||
if exists("b:match_ignorecase") && b:match_ignorecase != &ic
|
||||
let restore_options .= (&ic ? " " : " no") . "ignorecase"
|
||||
let &ignorecase = b:match_ignorecase
|
||||
endif
|
||||
let startline = line(".")
|
||||
let startcol = col(".")
|
||||
|
||||
" First step: if not already done, set the script variables
|
||||
" s:do_BR flag for whether there are backrefs
|
||||
" s:pat parsed version of b:match_words
|
||||
" s:all regexp based on s:pat and the default groups
|
||||
" This part is copied and slightly modified from s:Match_wrapper().
|
||||
let default = escape(&mps, '[$^.*~\\/?]') . (strlen(&mps) ? "," : "") .
|
||||
\ '\/\*:\*\/,#\s*if\%(def\)\=:#\s*else\>:#\s*elif\>:#\s*endif\>'
|
||||
" Allow b:match_words = "GetVimMatchWords()" .
|
||||
if b:match_words =~ ":"
|
||||
let match_words = b:match_words
|
||||
else
|
||||
execute "let match_words =" b:match_words
|
||||
endif
|
||||
if (match_words != s:last_words) || (&mps != s:last_mps) ||
|
||||
\ exists("b:match_debug")
|
||||
let s:last_words = match_words
|
||||
let s:last_mps = &mps
|
||||
let match_words = match_words . (strlen(match_words) ? "," : "") . default
|
||||
if match_words !~ s:notslash . '\\\d'
|
||||
let s:do_BR = 0
|
||||
let s:pat = match_words
|
||||
else
|
||||
let s:do_BR = 1
|
||||
let s:pat = s:ParseWords(match_words)
|
||||
endif
|
||||
let s:all = '\%(' . substitute(s:pat . (strlen(s:pat) ? "," : "") . default,
|
||||
\ '[,:]\+', '\\|', 'g') . '\)'
|
||||
if exists("b:match_debug")
|
||||
let b:match_pat = s:pat
|
||||
endif
|
||||
endif
|
||||
|
||||
" Second step: figure out the patterns for searchpair()
|
||||
" and save the screen, cursor position, and 'ignorecase'.
|
||||
" - TODO: A lot of this is copied from s:Match_wrapper().
|
||||
" - maybe even more functionality should be split off
|
||||
" - into separate functions!
|
||||
let cdefault = (s:pat =~ '[^,]$' ? "," : "") . default
|
||||
let open = substitute(s:pat . cdefault,
|
||||
\ s:notslash . '\zs:.\{-}' . s:notslash . ',', '\\),\\(', 'g')
|
||||
let open = '\(' . substitute(open, s:notslash . '\zs:.*$', '\\)', '')
|
||||
let close = substitute(s:pat . cdefault,
|
||||
\ s:notslash . '\zs,.\{-}' . s:notslash . ':', '\\),\\(', 'g')
|
||||
let close = substitute(close, '^.\{-}' . s:notslash . ':', '\\(', '') . '\)'
|
||||
if exists("b:match_skip")
|
||||
let skip = b:match_skip
|
||||
elseif exists("b:match_comment") " backwards compatibility and testing!
|
||||
let skip = "r:" . b:match_comment
|
||||
else
|
||||
let skip = 's:comment\|string'
|
||||
endif
|
||||
let skip = s:ParseSkip(skip)
|
||||
let view = winsaveview()
|
||||
|
||||
" Third step: call searchpair().
|
||||
" Replace '\('--but not '\\('--with '\%(' and ',' with '\|'.
|
||||
let openpat = substitute(open, '\(\\\@<!\(\\\\\)*\)\@<=\\(', '\\%(', 'g')
|
||||
let openpat = substitute(openpat, ',', '\\|', 'g')
|
||||
let closepat = substitute(close, '\(\\\@<!\(\\\\\)*\)\@<=\\(', '\\%(', 'g')
|
||||
let closepat = substitute(closepat, ',', '\\|', 'g')
|
||||
|
||||
if skip =~ 'synID' && !(has("syntax") && exists("g:syntax_on"))
|
||||
let skip = '0'
|
||||
else
|
||||
try
|
||||
execute "if " . skip . "| let skip = '0' | endif"
|
||||
catch /^Vim\%((\a\+)\)\=:E363/
|
||||
" We won't find anything, so skip searching, should keep Vim responsive.
|
||||
return {}
|
||||
endtry
|
||||
endif
|
||||
mark '
|
||||
let level = v:count1
|
||||
while level
|
||||
if searchpair(openpat, '', closepat, a:spflag, skip) < 1
|
||||
call s:CleanUp(restore_options, a:mode, startline, startcol)
|
||||
return {}
|
||||
endif
|
||||
let level = level - 1
|
||||
endwhile
|
||||
|
||||
" Restore options and return view dict to restore the original position.
|
||||
call s:CleanUp(restore_options, a:mode, startline, startcol)
|
||||
return view
|
||||
endfun
|
||||
|
||||
" Search backwards for "if" or "while" or "<tag>" or ...
|
||||
" and return "endif" or "endwhile" or "</tag>" or ... .
|
||||
" For now, this uses b:match_words and the same script variables
|
||||
" as s:Match_wrapper() . Later, it may get its own patterns,
|
||||
" either from a buffer variable or passed as arguments.
|
||||
" fun! s:Autocomplete()
|
||||
" echo "autocomplete not yet implemented :-("
|
||||
" if !exists("b:match_words") || b:match_words == ""
|
||||
" return ""
|
||||
" end
|
||||
" let startpos = s:MultiMatch("bW")
|
||||
"
|
||||
" if startpos == ""
|
||||
" return ""
|
||||
" endif
|
||||
" " - TODO: figure out whether 'if' or '<tag>' matched, and construct
|
||||
" " - the appropriate closing.
|
||||
" let matchline = getline(".")
|
||||
" let curcol = col(".") - 1
|
||||
" " - TODO: Change the s:all argument if there is a new set of match pats.
|
||||
" let regexp = s:Wholematch(matchline, s:all, curcol)
|
||||
" let suf = strlen(matchline) - matchend(matchline, regexp)
|
||||
" let prefix = (curcol ? '^.\{' . curcol . '}\%(' : '^\%(')
|
||||
" let suffix = (suf ? '\).\{' . suf . '}$' : '\)$')
|
||||
" " Reconstruct the version with unresolved backrefs.
|
||||
" let patBR = substitute(b:match_words.',', '[,:]*,[,:]*', ',', 'g')
|
||||
" let patBR = substitute(patBR, ':\{2,}', ':', "g")
|
||||
" " Now, set group and groupBR to the matching group: 'if:endif' or
|
||||
" " 'while:endwhile' or whatever.
|
||||
" let group = s:Choose(s:pat, matchline, ",", ":", prefix, suffix, patBR)
|
||||
" let i = matchend(group, s:notslash . ",")
|
||||
" let groupBR = strpart(group, i)
|
||||
" let group = strpart(group, 0, i-1)
|
||||
" " Now, matchline =~ prefix . substitute(group,':','\|','g') . suffix
|
||||
" if s:do_BR
|
||||
" let group = s:InsertRefs(groupBR, prefix, group, suffix, matchline)
|
||||
" endif
|
||||
" " let g:group = group
|
||||
"
|
||||
" " - TODO: Construct the closing from group.
|
||||
" let fake = "end" . expand("<cword>")
|
||||
" execute startpos
|
||||
" return fake
|
||||
" endfun
|
||||
|
||||
" Close all open structures. "Get the heck out of here!"
|
||||
" fun! s:Gthhoh()
|
||||
" let close = s:Autocomplete()
|
||||
" while strlen(close)
|
||||
" put=close
|
||||
" let close = s:Autocomplete()
|
||||
" endwhile
|
||||
" endfun
|
||||
|
||||
" Parse special strings as typical skip arguments for searchpair():
|
||||
" s:foo becomes (current syntax item) =~ foo
|
||||
" S:foo becomes (current syntax item) !~ foo
|
||||
" r:foo becomes (line before cursor) =~ foo
|
||||
" R:foo becomes (line before cursor) !~ foo
|
||||
fun! s:ParseSkip(str)
|
||||
let skip = a:str
|
||||
if skip[1] == ":"
|
||||
if skip[0] == "s"
|
||||
let skip = "synIDattr(synID(line('.'),col('.'),1),'name') =~? '" .
|
||||
\ strpart(skip,2) . "'"
|
||||
elseif skip[0] == "S"
|
||||
let skip = "synIDattr(synID(line('.'),col('.'),1),'name') !~? '" .
|
||||
\ strpart(skip,2) . "'"
|
||||
elseif skip[0] == "r"
|
||||
let skip = "strpart(getline('.'),0,col('.'))=~'" . strpart(skip,2). "'"
|
||||
elseif skip[0] == "R"
|
||||
let skip = "strpart(getline('.'),0,col('.'))!~'" . strpart(skip,2). "'"
|
||||
endif
|
||||
endif
|
||||
return skip
|
||||
endfun
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
|
||||
" vim:sts=2:sw=2:
|
||||
" Nvim: load the matchit plugin by default.
|
||||
packadd matchit
|
||||
|
|
|
@ -1,82 +1,33 @@
|
|||
" Vim plugin for converting a syntax highlighted file to HTML.
|
||||
" Maintainer: Ben Fritz <fritzophrenic@gmail.com>
|
||||
" Last Change: 2015 Sep 08
|
||||
" Last Change: 2018 Nov 11
|
||||
"
|
||||
" The core of the code is in $VIMRUNTIME/autoload/tohtml.vim and
|
||||
" $VIMRUNTIME/syntax/2html.vim
|
||||
"
|
||||
" TODO: {{{
|
||||
" * Options for generating the CSS in external style sheets. New :TOcss
|
||||
" command to convert the current color scheme into a (mostly) generic CSS
|
||||
" stylesheet which can be re-used. Alternate stylesheet support? Good start
|
||||
" by Erik Falor
|
||||
" ( https://groups.google.com/d/topic/vim_use/7XTmC4D22dU/discussion ).
|
||||
" * Add optional argument to :TOhtml command to specify mode (gui, cterm,
|
||||
" term) to use for the styling. Suggestion by "nacitar".
|
||||
" * Add way to override or specify which RGB colors map to the color numbers
|
||||
" in cterm. Get better defaults than just guessing? Suggestion by "nacitar".
|
||||
" * Disable filetype detection until after all processing is done.
|
||||
" * Add option for not generating the hyperlink on stuff that looks like a
|
||||
" URL? Or just color the link to fit with the colorscheme (and only special
|
||||
" when hovering)?
|
||||
" * Bug: Opera does not allow printing more than one page if uncopyable
|
||||
" regions is turned on. Possible solution: Add normal text line numbers with
|
||||
" display:none, set to display:inline for print style sheets, and hide
|
||||
" <input> elements for print, to allow Opera printing multiple pages (and
|
||||
" other uncopyable areas?). May need to make the new text invisible to IE
|
||||
" with conditional comments to prevent copying it, IE for some reason likes
|
||||
" to copy hidden text. Other browsers too?
|
||||
" * Bug: still a 1px gap throughout the fold column when html_prevent_copy is
|
||||
" "fn" in some browsers. Specifically, in Chromium on Ubuntu (but not Chrome
|
||||
" on Windows). Perhaps it is font related?
|
||||
" * Bug: still some gaps in the fold column when html_prevent_copy contains
|
||||
" 'd' and showing the whole diff (observed in multiple browsers). Only gaps
|
||||
" on diff lines though.
|
||||
" * Undercurl support via CSS3, with fallback to dotted or something:
|
||||
" https://groups.google.com/d/topic/vim_use/BzXA6He1pHg/discussion
|
||||
" * Redo updates for modified default foldtext (v11) when/if the patch is
|
||||
" accepted to modify it.
|
||||
" * Test case +diff_one_file-dynamic_folds+expand_tabs-hover_unfold
|
||||
" +ignore_conceal-ignore_folding+no_foldcolumn+no_pre+no_progress
|
||||
" +number_lines-pre_wrap-use_css+use_xhtml+whole_filler.xhtml
|
||||
" does not show the whole diff filler as it is supposed to?
|
||||
" * Bug: when 'isprint' is wrong for the current encoding, will generate
|
||||
" invalid content. Can/should anything be done about this? Maybe a separate
|
||||
" plugin to correct 'isprint' based on encoding?
|
||||
" * Check to see if the windows-125\d encodings actually work in Unix without
|
||||
" the 8bit- prefix. Add prefix to autoload dictionaries for Unix if not.
|
||||
" * Font auto-detection similar to
|
||||
" http://www.vim.org/scripts/script.php?script_id=2384 but for a variety of
|
||||
" platforms.
|
||||
" * Error thrown when sourcing 2html.vim directly when plugins are not loaded.
|
||||
" * Pull in code from http://www.vim.org/scripts/script.php?script_id=3113 :
|
||||
" - listchars support
|
||||
" - full-line background highlight
|
||||
" - other?
|
||||
" * Make it so deleted lines in a diff don't create side-scrolling (get it
|
||||
" free with full-line background highlight above).
|
||||
" * Restore open/closed folds and cursor position after processing each file
|
||||
" with option not to restore for speed increase.
|
||||
" * Add extra meta info (generation time, etc.)?
|
||||
" * Tidy up so we can use strict doctype in even more situations
|
||||
" * Implementation detail: add threshold for writing the lines to the html
|
||||
" buffer before we're done (5000 or so lines should do it)
|
||||
" * TODO comments for code cleanup scattered throughout
|
||||
"}}}
|
||||
|
||||
if exists('g:loaded_2html_plugin')
|
||||
finish
|
||||
endif
|
||||
let g:loaded_2html_plugin = 'vim7.4_v2'
|
||||
let g:loaded_2html_plugin = 'vim8.1_v1'
|
||||
|
||||
"
|
||||
" Changelog: {{{
|
||||
" 7.4_v2 (this version): Fix error raised when converting a diff containing
|
||||
" 8.1_v1 (this version): Fix Bitbucket issue #6: Don't generate empty script
|
||||
" tag.
|
||||
" Fix Bitbucket issue #5: javascript should
|
||||
" declare variables with "var".
|
||||
" Fix Bitbucket issue #13: errors thrown sourcing
|
||||
" 2html.vim directly when plugins not loaded.
|
||||
" Fix Bitbucket issue #16: support 'vartabstop'.
|
||||
"
|
||||
" 7.4 updates: {{{
|
||||
" 7.4_v2 (Vim 7.4.0899): Fix error raised when converting a diff containing
|
||||
" an empty buffer. Jan Stocker: allow g:html_font to
|
||||
" take a list so it is easier to specfiy fallback
|
||||
" fonts in the generated CSS.
|
||||
" 7.4_v1 (Vim 7.4.0000): Fix modeline mangling for new "Vim:" format, and
|
||||
" also for version-specific modelines like "vim>703:".
|
||||
"}}}
|
||||
"
|
||||
" 7.3 updates: {{{
|
||||
" 7.3_v14 (Vim 7.3.1246): Allow suppressing line number anchors using
|
||||
|
@ -170,9 +121,69 @@ let g:loaded_2html_plugin = 'vim7.4_v2'
|
|||
"}}}
|
||||
"}}}
|
||||
|
||||
" TODO: {{{
|
||||
" * Check the issue tracker:
|
||||
" https://bitbucket.org/fritzophrenic/vim-tohtml/issues?status=new&status=open
|
||||
" * Options for generating the CSS in external style sheets. New :TOcss
|
||||
" command to convert the current color scheme into a (mostly) generic CSS
|
||||
" stylesheet which can be re-used. Alternate stylesheet support? Good start
|
||||
" by Erik Falor
|
||||
" ( https://groups.google.com/d/topic/vim_use/7XTmC4D22dU/discussion ).
|
||||
" * Add optional argument to :TOhtml command to specify mode (gui, cterm,
|
||||
" term) to use for the styling. Suggestion by "nacitar".
|
||||
" * Add way to override or specify which RGB colors map to the color numbers
|
||||
" in cterm. Get better defaults than just guessing? Suggestion by "nacitar".
|
||||
" * Disable filetype detection until after all processing is done.
|
||||
" * Add option for not generating the hyperlink on stuff that looks like a
|
||||
" URL? Or just color the link to fit with the colorscheme (and only special
|
||||
" when hovering)?
|
||||
" * Bug: Opera does not allow printing more than one page if uncopyable
|
||||
" regions is turned on. Possible solution: Add normal text line numbers with
|
||||
" display:none, set to display:inline for print style sheets, and hide
|
||||
" <input> elements for print, to allow Opera printing multiple pages (and
|
||||
" other uncopyable areas?). May need to make the new text invisible to IE
|
||||
" with conditional comments to prevent copying it, IE for some reason likes
|
||||
" to copy hidden text. Other browsers too?
|
||||
" * Bug: still a 1px gap throughout the fold column when html_prevent_copy is
|
||||
" "fn" in some browsers. Specifically, in Chromium on Ubuntu (but not Chrome
|
||||
" on Windows). Perhaps it is font related?
|
||||
" * Bug: still some gaps in the fold column when html_prevent_copy contains
|
||||
" 'd' and showing the whole diff (observed in multiple browsers). Only gaps
|
||||
" on diff lines though.
|
||||
" * Undercurl support via CSS3, with fallback to dotted or something:
|
||||
" https://groups.google.com/d/topic/vim_use/BzXA6He1pHg/discussion
|
||||
" * Redo updates for modified default foldtext (v11) when/if the patch is
|
||||
" accepted to modify it.
|
||||
" * Test case +diff_one_file-dynamic_folds+expand_tabs-hover_unfold
|
||||
" +ignore_conceal-ignore_folding+no_foldcolumn+no_pre+no_progress
|
||||
" +number_lines-pre_wrap-use_css+use_xhtml+whole_filler.xhtml
|
||||
" does not show the whole diff filler as it is supposed to?
|
||||
" * Bug: when 'isprint' is wrong for the current encoding, will generate
|
||||
" invalid content. Can/should anything be done about this? Maybe a separate
|
||||
" plugin to correct 'isprint' based on encoding?
|
||||
" * Check to see if the windows-125\d encodings actually work in Unix without
|
||||
" the 8bit- prefix. Add prefix to autoload dictionaries for Unix if not.
|
||||
" * Font auto-detection similar to
|
||||
" http://www.vim.org/scripts/script.php?script_id=2384 but for a variety of
|
||||
" platforms.
|
||||
" * Pull in code from http://www.vim.org/scripts/script.php?script_id=3113 :
|
||||
" - listchars support
|
||||
" - full-line background highlight
|
||||
" - other?
|
||||
" * Make it so deleted lines in a diff don't create side-scrolling (get it
|
||||
" free with full-line background highlight above).
|
||||
" * Restore open/closed folds and cursor position after processing each file
|
||||
" with option not to restore for speed increase.
|
||||
" * Add extra meta info (generation time, etc.)?
|
||||
" * Tidy up so we can use strict doctype in even more situations
|
||||
" * Implementation detail: add threshold for writing the lines to the html
|
||||
" buffer before we're done (5000 or so lines should do it)
|
||||
" * TODO comments for code cleanup scattered throughout
|
||||
"}}}
|
||||
|
||||
" Define the :TOhtml command when:
|
||||
" - 'compatible' is not set
|
||||
" - this plugin was not already loaded
|
||||
" - this plugin or user override was not already loaded
|
||||
" - user commands are available. {{{
|
||||
if !&cp && !exists(":TOhtml") && has("user_commands")
|
||||
command -range=% -bar TOhtml :call tohtml#Convert2HTML(<line1>, <line2>)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
" Vim support file to detect file types in scripts
|
||||
"
|
||||
" Maintainer: Bram Moolenaar <Bram@vim.org>
|
||||
" Last change: 2018 Feb 03
|
||||
" Last change: 2019 Jun 25
|
||||
|
||||
" This file is called by an autocommand for every file that has just been
|
||||
" loaded into a buffer. It checks if the type of file can be recognized by
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
" Vim syntax support file
|
||||
" Maintainer: Ben Fritz <fritzophrenic@gmail.com>
|
||||
" Last Change: 2015 Sep 08
|
||||
" Last Change: 2018 Nov 11
|
||||
"
|
||||
" Additional contributors:
|
||||
"
|
||||
|
@ -633,6 +633,45 @@ if s:current_syntax == ''
|
|||
let s:current_syntax = 'none'
|
||||
endif
|
||||
|
||||
" If the user is sourcing this script directly then the plugin version isn't
|
||||
" known because the main plugin script didn't load. In the usual case where the
|
||||
" user still has the full Vim runtime installed, or has this full plugin
|
||||
" installed in a package or something, then we can extract the version from the
|
||||
" main plugin file at it's usual spot relative to this file. Otherwise the user
|
||||
" is assembling their runtime piecemeal and we have no idea what versions of
|
||||
" other files may be present so don't even try to make a guess or assume the
|
||||
" presence of other specific files with specific meaning.
|
||||
"
|
||||
" We don't want to actually source the main plugin file here because the user
|
||||
" may have a good reason not to (e.g. they define their own TOhtml command or
|
||||
" something).
|
||||
"
|
||||
" If this seems way too complicated and convoluted, it is. Probably I should
|
||||
" have put the version information in the autoload file from the start. But the
|
||||
" version has been in the global variable for so long that changing it could
|
||||
" break a lot of user scripts.
|
||||
if exists("g:loaded_2html_plugin")
|
||||
let s:pluginversion = g:loaded_2html_plugin
|
||||
else
|
||||
if !exists("g:unloaded_tohtml_plugin")
|
||||
let s:main_plugin_path = expand("<sfile>:p:h:h")."/plugin/tohtml.vim"
|
||||
if filereadable(s:main_plugin_path)
|
||||
let s:lines = readfile(s:main_plugin_path, "", 20)
|
||||
call filter(s:lines, 'v:val =~ "loaded_2html_plugin = "')
|
||||
if empty(s:lines)
|
||||
let g:unloaded_tohtml_plugin = "unknown"
|
||||
else
|
||||
let g:unloaded_tohtml_plugin = substitute(s:lines[0], '.*loaded_2html_plugin = \([''"]\)\(\%(\1\@!.\)\+\)\1', '\2', '')
|
||||
endif
|
||||
unlet s:lines
|
||||
else
|
||||
let g:unloaded_tohtml_plugin = "unknown"
|
||||
endif
|
||||
unlet s:main_plugin_path
|
||||
endif
|
||||
let s:pluginversion = g:unloaded_tohtml_plugin
|
||||
endif
|
||||
|
||||
" Split window to create a buffer with the HTML file.
|
||||
let s:orgbufnr = winbufnr(0)
|
||||
let s:origwin_stl = &l:stl
|
||||
|
@ -721,7 +760,7 @@ endif
|
|||
call extend(s:lines, [
|
||||
\ ("<title>".expand("%:p:~")."</title>"),
|
||||
\ ("<meta name=\"Generator\" content=\"Vim/".v:version/100.".".v:version%100.'"'.s:tag_close),
|
||||
\ ("<meta name=\"plugin-version\" content=\"".g:loaded_2html_plugin.'"'.s:tag_close)
|
||||
\ ("<meta name=\"plugin-version\" content=\"".s:pluginversion.'"'.s:tag_close)
|
||||
\ ])
|
||||
call add(s:lines, '<meta name="syntax" content="'.s:current_syntax.'"'.s:tag_close)
|
||||
call add(s:lines, '<meta name="settings" content="'.
|
||||
|
@ -807,12 +846,15 @@ if s:settings.use_css
|
|||
endif
|
||||
endif
|
||||
|
||||
" insert script tag; javascript is always needed for the line number
|
||||
" normalization for URL hashes
|
||||
call extend(s:lines, [
|
||||
\ "",
|
||||
\ "<script type='text/javascript'>",
|
||||
\ s:settings.use_xhtml ? '//<![CDATA[' : "<!--"])
|
||||
let s:uses_script = s:settings.dynamic_folds || s:settings.line_ids || !empty(s:settings.prevent_copy)
|
||||
|
||||
" insert script tag if needed
|
||||
if s:uses_script
|
||||
call extend(s:lines, [
|
||||
\ "",
|
||||
\ "<script type='text/javascript'>",
|
||||
\ s:settings.use_xhtml ? '//<![CDATA[' : "<!--"])
|
||||
endif
|
||||
|
||||
" insert javascript to toggle folds open and closed
|
||||
if s:settings.dynamic_folds
|
||||
|
@ -849,8 +891,9 @@ if s:settings.line_ids
|
|||
\ " if (lineNum.indexOf('L') == -1) {",
|
||||
\ " lineNum = 'L'+lineNum;",
|
||||
\ " }",
|
||||
\ " lineElem = document.getElementById(lineNum);"
|
||||
\ " var lineElem = document.getElementById(lineNum);"
|
||||
\ ])
|
||||
|
||||
if s:settings.dynamic_folds
|
||||
call extend(s:lines, [
|
||||
\ "",
|
||||
|
@ -940,12 +983,14 @@ if !empty(s:settings.prevent_copy)
|
|||
\ ])
|
||||
endif
|
||||
|
||||
" insert script closing tag
|
||||
call extend(s:lines, [
|
||||
\ '',
|
||||
\ s:settings.use_xhtml ? '//]]>' : '-->',
|
||||
\ "</script>"
|
||||
\ ])
|
||||
" insert script closing tag if needed
|
||||
if s:uses_script
|
||||
call extend(s:lines, [
|
||||
\ '',
|
||||
\ s:settings.use_xhtml ? '//]]>' : '-->',
|
||||
\ "</script>"
|
||||
\ ])
|
||||
endif
|
||||
|
||||
call extend(s:lines, ["</head>"])
|
||||
if !empty(s:settings.prevent_copy)
|
||||
|
@ -1525,10 +1570,22 @@ while s:lnum <= s:end
|
|||
if s:settings.expand_tabs
|
||||
let s:offset = 0
|
||||
let s:idx = stridx(s:expandedtab, "\t")
|
||||
let s:tablist = split(&vts,',')
|
||||
if empty(s:tablist)
|
||||
let s:tablist = [ &ts ]
|
||||
endif
|
||||
let s:tabidx = 0
|
||||
let s:tabwidth = 0
|
||||
while s:idx >= 0
|
||||
while s:startcol+s:idx > s:tabwidth + s:tablist[s:tabidx]
|
||||
let s:tabwidth += s:tablist[s:tabidx]
|
||||
if s:tabidx < len(s:tablist)-1
|
||||
let s:tabidx = s:tabidx+1
|
||||
endif
|
||||
endwhile
|
||||
if has("multi_byte_encoding")
|
||||
if s:startcol + s:idx == 1
|
||||
let s:i = &ts
|
||||
let s:i = s:tablist[s:tabidx]
|
||||
else
|
||||
if s:idx == 0
|
||||
let s:prevc = matchstr(s:line, '.\%' . (s:startcol + s:idx + s:offset) . 'c')
|
||||
|
@ -1536,11 +1593,11 @@ while s:lnum <= s:end
|
|||
let s:prevc = matchstr(s:expandedtab, '.\%' . (s:idx + 1) . 'c')
|
||||
endif
|
||||
let s:vcol = virtcol([s:lnum, s:startcol + s:idx + s:offset - len(s:prevc)])
|
||||
let s:i = &ts - (s:vcol % &ts)
|
||||
let s:i = s:tablist[s:tabidx] - (s:vcol - s:tabwidth)
|
||||
endif
|
||||
let s:offset -= s:i - 1
|
||||
else
|
||||
let s:i = &ts - ((s:idx + s:startcol - 1) % &ts)
|
||||
let s:i = s:tablist[s:tabidx] - ((s:idx + s:startcol - 1) - s:tabwidth)
|
||||
endif
|
||||
let s:expandedtab = substitute(s:expandedtab, '\t', repeat(' ', s:i), '')
|
||||
let s:idx = stridx(s:expandedtab, "\t")
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
" Vim ABAP syntax file
|
||||
" Language: SAP - ABAP/R4
|
||||
" Revision: 2.1
|
||||
" Maintainer: Marius Piedallu van Wyk <lailoken@gmail.com>
|
||||
" Last Change: 2013 Jun 13
|
||||
" Last Change: 2018 Dec 12
|
||||
" Comment: Thanks to EPI-USE Labs for all your assistance. :)
|
||||
|
||||
" quit when a syntax file was already loaded
|
||||
" Quit when a syntax file was already loaded
|
||||
if exists("b:current_syntax")
|
||||
finish
|
||||
endif
|
||||
|
@ -55,6 +54,7 @@ syn match abapComplexStatement "\<RESPECTING\W\+BLANKS\>"
|
|||
syn match abapComplexStatement "\<SEPARATED\W\+BY\>"
|
||||
syn match abapComplexStatement "\<USING\(\W\+EDIT\W\+MASK\)\?\>"
|
||||
syn match abapComplexStatement "\<WHERE\(\W\+LINE\)\?\>"
|
||||
syn match abapComplexStatement "\<GET\W\+\(TIME\(\W\+STAMP\)\?\(\W\+FIELD\)\?\|PF-STATUS\|BADI\|BIT\|CONNECTION\|CURSOR\|REFERENCE\W\+OF\)\>"
|
||||
syn match abapComplexStatement "\<RADIOBUTTON\W\+GROUP\>"
|
||||
syn match abapComplexStatement "\<REF\W\+TO\>"
|
||||
syn match abapComplexStatement "\<\(PUBLIC\|PRIVATE\|PROTECTED\)\(\W\+SECTION\)\?\>"
|
||||
|
@ -109,7 +109,7 @@ syn keyword abapStatement CALL CASE CATCH CHECK CLASS CLEAR CLOSE CNT COLLECT CO
|
|||
syn keyword abapStatement DATA DEFINE DEFINITION DEFERRED DELETE DESCRIBE DETAIL DIVIDE DO
|
||||
syn keyword abapStatement ELSE ELSEIF ENDAT ENDCASE ENDCLASS ENDDO ENDEXEC ENDFORM ENDFUNCTION ENDIF ENDIFEND ENDINTERFACE ENDLOOP ENDMETHOD ENDMODULE ENDON ENDPROVIDE ENDSELECT ENDTRY ENDWHILE EVENT EVENTS EXEC EXIT EXPORT EXPORTING EXTRACT
|
||||
syn keyword abapStatement FETCH FIELDS FORM FORMAT FREE FROM FUNCTION
|
||||
syn keyword abapStatement GENERATE GET
|
||||
syn keyword abapStatement GENERATE
|
||||
syn keyword abapStatement HIDE
|
||||
syn keyword abapStatement IF IMPORT IMPORTING INDEX INFOTYPES INITIALIZATION INTERFACE INTERFACES INPUT INSERT IMPLEMENTATION
|
||||
syn keyword abapStatement LEAVE LIKE LINE LOAD LOCAL LOOP
|
||||
|
@ -147,7 +147,7 @@ syn keyword abapSpecial TRUE FALSE NULL SPACE
|
|||
syn region abapInclude start="include" end="." contains=abapComment
|
||||
|
||||
" Types
|
||||
syn keyword abapTypes c n i p f d t x string xstring decfloat16 decfloat34
|
||||
syn keyword abapTypes c n i int8 p f d t x string xstring decfloat16 decfloat34
|
||||
|
||||
" Atritmitic operators
|
||||
syn keyword abapOperator abs sign ceil floor trunc frac acos asin atan cos sin tan
|
||||
|
@ -193,5 +193,4 @@ hi def link abapHex Number
|
|||
|
||||
let b:current_syntax = "abap"
|
||||
|
||||
" vim: ts=8 sw=2
|
||||
|
||||
" vim: ts=8 sw=2
|
|
@ -3,7 +3,7 @@
|
|||
" Maintainer: David Necas (Yeti) <yeti@physics.muni.cz>
|
||||
" License: This file can be redistribued and/or modified under the same terms
|
||||
" as Vim itself.
|
||||
" Last Change: 2014-03-04
|
||||
" Last Change: 2018-12-06
|
||||
" Notes: Last synced with apache-2.2.3, version 1.x is no longer supported
|
||||
" TODO: see particular FIXME's scattered through the file
|
||||
" make it really linewise?
|
||||
|
@ -159,7 +159,7 @@ syn keyword apacheOption inherit
|
|||
syn keyword apacheDeclaration BrowserMatch BrowserMatchNoCase SetEnvIf SetEnvIfNoCase
|
||||
syn keyword apacheDeclaration LoadFile LoadModule
|
||||
syn keyword apacheDeclaration CheckSpelling CheckCaseOnly
|
||||
syn keyword apacheDeclaration SSLCACertificateFile SSLCACertificatePath SSLCADNRequestFile SSLCADNRequestPath SSLCARevocationFile SSLCARevocationPath SSLCertificateChainFile SSLCertificateFile SSLCertificateKeyFile SSLCipherSuite SSLCryptoDevice SSLEngine SSLHonorCipherOrder SSLMutex SSLOptions SSLPassPhraseDialog SSLProtocol SSLProxyCACertificateFile SSLProxyCACertificatePath SSLProxyCARevocationFile SSLProxyCARevocationPath SSLProxyCipherSuite SSLProxyEngine SSLProxyMachineCertificateFile SSLProxyMachineCertificatePath SSLProxyProtocol SSLProxyVerify SSLProxyVerifyDepth SSLRandomSeed SSLRequire SSLRequireSSL SSLSessionCache SSLSessionCacheTimeout SSLUserName SSLVerifyClient SSLVerifyDepth
|
||||
syn keyword apacheDeclaration SSLCACertificateFile SSLCACertificatePath SSLCADNRequestFile SSLCADNRequestPath SSLCARevocationFile SSLCARevocationPath SSLCertificateChainFile SSLCertificateFile SSLCertificateKeyFile SSLCipherSuite SSLCompression SSLCryptoDevice SSLEngine SSLFIPS SSLHonorCipherOrder SSLInsecureRenegotiation SSLMutex SSLOptions SSLPassPhraseDialog SSLProtocol SSLProxyCACertificateFile SSLProxyCACertificatePath SSLProxyCARevocationFile SSLProxyCARevocationPath SSLProxyCheckPeerCN SSLProxyCheckPeerExpire SSLProxyCipherSuite SSLProxyEngine SSLProxyMachineCertificateChainFile SSLProxyMachineCertificateFile SSLProxyMachineCertificatePath SSLProxyProtocol SSLProxyVerify SSLProxyVerifyDepth SSLRandomSeed SSLRenegBufferSize SSLRequire SSLRequireSSL SSLSessionCache SSLSessionCacheTimeout SSLSessionTicketKeyFile SSLSessionTickets SSLStrictSNIVHostCheck SSLUserName SSLVerifyClient SSLVerifyDepth
|
||||
syn match apacheOption "[+-]\?\<\(StdEnvVars\|CompatEnvVars\|ExportCertData\|FakeBasicAuth\|StrictRequire\|OptRenegotiate\)\>"
|
||||
syn keyword apacheOption builtin sem
|
||||
syn match apacheOption "\(file\|exec\|egd\|dbm\|shm\):"
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
" Vim syntax file
|
||||
" Language: automake Makefile.am
|
||||
" Maintainer: Debian VIM Maintainers <pkg-vim-maintainers@lists.alioth.debian.org>
|
||||
" Former Maintainer: John Williams <jrw@pobox.com>
|
||||
" Last Change: 2011-06-13
|
||||
" URL: http://anonscm.debian.org/hg/pkg-vim/vim/raw-file/unstable/runtime/syntax/automake.vim
|
||||
" Language: automake Makefile.am
|
||||
" Maintainer: Debian Vim Maintainers
|
||||
" Former Maintainer: John Williams <jrw@pobox.com>
|
||||
" Last Change: 2018 Dec 27
|
||||
" URL: https://salsa.debian.org/vim-team/vim-debian/blob/master/syntax/automake.vim
|
||||
"
|
||||
" XXX This file is in need of a new maintainer, Debian VIM Maintainers maintain
|
||||
" it only because patches have been submitted for it by Debian users and the
|
||||
|
@ -18,7 +18,7 @@
|
|||
" EXTRA_SOURCES.
|
||||
|
||||
" Standard syntax initialization
|
||||
if exists("b:current_syntax")
|
||||
if exists('b:current_syntax')
|
||||
finish
|
||||
endif
|
||||
|
||||
|
@ -37,8 +37,8 @@ syn match automakeConditional "^\(if\s*!\=\w\+\|else\|endif\)\s*$"
|
|||
|
||||
syn match automakeSubst "@\w\+@"
|
||||
syn match automakeSubst "^\s*@\w\+@"
|
||||
syn match automakeComment1 "#.*$" contains=automakeSubst
|
||||
syn match automakeComment2 "##.*$"
|
||||
syn match automakeComment1 "#.*$" contains=automakeSubst,@Spell
|
||||
syn match automakeComment2 "##.*$" contains=@Spell
|
||||
|
||||
syn match automakeMakeError "$[{(][^})]*[^a-zA-Z0-9_})][^})]*[})]" " GNU make function call
|
||||
syn match automakeMakeError "^AM_LDADD\s*\ze+\==" " Common mistake
|
||||
|
@ -72,6 +72,6 @@ hi def link automakeMakeSString makeSString
|
|||
hi def link automakeMakeBString makeBString
|
||||
|
||||
|
||||
let b:current_syntax = "automake"
|
||||
let b:current_syntax = 'automake'
|
||||
|
||||
" vi: ts=8 sw=4 sts=4
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
" Maintainer: Nick Jensen <nickspoon@gmail.com>
|
||||
" Former Maintainers: Anduin Withers <awithers@anduin.com>
|
||||
" Johannes Zellner <johannes@zellner.org>
|
||||
" Last Change: 2018-06-29
|
||||
" Last Change: 2018-11-26
|
||||
" Filenames: *.cs
|
||||
" License: Vim (see :h license)
|
||||
" Repository: https://github.com/nickspoons/vim-cs
|
||||
|
@ -11,12 +11,12 @@
|
|||
" REFERENCES:
|
||||
" [1] ECMA TC39: C# Language Specification (WD13Oct01.doc)
|
||||
|
||||
if exists("b:current_syntax")
|
||||
finish
|
||||
if exists('b:current_syntax')
|
||||
finish
|
||||
endif
|
||||
|
||||
let s:cs_cpo_save = &cpo
|
||||
set cpo&vim
|
||||
let s:save_cpo = &cpoptions
|
||||
set cpoptions&vim
|
||||
|
||||
|
||||
syn keyword csType bool byte char decimal double float int long object sbyte short string T uint ulong ushort var void dynamic
|
||||
|
@ -34,7 +34,7 @@ syn keyword csException try catch finally throw when
|
|||
syn keyword csLinq ascending by descending equals from group in into join let on orderby select where
|
||||
syn keyword csAsync async await
|
||||
|
||||
syn keyword csUnspecifiedStatement as base checked event fixed in is lock nameof operator out params ref sizeof stackalloc this typeof unchecked unsafe using
|
||||
syn keyword csUnspecifiedStatement as base checked event fixed in is lock nameof operator out params ref sizeof stackalloc this unchecked unsafe using
|
||||
syn keyword csUnsupportedStatement add remove value
|
||||
syn keyword csUnspecifiedKeyword explicit implicit
|
||||
|
||||
|
@ -44,10 +44,16 @@ syn match csContextualStatement /\<partial[[:space:]\n]\+\(class\|struct\|interf
|
|||
syn match csContextualStatement /\<\(get\|set\)\(;\|[[:space:]\n]*{\)/me=s+3
|
||||
syn match csContextualStatement /\<where\>[^:]\+:/me=s+5
|
||||
|
||||
" Operators
|
||||
syn keyword csTypeOf typeof contained
|
||||
syn region csTypeOfStatement start="typeof(" end=")" contains=csType, csTypeOf
|
||||
|
||||
" Punctuation
|
||||
syn match csBraces "[{}\[\]]" display
|
||||
syn match csParens "[()]" display
|
||||
syn match csOpSymbols "[+\-><=]\{1,2}" display
|
||||
syn match csOpSymbols "[+\-=]\{1,2}" display
|
||||
syn match csOpSymbols "[><]\{2}" display
|
||||
syn match csOpSymbols "\s\zs[><]\ze\_s" display
|
||||
syn match csOpSymbols "[!><+\-*/]=" display
|
||||
syn match csOpSymbols "[!*/^]" display
|
||||
syn match csOpSymbols "=>" display
|
||||
|
@ -144,17 +150,18 @@ syn cluster csAll contains=csCharacter,csClassType,csComment,csContextualStateme
|
|||
|
||||
" The default highlighting.
|
||||
hi def link csType Type
|
||||
hi def link csNewType Type
|
||||
hi def link csClassType Type
|
||||
hi def link csIsType Type
|
||||
hi def link csStorage StorageClass
|
||||
hi def link csClass StorageClass
|
||||
hi def link csStorage Structure
|
||||
hi def link csClass Structure
|
||||
hi def link csRepeat Repeat
|
||||
hi def link csConditional Conditional
|
||||
hi def link csLabel Label
|
||||
hi def link csModifier StorageClass
|
||||
hi def link csConstant Constant
|
||||
hi def link csException Exception
|
||||
hi def link csTypeOf Operator
|
||||
hi def link csTypeOfStatement Typedef
|
||||
hi def link csUnspecifiedStatement Statement
|
||||
hi def link csUnsupportedStatement Statement
|
||||
hi def link csUnspecifiedKeyword Keyword
|
||||
|
@ -164,16 +171,12 @@ hi def link csIsAs Keyword
|
|||
hi def link csAsync Keyword
|
||||
hi def link csContextualStatement Statement
|
||||
hi def link csOperatorError Error
|
||||
hi def link csInterfaceDeclaration Include
|
||||
|
||||
hi def link csTodo Todo
|
||||
hi def link csComment Comment
|
||||
|
||||
hi def link csEndColon Statement
|
||||
hi def link csOpSymbols Operator
|
||||
hi def link csLogicSymbols Boolean
|
||||
hi def link csBraces Function
|
||||
hi def link csParens Operator
|
||||
hi def link csLogicSymbols Operator
|
||||
|
||||
hi def link csSpecialError Error
|
||||
hi def link csSpecialCharError Error
|
||||
|
@ -200,9 +203,9 @@ hi def link csXmlCommentLeader Comment
|
|||
hi def link csXmlComment Comment
|
||||
hi def link csXmlTag Statement
|
||||
|
||||
let b:current_syntax = "cs"
|
||||
let b:current_syntax = 'cs'
|
||||
|
||||
let &cpo = s:cs_cpo_save
|
||||
unlet s:cs_cpo_save
|
||||
let &cpoptions = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
|
||||
" vim: vts=16,28
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
" Maintainer: Debian Vim Maintainers
|
||||
" Former Maintainers: Gerfried Fuchs <alfie@ist.org>
|
||||
" Wichert Akkerman <wakkerma@debian.org>
|
||||
" Last Change: 2018 May 03
|
||||
" Last Change: 2019 Jan 26
|
||||
" URL: https://salsa.debian.org/vim-team/vim-debian/blob/master/syntax/debchangelog.vim
|
||||
|
||||
" Standard syntax initialization
|
||||
|
@ -14,14 +14,14 @@ endif
|
|||
" Case doesn't matter for us
|
||||
syn case ignore
|
||||
|
||||
let s:urgency='urgency=\(low\|medium\|high\|critical\)\( [^[:space:],][^,]*\)\='
|
||||
let s:urgency='urgency=\(low\|medium\|high\|emergency\|critical\)\( [^[:space:],][^,]*\)\='
|
||||
let s:binNMU='binary-only=yes'
|
||||
|
||||
" Define some common expressions we can use later on
|
||||
syn match debchangelogName contained "^[[:alnum:]][[:alnum:].+-]\+ "
|
||||
exe 'syn match debchangelogFirstKV contained "; \('.s:urgency.'\|'.s:binNMU.'\)"'
|
||||
exe 'syn match debchangelogOtherKV contained ", \('.s:urgency.'\|'.s:binNMU.'\)"'
|
||||
syn match debchangelogTarget contained "\v %(frozen|unstable|sid|%(testing|%(old)=stable)%(-proposed-updates|-security)=|experimental|squeeze-%(backports%(-sloppy)=|volatile|lts|security)|%(wheezy|jessie)%(-backports%(-sloppy)=|-security)=|stretch%(-backports|-security)=|%(devel|precise|trusty|vivid|wily|xenial|yakkety|zesty|artful|bionic|cosmic)%(-%(security|proposed|updates|backports|commercial|partner))=)+"
|
||||
syn match debchangelogTarget contained "\v %(frozen|unstable|sid|%(testing|%(old)=stable)%(-proposed-updates|-security)=|experimental|squeeze-%(backports%(-sloppy)=|volatile|lts|security)|%(wheezy|jessie)%(-backports%(-sloppy)=|-security)=|stretch%(-backports|-security)=|%(devel|precise|trusty|vivid|wily|xenial|yakkety|zesty|artful|bionic|cosmic|disco)%(-%(security|proposed|updates|backports|commercial|partner))=)+"
|
||||
syn match debchangelogVersion contained "(.\{-})"
|
||||
syn match debchangelogCloses contained "closes:\_s*\(bug\)\=#\=\_s\=\d\+\(,\_s*\(bug\)\=#\=\_s\=\d\+\)*"
|
||||
syn match debchangelogLP contained "\clp:\s\+#\d\+\(,\s*#\d\+\)*"
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
" Language: Debian sources.list
|
||||
" Maintainer: Debian Vim Maintainers
|
||||
" Former Maintainer: Matthijs Mohlmann <matthijs@cacholong.nl>
|
||||
" Last Change: 2018 Aug 11
|
||||
" Last Change: 2018 Oct 30
|
||||
" URL: https://salsa.debian.org/vim-team/vim-debian/blob/master/syntax/debsources.vim
|
||||
|
||||
" Standard syntax initialization
|
||||
|
@ -25,7 +25,7 @@ let s:supported = [
|
|||
\ 'oldstable', 'stable', 'testing', 'unstable', 'experimental',
|
||||
\ 'wheezy', 'jessie', 'stretch', 'sid', 'rc-buggy',
|
||||
\
|
||||
\ 'trusty', 'xenial', 'bionic', 'cosmic', 'devel'
|
||||
\ 'trusty', 'xenial', 'bionic', 'cosmic', 'disco', 'devel'
|
||||
\ ]
|
||||
let s:unsupported = [
|
||||
\ 'buzz', 'rex', 'bo', 'hamm', 'slink', 'potato',
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
" Language: Dune buildsystem
|
||||
" Maintainer: Markus Mottl <markus.mottl@gmail.com>
|
||||
" Anton Kochkov <anton.kochkov@gmail.com>
|
||||
" URL: https://github.com/rgrinberg/vim-ocaml
|
||||
" Last Change:
|
||||
" 2019 Feb 27 - Add newer keywords to the syntax (Simon Cruanes)
|
||||
" 2018 May 8 - Check current_syntax (Kawahara Satoru)
|
||||
" 2018 Mar 29 - Extend jbuild syntax with more keywords (Petter A. Urkedal)
|
||||
" 2017 Sep 6 - Initial version (Etienne Millon)
|
||||
|
||||
if exists("b:current_syntax")
|
||||
finish
|
||||
endif
|
||||
|
||||
set syntax=lisp
|
||||
syn case match
|
||||
|
||||
" The syn-iskeyword setting lacks #,? from the iskeyword setting here.
|
||||
" Clearing it avoids maintaining keyword characters in multiple places.
|
||||
syn iskeyword clear
|
||||
|
||||
syn keyword lispDecl jbuild_version library executable executables rule ocamllex ocamlyacc menhir alias install
|
||||
|
||||
syn keyword lispKey name public_name synopsis modules libraries wrapped
|
||||
syn keyword lispKey preprocess preprocessor_deps optional c_names cxx_names
|
||||
syn keyword lispKey install_c_headers modes no_dynlink self_build_stubs_archive
|
||||
syn keyword lispKey ppx_runtime_libraries virtual_deps js_of_ocaml link_flags
|
||||
syn keyword lispKey javascript_files flags ocamlc_flags ocamlopt_flags pps staged_pps
|
||||
syn keyword lispKey library_flags c_flags c_library_flags kind package action
|
||||
syn keyword lispKey deps targets locks fallback
|
||||
syn keyword lispKey inline_tests tests names
|
||||
|
||||
syn keyword lispAtom true false
|
||||
|
||||
syn keyword lispFunc cat chdir copy# diff? echo run setenv
|
||||
syn keyword lispFunc ignore-stdout ignore-stderr ignore-outputs
|
||||
syn keyword lispFunc with-stdout-to with-stderr-to with-outputs-to
|
||||
syn keyword lispFunc write-file system bash
|
||||
|
||||
syn cluster lispBaseListCluster add=duneVar
|
||||
syn match duneVar '\${[@<^]}' containedin=lispSymbol
|
||||
syn match duneVar '\${\k\+\(:\k\+\)\?}' containedin=lispSymbol
|
||||
|
||||
hi def link duneVar Identifier
|
||||
|
||||
let b:current_syntax = "dune"
|
|
@ -3,8 +3,9 @@
|
|||
" Maintainer: Tim Pope <vimNOSPAM@tpope.org>
|
||||
" URL: https://github.com/vim-ruby/vim-ruby
|
||||
" Release Coordinator: Doug Kearns <dougkearns@gmail.com>
|
||||
" Last Change: 2018 Jul 04
|
||||
|
||||
if exists("b:current_syntax")
|
||||
if &syntax !~# '\<eruby\>' || get(b:, 'current_syntax') =~# '\<eruby\>'
|
||||
finish
|
||||
endif
|
||||
|
||||
|
@ -18,11 +19,13 @@ endif
|
|||
|
||||
if &filetype =~ '^eruby\.'
|
||||
let b:eruby_subtype = matchstr(&filetype,'^eruby\.\zs\w\+')
|
||||
elseif &filetype =~ '^.*\.eruby\>'
|
||||
let b:eruby_subtype = matchstr(&filetype,'^.\{-\}\ze\.eruby\>')
|
||||
elseif !exists("b:eruby_subtype") && main_syntax == 'eruby'
|
||||
let s:lines = getline(1)."\n".getline(2)."\n".getline(3)."\n".getline(4)."\n".getline(5)."\n".getline("$")
|
||||
let b:eruby_subtype = matchstr(s:lines,'eruby_subtype=\zs\w\+')
|
||||
if b:eruby_subtype == ''
|
||||
let b:eruby_subtype = matchstr(substitute(expand("%:t"),'\c\%(\.erb\|\.eruby\|\.erubis\)\+$','',''),'\.\zs\w\+\%(\ze+\w\+\)\=$')
|
||||
let b:eruby_subtype = matchstr(substitute(expand("%:t"),'\c\%(\.erb\|\.eruby\|\.erubis\|\.example\)\+$','',''),'\.\zs\w\+\%(\ze+\w\+\)\=$')
|
||||
endif
|
||||
if b:eruby_subtype == 'rhtml'
|
||||
let b:eruby_subtype = 'html'
|
||||
|
@ -41,16 +44,20 @@ elseif !exists("b:eruby_subtype") && main_syntax == 'eruby'
|
|||
endif
|
||||
|
||||
if !exists("b:eruby_nest_level")
|
||||
let b:eruby_nest_level = strlen(substitute(substitute(substitute(expand("%:t"),'@','','g'),'\c\.\%(erb\|rhtml\)\>','@','g'),'[^@]','','g'))
|
||||
if &syntax =~# '\<eruby\.eruby\>'
|
||||
let b:eruby_nest_level = strlen(substitute(substitute(&filetype,'\C\<eruby\>','@','g'),'[^@]','','g'))
|
||||
else
|
||||
let b:eruby_nest_level = strlen(substitute(substitute(substitute(expand("%:t"),'@','','g'),'\c\.\%(erb\|rhtml\)\>','@','g'),'[^@]','','g'))
|
||||
endif
|
||||
endif
|
||||
if !b:eruby_nest_level
|
||||
let b:eruby_nest_level = 1
|
||||
endif
|
||||
|
||||
if exists("b:eruby_subtype") && b:eruby_subtype != ''
|
||||
if get(b:, 'eruby_subtype', '') !~# '^\%(eruby\)\=$' && &syntax =~# '^eruby\>'
|
||||
exe "runtime! syntax/".b:eruby_subtype.".vim"
|
||||
unlet! b:current_syntax
|
||||
endif
|
||||
unlet! b:current_syntax
|
||||
syn include @rubyTop syntax/ruby.vim
|
||||
|
||||
syn cluster erubyRegions contains=erubyOneLiner,erubyBlock,erubyExpression,erubyComment
|
||||
|
@ -65,7 +72,7 @@ exe 'syn region erubyComment matchgroup=erubyDelimiter start="<%\{1,'.b:erub
|
|||
hi def link erubyDelimiter PreProc
|
||||
hi def link erubyComment Comment
|
||||
|
||||
let b:current_syntax = 'eruby'
|
||||
let b:current_syntax = matchstr(&syntax, '^.*\<eruby\>')
|
||||
|
||||
if main_syntax == 'eruby'
|
||||
unlet main_syntax
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
" Maintainers: Markus Mottl <markus.mottl@gmail.com>
|
||||
" Karl-Heinz Sylla <Karl-Heinz.Sylla@gmd.de>
|
||||
" Issac Trotts <ijtrotts@ucdavis.edu>
|
||||
" URL: http://www.ocaml.info/vim/syntax/ocaml.vim
|
||||
" URL: https://github.com/rgrinberg/vim-ocaml
|
||||
" Last Change: 2012 May 12 - Added Dominique Pellé's spell checking patch (MM)
|
||||
" 2012 Feb 01 - Improved module path highlighting (MM)
|
||||
" 2010 Oct 11 - Added highlighting of lnot (MM, thanks to Erick Matsen)
|
||||
|
|
|
@ -0,0 +1,106 @@
|
|||
" Vim syntax file
|
||||
" Language: RAML (RESTful API Modeling Language)
|
||||
" Maintainer: Eric Hopkins <eric.on.tech@gmail.com>
|
||||
" URL: https://github.com/in3d/vim-raml
|
||||
" License: Same as Vim
|
||||
" Last Change: 2018-11-03
|
||||
|
||||
if exists("b:current_syntax")
|
||||
finish
|
||||
endif
|
||||
|
||||
let s:cpo_save = &cpo
|
||||
set cpo&vim
|
||||
|
||||
syn keyword ramlTodo contained TODO FIXME XXX NOTE
|
||||
|
||||
syn region ramlComment display oneline start='\%(^\|\s\)#' end='$'
|
||||
\ contains=ramlTodo,@Spell
|
||||
|
||||
syn region ramlVersion display oneline start='#%RAML' end='$'
|
||||
|
||||
syn match ramlNodeProperty '!\%(![^\\^% ]\+\|[^!][^:/ ]*\)'
|
||||
|
||||
syn match ramlAnchor '&.\+'
|
||||
|
||||
syn match ramlAlias '\*.\+'
|
||||
|
||||
syn match ramlDelimiter '[-,:]'
|
||||
syn match ramlBlock '[\[\]{}>|]'
|
||||
syn match ramlOperator '[?+-]'
|
||||
syn match ramlKey '\h\+\(?\)\?\ze\s*:'
|
||||
syn match ramlKey '\w\+\(\s\+\w\+\)*\(?\)\?\ze\s*:'
|
||||
syn match routeKey '\/\w\+\(\s\+\w\+\)*\ze\s*:'
|
||||
syn match routeKey 'application\/\w\+\ze\s*:'
|
||||
syn match routeParamKey '\/{\w\+}*\ze\s*:'
|
||||
|
||||
syn region ramlString matchgroup=ramlStringDelimiter
|
||||
\ start=+\s"+ skip=+\\"+ end=+"+
|
||||
\ contains=ramlEscape
|
||||
syn region ramlString matchgroup=ramlStringDelimiter
|
||||
\ start=+\s'+ skip=+''+ end=+'+
|
||||
\ contains=ramlStringEscape
|
||||
syn region ramlParameter matchgroup=ramlParameterDelimiter
|
||||
\ start=+<<+ skip=+''+ end=+>>+
|
||||
syn match ramlEscape contained display +\\[\\"abefnrtv^0_ NLP]+
|
||||
syn match ramlEscape contained display '\\x\x\{2}'
|
||||
syn match ramlEscape contained display '\\u\x\{4}'
|
||||
syn match ramlEscape contained display '\\U\x\{8}'
|
||||
syn match ramlEscape display '\\\%(\r\n\|[\r\n]\)'
|
||||
syn match ramlStringEscape contained +''+
|
||||
|
||||
syn match ramlNumber display
|
||||
\ '\<[+-]\=\d\+\%(\.\d\+\%([eE][+-]\=\d\+\)\=\)\='
|
||||
syn match ramlNumber display '0\o\+'
|
||||
syn match ramlNumber display '0x\x\+'
|
||||
syn match ramlNumber display '([+-]\=[iI]nf)'
|
||||
syn match ramlNumber display '(NaN)'
|
||||
|
||||
syn match ramlConstant '\<[~yn]\>'
|
||||
syn keyword ramlConstant true True TRUE false False FALSE
|
||||
syn keyword ramlConstant yes Yes on ON no No off OFF
|
||||
syn keyword ramlConstant null Null NULL nil Nil NIL
|
||||
|
||||
syn keyword httpVerbs get post put delete head patch options
|
||||
syn keyword ramlTypes string number integer date boolean file
|
||||
|
||||
syn match ramlTimestamp '\d\d\d\d-\%(1[0-2]\|\d\)-\%(3[0-2]\|2\d\|1\d\|\d\)\%( \%([01]\d\|2[0-3]\):[0-5]\d:[0-5]\d.\d\d [+-]\%([01]\d\|2[0-3]\):[0-5]\d\|t\%([01]\d\|2[0-3]\):[0-5]\d:[0-5]\d.\d\d[+-]\%([01]\d\|2[0-3]\):[0-5]\d\|T\%([01]\d\|2[0-3]\):[0-5]\d:[0-5]\d.\dZ\)\='
|
||||
|
||||
syn region ramlDocumentHeader start='---' end='$' contains=ramlDirective
|
||||
syn match ramlDocumentEnd '\.\.\.'
|
||||
|
||||
syn match ramlDirective contained '%[^:]\+:.\+'
|
||||
|
||||
hi def link ramlVersion String
|
||||
hi def link routeInterpolation String
|
||||
hi def link ramlInterpolation Constant
|
||||
hi def link ramlTodo Todo
|
||||
hi def link ramlComment Comment
|
||||
hi def link ramlDocumentHeader PreProc
|
||||
hi def link ramlDocumentEnd PreProc
|
||||
hi def link ramlDirective Keyword
|
||||
hi def link ramlNodeProperty Type
|
||||
hi def link ramlAnchor Type
|
||||
hi def link ramlAlias Type
|
||||
hi def link ramlBlock Operator
|
||||
hi def link ramlOperator Operator
|
||||
hi def link routeParamKey SpecialChar
|
||||
hi def link ramlKey Identifier
|
||||
hi def link routeKey SpecialChar
|
||||
hi def link ramlParameterDelimiter Type
|
||||
hi def link ramlParameter Type
|
||||
hi def link ramlString String
|
||||
hi def link ramlStringDelimiter ramlString
|
||||
hi def link ramlEscape SpecialChar
|
||||
hi def link ramlStringEscape SpecialChar
|
||||
hi def link ramlNumber Number
|
||||
hi def link ramlConstant Constant
|
||||
hi def link ramlTimestamp Number
|
||||
hi def link httpVerbs Statement
|
||||
hi def link ramlTypes Type
|
||||
hi def link ramlDelimiter Delimiter
|
||||
|
||||
let b:current_syntax = "raml"
|
||||
|
||||
let &cpo = s:cpo_save
|
||||
unlet s:cpo_save
|
|
@ -3,7 +3,7 @@
|
|||
" Maintainer: Marshall Ward <marshall.ward@gmail.com>
|
||||
" Previous Maintainer: Nikolai Weibull <now@bitwi.se>
|
||||
" Website: https://github.com/marshallward/vim-restructuredtext
|
||||
" Latest Revision: 2018-07-23
|
||||
" Latest Revision: 2018-12-29
|
||||
|
||||
if exists("b:current_syntax")
|
||||
finish
|
||||
|
@ -59,6 +59,7 @@ syn keyword rstTodo contained FIXME TODO XXX NOTE
|
|||
|
||||
execute 'syn region rstComment contained' .
|
||||
\ ' start=/.*/'
|
||||
\ ' skip=+^$+' .
|
||||
\ ' end=/^\s\@!/ contains=rstTodo'
|
||||
|
||||
execute 'syn region rstFootnote contained matchgroup=rstDirective' .
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
" Maintainer: Doug Kearns <dougkearns@gmail.com>
|
||||
" URL: https://github.com/vim-ruby/vim-ruby
|
||||
" Release Coordinator: Doug Kearns <dougkearns@gmail.com>
|
||||
" Last Change: 2018 Jul 09
|
||||
" ----------------------------------------------------------------------------
|
||||
"
|
||||
" Previous Maintainer: Mirko Nasato
|
||||
|
@ -45,7 +46,7 @@ function! s:foldable(...) abort
|
|||
return 0
|
||||
endfunction " }}}
|
||||
|
||||
syn cluster rubyNotTop contains=@rubyExtendedStringSpecial,@rubyRegexpSpecial,@rubyDeclaration,rubyConditional,rubyExceptional,rubyMethodExceptional,rubyTodo
|
||||
syn cluster rubyNotTop contains=@rubyExtendedStringSpecial,@rubyRegexpSpecial,@rubyDeclaration,rubyConditional,rubyExceptional,rubyMethodExceptional,rubyTodo,rubyModuleName,rubyClassName,rubySymbolDelimiter
|
||||
|
||||
" Whitespace Errors {{{1
|
||||
if exists("ruby_space_errors")
|
||||
|
@ -122,21 +123,24 @@ syn match rubyFloat "\%(\%(\w\|[]})\"']\s*\)\@<!-\)\=\<\%(0\|[1-9]\d*\%(_\d\+\)*
|
|||
syn match rubyLocalVariableOrMethod "\<[_[:lower:]][_[:alnum:]]*[?!=]\=" contains=NONE display transparent
|
||||
syn match rubyBlockArgument "&[_[:lower:]][_[:alnum:]]" contains=NONE display transparent
|
||||
|
||||
syn match rubyClassName "\%(\%(^\|[^.]\)\.\s*\)\@<!\<\u\%(\w\|[^\x00-\x7F]\)*\>\%(\s*(\)\@!" contained
|
||||
syn match rubyModuleName "\%(\%(^\|[^.]\)\.\s*\)\@<!\<\u\%(\w\|[^\x00-\x7F]\)*\>\%(\s*(\)\@!" contained
|
||||
syn match rubyConstant "\%(\%(^\|[^.]\)\.\s*\)\@<!\<\u\%(\w\|[^\x00-\x7F]\)*\>\%(\s*(\)\@!"
|
||||
syn match rubyClassVariable "@@\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*" display
|
||||
syn match rubyInstanceVariable "@\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*" display
|
||||
syn match rubyGlobalVariable "$\%(\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*\|-.\)"
|
||||
syn match rubySymbol "[]})\"':]\@1<!:\%(\^\|\~@\|\~\|<<\|<=>\|<=\|<\|===\|[=!]=\|[=!]\~\|!@\|!\|>>\|>=\|>\||\|-@\|-\|/\|\[]=\|\[]\|\*\*\|\*\|&\|%\|+@\|+\|`\)"
|
||||
syn match rubySymbol "[]})\"':]\@1<!:\$\%(-.\|[`~<=>_,;:!?/.'"@$*\&+0]\)"
|
||||
syn match rubySymbol "[]})\"':]\@1<!:\%(\$\|@@\=\)\=\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*"
|
||||
syn match rubySymbol "[]})\"':]\@1<!:\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*\%([?!=]>\@!\)\="
|
||||
syn match rubySymbolDelimiter ":" contained
|
||||
syn match rubySymbol "[]})\"':]\@1<!:\%(\^\|\~@\|\~\|<<\|<=>\|<=\|<\|===\|[=!]=\|[=!]\~\|!@\|!\|>>\|>=\|>\||\|-@\|-\|/\|\[]=\|\[]\|\*\*\|\*\|&\|%\|+@\|+\|`\)" contains=rubySymbolDelimiter
|
||||
syn match rubySymbol "[]})\"':]\@1<!:\$\%(-.\|[`~<=>_,;:!?/.'"@$*\&+0]\)" contains=rubySymbolDelimiter
|
||||
syn match rubySymbol "[]})\"':]\@1<!:\%(\$\|@@\=\)\=\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*" contains=rubySymbolDelimiter
|
||||
syn match rubySymbol "[]})\"':]\@1<!:\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*\%([?!=]>\@!\)\=" contains=rubySymbolDelimiter
|
||||
|
||||
if s:foldable(':')
|
||||
syn region rubySymbol start="[]})\"':]\@1<!:'" end="'" skip="\\\\\|\\'" contains=rubyQuoteEscape fold
|
||||
syn region rubySymbol start="[]})\"':]\@1<!:\"" end="\"" skip="\\\\\|\\\"" contains=@rubyStringSpecial fold
|
||||
syn region rubySymbol matchgroup=rubySymbolDelimiter start="[]})\"':]\@1<!:'" end="'" skip="\\\\\|\\'" contains=rubyQuoteEscape fold
|
||||
syn region rubySymbol matchgroup=rubySymbolDelimiter start="[]})\"':]\@1<!:\"" end="\"" skip="\\\\\|\\\"" contains=@rubyStringSpecial fold
|
||||
else
|
||||
syn region rubySymbol start="[]})\"':]\@1<!:'" end="'" skip="\\\\\|\\'" contains=rubyQuoteEscape
|
||||
syn region rubySymbol start="[]})\"':]\@1<!:\"" end="\"" skip="\\\\\|\\\"" contains=@rubyStringSpecial
|
||||
syn region rubySymbol matchgroup=rubySymbolDelimiter start="[]})\"':]\@1<!:'" end="'" skip="\\\\\|\\'" contains=rubyQuoteEscape
|
||||
syn region rubySymbol matchgroup=rubySymbolDelimiter start="[]})\"':]\@1<!:\"" end="\"" skip="\\\\\|\\\"" contains=@rubyStringSpecial
|
||||
endif
|
||||
|
||||
syn match rubyCapitalizedMethod "\%(\%(^\|[^.]\)\.\s*\)\@<!\<\u\%(\w\|[^\x00-\x7F]\)*\>\%(\s*(\)*\s*(\@="
|
||||
|
@ -157,10 +161,10 @@ syn match rubyPredefinedConstant "\%(\%(^\|[^.]\)\.\s*\)\@<!\<\%(RUBY_\%(VERSION
|
|||
" Normal Regular Expression {{{1
|
||||
if s:foldable('/')
|
||||
syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="\%(\%(^\|\<\%(and\|or\|while\|until\|unless\|if\|elsif\|when\|not\|then\|else\)\|[;\~=!|&(,{[<>?:*+-]\)\s*\)\@<=/" end="/[iomxneus]*" skip="\\\\\|\\/" contains=@rubyRegexpSpecial fold
|
||||
syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="\%(\h\k*\s\+\)\@<=/[ \t=]\@!" end="/[iomxneus]*" skip="\\\\\|\\/" contains=@rubyRegexpSpecial fold
|
||||
syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="\%(\h\k*\s\+\)\@<=/\%([ \t=]\|$\)\@!" end="/[iomxneus]*" skip="\\\\\|\\/" contains=@rubyRegexpSpecial fold
|
||||
else
|
||||
syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="\%(\%(^\|\<\%(and\|or\|while\|until\|unless\|if\|elsif\|when\|not\|then\|else\)\|[;\~=!|&(,{[<>?:*+-]\)\s*\)\@<=/" end="/[iomxneus]*" skip="\\\\\|\\/" contains=@rubyRegexpSpecial
|
||||
syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="\%(\h\k*\s\+\)\@<=/[ \t=]\@!" end="/[iomxneus]*" skip="\\\\\|\\/" contains=@rubyRegexpSpecial
|
||||
syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="\%(\h\k*\s\+\)\@<=/\%([ \t=]\|$\)\@!" end="/[iomxneus]*" skip="\\\\\|\\/" contains=@rubyRegexpSpecial
|
||||
endif
|
||||
|
||||
" Generalized Regular Expression {{{1
|
||||
|
@ -275,10 +279,10 @@ else
|
|||
endif
|
||||
|
||||
" Here Document {{{1
|
||||
syn region rubyHeredocStart matchgroup=rubyStringDelimiter start=+\%(\%(class\s*\|\%([]})"'.]\|::\)\)\_s*\|\w\)\@<!<<[-~]\=\zs\%(\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*\)+ end=+$+ oneline contains=ALLBUT,@rubyNotTop
|
||||
syn region rubyHeredocStart matchgroup=rubyStringDelimiter start=+\%(\%(class\s*\|\%([]})"'.]\|::\)\)\_s*\|\w\)\@<!<<[-~]\=\zs"\%([^"]*\)"+ end=+$+ oneline contains=ALLBUT,@rubyNotTop
|
||||
syn region rubyHeredocStart matchgroup=rubyStringDelimiter start=+\%(\%(class\s*\|\%([]})"'.]\|::\)\)\_s*\|\w\)\@<!<<[-~]\=\zs'\%([^']*\)'+ end=+$+ oneline contains=ALLBUT,@rubyNotTop
|
||||
syn region rubyHeredocStart matchgroup=rubyStringDelimiter start=+\%(\%(class\s*\|\%([]})"'.]\|::\)\)\_s*\|\w\)\@<!<<[-~]\=\zs`\%([^`]*\)`+ end=+$+ oneline contains=ALLBUT,@rubyNotTop
|
||||
syn region rubyHeredocStart matchgroup=rubyStringDelimiter start=+\%(\%(class\|::\)\_s*\|\%([]})"'.]\)\s\|\w\)\@<!<<[-~]\=\zs\%(\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*\)+ end=+$+ oneline contains=ALLBUT,@rubyNotTop
|
||||
syn region rubyHeredocStart matchgroup=rubyStringDelimiter start=+\%(\%(class\|::\)\_s*\|\%([]})"'.]\)\s\|\w\)\@<!<<[-~]\=\zs"\%([^"]*\)"+ end=+$+ oneline contains=ALLBUT,@rubyNotTop
|
||||
syn region rubyHeredocStart matchgroup=rubyStringDelimiter start=+\%(\%(class\|::\)\_s*\|\%([]})"'.]\)\s\|\w\)\@<!<<[-~]\=\zs'\%([^']*\)'+ end=+$+ oneline contains=ALLBUT,@rubyNotTop
|
||||
syn region rubyHeredocStart matchgroup=rubyStringDelimiter start=+\%(\%(class\|::\)\_s*\|\%([]})"'.]\)\s\|\w\)\@<!<<[-~]\=\zs`\%([^`]*\)`+ end=+$+ oneline contains=ALLBUT,@rubyNotTop
|
||||
|
||||
if s:foldable('<<')
|
||||
syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]})"'.]\)\s\|\w\)\@<!<<\z(\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*\)\ze\%(.*<<[-~]\=['`"]\=\h\)\@!+hs=s+2 matchgroup=rubyStringDelimiter end=+^\z1$+ contains=rubyHeredocStart,rubyHeredoc,@rubyStringSpecial fold keepend
|
||||
|
@ -305,19 +309,19 @@ endif
|
|||
" eRuby Config {{{1
|
||||
if exists('main_syntax') && main_syntax == 'eruby'
|
||||
let b:ruby_no_expensive = 1
|
||||
end
|
||||
endif
|
||||
|
||||
" Module, Class, Method and Alias Declarations {{{1
|
||||
syn match rubyAliasDeclaration "[^[:space:];#.()]\+" contained contains=rubySymbol,rubyGlobalVariable,rubyPredefinedVariable nextgroup=rubyAliasDeclaration2 skipwhite
|
||||
syn match rubyAliasDeclaration2 "[^[:space:];#.()]\+" contained contains=rubySymbol,rubyGlobalVariable,rubyPredefinedVariable
|
||||
syn match rubyMethodDeclaration "[^[:space:];#(]\+" contained contains=rubyConstant,rubyBoolean,rubyPseudoVariable,rubyInstanceVariable,rubyClassVariable,rubyGlobalVariable
|
||||
syn match rubyClassDeclaration "[^[:space:];#<]\+" contained contains=rubyConstant,rubyOperator
|
||||
syn match rubyModuleDeclaration "[^[:space:];#<]\+" contained contains=rubyConstant,rubyOperator
|
||||
syn match rubyFunction "\<[_[:alpha:]][_[:alnum:]]*[?!=]\=[[:alnum:]_.:?!=]\@!" contained containedin=rubyMethodDeclaration
|
||||
syn match rubyFunction "\%(\s\|^\)\@1<=[_[:alpha:]][_[:alnum:]]*[?!=]\=\%(\s\|$\)\@=" contained containedin=rubyAliasDeclaration,rubyAliasDeclaration2
|
||||
syn match rubyFunction "\%([[:space:].]\|^\)\@2<=\%(\[\]=\=\|\*\*\|[-+!~]@\=\|[*/%|&^~]\|<<\|>>\|[<>]=\=\|<=>\|===\|[=!]=\|[=!]\~\|!\|`\)\%([[:space:];#(]\|$\)\@=" contained containedin=rubyAliasDeclaration,rubyAliasDeclaration2,rubyMethodDeclaration
|
||||
syn match rubyClassDeclaration "[^[:space:];#<]\+" contained contains=rubyClassName,rubyOperator
|
||||
syn match rubyModuleDeclaration "[^[:space:];#<]\+" contained contains=rubyModuleName,rubyOperator
|
||||
syn match rubyMethodName "\<[_[:alpha:]][_[:alnum:]]*[?!=]\=[[:alnum:]_.:?!=]\@!" contained containedin=rubyMethodDeclaration
|
||||
syn match rubyMethodName "\%(\s\|^\)\@1<=[_[:alpha:]][_[:alnum:]]*[?!=]\=\%(\s\|$\)\@=" contained containedin=rubyAliasDeclaration,rubyAliasDeclaration2
|
||||
syn match rubyMethodName "\%([[:space:].]\|^\)\@2<=\%(\[\]=\=\|\*\*\|[-+!~]@\=\|[*/%|&^~]\|<<\|>>\|[<>]=\=\|<=>\|===\|[=!]=\|[=!]\~\|!\|`\)\%([[:space:];#(]\|$\)\@=" contained containedin=rubyAliasDeclaration,rubyAliasDeclaration2,rubyMethodDeclaration
|
||||
|
||||
syn cluster rubyDeclaration contains=rubyAliasDeclaration,rubyAliasDeclaration2,rubyMethodDeclaration,rubyModuleDeclaration,rubyClassDeclaration,rubyFunction,rubyBlockParameter
|
||||
syn cluster rubyDeclaration contains=rubyAliasDeclaration,rubyAliasDeclaration2,rubyMethodDeclaration,rubyModuleDeclaration,rubyClassDeclaration,rubyMethodName,rubyBlockParameter
|
||||
|
||||
" Keywords {{{1
|
||||
" Note: the following keywords have already been defined:
|
||||
|
@ -335,7 +339,7 @@ syn match rubyBeginEnd "\<\%(BEGIN\|END\)\>[?!]\@!"
|
|||
if !exists("b:ruby_no_expensive") && !exists("ruby_no_expensive")
|
||||
syn match rubyDefine "\<alias\>" nextgroup=rubyAliasDeclaration skipwhite skipnl
|
||||
syn match rubyDefine "\<def\>" nextgroup=rubyMethodDeclaration skipwhite skipnl
|
||||
syn match rubyDefine "\<undef\>" nextgroup=rubyFunction skipwhite skipnl
|
||||
syn match rubyDefine "\<undef\>" nextgroup=rubyMethodName skipwhite skipnl
|
||||
syn match rubyClass "\<class\>" nextgroup=rubyClassDeclaration skipwhite skipnl
|
||||
syn match rubyModule "\<module\>" nextgroup=rubyModuleDeclaration skipwhite skipnl
|
||||
|
||||
|
@ -377,8 +381,6 @@ if !exists("b:ruby_no_expensive") && !exists("ruby_no_expensive")
|
|||
|
||||
if s:foldable('[')
|
||||
syn region rubyArrayLiteral matchgroup=rubyArrayDelimiter start="\%(\w\|[\]})]\)\@<!\[" end="]" contains=ALLBUT,@rubyNotTop fold
|
||||
else
|
||||
syn region rubyArrayLiteral matchgroup=rubyArrayDelimiter start="\%(\w\|[\]})]\)\@<!\[" end="]" contains=ALLBUT,@rubyNotTop
|
||||
endif
|
||||
|
||||
" statements without 'do'
|
||||
|
@ -437,10 +439,12 @@ if !exists("ruby_no_special_methods")
|
|||
syn match rubyControl "\<\%(exit!\|\%(abort\|at_exit\|exit\|fork\|loop\|trap\)\>[?!]\@!\)"
|
||||
syn keyword rubyEval eval class_eval instance_eval module_eval
|
||||
syn keyword rubyException raise fail catch throw
|
||||
" false positive with 'include?'
|
||||
syn match rubyInclude "\<include\>[?!]\@!"
|
||||
syn keyword rubyInclude autoload extend load prepend refine require require_relative using
|
||||
syn keyword rubyInclude autoload gem load require require_relative
|
||||
syn keyword rubyKeyword callcc caller lambda proc
|
||||
" false positive with 'include?'
|
||||
syn match rubyMacro "\<include\>[?!]\@!"
|
||||
syn keyword rubyMacro extend prepend refine using
|
||||
syn keyword rubyMacro alias_method define_method define_singleton_method remove_method undef_method
|
||||
endif
|
||||
|
||||
" Comments and Documentation {{{1
|
||||
|
@ -461,7 +465,7 @@ syn match rubyKeywordAsMethod "\(defined?\|exit!\)\@!\<[_[:lower:]][_[:alnum:]]*
|
|||
|
||||
" More Symbols {{{1
|
||||
syn match rubySymbol "\%([{(,]\_s*\)\zs\l\w*[!?]\=::\@!"he=e-1
|
||||
syn match rubySymbol "[]})\"':]\@1<!\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*[!?]\=:[[:space:],]\@="he=e-1
|
||||
syn match rubySymbol "[]})\"':]\@1<!\<\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*[!?]\=:[[:space:],]\@="he=e-1
|
||||
syn match rubySymbol "\%([{(,]\_s*\)\zs[[:space:],{]\l\w*[!?]\=::\@!"hs=s+1,he=e-1
|
||||
syn match rubySymbol "[[:space:],{(]\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*[!?]\=:[[:space:],]\@="hs=s+1,he=e-1
|
||||
|
||||
|
@ -477,6 +481,10 @@ hi def link rubyClass rubyDefine
|
|||
hi def link rubyModule rubyDefine
|
||||
hi def link rubyMethodExceptional rubyDefine
|
||||
hi def link rubyDefine Define
|
||||
hi def link rubyAccess rubyMacro
|
||||
hi def link rubyAttribute rubyMacro
|
||||
hi def link rubyMacro Macro
|
||||
hi def link rubyMethodName rubyFunction
|
||||
hi def link rubyFunction Function
|
||||
hi def link rubyConditional Conditional
|
||||
hi def link rubyConditionalModifier rubyConditional
|
||||
|
@ -498,8 +506,9 @@ else
|
|||
endif
|
||||
hi def link rubyClassVariable rubyIdentifier
|
||||
hi def link rubyConstant Type
|
||||
hi def link rubyClassName rubyConstant
|
||||
hi def link rubyModuleName rubyConstant
|
||||
hi def link rubyGlobalVariable rubyIdentifier
|
||||
hi def link rubyBlockParameter rubyIdentifier
|
||||
hi def link rubyInstanceVariable rubyIdentifier
|
||||
hi def link rubyPredefinedIdentifier rubyIdentifier
|
||||
hi def link rubyPredefinedConstant rubyPredefinedIdentifier
|
||||
|
@ -508,8 +517,6 @@ hi def link rubySymbol Constant
|
|||
hi def link rubyKeyword Keyword
|
||||
hi def link rubyOperator Operator
|
||||
hi def link rubyBeginEnd Statement
|
||||
hi def link rubyAccess Statement
|
||||
hi def link rubyAttribute Statement
|
||||
hi def link rubyEval Statement
|
||||
hi def link rubyPseudoVariable Constant
|
||||
hi def link rubyCapitalizedMethod rubyLocalVariableOrMethod
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
" Language: shell (sh) Korn shell (ksh) bash (sh)
|
||||
" Maintainer: Charles E. Campbell <NdrOchipS@PcampbellAfamily.Mbiz>
|
||||
" Previous Maintainer: Lennart Schultz <Lennart.Schultz@ecmwf.int>
|
||||
" Last Change: Sep 04, 2018
|
||||
" Version: 182
|
||||
" Last Change: Nov 23, 2018
|
||||
" Version: 185
|
||||
" URL: http://www.drchip.org/astronaut/vim/index.html#SYNTAX_SH
|
||||
" For options and settings, please use: :help ft-sh-syntax
|
||||
" This file includes many ideas from Eric Brunet (eric.brunet@ens.fr)
|
||||
|
@ -144,12 +144,12 @@ endif
|
|||
syn cluster shHereBeginList contains=@shCommandSubList
|
||||
syn cluster shHereList contains=shBeginHere,shHerePayload
|
||||
syn cluster shHereListDQ contains=shBeginHere,@shDblQuoteList,shHerePayload
|
||||
syn cluster shIdList contains=shCommandSub,shCommandSubBQ,shWrapLineOperator,shSetOption,shComment,shDeref,shDerefSimple,shHereString,shRedir,shExSingleQuote,shExDoubleQuote,shSingleQuote,shDoubleQuote,shExpr,shCtrlSeq,shStringSpecial,shAtExpr
|
||||
syn cluster shIdList contains=shCommandSub,shCommandSubBQ,shWrapLineOperator,shSetOption,shComment,shDeref,shDerefSimple,shHereString,shNumber,shOperator,shRedir,shExSingleQuote,shExDoubleQuote,shSingleQuote,shDoubleQuote,shExpr,shCtrlSeq,shStringSpecial,shAtExpr
|
||||
syn cluster shIfList contains=@shLoopList,shDblBrace,shDblParen,shFunctionKey,shFunctionOne,shFunctionTwo
|
||||
syn cluster shLoopList contains=@shCaseList,@shErrorList,shCaseEsac,shConditional,shDblBrace,shExpr,shFor,shForPP,shIf,shOption,shSet,shTest,shTestOpr,shTouch
|
||||
syn cluster shPPSRightList contains=shComment,shDeref,shDerefSimple,shEscape,shPosnParm
|
||||
syn cluster shSubShList contains=@shCommandSubList,shCommandSubBQ,shCaseEsac,shColon,shCommandSub,shComment,shDo,shEcho,shExpr,shFor,shIf,shHereString,shRedir,shSetList,shSource,shStatement,shVariable,shCtrlSeq,shOperator
|
||||
syn cluster shTestList contains=shCharClass,shCommandSub,shCommandSubBQ,shCtrlSeq,shDeref,shDerefSimple,shDoubleQuote,shSpecialDQ,shExDoubleQuote,shExpr,shExSingleQuote,shNumber,shOperator,shSingleQuote,shTest,shTestOpr
|
||||
syn cluster shTestList contains=shArithmetic,shCharClass,shCommandSub,shCommandSubBQ,shCtrlSeq,shDeref,shDerefSimple,shDoubleQuote,shSpecialDQ,shExDoubleQuote,shExpr,shExSingleQuote,shNumber,shOperator,shSingleQuote,shTest,shTestOpr
|
||||
syn cluster shNoZSList contains=shSpecialNoZS
|
||||
syn cluster shForList contains=shTestOpr,shNumber,shDerefSimple,shDeref,shCommandSub,shCommandSubBQ,shArithmetic
|
||||
|
||||
|
@ -292,7 +292,9 @@ endif
|
|||
"======
|
||||
syn match shWrapLineOperator "\\$"
|
||||
syn region shCommandSubBQ start="`" skip="\\\\\|\\." end="`" contains=shBQComment,@shCommandSubList
|
||||
syn match shEscape contained '\%(^\)\@!\%(\\\\\)*\\.' nextgroup=shSingleQuote,shDoubleQuote,shComment
|
||||
"see ksh13
|
||||
"syn match shEscape contained '\%(^\)\@!\%(\\\\\)*\\.' nextgroup=shSingleQuote,shDoubleQuote,shComment
|
||||
syn match shEscape contained '\%(^\)\@!\%(\\\\\)*\\.' nextgroup=shComment
|
||||
|
||||
" $() and $(()): {{{1
|
||||
" $(..) is not supported by sh (Bourne shell). However, apparently
|
||||
|
@ -379,22 +381,22 @@ syn match shBQComment contained "#.\{-}\ze`" contains=@shCommentGroup
|
|||
|
||||
" Here Documents: {{{1
|
||||
" =========================================
|
||||
ShFoldHereDoc syn region shHereDoc matchgroup=shHereDoc01 start="<<\s*\\\=\z([^ \t0-9|>]\+\)" matchgroup=shHereDoc01 end="^\z1\s*$" contains=@shDblQuoteList
|
||||
ShFoldHereDoc syn region shHereDoc matchgroup=shHereDoc02 start="<<\s*\"\z([^ \t|>]\+\)\"" matchgroup=shHereDoc02 end="^\z1\s*$"
|
||||
ShFoldHereDoc syn region shHereDoc matchgroup=shHereDoc03 start="<<-\s*\z([^ \t0-9|>]\+\)" matchgroup=shHereDoc03 end="^\s*\z1\s*$" contains=@shDblQuoteList
|
||||
ShFoldHereDoc syn region shHereDoc matchgroup=shHereDoc01 start="<<\s*\\\=\z([^ \t|>]\+\)" matchgroup=shHereDoc01 end="^\z1\s*$" contains=@shDblQuoteList
|
||||
ShFoldHereDoc syn region shHereDoc matchgroup=shHereDoc02 start="<<\s*\"\z([^"]\+\)\"" matchgroup=shHereDoc02 end="^\z1\s*$"
|
||||
ShFoldHereDoc syn region shHereDoc matchgroup=shHereDoc03 start="<<-\s*\z([^ \t|>]\+\)" matchgroup=shHereDoc03 end="^\s*\z1\s*$" contains=@shDblQuoteList
|
||||
ShFoldHereDoc syn region shHereDoc matchgroup=shHereDoc04 start="<<-\s*'\z([^']\+\)'" matchgroup=shHereDoc04 end="^\s*\z1\s*$"
|
||||
ShFoldHereDoc syn region shHereDoc matchgroup=shHereDoc05 start="<<\s*'\z([^']\+\)'" matchgroup=shHereDoc05 end="^\z1\s*$"
|
||||
ShFoldHereDoc syn region shHereDoc matchgroup=shHereDoc06 start="<<-\s*\"\z([^ \t|>]\+\)\"" matchgroup=shHereDoc06 end="^\s*\z1\s*$"
|
||||
ShFoldHereDoc syn region shHereDoc matchgroup=shHereDoc07 start="<<\s*\\\_$\_s*\z([^ \t0-9|>]\+\)" matchgroup=shHereDoc07 end="^\z1\s*$" contains=@shDblQuoteList
|
||||
ShFoldHereDoc syn region shHereDoc matchgroup=shHereDoc08 start="<<\s*\\\_$\_s*'\z([^ \t0-9|>]\+\)'" matchgroup=shHereDoc08 end="^\z1\s*$"
|
||||
ShFoldHereDoc syn region shHereDoc matchgroup=shHereDoc09 start="<<\s*\\\_$\_s*\"\z([^ \t0-9|>]\+\)\"" matchgroup=shHereDoc09 end="^\z1\s*$"
|
||||
ShFoldHereDoc syn region shHereDoc matchgroup=shHereDoc10 start="<<-\s*\\\_$\_s*\z([^ \t0-9|>]\+\)" matchgroup=shHereDoc10 end="^\s*\z1\s*$"
|
||||
ShFoldHereDoc syn region shHereDoc matchgroup=shHereDoc11 start="<<-\s*\\\_$\_s*\\\z([^ \t0-9|>]\+\)" matchgroup=shHereDoc11 end="^\s*\z1\s*$"
|
||||
ShFoldHereDoc syn region shHereDoc matchgroup=shHereDoc12 start="<<-\s*\\\_$\_s*'\z([^ \t|>]\+\)'" matchgroup=shHereDoc12 end="^\s*\z1\s*$"
|
||||
ShFoldHereDoc syn region shHereDoc matchgroup=shHereDoc13 start="<<-\s*\\\_$\_s*\"\z([^ \t|>]\+\)\"" matchgroup=shHereDoc13 end="^\s*\z1\s*$"
|
||||
ShFoldHereDoc syn region shHereDoc matchgroup=shHereDoc14 start="<<\\\z([^ \t0-9|>]\+\)" matchgroup=shHereDoc14 end="^\z1\s*$"
|
||||
ShFoldHereDoc syn region shHereDoc matchgroup=shHereDoc15 start="<<-\s*\\\z([^ \t0-9|>]\+\)" matchgroup=shHereDoc15 end="^\s*\z1\s*$"
|
||||
ShFoldHereDoc syn region shHereDoc matchgroup=shHereDoc16 start="<<-\s*\\\z([^ \t0-9|>]\+\)" matchgroup=shHereDoc15 end="^\s*\z1\s*$"
|
||||
ShFoldHereDoc syn region shHereDoc matchgroup=shHereDoc06 start="<<-\s*\"\z([^"]\+\)\"" matchgroup=shHereDoc06 end="^\s*\z1\s*$"
|
||||
ShFoldHereDoc syn region shHereDoc matchgroup=shHereDoc07 start="<<\s*\\\_$\_s*\z([^ \t|>]\+\)" matchgroup=shHereDoc07 end="^\z1\s*$" contains=@shDblQuoteList
|
||||
ShFoldHereDoc syn region shHereDoc matchgroup=shHereDoc08 start="<<\s*\\\_$\_s*'\z([^ \t|>]\+\)'" matchgroup=shHereDoc08 end="^\z1\s*$"
|
||||
ShFoldHereDoc syn region shHereDoc matchgroup=shHereDoc09 start="<<\s*\\\_$\_s*\"\z([^ \t|>]\+\)\"" matchgroup=shHereDoc09 end="^\z1\s*$"
|
||||
ShFoldHereDoc syn region shHereDoc matchgroup=shHereDoc10 start="<<-\s*\\\_$\_s*\z([^ \t|>]\+\)" matchgroup=shHereDoc10 end="^\s*\z1\s*$"
|
||||
ShFoldHereDoc syn region shHereDoc matchgroup=shHereDoc11 start="<<-\s*\\\_$\_s*\\\z([^ \t|>]\+\)" matchgroup=shHereDoc11 end="^\s*\z1\s*$"
|
||||
ShFoldHereDoc syn region shHereDoc matchgroup=shHereDoc12 start="<<-\s*\\\_$\_s*'\z([^']\+\)'" matchgroup=shHereDoc12 end="^\s*\z1\s*$"
|
||||
ShFoldHereDoc syn region shHereDoc matchgroup=shHereDoc13 start="<<-\s*\\\_$\_s*\"\z([^"]\+\)\"" matchgroup=shHereDoc13 end="^\s*\z1\s*$"
|
||||
ShFoldHereDoc syn region shHereDoc matchgroup=shHereDoc14 start="<<\\\z([^ \t|>]\+\)" matchgroup=shHereDoc14 end="^\z1\s*$"
|
||||
ShFoldHereDoc syn region shHereDoc matchgroup=shHereDoc15 start="<<-\s*\\\z([^ \t|>]\+\)" matchgroup=shHereDoc15 end="^\s*\z1\s*$"
|
||||
ShFoldHereDoc syn region shHereDoc matchgroup=shHereDoc16 start="<<-\s*\\\z([^ \t|>]\+\)" matchgroup=shHereDoc15 end="^\s*\z1\s*$"
|
||||
|
||||
" Here Strings: {{{1
|
||||
" =============
|
||||
|
@ -407,18 +409,19 @@ endif
|
|||
"=============
|
||||
syn match shSetOption "\s\zs[-+][a-zA-Z0-9]\+\>" contained
|
||||
syn match shVariable "\<\([bwglsav]:\)\=[a-zA-Z0-9.!@_%+,]*\ze=" nextgroup=shVarAssign
|
||||
syn match shVarAssign "=" contained nextgroup=shCmdParenRegion,shPattern,shDeref,shDerefSimple,shDoubleQuote,shExDoubleQuote,shSingleQuote,shExSingleQuote
|
||||
syn match shVarAssign "=" contained nextgroup=shCmdParenRegion,shPattern,shDeref,shDerefSimple,shDoubleQuote,shExDoubleQuote,shSingleQuote,shExSingleQuote,shVar
|
||||
syn match shVar contained "\h\w*"
|
||||
syn region shAtExpr contained start="@(" end=")" contains=@shIdList
|
||||
if exists("b:is_bash")
|
||||
syn match shSet "^\s*set\ze\s*$"
|
||||
syn region shSetList oneline matchgroup=shSet start="\<\(declare\|typeset\|local\|export\|unset\)\>\ze[^/]" end="$" matchgroup=shSetListDelim end="\ze[}|);&]" matchgroup=NONE end="\ze\s\+#\|=" contains=@shIdList
|
||||
syn region shSetList oneline matchgroup=shSet start="\<set\>\ze[^/]" end="\ze[;|#)]\|$" matchgroup=shSetListDelim end="\ze[}|);&]" matchgroup=NONE end="\ze\s\+=" contains=@shIdList nextgroup=shComment
|
||||
syn match shSet "^\s*set\ze\s\+$"
|
||||
syn region shSetList oneline matchgroup=shSet start="\<\%(declare\|local\|export\)\>\ze[/a-zA-Z_]\@!" end="$" matchgroup=shSetListDelim end="\ze[}|);&]" matchgroup=NONE end="\ze\s\+#\|=" contains=@shIdList
|
||||
syn region shSetList oneline matchgroup=shSet start="\<\%(set\|unset\)\>[/a-zA-Z_]\@!" end="\ze[;|#)]\|$" matchgroup=shSetListDelim end="\ze[}|);&]" matchgroup=NONE end="\ze\s\+=" contains=@shIdList nextgroup=shComment
|
||||
elseif exists("b:is_kornshell") || exists("b:is_posix")
|
||||
syn match shSet "^\s*set\ze\s*$"
|
||||
syn region shSetList oneline matchgroup=shSet start="\<\(typeset\|export\|unset\)\>\ze[^/]" end="$" matchgroup=shSetListDelim end="\ze[}|);&]" matchgroup=NONE end="\ze\s\+[#=]" contains=@shIdList
|
||||
syn region shSetList oneline matchgroup=shSet start="\<set\>\ze[^/]" end="$" matchgroup=shSetListDelim end="\ze[}|);&]" matchgroup=NONE end="\ze\s\+[#=]" contains=@shIdList
|
||||
syn match shSet "^\s*set\ze\s\+$"
|
||||
syn region shSetList oneline matchgroup=shSet start="\<\(export\)\>\ze[/]\@!" end="$" matchgroup=shSetListDelim end="\ze[}|);&]" matchgroup=NONE end="\ze\s\+[#=]" contains=@shIdList
|
||||
syn region shSetList oneline matchgroup=shSet start="\<\%(set\|unset\>\)\ze[/a-zA-Z_]\@!" end="\ze[;|#)]\|$" matchgroup=shSetListDelim end="\ze[}|);&]" matchgroup=NONE end="\ze\s\+[#=]" contains=@shIdList nextgroup=shComment
|
||||
else
|
||||
syn region shSetList oneline matchgroup=shSet start="\<\(set\|export\|unset\)\>\ze[^/]" end="$" matchgroup=shSetListDelim end="\ze[}|);&]" matchgroup=NONE end="\ze\s\+[#=]" contains=@shIdList
|
||||
syn region shSetList oneline matchgroup=shSet start="\<\(set\|export\|unset\)\>\ze[/a-zA-Z_]\@!" end="\ze[;|#)]\|$" matchgroup=shSetListDelim end="\ze[}|);&]" matchgroup=NONE end="\ze\s\+[#=]" contains=@shIdList
|
||||
endif
|
||||
|
||||
" Functions: {{{1
|
||||
|
@ -523,12 +526,12 @@ if exists("b:is_bash")
|
|||
" bash : ${parameter//pattern/string}
|
||||
" bash : ${parameter//pattern}
|
||||
syn match shDerefPPS contained '/\{1,2}' nextgroup=shDerefPPSleft
|
||||
syn region shDerefPPSleft contained start='.' skip=@\%(\\\\\)*\\/@ matchgroup=shDerefOp end='/' end='\ze}' nextgroup=shDerefPPSright contains=@shCommandSubList
|
||||
syn region shDerefPPSright contained start='.' skip=@\%(\\\\\)\+@ end='\ze}' contains=@shPPSRightList
|
||||
syn region shDerefPPSleft contained start='.' skip=@\%(\\\\\)*\\/@ matchgroup=shDerefOp end='/' end='\ze}' nextgroup=shDerefPPSright contains=@shCommandSubList
|
||||
syn region shDerefPPSright contained start='.' skip=@\%(\\\\\)\+@ end='\ze}' contains=@shPPSRightList
|
||||
|
||||
" bash : ${parameter/#substring/replacement}
|
||||
syn match shDerefPSR contained '/#' nextgroup=shDerefPSRleft,shDoubleQuote,shSingleQuote
|
||||
syn region shDerefPSRleft contained start='[^"']' skip=@\%(\\\\\)*\\/@ matchgroup=shDerefOp end='/' end='\ze}' nextgroup=shDerefPSRright
|
||||
syn region shDerefPSRleft contained start='[^"']' skip=@\%(\\\\\)*\\/@ matchgroup=shDerefOp end='/' end='\ze}' nextgroup=shDerefPSRright
|
||||
syn region shDerefPSRright contained start='.' skip=@\%(\\\\\)\+@ end='\ze}'
|
||||
endif
|
||||
|
||||
|
@ -546,8 +549,9 @@ endif
|
|||
|
||||
" Additional ksh Keywords and Aliases: {{{1
|
||||
" ===================================
|
||||
if exists("b:is_kornshell") || exists("b:is_bash") || exists("b:is_posix")
|
||||
syn keyword shStatement bg builtin disown enum export false fg getconf getopts hist jobs let printf sleep true typeset unalias unset whence
|
||||
if exists("b:is_kornshell") || exists("b:is_posix")
|
||||
syn keyword shStatement bg builtin disown enum export false fg getconf getopts hist jobs let printf sleep true unalias whence
|
||||
syn keyword shStatement typeset skipwhite nextgroup=shSetOption
|
||||
syn keyword shStatement autoload compound fc float functions hash history integer nameref nohup r redirect source stop suspend times type
|
||||
if exists("b:is_posix")
|
||||
syn keyword shStatement command
|
||||
|
@ -557,12 +561,13 @@ if exists("b:is_kornshell") || exists("b:is_bash") || exists("b:is_posix")
|
|||
|
||||
" Additional bash Keywords: {{{1
|
||||
" =====================
|
||||
if exists("b:is_bash")
|
||||
" syn keyword shStatement bind builtin dirs disown enable help logout popd pushd shopt source
|
||||
syn keyword shStatement bind builtin caller compopt declare dirs disown enable export help local logout mapfile popd pushd readarray shopt source typeset unset
|
||||
else
|
||||
syn keyword shStatement login newgrp
|
||||
endif
|
||||
elseif exists("b:is_bash")
|
||||
syn keyword shStatement bg builtin disown export false fg getopts jobs let printf sleep true unalias
|
||||
syn keyword shStatement typeset nextgroup=shSetOption
|
||||
syn keyword shStatement fc hash history source suspend times type
|
||||
syn keyword shStatement bind builtin caller compopt declare dirs disown enable export help logout mapfile popd pushd readarray shopt source typeset
|
||||
else
|
||||
syn keyword shStatement login newgrp
|
||||
endif
|
||||
|
||||
" Synchronization: {{{1
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
" Vim syntax file
|
||||
" Language: TASM: turbo assembler by Borland
|
||||
" Maintaner: FooLman of United Force <foolman@bigfoot.com>
|
||||
" Last Change: 2012 Feb 03 by Thilo Six
|
||||
" Last Change: 2012 Feb 03 by Thilo Six, and 2018 Nov 27.
|
||||
|
||||
" quit when a syntax file was already loaded
|
||||
if exists("b:current_syntax")
|
||||
|
@ -109,7 +109,7 @@ hi def link tasmComment Comment
|
|||
hi def link tasmLabel Label
|
||||
|
||||
|
||||
let b:curret_syntax = "tasm"
|
||||
let b:current_syntax = "tasm"
|
||||
|
||||
let &cpo = s:cpo_save
|
||||
unlet s:cpo_save
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
" Vim syntax file
|
||||
" Language: TeX
|
||||
" Maintainer: Charles E. Campbell <NdrchipO@ScampbellPfamily.AbizM>
|
||||
" Last Change: Sep 09, 2018
|
||||
" Version: 110
|
||||
" Last Change: Nov 02, 2018
|
||||
" Version: 111
|
||||
" URL: http://www.drchip.org/astronaut/vim/index.html#SYNTAX_TEX
|
||||
"
|
||||
" Notes: {{{1
|
||||
|
@ -159,9 +159,9 @@ syn cluster texFoldGroup contains=texAccent,texBadMath,texComment,texDefCmd,tex
|
|||
syn cluster texBoldGroup contains=texAccent,texBadMath,texComment,texDefCmd,texDelimiter,texDocType,texInput,texInputFile,texLength,texLigature,texMatcher,texMathZoneV,texMathZoneW,texMathZoneX,texMathZoneY,texMathZoneZ,texNewCmd,texNewEnv,texOnlyMath,texOption,texParen,texRefZone,texSection,texBeginEnd,texSectionZone,texSpaceCode,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle,texZone,@texMathZones,texTitle,texAbstract,texBoldStyle,texBoldItalStyle,texNoSpell
|
||||
syn cluster texItalGroup contains=texAccent,texBadMath,texComment,texDefCmd,texDelimiter,texDocType,texInput,texInputFile,texLength,texLigature,texMatcher,texMathZoneV,texMathZoneW,texMathZoneX,texMathZoneY,texMathZoneZ,texNewCmd,texNewEnv,texOnlyMath,texOption,texParen,texRefZone,texSection,texBeginEnd,texSectionZone,texSpaceCode,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle,texZone,@texMathZones,texTitle,texAbstract,texItalStyle,texItalBoldStyle,texNoSpell
|
||||
if !s:tex_nospell
|
||||
syn cluster texMatchGroup contains=texAccent,texBadMath,texComment,texDefCmd,texDelimiter,texDocType,texInput,texLength,texLigature,texMatcher,texNewCmd,texNewEnv,texOnlyMath,texParen,texRefZone,texSection,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle,texZone,texInputFile,texOption,@Spell
|
||||
syn cluster texMatchNMGroup contains=texAccent,texBadMath,texComment,texDefCmd,texDelimiter,texDocType,texInput,texLength,texLigature,texMatcherNM,texNewCmd,texNewEnv,texOnlyMath,texParen,texRefZone,texSection,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle,texZone,texInputFile,texOption,@Spell
|
||||
syn cluster texStyleGroup contains=texAccent,texBadMath,texComment,texDefCmd,texDelimiter,texDocType,texInput,texLength,texLigature,texNewCmd,texNewEnv,texOnlyMath,texParen,texRefZone,texSection,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle,texZone,texInputFile,texOption,texStyleStatement,@Spell,texStyleMatcher
|
||||
syn cluster texMatchGroup contains=texAccent,texBadMath,texComment,texDefCmd,texDelimiter,texDocType,texInput,texLength,texLigature,texMatcher,texNewCmd,texNewEnv,texOnlyMath,texParen,texRefZone,texSection,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle,texBoldStyle,texBoldItalStyle,texItalStyle,texItalBoldStyle,texZone,texInputFile,texOption,@Spell
|
||||
syn cluster texMatchNMGroup contains=texAccent,texBadMath,texComment,texDefCmd,texDelimiter,texDocType,texInput,texLength,texLigature,texMatcherNM,texNewCmd,texNewEnv,texOnlyMath,texParen,texRefZone,texSection,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle,texBoldStyle,texBoldItalStyle,texItalStyle,texItalBoldStyle,texZone,texInputFile,texOption,@Spell
|
||||
syn cluster texStyleGroup contains=texAccent,texBadMath,texComment,texDefCmd,texDelimiter,texDocType,texInput,texLength,texLigature,texNewCmd,texNewEnv,texOnlyMath,texParen,texRefZone,texSection,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle,texBoldStyle,texBoldItalStyle,texItalStyle,texItalBoldStyle,texZone,texInputFile,texOption,texStyleStatement,texStyleMatcher,@Spell
|
||||
else
|
||||
syn cluster texMatchGroup contains=texAccent,texBadMath,texComment,texDefCmd,texDelimiter,texDocType,texInput,texLength,texLigature,texMatcher,texNewCmd,texNewEnv,texOnlyMath,texParen,texRefZone,texSection,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle,texZone,texInputFile,texOption
|
||||
syn cluster texMatchNMGroup contains=texAccent,texBadMath,texComment,texDefCmd,texDelimiter,texDocType,texInput,texLength,texLigature,texMatcherNM,texNewCmd,texNewEnv,texOnlyMath,texParen,texRefZone,texSection,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle,texZone,texInputFile,texOption
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
" Vim syntax file
|
||||
" Language: tpp - Text Presentation Program
|
||||
" Maintainer: Debian Vim Maintainers <pkg-vim-maintainers@lists.alioth.debian.org>
|
||||
" Former Maintainer: Gerfried Fuchs <alfie@ist.org>
|
||||
" Last Change: 2007-10-14
|
||||
" URL: http://git.debian.org/?p=pkg-vim/vim.git;a=blob_plain;f=runtime/syntax/tpp.vim;hb=debian
|
||||
" Filenames: *.tpp
|
||||
" License: BSD
|
||||
" Language: tpp - Text Presentation Program
|
||||
" Maintainer: Debian Vim Maintainers
|
||||
" Former Maintainer: Gerfried Fuchs <alfie@ist.org>
|
||||
" Last Change: 2018 Dec 27
|
||||
" URL: https://salsa.debian.org/vim-team/vim-debian/master/syntax/tpp.vim
|
||||
" Filenames: *.tpp
|
||||
" License: BSD
|
||||
"
|
||||
" XXX This file is in need of a new maintainer, Debian VIM Maintainers maintain
|
||||
" it only because patches have been submitted for it by Debian users and the
|
||||
|
@ -18,11 +18,11 @@
|
|||
" SPAM is _NOT_ welcome - be ready to be reported!
|
||||
|
||||
" quit when a syntax file was already loaded
|
||||
if exists("b:current_syntax")
|
||||
if exists('b:current_syntax')
|
||||
finish
|
||||
endif
|
||||
|
||||
if !exists("main_syntax")
|
||||
if !exists('main_syntax')
|
||||
let main_syntax = 'tpp'
|
||||
endif
|
||||
|
||||
|
@ -46,7 +46,7 @@ syn region tppNewPageOption start="^--newpage" end="$" contains=tppNewPageOption
|
|||
syn region tppPageLocalOption start="^--\%(heading\|center\|right\|huge\|sethugefont\|exec\)" end="$" contains=tppPageLocalOptionKey oneline
|
||||
syn region tppAbstractOption start="^--\%(author\|title\|date\|footer\)" end="$" contains=tppAbstractOptionKey oneline
|
||||
|
||||
if main_syntax != 'sh'
|
||||
if main_syntax !=# 'sh'
|
||||
" shell command
|
||||
syn include @tppShExec syntax/sh.vim
|
||||
unlet b:current_syntax
|
||||
|
@ -78,6 +78,6 @@ hi def link tppNewPageOption Error
|
|||
hi def link tppTimeOption Error
|
||||
|
||||
|
||||
let b:current_syntax = "tpp"
|
||||
let b:current_syntax = 'tpp'
|
||||
|
||||
" vim: ts=8 sw=2
|
||||
|
|
|
@ -273,7 +273,7 @@ syn match vimEnvvar "\${\I\i*}"
|
|||
syn region vimEscapeBrace oneline contained transparent start="[^\\]\(\\\\\)*\[\zs\^\=\]\=" skip="\\\\\|\\\]" end="]"me=e-1
|
||||
syn match vimPatSepErr contained "\\)"
|
||||
syn match vimPatSep contained "\\|"
|
||||
syn region vimPatSepZone oneline contained matchgroup=vimPatSepZ start="\\%\=\ze(" skip="\\\\" end="\\)\|[^\]['"]" contains=@vimStringGroup
|
||||
syn region vimPatSepZone oneline contained matchgroup=vimPatSepZ start="\\%\=\ze(" skip="\\\\" end="\\)\|[^\\]['"]" contains=@vimStringGroup
|
||||
syn region vimPatRegion contained transparent matchgroup=vimPatSepR start="\\[z%]\=(" end="\\)" contains=@vimSubstList oneline
|
||||
syn match vimNotPatSep contained "\\\\"
|
||||
syn cluster vimStringGroup contains=vimEscapeBrace,vimPatSep,vimNotPatSep,vimPatSepErr,vimPatSepZone,@Spell
|
||||
|
|
|
@ -197,12 +197,6 @@ preprocess_patch() {
|
|||
LC_ALL=C sed -e 's/\( [ab]\/src\)/\1\/nvim/g' \
|
||||
"$file" > "$file".tmp && mv "$file".tmp "$file"
|
||||
|
||||
# Rename path to matchit plugin.
|
||||
LC_ALL=C sed -e 's@\( [ab]/runtime\)/pack/dist/opt/matchit/\(plugin/matchit.vim\)@\1/\2@g' \
|
||||
"$file" > "$file".tmp && mv "$file".tmp "$file"
|
||||
LC_ALL=C sed -e 's@\( [ab]/runtime\)/pack/dist/opt/matchit/doc/\(matchit.txt\)@\1/doc/pi_\2@g' \
|
||||
"$file" > "$file".tmp && mv "$file".tmp "$file"
|
||||
|
||||
# Rename test_urls.vim to check_urls.vim
|
||||
LC_ALL=C sed -e 's@\( [ab]\)/runtime/doc/test\(_urls.vim\)@\1/scripts/check\2@g' \
|
||||
"$file" > "$file".tmp && mv "$file".tmp "$file"
|
||||
|
|
Loading…
Reference in New Issue