aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2019-08-01 15:29:47 +0200
committerJustin M. Keyes <justinkz@gmail.com>2019-08-01 15:43:53 +0200
commit5342342426777160300a431ef8c9200fb151f793 (patch)
treea42d08dce118ecbad51c0c74fa475e37ecf7b06e
parent62b5f25b6b2c2f49b9e2e6525e87dacd41d82183 (diff)
downloadrneovim-5342342426777160300a431ef8c9200fb151f793.tar.gz
rneovim-5342342426777160300a431ef8c9200fb151f793.tar.bz2
rneovim-5342342426777160300a431ef8c9200fb151f793.zip
runtime: move matchit.vim to /pack/dist/opt/
Align matchit.vim with upstream Vim. We don't want to maintain a fork of matchit.vim; our small changes should be sent to https://github.com/chrisbra/matchit
-rw-r--r--runtime/doc/vim_diff.txt4
-rw-r--r--runtime/pack/dist/opt/matchit/doc/matchit.txt (renamed from runtime/doc/pi_matchit.txt)85
-rw-r--r--runtime/pack/dist/opt/matchit/plugin/matchit.vim92
-rw-r--r--runtime/plugin/matchit.vim94
-rwxr-xr-xscripts/vim-patch.sh6
5 files changed, 158 insertions, 123 deletions
diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt
index a5ef55b8f2..bc742b9221 100644
--- a/runtime/doc/vim_diff.txt
+++ b/runtime/doc/vim_diff.txt
@@ -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*
diff --git a/runtime/doc/pi_matchit.txt b/runtime/pack/dist/opt/matchit/doc/matchit.txt
index 87dd72a54c..b2b78089a0 100644
--- a/runtime/doc/pi_matchit.txt
+++ b/runtime/pack/dist/opt/matchit/doc/matchit.txt
@@ -1,6 +1,13 @@
-*pi_matchit.txt* Extended "%" matching
+*matchit.txt* Extended "%" matching
-For Vim version 8.1. Last change: 2019 Jan 28
+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
@@ -77,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
@@ -124,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
@@ -138,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*
@@ -231,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"
@@ -252,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>".
@@ -271,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, >
@@ -293,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
@@ -301,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.
@@ -318,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.
@@ -330,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|.
@@ -349,8 +377,15 @@ The back reference '\'.d refers to the same thing as '\'.b:match_table[d] in
==============================================================================
5. Known Bugs and Limitations *matchit-bugs*
+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:
diff --git a/runtime/pack/dist/opt/matchit/plugin/matchit.vim b/runtime/pack/dist/opt/matchit/plugin/matchit.vim
new file mode 100644
index 0000000000..84147f1fc8
--- /dev/null
+++ b/runtime/pack/dist/opt/matchit/plugin/matchit.vim
@@ -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:
diff --git a/runtime/plugin/matchit.vim b/runtime/plugin/matchit.vim
index 84147f1fc8..ef698631b9 100644
--- a/runtime/plugin/matchit.vim
+++ b/runtime/plugin/matchit.vim
@@ -1,92 +1,2 @@
-" 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:
+" Nvim: load the matchit plugin by default.
+packadd matchit
diff --git a/scripts/vim-patch.sh b/scripts/vim-patch.sh
index d16266dd36..7de9d9c0a3 100755
--- a/scripts/vim-patch.sh
+++ b/scripts/vim-patch.sh
@@ -178,12 +178,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"