mirror of
https://github.com/zoriya/vim.git
synced 2026-01-01 03:48:10 +00:00
Compare commits
20 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ea6553bec3 | ||
|
|
4f3f668c84 | ||
|
|
c4dcd60c76 | ||
|
|
fa8b2e173d | ||
|
|
819821c5a9 | ||
|
|
e1581307d2 | ||
|
|
1473551a44 | ||
|
|
8fdd721047 | ||
|
|
92e35efaf6 | ||
|
|
1e7885abe8 | ||
|
|
52c6eaffd4 | ||
|
|
da64ab322a | ||
|
|
610cc1b9b3 | ||
|
|
780d4c3fff | ||
|
|
f68f1d7079 | ||
|
|
aedfcbe1e6 | ||
|
|
bee6c0cf86 | ||
|
|
8b20179c65 | ||
|
|
4c90861e9f | ||
|
|
c5fbe8af4c |
4
Filelist
4
Filelist
@@ -495,7 +495,6 @@ RT_ALL = \
|
||||
runtime/macros/life/click.me \
|
||||
runtime/macros/life/life.vim \
|
||||
runtime/macros/matchit.vim \
|
||||
runtime/macros/matchit.txt \
|
||||
runtime/macros/maze/README.txt \
|
||||
runtime/macros/maze/[mM]akefile \
|
||||
runtime/macros/maze/main.aap \
|
||||
@@ -525,6 +524,9 @@ RT_ALL = \
|
||||
runtime/tutor/tutor \
|
||||
runtime/tutor/tutor.vim \
|
||||
runtime/vimrc_example.vim \
|
||||
runtime/pack/dist/opt/matchit/plugin/matchit.vim \
|
||||
runtime/pack/dist/opt/matchit/doc/matchit.txt \
|
||||
runtime/pack/dist/opt/matchit/doc/tags \
|
||||
|
||||
# runtime files for all distributions without CR-NL translation
|
||||
RT_ALL_BIN = \
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
*autocmd.txt* For Vim version 7.4. Last change: 2015 Dec 05
|
||||
*autocmd.txt* For Vim version 7.4. Last change: 2016 Mar 26
|
||||
|
||||
|
||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||
@@ -918,7 +918,15 @@ VimEnter After doing all the startup stuff, including
|
||||
loading .vimrc files, executing the "-c cmd"
|
||||
arguments, creating all windows and loading
|
||||
the buffers in them.
|
||||
*VimLeave*
|
||||
Just before this event is triggered the
|
||||
|v:vim_did_enter| variable is set, so that you
|
||||
can do: >
|
||||
if v:vim_did_enter
|
||||
call s:init()
|
||||
else
|
||||
au VimEnter * call s:init()
|
||||
endif
|
||||
< *VimLeave*
|
||||
VimLeave Before exiting Vim, just after writing the
|
||||
.viminfo file. Executed only once, like
|
||||
VimLeavePre.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
*channel.txt* For Vim version 7.4. Last change: 2016 Mar 15
|
||||
*channel.txt* For Vim version 7.4. Last change: 2016 Mar 26
|
||||
|
||||
|
||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||
@@ -120,24 +120,13 @@ Use |ch_status()| to see if the channel could be opened.
|
||||
|
||||
{address} has the form "hostname:port". E.g., "localhost:8765".
|
||||
|
||||
{options} is a dictionary with optional entries:
|
||||
{options} is a dictionary with optional entries: *channel-open-options*
|
||||
|
||||
"mode" can be: *channel-mode*
|
||||
"json" - Use JSON, see below; most convenient way. Default.
|
||||
"js" - Use JS (JavaScript) encoding, more efficient than JSON.
|
||||
"nl" - Use messages that end in a NL character
|
||||
"raw" - Use raw messages
|
||||
*in_mode* *out_mode* *err_mode*
|
||||
"in_mode" mode specifically for stdin, only when using pipes
|
||||
"out_mode" mode specifically for stdout, only when using pipes
|
||||
"err_mode" mode specifically for stderr, only when using pipes
|
||||
Note: when setting "mode" the part specific mode is
|
||||
overwritten. Therefore set "mode" first and the part specific
|
||||
mode later.
|
||||
|
||||
Note: when writing to a file or buffer and when reading from a
|
||||
buffer NL mode is used by default.
|
||||
|
||||
*channel-callback* *E921*
|
||||
"callback" A function that is called when a message is received that is
|
||||
not handled otherwise. It gets two arguments: the channel
|
||||
@@ -155,16 +144,8 @@ Use |ch_status()| to see if the channel could be opened.
|
||||
as a string.
|
||||
|
||||
For all callbacks: Use |function()| to bind it to arguments
|
||||
and/or a dictionary.
|
||||
*out_cb*
|
||||
"out_cb" A function like "callback" but used for stdout. Only for when
|
||||
the channel uses pipes. When "out_cb" wasn't set the channel
|
||||
callback is used.
|
||||
*err_cb*
|
||||
"err_cb" A function like "callback" but used for stderr. Only for when
|
||||
the channel uses pipes. When "err_cb" wasn't set the channel
|
||||
callback is used.
|
||||
|
||||
and/or a Dictionary. Or use the form "dict.function" to bind
|
||||
the Dictionary.
|
||||
*close_cb*
|
||||
"close_cb" A function that is called when the channel gets closed, other
|
||||
than by calling ch_close(). It should be defined like this: >
|
||||
@@ -178,16 +159,10 @@ Use |ch_status()| to see if the channel could be opened.
|
||||
actually uses a 1 msec timeout, that is required on many
|
||||
systems. Use a larger value for a remote server, e.g. 10
|
||||
msec at least.
|
||||
|
||||
*channel-timeout*
|
||||
"timeout" The time to wait for a request when blocking, E.g. when using
|
||||
ch_evalexpr(). In milliseconds. The default is 2000 (2
|
||||
seconds).
|
||||
*out_timeout* *err_timeout*
|
||||
"out_timeout" Timeout for stdout. Only when using pipes.
|
||||
"err_timeout" Timeout for stderr. Only when using pipes.
|
||||
Note: when setting "timeout" the part specific mode is
|
||||
overwritten. Therefore set "timeout" first and the part
|
||||
specific mode later.
|
||||
|
||||
When "mode" is "json" or "js" the "callback" is optional. When omitted it is
|
||||
only possible to receive a message after sending one.
|
||||
@@ -215,6 +190,13 @@ pipes are used (stdin/stdout/stderr) they are all closed. This might not be
|
||||
what you want! Stopping the job with job_stop() might be better.
|
||||
All readahead is discarded, callbacks will no longer be invoked.
|
||||
|
||||
Note that a channel is closed in three stages:
|
||||
- The I/O ends, log message: "Closing channel". There can still be queued
|
||||
messages to read or callbacks to invoke.
|
||||
- The readahead is cleared, log message: "Clearing channel". Some variables
|
||||
may still reference the channel.
|
||||
- The channel is freed, log message: "Freeing channel".
|
||||
|
||||
When the channel can't be opened you will get an error message. There is a
|
||||
difference between MS-Windows and Unix: On Unix when the port doesn't exist
|
||||
ch_open() fails quickly. On MS-Windows "waittime" applies.
|
||||
@@ -326,6 +308,9 @@ completion or error. You could use functions in an |autoload| script:
|
||||
|
||||
You can also use "call |feedkeys()|" to insert any key sequence.
|
||||
|
||||
When there is an error a message is written to the channel log, if it exists,
|
||||
and v:errmsg is set to the error.
|
||||
|
||||
|
||||
Command "normal" ~
|
||||
|
||||
@@ -428,6 +413,23 @@ To read all output from a RAW channel that is available: >
|
||||
To read the error output: >
|
||||
let output = ch_readraw(channel, {"part": "err"})
|
||||
|
||||
ch_read() and ch_readraw() use the channel timeout. When there is nothing to
|
||||
read within that time an empty string is returned. To specify a different
|
||||
timeout in msec use the "timeout" option:
|
||||
{"timeout": 123} ~
|
||||
To read from the error output use the "part" option:
|
||||
{"part": "err"} ~
|
||||
To read a message with a specific ID, on a JS or JSON channel:
|
||||
{"id": 99} ~
|
||||
When no ID is specified or the ID is -1, the first message is returned. This
|
||||
overrules any callback waiting for this message.
|
||||
|
||||
For a RAW channel this returns whatever is available, since Vim does not know
|
||||
where a message ends.
|
||||
For a NL channel this returns one message.
|
||||
For a JS or JSON channel this returns one decoded message.
|
||||
This includes any sequence number.
|
||||
|
||||
==============================================================================
|
||||
8. Starting a job with a channel *job-start* *job*
|
||||
|
||||
@@ -524,15 +526,31 @@ job_setoptions(job, {options}). Many options can be used with the channel
|
||||
related to the job, using ch_setoptions(channel, {options}).
|
||||
See |job_setoptions()| and |ch_setoptions()|.
|
||||
|
||||
*in_mode* *out_mode* *err_mode*
|
||||
"in_mode" mode specifically for stdin, only when using pipes
|
||||
"out_mode" mode specifically for stdout, only when using pipes
|
||||
"err_mode" mode specifically for stderr, only when using pipes
|
||||
See |channel-mode| for the values.
|
||||
|
||||
Note: when setting "mode" the part specific mode is
|
||||
overwritten. Therefore set "mode" first and the part
|
||||
specific mode later.
|
||||
|
||||
Note: when writing to a file or buffer and when
|
||||
reading from a buffer NL mode is used by default.
|
||||
|
||||
*job-callback*
|
||||
"callback": handler Callback for something to read on any part of the
|
||||
channel.
|
||||
*job-out_cb*
|
||||
*job-out_cb* *out_cb*
|
||||
"out_cb": handler Callback for when there is something to read on
|
||||
stdout.
|
||||
*job-err_cb*
|
||||
stdout. Only for when the channel uses pipes. When
|
||||
"out_cb" wasn't set the channel callback is used.
|
||||
|
||||
*job-err_cb* *err_cb*
|
||||
"err_cb": handler Callback for when there is something to read on
|
||||
stderr.
|
||||
stderr. Only for when the channel uses pipes. When
|
||||
"err_cb" wasn't set the channel callback is used.
|
||||
*job-close_cb*
|
||||
"close_cb": handler Callback for when the channel is closed. Same as
|
||||
"close_cb" on ch_open().
|
||||
@@ -542,6 +560,17 @@ See |job_setoptions()| and |ch_setoptions()|.
|
||||
Vim checks about every 10 seconds for jobs that ended.
|
||||
The callback can also be triggered by calling
|
||||
|job_status()|.
|
||||
*job-timeout*
|
||||
"timeout" The time to wait for a request when blocking, E.g.
|
||||
when using ch_evalexpr(). In milliseconds. The
|
||||
default is 2000 (2 seconds).
|
||||
*out_timeout* *err_timeout*
|
||||
"out_timeout" Timeout for stdout. Only when using pipes.
|
||||
"err_timeout" Timeout for stderr. Only when using pipes.
|
||||
Note: when setting "timeout" the part specific mode is
|
||||
overwritten. Therefore set "timeout" first and the
|
||||
part specific mode later.
|
||||
|
||||
*job-stoponexit*
|
||||
"stoponexit": {signal} Send {signal} to the job when Vim exits. See
|
||||
|job_stop()| for possible values.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
*eval.txt* For Vim version 7.4. Last change: 2016 Mar 20
|
||||
*eval.txt* For Vim version 7.4. Last change: 2016 Mar 27
|
||||
|
||||
|
||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||
@@ -1762,6 +1762,10 @@ v:version Version number of Vim: Major version number times 100 plus
|
||||
version 5.0 and 5.1 may have a patch 123, but these are
|
||||
completely different.
|
||||
|
||||
*v:vim_did_enter* *vim_did_enter-variable*
|
||||
v:vim_did_enter Zero until most of startup is done. It is set to one just
|
||||
before |VimEnter| autocommands are triggered.
|
||||
|
||||
*v:warningmsg* *warningmsg-variable*
|
||||
v:warningmsg Last given warning message. It's allowed to set this variable.
|
||||
|
||||
@@ -1801,6 +1805,7 @@ assert_equal( {exp}, {act} [, {msg}]) none assert {exp} equals {act}
|
||||
assert_exception( {error} [, {msg}]) none assert {error} is in v:exception
|
||||
assert_fails( {cmd} [, {error}]) none assert {cmd} fails
|
||||
assert_false( {actual} [, {msg}]) none assert {actual} is false
|
||||
assert_match( {pat}, {text} [, {msg}]) none assert {pat} matches {text}
|
||||
assert_true( {actual} [, {msg}]) none assert {actual} is true
|
||||
asin( {expr}) Float arc sine of {expr}
|
||||
atan( {expr}) Float arc tangent of {expr}
|
||||
@@ -2311,6 +2316,26 @@ assert_false({actual} [, {msg}]) *assert_false()*
|
||||
When {msg} is omitted an error in the form "Expected False but
|
||||
got {actual}" is produced.
|
||||
|
||||
*assert_match()*
|
||||
assert_match({pattern}, {actual} [, {msg}])
|
||||
When {pattern} does not match {actual} an error message is
|
||||
added to |v:errors|.
|
||||
|
||||
{pattern} is used as with |=~|: The matching is always done
|
||||
like 'magic' was set and 'cpoptions' is empty, no matter what
|
||||
the actual value of 'magic' or 'cpoptions' is.
|
||||
|
||||
{actual} is used as a string, automatic conversion applies.
|
||||
Use "^" and "$" to match with the start and end of the text.
|
||||
Use both to match the whole text.
|
||||
|
||||
When {msg} is omitted an error in the form "Pattern {pattern}
|
||||
does not match {actual}" is produced.
|
||||
Example: >
|
||||
assert_match('^f.*o$', 'foobar')
|
||||
< Will result in a string to be added to |v:errors|:
|
||||
test.vim line 12: Pattern '^f.*o$' does not match 'foobar' ~
|
||||
|
||||
assert_true({actual} [, {msg}]) *assert_true()*
|
||||
When {actual} is not true an error message is added to
|
||||
|v:errors|, like with |assert_equal()|.
|
||||
@@ -2712,13 +2737,6 @@ ch_close({handle}) *ch_close()*
|
||||
Close {handle}. See |channel-close|.
|
||||
{handle} can be Channel or a Job that has a Channel.
|
||||
|
||||
Note that a channel is closed in three stages:
|
||||
- The I/O ends, log message: "Closing channel". There can
|
||||
still be queued messages to read or callbacks to invoke.
|
||||
- The readahead is cleared, log message: "Clearing channel".
|
||||
Some variables may still reference the channel.
|
||||
- The channel is freed, log message: "Freeing channel".
|
||||
|
||||
{only available when compiled with the |+channel| feature}
|
||||
|
||||
ch_evalexpr({handle}, {expr} [, {options}]) *ch_evalexpr()*
|
||||
@@ -2728,7 +2746,8 @@ ch_evalexpr({handle}, {expr} [, {options}]) *ch_evalexpr()*
|
||||
{handle} can be Channel or a Job that has a Channel.
|
||||
*E917*
|
||||
{options} must be a Dictionary. It must not have a "callback"
|
||||
entry. It can have a "timeout" entry.
|
||||
entry. It can have a "timeout" entry to specify the timeout
|
||||
for this specific request.
|
||||
|
||||
ch_evalexpr() waits for a response and returns the decoded
|
||||
expression. When there is an error or timeout it returns an
|
||||
@@ -2812,65 +2831,34 @@ ch_logfile({fname} [, {mode}]) *ch_logfile()*
|
||||
|
||||
ch_open({address} [, {options}]) *ch_open()*
|
||||
Open a channel to {address}. See |channel|.
|
||||
Returns a Channel. Use |ch_status()| to check for
|
||||
failure.
|
||||
Returns a Channel. Use |ch_status()| to check for failure.
|
||||
|
||||
{address} has the form "hostname:port", e.g.,
|
||||
"localhost:8765".
|
||||
|
||||
If {options} is given it must be a |Dictionary|. The optional
|
||||
items are:
|
||||
mode "raw", "js" or "json".
|
||||
Default "json".
|
||||
callback function to call for requests with a zero
|
||||
sequence number. See |channel-callback|.
|
||||
Default: none.
|
||||
waittime Specify connect timeout as milliseconds.
|
||||
Negative means forever.
|
||||
Default: 0 (don't wait)
|
||||
timeout Specify response read timeout value in
|
||||
milliseconds.
|
||||
Default: 2000.
|
||||
If {options} is given it must be a |Dictionary|.
|
||||
See |channel-open-options|.
|
||||
|
||||
{only available when compiled with the |+channel| feature}
|
||||
|
||||
ch_read({handle} [, {options}]) *ch_read()*
|
||||
Read from {handle} and return the received message.
|
||||
{handle} can be Channel or a Job that has a Channel.
|
||||
|
||||
This uses the channel timeout. When there is nothing to read
|
||||
within that time an empty string is returned. To specify a
|
||||
different timeout in msec use the "timeout" option:
|
||||
{"timeout": 123} ~
|
||||
To read from the error output use the "part" option:
|
||||
{"part": "err"} ~
|
||||
To read a message with a specific ID, on a JS or JSON channel:
|
||||
{"id": 99} ~
|
||||
When no ID is specified or the ID is -1, the first message is
|
||||
returned. This overrules any callback waiting for this
|
||||
message.
|
||||
|
||||
For a RAW channel this returns whatever is available, since
|
||||
Vim does not know where a message ends.
|
||||
For a NL channel this returns one message.
|
||||
For a JS or JSON channel this returns one decoded message.
|
||||
This includes any sequence number.
|
||||
See |channel-more|.
|
||||
{only available when compiled with the |+channel| feature}
|
||||
|
||||
ch_readraw({handle} [, {options}]) *ch_readraw()*
|
||||
Like ch_read() but for a JS and JSON channel does not decode
|
||||
the message.
|
||||
the message. See |channel-more|.
|
||||
{only available when compiled with the |+channel| feature}
|
||||
|
||||
ch_sendexpr({handle}, {expr} [, {options}]) *ch_sendexpr()*
|
||||
Send {expr} over {handle}. The {expr} is encoded
|
||||
according to the type of channel. The function cannot be used
|
||||
with a raw channel. See |channel-use|. *E912*
|
||||
with a raw channel.
|
||||
See |channel-use|. *E912*
|
||||
{handle} can be Channel or a Job that has a Channel.
|
||||
|
||||
{options} must be a Dictionary. The "callback" item is a
|
||||
Funcref or the name of a function it is invoked when the
|
||||
response is received. See |channel-callback|.
|
||||
Without "callback" the channel handler is invoked, otherwise
|
||||
any received message is dropped.
|
||||
|
||||
{only available when compiled with the |+channel| feature}
|
||||
|
||||
ch_sendraw({handle}, {string} [, {options}]) *ch_sendraw()*
|
||||
@@ -6671,13 +6659,17 @@ string({expr}) Return {expr} converted to a String. If {expr} is a Number,
|
||||
Float, String or a composition of them, then the result can be
|
||||
parsed back with |eval()|.
|
||||
{expr} type result ~
|
||||
String 'string'
|
||||
String 'string' (single quotes are doubled)
|
||||
Number 123
|
||||
Float 123.123456 or 1.123456e8
|
||||
Funcref function('name')
|
||||
List [item, item]
|
||||
Dictionary {key: value, key: value}
|
||||
Note that in String values the ' character is doubled.
|
||||
|
||||
When a List or Dictionary has a recursive reference it is
|
||||
replaced by "[...]" or "{...}". Using eval() on the result
|
||||
will then fail.
|
||||
|
||||
Also see |strtrans()|.
|
||||
|
||||
*strlen()*
|
||||
@@ -7661,6 +7653,7 @@ unix Unix version of Vim.
|
||||
user_commands User-defined commands.
|
||||
vertsplit Compiled with vertically split windows |:vsplit|.
|
||||
vim_starting True while initial source'ing takes place. |startup|
|
||||
*vim_starting*
|
||||
viminfo Compiled with viminfo support.
|
||||
virtualedit Compiled with 'virtualedit' option.
|
||||
visual Compiled with Visual mode.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
*helphelp.txt* For Vim version 7.4. Last change: 2016 Mar 12
|
||||
*helphelp.txt* For Vim version 7.4. Last change: 2016 Mar 26
|
||||
|
||||
|
||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||
@@ -208,9 +208,11 @@ command: >
|
||||
sorted.
|
||||
When there are duplicates an error message is given.
|
||||
An existing tags file is silently overwritten.
|
||||
|
||||
The optional "++t" argument forces adding the
|
||||
"help-tags" tag. This is also done when the {dir} is
|
||||
equal to $VIMRUNTIME/doc.
|
||||
|
||||
To rebuild the help tags in the runtime directory
|
||||
(requires write permission there): >
|
||||
:helptags $VIMRUNTIME/doc
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
*options.txt* For Vim version 7.4. Last change: 2016 Mar 19
|
||||
*options.txt* For Vim version 7.4. Last change: 2016 Mar 24
|
||||
|
||||
|
||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||
@@ -2292,6 +2292,8 @@ A jump table for the options with a short description can be found at |Q_op|.
|
||||
different. The whole undo file is encrypted, not just
|
||||
the pieces of text.
|
||||
|
||||
You should use "blowfish2", also to re-encrypt older files.
|
||||
|
||||
When reading an encrypted file 'cryptmethod' will be set automatically
|
||||
to the detected method of the file being read. Thus if you write it
|
||||
without changing 'cryptmethod' the same method will be used.
|
||||
@@ -3030,8 +3032,8 @@ A jump table for the options with a short description can be found at |Q_op|.
|
||||
file only, the option is not changed.
|
||||
When 'binary' is set, the value of 'fileformats' is not used.
|
||||
|
||||
Note that when Vim starts up with an empty buffer this option is not
|
||||
used. Set 'fileformat' in your .vimrc instead.
|
||||
When Vim starts up with an empty buffer the first item is used. You
|
||||
can overrule this by setting 'fileformat' in your .vimrc.
|
||||
|
||||
For systems with a Dos-like <EOL> (<CR><NL>), when reading files that
|
||||
are ":source"ed and for vimrc files, automatic <EOL> detection may be
|
||||
@@ -5115,6 +5117,7 @@ A jump table for the options with a short description can be found at |Q_op|.
|
||||
written. A ":set nomodified" command also resets the original
|
||||
values to the current values and the 'modified' option will be
|
||||
reset.
|
||||
Similarly for 'eol' and 'bomb'.
|
||||
This option is not set when a change is made to the buffer as the
|
||||
result of a BufNewFile, BufRead/BufReadPost, BufWritePost,
|
||||
FileAppendPost or VimLeave autocommand event. See |gzip-example| for
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
*repeat.txt* For Vim version 7.4. Last change: 2016 Mar 15
|
||||
*repeat.txt* For Vim version 7.4. Last change: 2016 Mar 26
|
||||
|
||||
|
||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||
@@ -8,13 +8,14 @@ Repeating commands, Vim scripts and debugging *repeating*
|
||||
|
||||
Chapter 26 of the user manual introduces repeating |usr_26.txt|.
|
||||
|
||||
1. Single repeats |single-repeat|
|
||||
2. Multiple repeats |multi-repeat|
|
||||
3. Complex repeats |complex-repeat|
|
||||
4. Using Vim scripts |using-scripts|
|
||||
5. Using Vim packages |packages|
|
||||
6. Debugging scripts |debug-scripts|
|
||||
7. Profiling |profiling|
|
||||
1. Single repeats |single-repeat|
|
||||
2. Multiple repeats |multi-repeat|
|
||||
3. Complex repeats |complex-repeat|
|
||||
4. Using Vim scripts |using-scripts|
|
||||
5. Using Vim packages |packages|
|
||||
6. Creating Vim packages |package-create|
|
||||
7. Debugging scripts |debug-scripts|
|
||||
8. Profiling |profiling|
|
||||
|
||||
==============================================================================
|
||||
1. Single repeats *single-repeat*
|
||||
@@ -481,7 +482,7 @@ find the syntax/some.vim file, because its directory is in 'runtimepath'.
|
||||
|
||||
Vim will also load ftdetect files, if there are any.
|
||||
|
||||
Note that the files under "pack/foo/opt" or not loaded automatically, only the
|
||||
Note that the files under "pack/foo/opt" are not loaded automatically, only the
|
||||
ones under "pack/foo/start". See |pack-add| below for how the "opt" directory
|
||||
is used.
|
||||
|
||||
@@ -516,14 +517,90 @@ To load an optional plugin from a pack use the `:packadd` command: >
|
||||
This searches for "pack/*/opt/foodebug" in 'packpath' and will find
|
||||
~/.vim/pack/foo/opt/foodebug/plugin/debugger.vim and source it.
|
||||
|
||||
This could be done inside always.vim, if some conditions are met. Or you
|
||||
could add this command to your |.vimrc|.
|
||||
This could be done if some conditions are met. For example, depending on
|
||||
whether Vim supports a feature or a dependency is missing.
|
||||
|
||||
You can also load an optional plugin at startup, by putting this command in
|
||||
your |.vimrc|: >
|
||||
:packadd! foodebug
|
||||
The extra "!" is so that the plugin isn't loaded with Vim was started with
|
||||
|--noplugin|.
|
||||
|
||||
It is perfectly normal for a package to only have files in the "opt"
|
||||
directory. You then need to load each plugin when you want to use it.
|
||||
|
||||
|
||||
Where to put what ~
|
||||
|
||||
Since color schemes, loaded with `:colorscheme`, are found below
|
||||
"pack/*/start" and "pack/*/opt", you could put them anywhere. We recommend
|
||||
you put them below "pack/*/opt", for example
|
||||
".vim/pack/mycolors/opt/dark/colors/very_dark.vim".
|
||||
|
||||
Filetype plugins should go under "pack/*/start", so that they are always
|
||||
found. Unless you have more than one plugin for a file type and want to
|
||||
select which one to load with `:packadd`. E.g. depending on the compiler
|
||||
version: >
|
||||
if foo_compiler_version > 34
|
||||
packadd foo_new
|
||||
else
|
||||
packadd foo_old
|
||||
endif
|
||||
|
||||
The "after" directory is most likely not useful in a package. It's not
|
||||
disallowed though.
|
||||
|
||||
==============================================================================
|
||||
6. Debugging scripts *debug-scripts*
|
||||
6. Creating Vim packages *package-create*
|
||||
|
||||
This assumes you write one or more plugins that you distribute as a package.
|
||||
|
||||
If you have two unrelated plugins you would use two packages, so that Vim
|
||||
users can chose what they include or not. Or you can decide to use one
|
||||
package with optional plugins, and tell the user to add the ones he wants with
|
||||
`:packadd`.
|
||||
|
||||
Decide how you want to distribute the package. You can create an archive or
|
||||
you could use a repository. An archive can be used by more users, but is a
|
||||
bit harder to update to a new version. A repository can usually be kept
|
||||
up-to-date easily, but it requires a program like "git" to be available.
|
||||
You can do both, github can automatically create an archive for a release.
|
||||
|
||||
Your directory layout would be like this:
|
||||
start/foobar/plugin/foo.vim " always loaded, defines commands
|
||||
start/foobar/plugin/bar.vim " always loaded, defines commands
|
||||
start/foobar/autoload/foo.vim " loaded when foo command used
|
||||
start/foobar/doc/foo.txt " help for foo.vim
|
||||
start/foobar/doc/tags " help tags
|
||||
opt/fooextra/plugin/extra.vim " optional plugin, defines commands
|
||||
opt/fooextra/autoload/extra.vim " loaded when extra command used
|
||||
opt/fooextra/doc/extra.txt " help for extra.vim
|
||||
opt/fooextra/doc/tags " help tags
|
||||
|
||||
This allows for the user to do: >
|
||||
mkdir ~/.vim/pack/myfoobar
|
||||
cd ~/.vim/pack/myfoobar
|
||||
git clone https://github.com/you/foobar.git
|
||||
|
||||
Here "myfoobar" is a name that the user can choose, the only condition is that
|
||||
it differs from other packages.
|
||||
|
||||
In your documentation you explain what the plugins do, and tell the user how
|
||||
to load the optional plugin: >
|
||||
:packadd! fooextra
|
||||
|
||||
You could add this packadd command in one of your plugins, to be executed when
|
||||
the optional plugin is needed.
|
||||
|
||||
Run the `:helptags` command to generate the doc/tags file. Including this
|
||||
generated file in the package means that the user can drop the package in his
|
||||
pack directory and the help command works right away. Don't forget to re-run
|
||||
the command after changing the plugin help: >
|
||||
:helptags path/start/foobar/doc
|
||||
:helptags path/opt/fooextra/doc
|
||||
|
||||
==============================================================================
|
||||
7. Debugging scripts *debug-scripts*
|
||||
|
||||
Besides the obvious messages that you can add to your scripts to find out what
|
||||
they are doing, Vim offers a debug mode. This allows you to step through a
|
||||
@@ -748,7 +825,7 @@ OBSCURE
|
||||
user, don't use typeahead for debug commands.
|
||||
|
||||
==============================================================================
|
||||
7. Profiling *profile* *profiling*
|
||||
8. Profiling *profile* *profiling*
|
||||
|
||||
Profiling means that Vim measures the time that is spent on executing
|
||||
functions and/or scripts. The |+profile| feature is required for this.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
*starting.txt* For Vim version 7.4. Last change: 2016 Mar 05
|
||||
*starting.txt* For Vim version 7.4. Last change: 2016 Mar 26
|
||||
|
||||
|
||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||
@@ -866,8 +866,8 @@ accordingly. Vim proceeds in this order:
|
||||
use "--cmd 'set noloadplugins'" |--cmd|.
|
||||
|
||||
Plugin packs are loaded. These are plugins, as above, but found in
|
||||
'packpath' directories. Every plugin directory found is added in
|
||||
'runtimepath'. See |packages|.
|
||||
'packpath' "start" directories. Every plugin directory found is added
|
||||
in 'runtimepath'. See |packages|.
|
||||
|
||||
5. Set 'shellpipe' and 'shellredir'
|
||||
The 'shellpipe' and 'shellredir' options are set according to the
|
||||
@@ -905,8 +905,9 @@ accordingly. Vim proceeds in this order:
|
||||
12. Execute startup commands
|
||||
If a "-t" flag was given to Vim, the tag is jumped to.
|
||||
The commands given with the |-c| and |+cmd| arguments are executed.
|
||||
The starting flag is reset, has("vim_starting") will now return zero.
|
||||
If the 'insertmode' option is set, Insert mode is entered.
|
||||
The starting flag is reset, has("vim_starting") will now return zero.
|
||||
The |v:vim_did_enter| variable is set to 1.
|
||||
The |VimEnter| autocommands are executed.
|
||||
|
||||
Some hints on using initializations:
|
||||
|
||||
@@ -1637,6 +1637,7 @@ $VIM_POSIX vi_diff.txt /*$VIM_POSIX*
|
||||
05.5 usr_05.txt /*05.5*
|
||||
05.6 usr_05.txt /*05.6*
|
||||
05.7 usr_05.txt /*05.7*
|
||||
05.8 usr_05.txt /*05.8*
|
||||
06.1 usr_06.txt /*06.1*
|
||||
06.2 usr_06.txt /*06.2*
|
||||
06.3 usr_06.txt /*06.3*
|
||||
@@ -4453,6 +4454,8 @@ E921 channel.txt /*E921*
|
||||
E922 eval.txt /*E922*
|
||||
E923 eval.txt /*E923*
|
||||
E924 quickfix.txt /*E924*
|
||||
E925 quickfix.txt /*E925*
|
||||
E926 quickfix.txt /*E926*
|
||||
E93 windows.txt /*E93*
|
||||
E94 windows.txt /*E94*
|
||||
E95 message.txt /*E95*
|
||||
@@ -4886,6 +4889,7 @@ add-filetype-plugin usr_05.txt /*add-filetype-plugin*
|
||||
add-global-plugin usr_05.txt /*add-global-plugin*
|
||||
add-local-help usr_05.txt /*add-local-help*
|
||||
add-option-flags options.txt /*add-option-flags*
|
||||
add-package usr_05.txt /*add-package*
|
||||
add-plugin usr_05.txt /*add-plugin*
|
||||
added-5.1 version5.txt /*added-5.1*
|
||||
added-5.2 version5.txt /*added-5.2*
|
||||
@@ -5222,7 +5226,9 @@ channel-demo channel.txt /*channel-demo*
|
||||
channel-mode channel.txt /*channel-mode*
|
||||
channel-more channel.txt /*channel-more*
|
||||
channel-open channel.txt /*channel-open*
|
||||
channel-open-options channel.txt /*channel-open-options*
|
||||
channel-raw channel.txt /*channel-raw*
|
||||
channel-timeout channel.txt /*channel-timeout*
|
||||
channel-use channel.txt /*channel-use*
|
||||
channel.txt channel.txt /*channel.txt*
|
||||
char-variable eval.txt /*char-variable*
|
||||
@@ -6872,6 +6878,7 @@ job-start-if-needed channel.txt /*job-start-if-needed*
|
||||
job-start-nochannel channel.txt /*job-start-nochannel*
|
||||
job-stoponexit channel.txt /*job-stoponexit*
|
||||
job-term channel.txt /*job-term*
|
||||
job-timeout channel.txt /*job-timeout*
|
||||
job_getchannel() eval.txt /*job_getchannel()*
|
||||
job_info() eval.txt /*job_info()*
|
||||
job_setoptions() eval.txt /*job_setoptions()*
|
||||
@@ -7600,6 +7607,7 @@ out_name channel.txt /*out_name*
|
||||
out_timeout channel.txt /*out_timeout*
|
||||
p change.txt /*p*
|
||||
pack-add repeat.txt /*pack-add*
|
||||
package-create repeat.txt /*package-create*
|
||||
packages repeat.txt /*packages*
|
||||
page-down intro.txt /*page-down*
|
||||
page-up intro.txt /*page-up*
|
||||
@@ -8767,6 +8775,7 @@ v:true eval.txt /*v:true*
|
||||
v:val eval.txt /*v:val*
|
||||
v:var eval.txt /*v:var*
|
||||
v:version eval.txt /*v:version*
|
||||
v:vim_did_enter eval.txt /*v:vim_did_enter*
|
||||
v:warningmsg eval.txt /*v:warningmsg*
|
||||
v:windowid eval.txt /*v:windowid*
|
||||
v_! change.txt /*v_!*
|
||||
@@ -8940,6 +8949,8 @@ vim-variable eval.txt /*vim-variable*
|
||||
vim.vim syntax.txt /*vim.vim*
|
||||
vim7 version7.txt /*vim7*
|
||||
vim: options.txt /*vim:*
|
||||
vim_did_enter-variable eval.txt /*vim_did_enter-variable*
|
||||
vim_starting eval.txt /*vim_starting*
|
||||
vimball pi_vimball.txt /*vimball*
|
||||
vimball-contents pi_vimball.txt /*vimball-contents*
|
||||
vimball-extract pi_vimball.txt /*vimball-extract*
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
*todo.txt* For Vim version 7.4. Last change: 2016 Mar 20
|
||||
*todo.txt* For Vim version 7.4. Last change: 2016 Mar 26
|
||||
|
||||
|
||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||
@@ -34,22 +34,18 @@ not be repeated below, unless there is extra information.
|
||||
*known-bugs*
|
||||
-------------------- Known bugs and current work -----------------------
|
||||
|
||||
assert_matches('pattern', value)
|
||||
|
||||
+channel:
|
||||
- add test for out-cb and err-cb.
|
||||
- Move more details from eval.txt to channel.txt. Add tags in eval.txt.
|
||||
- When decoding json, don't read all the typeahead at once, use the reader
|
||||
properly.
|
||||
- When a message in the queue but there is no callback, drop it after a while?
|
||||
Add timestamp to queued messages and callbacks with ID, remove after a
|
||||
minute. Option to set the droptime.
|
||||
- Add more ch_log calls, basically at every branch, before every callback, etc.
|
||||
- Add remark about undo sync, is there a way to force it?
|
||||
- When starting a job, have an option to open the server socket, so we know
|
||||
the port, and pass it to the command with --socket-fd {nr}. (Olaf Dabrunz,
|
||||
Feb 9) How to do this on MS-Windows?
|
||||
- Add more unit-testing in json_test.c
|
||||
- Add a test where ["eval","getline(123)"] gets a line with special
|
||||
characters (NUL, 0x80, etc.). Check that it isn't garbled.
|
||||
- Make sure errors lead to a useful error msg. ["ex","foobar"]
|
||||
- For connection to server, a "keep open" flag would be useful. Retry
|
||||
connecting in the main loop with zero timeout.
|
||||
@@ -57,7 +53,11 @@ Later
|
||||
- job_start(): run job in a newly opened terminal.
|
||||
With xterm could use -S{pty}.
|
||||
|
||||
Packages: how about "after" directory?
|
||||
Partial:
|
||||
- Maybe we also need VAR_PARTIAL support in if_mzsch.
|
||||
|
||||
Packages:
|
||||
- make package for editexisting, others?
|
||||
|
||||
Make it so that the window ID can be used where currently a window nr is used
|
||||
|
||||
@@ -70,6 +70,9 @@ Why does this: echo "a" . 1.1
|
||||
result in: a11
|
||||
Should recognize float (so long as it's not ".1.1").
|
||||
|
||||
Patch to make tag jump work on function({expr}). (Hirohito Higashi, 2016 Mar
|
||||
25)
|
||||
|
||||
Allow for an empty dictionary key?
|
||||
|
||||
Patch to improve I/O for Perl. (Damien, 2016 Jan 9, update Jan 22 2nd one)
|
||||
@@ -119,6 +122,10 @@ Regexp problems:
|
||||
matches the empty string. (Dominique Pelle, 2015 Oct 2, Nov 24)
|
||||
- Search for \\~ causes error E874.
|
||||
|
||||
Using freed memory in quickfix code. (Dominique, 2016 Mar 21)
|
||||
|
||||
Patch 7.4.1401 caused autochdir not to work on startup. (Rob Hoelz, #704)
|
||||
|
||||
Patch to fix that folds close with autocomplete. #643
|
||||
Christian Brabandt, 2016 Feb 18.
|
||||
|
||||
@@ -137,6 +144,7 @@ Patch to put undo options together in undo window.
|
||||
Patch to have better check for {action} argument of setqflist().
|
||||
Nikolai Pavlov, Feb 25, #661. Can be even more strict.
|
||||
Also see patch from Hirohito Higash, Feb 25.
|
||||
Updated patch, 2016 Mar 25.
|
||||
|
||||
Patch to update the GTK icon cache when installing. (Kazunobu Kuriyama, 2016
|
||||
Feb 3)
|
||||
@@ -147,12 +155,18 @@ Cannot delete a file with square brackets with delete(). (#696)
|
||||
|
||||
Patch to add 'topbot' to 'belloff' option. (Coot, 2016 Mar 18, #695)
|
||||
|
||||
Patch to make matchit work better, respect 'matchpairs'. (Ken Takata, 2016 Mar
|
||||
25)
|
||||
|
||||
We can use '. to go to the last change in the current buffer, but how about
|
||||
the last change in any buffer? Can we use ', (, is next to .)?
|
||||
|
||||
Patch for Python: #622. (Roland Puntaier, 2016 Feb 2)
|
||||
What does it change?
|
||||
|
||||
It's possible to add ",," to 'wildignore', an empty entry. Causes problems.
|
||||
Reject the value? #710.
|
||||
|
||||
Win32: patch to use 64 bit stat() if possible. (Ken Takata, 2014 May 12)
|
||||
More tests May 14. Update May 29. Update Aug 10.
|
||||
Now part of large file patches. (Ken Takata, 2016 Feb 1)
|
||||
@@ -202,6 +216,10 @@ Patch to make "%:h:h" return "." instead of the full path.
|
||||
|
||||
Remove SPACE_IN_FILENAME ? What could possibly go wrong?
|
||||
|
||||
Patch to change GUI behavior: instead of changing the window size change the
|
||||
lines/columns when menu/toolbar/etc. is added/removed. (Ychin, 2016 Mar 20,
|
||||
#703)
|
||||
|
||||
Installation of .desktop files does not work everywhere.
|
||||
It's now fixed, but the target directory probably isn't right.
|
||||
Add configure check?
|
||||
@@ -220,6 +238,8 @@ Patch to avoid redrawing tabline when the popup menu is visible.
|
||||
|
||||
Patch to add {skip} argument to search(). (Christian Brabandt, 2016 Feb 24)
|
||||
|
||||
Add value "smart" to 'tagcase': ignore case when tag is all lower case.
|
||||
|
||||
7 Add a watchpoint in the debug mode: An expression that breaks execution
|
||||
when evaluating to non-zero. Add the "watchadd expr" command, stop when
|
||||
the value of the expression changes. ":watchdel" deletes an item,
|
||||
@@ -247,6 +267,8 @@ https://gist.github.com/presuku/d3d6b230b9b6dcfc0477
|
||||
Patch to make the behavior of "w" more straightforward, but not Vi compatible.
|
||||
With a 'cpo' flag. (Christian Brabandt, 2016 Feb 8)
|
||||
|
||||
Patch to add optionproperties(). (Anton Lindqvist, 2016 Mar 26)
|
||||
|
||||
Patch to add TagNotFound autocommand. (Anton Lindqvist, 2016 Feb 3)
|
||||
|
||||
Patch to add Error autocommand. (Anton Lindqvist, 2016 Feb 17)
|
||||
@@ -298,7 +320,7 @@ Value returned by virtcol() changes depending on how lines wrap. This is
|
||||
inconsistent with the documentation.
|
||||
|
||||
Patch to add filtering of the quickfix list. (Yegappan Lakshmanan, 2016 Mar
|
||||
13, last version)
|
||||
13, last version) Update Mar 21.
|
||||
|
||||
Can we cache the syntax attributes, so that updates for 'relativenumber' and
|
||||
'cursorline'/'cursorcolumn' are a lot faster?
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
*usr_05.txt* For Vim version 7.4. Last change: 2012 Nov 20
|
||||
*usr_05.txt* For Vim version 7.4. Last change: 2016 Mar 25
|
||||
|
||||
VIM USER MANUAL - by Bram Moolenaar
|
||||
|
||||
@@ -12,10 +12,11 @@ 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 plugin
|
||||
|05.5| Adding a help file
|
||||
|05.6| The option window
|
||||
|05.7| Often used options
|
||||
|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
|
||||
|
||||
Next chapter: |usr_06.txt| Using syntax highlighting
|
||||
Previous chapter: |usr_04.txt| Making small changes
|
||||
@@ -263,7 +264,45 @@ 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 plugin *add-plugin* *plugin*
|
||||
*05.4* Adding a package *add-package* *matchit-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.
|
||||
|
||||
The Vim distribution comes with a few packages that you can optionally use.
|
||||
For example, the matchit plugin. This plugin makes the "%" command jump to
|
||||
matching HTML tags, if/else/endif in Vim scripts, etc. Very useful, although
|
||||
it's not backwards compatible (that's why it is not enabled by default).
|
||||
|
||||
To start using the matchit plugin, add one line to your vimrc file: >
|
||||
packadd! matchit
|
||||
|
||||
That's all! After restarting Vim you can find help about this plugin: >
|
||||
:help matchit
|
||||
|
||||
This works, because when `:packadd` loaded the plugin it also added the
|
||||
package directory in 'runtimepath', so that the help file can be found.
|
||||
|
||||
You can find packages on the Internet in various places. It usually comes as
|
||||
an archive or as a repository. For an archive you can follow these steps:
|
||||
1. create the package directory: >
|
||||
mkdir -p ~/.vim/pack/fancy
|
||||
< "fancy" can be any name of your liking. Use one that describes the
|
||||
package.
|
||||
2. unpack the archive in that directory. This assumes the top
|
||||
directory in the archive is "start": >
|
||||
cd ~/.vim/pack/fancy
|
||||
unzip /tmp/fancy.zip
|
||||
< If the archive layout is different make sure that you end up with a
|
||||
path like this:
|
||||
~/.vim/pack/fancy/start/fancytext/plugin/fancy.vim ~
|
||||
Here "fancytext" is the name of the package, it can be anything
|
||||
else.
|
||||
|
||||
More information about packages can be found here: |packages|.
|
||||
|
||||
==============================================================================
|
||||
*05.5* 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
|
||||
@@ -415,23 +454,19 @@ Further reading:
|
||||
|new-filetype| How to detect a new file type.
|
||||
|
||||
==============================================================================
|
||||
*05.5* Adding a help file *add-local-help* *matchit-install*
|
||||
*05.6* 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
|
||||
for your new plugin.
|
||||
Let us use the "matchit.vim" plugin as an example (it is included with
|
||||
Vim). This plugin makes the "%" command jump to matching HTML tags,
|
||||
if/else/endif in Vim scripts, etc. Very useful, although it's not backwards
|
||||
compatible (that's why it is not enabled by default).
|
||||
This plugin comes with documentation: "matchit.txt". Let's first copy the
|
||||
plugin to the right directory. This time we will do it from inside Vim, so
|
||||
that we can use $VIMRUNTIME. (You may skip some of the "mkdir" commands if
|
||||
you already have the directory.) >
|
||||
Let us use the "doit.vim" plugin as an example. This plugin comes with
|
||||
documentation: "doit.txt". Let's first copy the plugin to the right
|
||||
directory. This time we will do it from inside Vim. (You may skip some of
|
||||
the "mkdir" commands if you already have the directory.) >
|
||||
|
||||
:!mkdir ~/.vim
|
||||
:!mkdir ~/.vim/plugin
|
||||
:!cp $VIMRUNTIME/macros/matchit.vim ~/.vim/plugin
|
||||
:!cp /tmp/doit.vim ~/.vim/plugin
|
||||
|
||||
The "cp" command is for Unix, on MS-DOS you can use "copy".
|
||||
|
||||
@@ -441,7 +476,7 @@ Now create a "doc" directory in one of the directories in 'runtimepath'. >
|
||||
|
||||
Copy the help file to the "doc" directory. >
|
||||
|
||||
:!cp $VIMRUNTIME/macros/matchit.txt ~/.vim/doc
|
||||
:!cp /tmp/doit.txt ~/.vim/doc
|
||||
|
||||
Now comes the trick, which allows you to jump to the subjects in the new help
|
||||
file: Generate the local tags file with the |:helptags| command. >
|
||||
@@ -450,10 +485,10 @@ file: Generate the local tags file with the |:helptags| command. >
|
||||
|
||||
Now you can use the >
|
||||
|
||||
:help g%
|
||||
:help doit
|
||||
|
||||
command to find help for "g%" in the help file you just added. You can see an
|
||||
entry for the local help file when you do: >
|
||||
command to find help for "doit" in the help file you just added. You can see
|
||||
an entry for the local help file when you do: >
|
||||
|
||||
:help local-additions
|
||||
|
||||
@@ -464,7 +499,7 @@ them through the tag.
|
||||
For writing a local help file, see |write-local-help|.
|
||||
|
||||
==============================================================================
|
||||
*05.6* The option window
|
||||
*05.7* 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: >
|
||||
@@ -503,7 +538,7 @@ border. This is what the 'scrolloff' option does, it specifies an offset
|
||||
from the window border where scrolling starts.
|
||||
|
||||
==============================================================================
|
||||
*05.7* Often used options
|
||||
*05.8* 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
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
*usr_toc.txt* For Vim version 7.4. Last change: 2010 Jul 20
|
||||
*usr_toc.txt* For Vim version 7.4. Last change: 2016 Mar 25
|
||||
|
||||
VIM USER MANUAL - by Bram Moolenaar
|
||||
|
||||
@@ -104,10 +104,11 @@ Read this from start to end to learn the essential commands.
|
||||
|05.1| The vimrc file
|
||||
|05.2| The example vimrc file explained
|
||||
|05.3| Simple mappings
|
||||
|05.4| Adding a plugin
|
||||
|05.5| Adding a help file
|
||||
|05.6| The option window
|
||||
|05.7| Often used options
|
||||
|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
|
||||
|
||||
|usr_06.txt| Using syntax highlighting
|
||||
|06.1| Switching it on
|
||||
|
||||
@@ -15,8 +15,6 @@ dvorak for when you use a Dvorak keyboard
|
||||
|
||||
justify.vim user function for justifying text
|
||||
|
||||
matchit.vim + matchit.txt make % match if-fi, HTML tags, and much more
|
||||
|
||||
less.sh + less.vim make Vim work like less (or more)
|
||||
|
||||
shellmenu.vim menus for editing shell scripts in the GUI version
|
||||
@@ -26,5 +24,9 @@ swapmous.vim swap left and right mouse buttons
|
||||
editexisting.vim when editing a file that is already edited with
|
||||
another Vim instance
|
||||
|
||||
This one is only for Unix. It can be found in the extra archive:
|
||||
This one is only for Unix.
|
||||
file_select.vim macros that make a handy file selector
|
||||
|
||||
The matchit plugin has been moved to an optional package. To load it put this
|
||||
line in your vimrc file:
|
||||
:packadd matchit
|
||||
|
||||
@@ -1,813 +1,3 @@
|
||||
" matchit.vim: (global plugin) Extended "%" matching
|
||||
" Last Change: Fri Jan 25 10:00 AM 2008 EST
|
||||
" Maintainer: Benji Fisher PhD <benji@member.AMS.org>
|
||||
" Version: 1.13.2, for Vim 6.3+
|
||||
" 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: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 = (&ic ? " " : " no") . "ignorecase"
|
||||
if exists("b:match_ignorecase")
|
||||
let &ignorecase = b:match_ignorecase
|
||||
endif
|
||||
let restore_options = " ve=" . &ve . restore_options
|
||||
set ve=
|
||||
" 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_words = match_words
|
||||
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
|
||||
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
|
||||
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
|
||||
"
|
||||
" Reconstruct the version with unresolved backrefs.
|
||||
let patBR = substitute(match_words.',',
|
||||
\ s:notslash.'\zs[,:]*,[,:]*', ',', 'g')
|
||||
let patBR = substitute(patBR, s:notslash.'\zs:\{2,}', ':', 'g')
|
||||
" 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, 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 restore_cursor = virtcol(".") . "|"
|
||||
normal! g0
|
||||
let restore_cursor = line(".") . "G" . virtcol(".") . "|zs" . restore_cursor
|
||||
normal! H
|
||||
let restore_cursor = "normal!" . line(".") . "Gzt" . restore_cursor
|
||||
execute restore_cursor
|
||||
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.
|
||||
execute restore_cursor
|
||||
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, ...)
|
||||
execute "set" a:options
|
||||
" 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 = (&ic ? "" : "no") . "ignorecase"
|
||||
if exists("b:match_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
|
||||
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 restore_cursor = line(".") . "G" . virtcol(".") . "|"
|
||||
" normal! H
|
||||
" let restore_cursor = "normal!" . line(".") . "Gzt" . restore_cursor
|
||||
let restore_cursor = virtcol(".") . "|"
|
||||
normal! g0
|
||||
let restore_cursor = line(".") . "G" . virtcol(".") . "|zs" . restore_cursor
|
||||
normal! H
|
||||
let restore_cursor = "normal!" . line(".") . "Gzt" . restore_cursor
|
||||
execute restore_cursor
|
||||
|
||||
" 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
|
||||
execute "if " . skip . "| let skip = '0' | endif"
|
||||
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 a string to restore the original position.
|
||||
call s:CleanUp(restore_options, a:mode, startline, startcol)
|
||||
return restore_cursor
|
||||
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:
|
||||
" Load the matchit package.
|
||||
" For those users who were loading the matchit plugin from here.
|
||||
packadd matchit
|
||||
|
||||
50
runtime/pack/dist/opt/matchit/doc/tags
vendored
Normal file
50
runtime/pack/dist/opt/matchit/doc/tags
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
:MatchDebug matchit.txt /*:MatchDebug*
|
||||
MatchError matchit.txt /*MatchError*
|
||||
[% matchit.txt /*[%*
|
||||
]% matchit.txt /*]%*
|
||||
b:match_col matchit.txt /*b:match_col*
|
||||
b:match_debug matchit.txt /*b:match_debug*
|
||||
b:match_ignorecase matchit.txt /*b:match_ignorecase*
|
||||
b:match_ini matchit.txt /*b:match_ini*
|
||||
b:match_iniBR matchit.txt /*b:match_iniBR*
|
||||
b:match_match matchit.txt /*b:match_match*
|
||||
b:match_pat matchit.txt /*b:match_pat*
|
||||
b:match_skip matchit.txt /*b:match_skip*
|
||||
b:match_table matchit.txt /*b:match_table*
|
||||
b:match_tail matchit.txt /*b:match_tail*
|
||||
b:match_wholeBR matchit.txt /*b:match_wholeBR*
|
||||
b:match_word matchit.txt /*b:match_word*
|
||||
b:match_words matchit.txt /*b:match_words*
|
||||
g% matchit.txt /*g%*
|
||||
matchit matchit.txt /*matchit*
|
||||
matchit-% matchit.txt /*matchit-%*
|
||||
matchit-\1 matchit.txt /*matchit-\\1*
|
||||
matchit-activate matchit.txt /*matchit-activate*
|
||||
matchit-backref matchit.txt /*matchit-backref*
|
||||
matchit-bugs matchit.txt /*matchit-bugs*
|
||||
matchit-choose matchit.txt /*matchit-choose*
|
||||
matchit-configure matchit.txt /*matchit-configure*
|
||||
matchit-debug matchit.txt /*matchit-debug*
|
||||
matchit-details matchit.txt /*matchit-details*
|
||||
matchit-highlight matchit.txt /*matchit-highlight*
|
||||
matchit-hl matchit.txt /*matchit-hl*
|
||||
matchit-intro matchit.txt /*matchit-intro*
|
||||
matchit-languages matchit.txt /*matchit-languages*
|
||||
matchit-modes matchit.txt /*matchit-modes*
|
||||
matchit-newlang matchit.txt /*matchit-newlang*
|
||||
matchit-o_% matchit.txt /*matchit-o_%*
|
||||
matchit-parse matchit.txt /*matchit-parse*
|
||||
matchit-s:notend matchit.txt /*matchit-s:notend*
|
||||
matchit-s:sol matchit.txt /*matchit-s:sol*
|
||||
matchit-spaces matchit.txt /*matchit-spaces*
|
||||
matchit-troubleshoot matchit.txt /*matchit-troubleshoot*
|
||||
matchit-v_% matchit.txt /*matchit-v_%*
|
||||
matchit.txt matchit.txt /*matchit.txt*
|
||||
matchit.vim matchit.txt /*matchit.vim*
|
||||
o_[% matchit.txt /*o_[%*
|
||||
o_]% matchit.txt /*o_]%*
|
||||
o_g% matchit.txt /*o_g%*
|
||||
v_[% matchit.txt /*v_[%*
|
||||
v_]% matchit.txt /*v_]%*
|
||||
v_a% matchit.txt /*v_a%*
|
||||
v_g% matchit.txt /*v_g%*
|
||||
813
runtime/pack/dist/opt/matchit/plugin/matchit.vim
vendored
Normal file
813
runtime/pack/dist/opt/matchit/plugin/matchit.vim
vendored
Normal file
@@ -0,0 +1,813 @@
|
||||
" matchit.vim: (global plugin) Extended "%" matching
|
||||
" Last Change: Fri Jan 25 10:00 AM 2008 EST
|
||||
" Maintainer: Benji Fisher PhD <benji@member.AMS.org>
|
||||
" Version: 1.13.2, for Vim 6.3+
|
||||
" 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: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 = (&ic ? " " : " no") . "ignorecase"
|
||||
if exists("b:match_ignorecase")
|
||||
let &ignorecase = b:match_ignorecase
|
||||
endif
|
||||
let restore_options = " ve=" . &ve . restore_options
|
||||
set ve=
|
||||
" 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_words = match_words
|
||||
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
|
||||
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
|
||||
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
|
||||
"
|
||||
" Reconstruct the version with unresolved backrefs.
|
||||
let patBR = substitute(match_words.',',
|
||||
\ s:notslash.'\zs[,:]*,[,:]*', ',', 'g')
|
||||
let patBR = substitute(patBR, s:notslash.'\zs:\{2,}', ':', 'g')
|
||||
" 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, 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 restore_cursor = virtcol(".") . "|"
|
||||
normal! g0
|
||||
let restore_cursor = line(".") . "G" . virtcol(".") . "|zs" . restore_cursor
|
||||
normal! H
|
||||
let restore_cursor = "normal!" . line(".") . "Gzt" . restore_cursor
|
||||
execute restore_cursor
|
||||
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.
|
||||
execute restore_cursor
|
||||
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, ...)
|
||||
execute "set" a:options
|
||||
" 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 = (&ic ? "" : "no") . "ignorecase"
|
||||
if exists("b:match_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
|
||||
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 restore_cursor = line(".") . "G" . virtcol(".") . "|"
|
||||
" normal! H
|
||||
" let restore_cursor = "normal!" . line(".") . "Gzt" . restore_cursor
|
||||
let restore_cursor = virtcol(".") . "|"
|
||||
normal! g0
|
||||
let restore_cursor = line(".") . "G" . virtcol(".") . "|zs" . restore_cursor
|
||||
normal! H
|
||||
let restore_cursor = "normal!" . line(".") . "Gzt" . restore_cursor
|
||||
execute restore_cursor
|
||||
|
||||
" 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
|
||||
execute "if " . skip . "| let skip = '0' | endif"
|
||||
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 a string to restore the original position.
|
||||
call s:CleanUp(restore_options, a:mode, startline, startcol)
|
||||
return restore_cursor
|
||||
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:
|
||||
@@ -1,7 +1,7 @@
|
||||
" An example for a vimrc file.
|
||||
"
|
||||
" Maintainer: Bram Moolenaar <Bram@vim.org>
|
||||
" Last change: 2015 Mar 24
|
||||
" Last change: 2016 Mar 25
|
||||
"
|
||||
" To use it, copy it to
|
||||
" for Unix and OS/2: ~/.vimrc
|
||||
@@ -100,3 +100,10 @@ if has('langmap') && exists('+langnoremap')
|
||||
" compatible).
|
||||
set langnoremap
|
||||
endif
|
||||
|
||||
|
||||
" Add optional packages.
|
||||
"
|
||||
" The matchit plugin makes the % command work better, but it is not backwards
|
||||
" compatible.
|
||||
packadd matchit
|
||||
|
||||
20
src/Makefile
20
src/Makefile
@@ -130,6 +130,7 @@
|
||||
# make installlinks only installs the Vim binary links
|
||||
# make installmanlinks only installs the Vim manpage links
|
||||
# make installmacros only installs the Vim macros
|
||||
# make installpack only installs the packages
|
||||
# make installtutorbin only installs the Vim tutor program
|
||||
# make installtutor only installs the Vim tutor files
|
||||
# make installspell only installs the spell files
|
||||
@@ -1008,6 +1009,7 @@ LANGSUBDIR = /lang
|
||||
COMPSUBDIR = /compiler
|
||||
KMAPSUBDIR = /keymap
|
||||
MACROSUBDIR = /macros
|
||||
PACKSUBDIR = /pack
|
||||
TOOLSSUBDIR = /tools
|
||||
TUTORSUBDIR = /tutor
|
||||
SPELLSUBDIR = /spell
|
||||
@@ -1029,6 +1031,7 @@ PODIR = po
|
||||
### COMPSUBLOC location for compiler files
|
||||
### KMAPSUBLOC location for keymap files
|
||||
### MACROSUBLOC location for macro files
|
||||
### PACKSUBLOC location for packages
|
||||
### TOOLSSUBLOC location for tools files
|
||||
### TUTORSUBLOC location for tutor files
|
||||
### SPELLSUBLOC location for spell files
|
||||
@@ -1050,6 +1053,7 @@ LANGSUBLOC = $(VIMRTLOC)$(LANGSUBDIR)
|
||||
COMPSUBLOC = $(VIMRTLOC)$(COMPSUBDIR)
|
||||
KMAPSUBLOC = $(VIMRTLOC)$(KMAPSUBDIR)
|
||||
MACROSUBLOC = $(VIMRTLOC)$(MACROSUBDIR)
|
||||
PACKSUBLOC = $(VIMRTLOC)$(PACKSUBDIR)
|
||||
TOOLSSUBLOC = $(VIMRTLOC)$(TOOLSSUBDIR)
|
||||
TUTORSUBLOC = $(VIMRTLOC)$(TUTORSUBDIR)
|
||||
SPELLSUBLOC = $(VIMRTLOC)$(SPELLSUBDIR)
|
||||
@@ -1155,6 +1159,9 @@ FTPLUGSOURCE = ../runtime/ftplugin
|
||||
# Where to copy the macro files from
|
||||
MACROSOURCE = ../runtime/macros
|
||||
|
||||
# Where to copy the package files from
|
||||
PACKSOURCE = ../runtime/pack
|
||||
|
||||
# Where to copy the tools files from
|
||||
TOOLSSOURCE = ../runtime/tools
|
||||
|
||||
@@ -1430,6 +1437,7 @@ DEST_LANG = $(DESTDIR)$(LANGSUBLOC)
|
||||
DEST_COMP = $(DESTDIR)$(COMPSUBLOC)
|
||||
DEST_KMAP = $(DESTDIR)$(KMAPSUBLOC)
|
||||
DEST_MACRO = $(DESTDIR)$(MACROSUBLOC)
|
||||
DEST_PACK = $(DESTDIR)$(PACKSUBLOC)
|
||||
DEST_TOOLS = $(DESTDIR)$(TOOLSSUBLOC)
|
||||
DEST_TUTOR = $(DESTDIR)$(TUTORSUBLOC)
|
||||
DEST_SPELL = $(DESTDIR)$(SPELLSUBLOC)
|
||||
@@ -2107,7 +2115,7 @@ INSTALLMANARGS = $(VIMLOC) $(SCRIPTLOC) $(VIMRCLOC) $(HELPSOURCE) $(MANMOD) \
|
||||
$(VIMNAME) $(VIMDIFFNAME) $(EVIMNAME)
|
||||
|
||||
# Install most of the runtime files
|
||||
installruntime: installrtbase installmacros installtutor installspell
|
||||
installruntime: installrtbase installmacros installpack installtutor installspell
|
||||
|
||||
# install the help files; first adjust the contents for the final location
|
||||
installrtbase: $(HELPSOURCE)/vim.1 $(DEST_VIM) $(DEST_RT) \
|
||||
@@ -2206,6 +2214,11 @@ installmacros: $(DEST_VIM) $(DEST_RT) $(DEST_MACRO)
|
||||
rm -rf $$cvs; \
|
||||
fi
|
||||
|
||||
installpack: $(DEST_VIM) $(DEST_RT) $(DEST_PACK)
|
||||
$(INSTALL_DATA_R) $(PACKSOURCE)/* $(DEST_PACK)
|
||||
chmod $(DIRMOD) `find $(DEST_PACK) -type d -print`
|
||||
chmod $(FILEMOD) `find $(DEST_PACK) -type f -print`
|
||||
|
||||
# install the tutor files
|
||||
installtutorbin: $(DEST_VIM)
|
||||
$(INSTALL_DATA) vimtutor $(DEST_BIN)/$(VIMNAME)tutor
|
||||
@@ -2355,8 +2368,8 @@ $(HELPSOURCE)/vim.1 $(MACROSOURCE) $(TOOLSSOURCE):
|
||||
$(DESTDIR)$(exec_prefix) $(DEST_BIN) \
|
||||
$(DEST_VIM) $(DEST_RT) $(DEST_HELP) \
|
||||
$(DEST_PRINT) $(DEST_COL) $(DEST_SYN) $(DEST_IND) $(DEST_FTP) \
|
||||
$(DEST_LANG) $(DEST_KMAP) $(DEST_COMP) \
|
||||
$(DEST_MACRO) $(DEST_TOOLS) $(DEST_TUTOR) $(DEST_SPELL) \
|
||||
$(DEST_LANG) $(DEST_KMAP) $(DEST_COMP) $(DEST_MACRO) \
|
||||
$(DEST_PACK) $(DEST_TOOLS) $(DEST_TUTOR) $(DEST_SPELL) \
|
||||
$(DEST_AUTO) $(DEST_AUTO)/xml $(DEST_PLUG):
|
||||
-$(SHELL) ./mkinstalldirs $@
|
||||
-chmod $(DIRMOD) $@
|
||||
@@ -2501,6 +2514,7 @@ uninstall_runtime:
|
||||
-rm -f $(DEST_SYN)/*.vim $(DEST_SYN)/README.txt
|
||||
-rm -f $(DEST_IND)/*.vim $(DEST_IND)/README.txt
|
||||
-rm -rf $(DEST_MACRO)
|
||||
-rm -rf $(DEST_PACK)
|
||||
-rm -rf $(DEST_TUTOR)
|
||||
-rm -rf $(DEST_SPELL)
|
||||
-rm -rf $(DEST_TOOLS)
|
||||
|
||||
@@ -1661,8 +1661,17 @@ channel_exe_cmd(channel_T *channel, int part, typval_T *argv)
|
||||
|
||||
if (STRCMP(cmd, "ex") == 0)
|
||||
{
|
||||
int save_called_emsg = called_emsg;
|
||||
|
||||
called_emsg = FALSE;
|
||||
ch_logs(channel, "Executing ex command '%s'", (char *)arg);
|
||||
++emsg_silent;
|
||||
do_cmdline_cmd(arg);
|
||||
--emsg_silent;
|
||||
if (called_emsg)
|
||||
ch_logs(channel, "Ex command error: '%s'",
|
||||
(char *)get_vim_var_str(VV_ERRMSG));
|
||||
called_emsg = save_called_emsg;
|
||||
}
|
||||
else if (STRCMP(cmd, "normal") == 0)
|
||||
{
|
||||
|
||||
110
src/eval.c
110
src/eval.c
@@ -292,13 +292,12 @@ typedef struct
|
||||
#define VV_RO 2 /* read-only */
|
||||
#define VV_RO_SBX 4 /* read-only in the sandbox */
|
||||
|
||||
#define VV_NAME(s, t) s, {{t, 0, {0}}, 0, {0}}, {0}
|
||||
#define VV_NAME(s, t) s, {{t, 0, {0}}, 0, {0}}
|
||||
|
||||
static struct vimvar
|
||||
{
|
||||
char *vv_name; /* name of variable, without v: */
|
||||
dictitem_T vv_di; /* value and name for key */
|
||||
char vv_filler[16]; /* space for LONGEST name below!!! */
|
||||
dictitem16_T vv_di; /* value and name for key (max 16 chars!) */
|
||||
char vv_flags; /* VV_COMPAT, VV_RO, VV_RO_SBX */
|
||||
} vimvars[VV_LEN] =
|
||||
{
|
||||
@@ -373,6 +372,7 @@ static struct vimvar
|
||||
{VV_NAME("true", VAR_SPECIAL), VV_RO},
|
||||
{VV_NAME("null", VAR_SPECIAL), VV_RO},
|
||||
{VV_NAME("none", VAR_SPECIAL), VV_RO},
|
||||
{VV_NAME("vim_did_enter", VAR_NUMBER), VV_RO},
|
||||
};
|
||||
|
||||
/* shorthand */
|
||||
@@ -475,6 +475,7 @@ static void f_assert_equal(typval_T *argvars, typval_T *rettv);
|
||||
static void f_assert_exception(typval_T *argvars, typval_T *rettv);
|
||||
static void f_assert_fails(typval_T *argvars, typval_T *rettv);
|
||||
static void f_assert_false(typval_T *argvars, typval_T *rettv);
|
||||
static void f_assert_match(typval_T *argvars, typval_T *rettv);
|
||||
static void f_assert_true(typval_T *argvars, typval_T *rettv);
|
||||
#ifdef FEAT_FLOAT
|
||||
static void f_asin(typval_T *argvars, typval_T *rettv);
|
||||
@@ -4105,6 +4106,31 @@ get_user_var_name(expand_T *xp, int idx)
|
||||
|
||||
#endif /* FEAT_CMDL_COMPL */
|
||||
|
||||
/*
|
||||
* Return TRUE if "pat" matches "text".
|
||||
* Does not use 'cpo' and always uses 'magic'.
|
||||
*/
|
||||
static int
|
||||
pattern_match(char_u *pat, char_u *text, int ic)
|
||||
{
|
||||
int matches = FALSE;
|
||||
char_u *save_cpo;
|
||||
regmatch_T regmatch;
|
||||
|
||||
/* avoid 'l' flag in 'cpoptions' */
|
||||
save_cpo = p_cpo;
|
||||
p_cpo = (char_u *)"";
|
||||
regmatch.regprog = vim_regcomp(pat, RE_MAGIC + RE_STRING);
|
||||
if (regmatch.regprog != NULL)
|
||||
{
|
||||
regmatch.rm_ic = ic;
|
||||
matches = vim_regexec_nl(®match, text, (colnr_T)0);
|
||||
vim_regfree(regmatch.regprog);
|
||||
}
|
||||
p_cpo = save_cpo;
|
||||
return matches;
|
||||
}
|
||||
|
||||
/*
|
||||
* types for expressions.
|
||||
*/
|
||||
@@ -4403,9 +4429,7 @@ eval4(char_u **arg, typval_T *rettv, int evaluate)
|
||||
long n1, n2;
|
||||
char_u *s1, *s2;
|
||||
char_u buf1[NUMBUFLEN], buf2[NUMBUFLEN];
|
||||
regmatch_T regmatch;
|
||||
int ic;
|
||||
char_u *save_cpo;
|
||||
|
||||
/*
|
||||
* Get the first variable.
|
||||
@@ -4646,20 +4670,9 @@ eval4(char_u **arg, typval_T *rettv, int evaluate)
|
||||
|
||||
case TYPE_MATCH:
|
||||
case TYPE_NOMATCH:
|
||||
/* avoid 'l' flag in 'cpoptions' */
|
||||
save_cpo = p_cpo;
|
||||
p_cpo = (char_u *)"";
|
||||
regmatch.regprog = vim_regcomp(s2,
|
||||
RE_MAGIC + RE_STRING);
|
||||
regmatch.rm_ic = ic;
|
||||
if (regmatch.regprog != NULL)
|
||||
{
|
||||
n1 = vim_regexec_nl(®match, s1, (colnr_T)0);
|
||||
vim_regfree(regmatch.regprog);
|
||||
if (type == TYPE_NOMATCH)
|
||||
n1 = !n1;
|
||||
}
|
||||
p_cpo = save_cpo;
|
||||
n1 = pattern_match(s2, s1, ic);
|
||||
if (type == TYPE_NOMATCH)
|
||||
n1 = !n1;
|
||||
break;
|
||||
|
||||
case TYPE_UNKNOWN: break; /* avoid gcc warning */
|
||||
@@ -8154,6 +8167,7 @@ static struct fst
|
||||
{"assert_exception", 1, 2, f_assert_exception},
|
||||
{"assert_fails", 1, 2, f_assert_fails},
|
||||
{"assert_false", 1, 2, f_assert_false},
|
||||
{"assert_match", 2, 3, f_assert_match},
|
||||
{"assert_true", 1, 2, f_assert_true},
|
||||
#ifdef FEAT_FLOAT
|
||||
{"atan", 1, 1, f_atan},
|
||||
@@ -9295,7 +9309,7 @@ f_argv(typval_T *argvars, typval_T *rettv)
|
||||
}
|
||||
|
||||
static void prepare_assert_error(garray_T*gap);
|
||||
static void fill_assert_error(garray_T *gap, typval_T *opt_msg_tv, char_u *exp_str, typval_T *exp_tv, typval_T *got_tv);
|
||||
static void fill_assert_error(garray_T *gap, typval_T *opt_msg_tv, char_u *exp_str, typval_T *exp_tv, typval_T *got_tv, int is_match);
|
||||
static void assert_error(garray_T *gap);
|
||||
static void assert_bool(typval_T *argvars, int isTrue);
|
||||
|
||||
@@ -9370,7 +9384,8 @@ fill_assert_error(
|
||||
typval_T *opt_msg_tv,
|
||||
char_u *exp_str,
|
||||
typval_T *exp_tv,
|
||||
typval_T *got_tv)
|
||||
typval_T *got_tv,
|
||||
int is_match)
|
||||
{
|
||||
char_u numbuf[NUMBUFLEN];
|
||||
char_u *tofree;
|
||||
@@ -9382,7 +9397,10 @@ fill_assert_error(
|
||||
}
|
||||
else
|
||||
{
|
||||
ga_concat(gap, (char_u *)"Expected ");
|
||||
if (is_match)
|
||||
ga_concat(gap, (char_u *)"Pattern ");
|
||||
else
|
||||
ga_concat(gap, (char_u *)"Expected ");
|
||||
if (exp_str == NULL)
|
||||
{
|
||||
ga_concat_esc(gap, tv2string(exp_tv, &tofree, numbuf, 0));
|
||||
@@ -9390,7 +9408,10 @@ fill_assert_error(
|
||||
}
|
||||
else
|
||||
ga_concat_esc(gap, exp_str);
|
||||
ga_concat(gap, (char_u *)" but got ");
|
||||
if (is_match)
|
||||
ga_concat(gap, (char_u *)" does not match ");
|
||||
else
|
||||
ga_concat(gap, (char_u *)" but got ");
|
||||
ga_concat_esc(gap, tv2string(got_tv, &tofree, numbuf, 0));
|
||||
vim_free(tofree);
|
||||
}
|
||||
@@ -9421,7 +9442,8 @@ f_assert_equal(typval_T *argvars, typval_T *rettv UNUSED)
|
||||
if (!tv_equal(&argvars[0], &argvars[1], FALSE, FALSE))
|
||||
{
|
||||
prepare_assert_error(&ga);
|
||||
fill_assert_error(&ga, &argvars[2], NULL, &argvars[0], &argvars[1]);
|
||||
fill_assert_error(&ga, &argvars[2], NULL, &argvars[0], &argvars[1],
|
||||
FALSE);
|
||||
assert_error(&ga);
|
||||
ga_clear(&ga);
|
||||
}
|
||||
@@ -9449,7 +9471,7 @@ f_assert_exception(typval_T *argvars, typval_T *rettv UNUSED)
|
||||
{
|
||||
prepare_assert_error(&ga);
|
||||
fill_assert_error(&ga, &argvars[1], NULL, &argvars[0],
|
||||
&vimvars[VV_EXCEPTION].vv_tv);
|
||||
&vimvars[VV_EXCEPTION].vv_tv, FALSE);
|
||||
assert_error(&ga);
|
||||
ga_clear(&ga);
|
||||
}
|
||||
@@ -9486,7 +9508,7 @@ f_assert_fails(typval_T *argvars, typval_T *rettv UNUSED)
|
||||
{
|
||||
prepare_assert_error(&ga);
|
||||
fill_assert_error(&ga, &argvars[2], NULL, &argvars[1],
|
||||
&vimvars[VV_ERRMSG].vv_tv);
|
||||
&vimvars[VV_ERRMSG].vv_tv, FALSE);
|
||||
assert_error(&ga);
|
||||
ga_clear(&ga);
|
||||
}
|
||||
@@ -9518,7 +9540,7 @@ assert_bool(typval_T *argvars, int isTrue)
|
||||
prepare_assert_error(&ga);
|
||||
fill_assert_error(&ga, &argvars[1],
|
||||
(char_u *)(isTrue ? "True" : "False"),
|
||||
NULL, &argvars[0]);
|
||||
NULL, &argvars[0], FALSE);
|
||||
assert_error(&ga);
|
||||
ga_clear(&ga);
|
||||
}
|
||||
@@ -9533,6 +9555,28 @@ f_assert_false(typval_T *argvars, typval_T *rettv UNUSED)
|
||||
assert_bool(argvars, FALSE);
|
||||
}
|
||||
|
||||
/*
|
||||
* "assert_match(pattern, actual[, msg])" function
|
||||
*/
|
||||
static void
|
||||
f_assert_match(typval_T *argvars, typval_T *rettv UNUSED)
|
||||
{
|
||||
garray_T ga;
|
||||
char_u buf1[NUMBUFLEN];
|
||||
char_u buf2[NUMBUFLEN];
|
||||
char_u *pat = get_tv_string_buf_chk(&argvars[0], buf1);
|
||||
char_u *text = get_tv_string_buf_chk(&argvars[1], buf2);
|
||||
|
||||
if (!pattern_match(pat, text, FALSE))
|
||||
{
|
||||
prepare_assert_error(&ga);
|
||||
fill_assert_error(&ga, &argvars[2], NULL, &argvars[0], &argvars[1],
|
||||
TRUE);
|
||||
assert_error(&ga);
|
||||
ga_clear(&ga);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* "assert_true(actual[, msg])" function
|
||||
*/
|
||||
@@ -13838,7 +13882,7 @@ f_has(typval_T *argvars, typval_T *rettv)
|
||||
if (STRNICMP(name, "patch", 5) == 0)
|
||||
{
|
||||
if (name[5] == '-'
|
||||
&& STRLEN(name) > 11
|
||||
&& STRLEN(name) >= 11
|
||||
&& vim_isdigit(name[6])
|
||||
&& vim_isdigit(name[8])
|
||||
&& vim_isdigit(name[10]))
|
||||
@@ -20191,6 +20235,7 @@ get_callback(typval_T *arg, partial_T **pp)
|
||||
if (arg->v_type == VAR_PARTIAL && arg->vval.v_partial != NULL)
|
||||
{
|
||||
*pp = arg->vval.v_partial;
|
||||
++(*pp)->pt_refcount;
|
||||
return (*pp)->pt_name;
|
||||
}
|
||||
*pp = NULL;
|
||||
@@ -23455,7 +23500,8 @@ ex_function(exarg_T *eap)
|
||||
else
|
||||
arg = fudi.fd_newkey;
|
||||
if (arg != NULL && (fudi.fd_di == NULL
|
||||
|| fudi.fd_di->di_tv.v_type != VAR_FUNC))
|
||||
|| (fudi.fd_di->di_tv.v_type != VAR_FUNC
|
||||
&& fudi.fd_di->di_tv.v_type != VAR_PARTIAL)))
|
||||
{
|
||||
if (*arg == K_SPECIAL)
|
||||
j = 3;
|
||||
@@ -26439,9 +26485,11 @@ repeat:
|
||||
{
|
||||
/* vim_strsave_shellescape() needs a NUL terminated string. */
|
||||
c = (*fnamep)[*fnamelen];
|
||||
(*fnamep)[*fnamelen] = NUL;
|
||||
if (c != NUL)
|
||||
(*fnamep)[*fnamelen] = NUL;
|
||||
p = vim_strsave_shellescape(*fnamep, FALSE, FALSE);
|
||||
(*fnamep)[*fnamelen] = c;
|
||||
if (c != NUL)
|
||||
(*fnamep)[*fnamelen] = c;
|
||||
if (p == NULL)
|
||||
return -1;
|
||||
vim_free(*bufp);
|
||||
|
||||
@@ -6032,13 +6032,26 @@ ConvertToPyObject(typval_T *tv)
|
||||
case VAR_FUNC:
|
||||
return NEW_FUNCTION(tv->vval.v_string == NULL
|
||||
? (char_u *)"" : tv->vval.v_string);
|
||||
case VAR_PARTIAL:
|
||||
return NEW_FUNCTION(tv->vval.v_partial == NULL
|
||||
? (char_u *)"" : tv->vval.v_partial->pt_name);
|
||||
case VAR_UNKNOWN:
|
||||
case VAR_CHANNEL:
|
||||
case VAR_JOB:
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
default:
|
||||
case VAR_SPECIAL:
|
||||
switch (tv->vval.v_number)
|
||||
{
|
||||
case VVAL_FALSE: return AlwaysFalse(NULL);
|
||||
case VVAL_TRUE: return AlwaysTrue(NULL);
|
||||
case VVAL_NONE:
|
||||
case VVAL_NULL: return AlwaysNone(NULL);
|
||||
}
|
||||
PyErr_SET_VIM(N_("internal error: invalid value type"));
|
||||
return NULL;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
typedef struct
|
||||
|
||||
@@ -606,6 +606,7 @@ ServerWait(
|
||||
{
|
||||
while (XCheckWindowEvent(dpy, commWindow, PropertyChangeMask, &event))
|
||||
serverEventProc(dpy, &event, 1);
|
||||
server_parse_messages();
|
||||
|
||||
if (endCond(endData) != 0)
|
||||
break;
|
||||
|
||||
@@ -969,6 +969,9 @@ vim_main2(int argc UNUSED, char **argv UNUSED)
|
||||
if (p_im)
|
||||
need_start_insertmode = TRUE;
|
||||
|
||||
#ifdef FEAT_EVAL
|
||||
set_vim_var_nr(VV_VIM_DID_ENTER, 1L);
|
||||
#endif
|
||||
#ifdef FEAT_AUTOCMD
|
||||
apply_autocmds(EVENT_VIMENTER, NULL, NULL, FALSE, curbuf);
|
||||
TIME_MSG("VimEnter autocommands");
|
||||
|
||||
45
src/misc1.c
45
src/misc1.c
@@ -9737,18 +9737,6 @@ pstrcmp(const void *a, const void *b)
|
||||
return (pathcmp(*(char **)a, *(char **)b, -1));
|
||||
}
|
||||
|
||||
# ifndef WIN3264
|
||||
static void
|
||||
namelowcpy(
|
||||
char_u *d,
|
||||
char_u *s)
|
||||
{
|
||||
while (*s)
|
||||
*d++ = TOLOWER_LOC(*s++);
|
||||
*d = NUL;
|
||||
}
|
||||
# endif
|
||||
|
||||
/*
|
||||
* Recursively expand one path component into all matching files and/or
|
||||
* directories. Adds matches to "gap". Handles "*", "?", "[a-z]", "**", etc.
|
||||
@@ -9777,16 +9765,12 @@ dos_expandpath(
|
||||
int len;
|
||||
int starstar = FALSE;
|
||||
static int stardepth = 0; /* depth for "**" expansion */
|
||||
#ifdef WIN3264
|
||||
WIN32_FIND_DATA fb;
|
||||
HANDLE hFind = (HANDLE)0;
|
||||
# ifdef FEAT_MBYTE
|
||||
WIN32_FIND_DATAW wfb;
|
||||
WCHAR *wn = NULL; /* UCS-2 name, NULL when not used. */
|
||||
# endif
|
||||
#else
|
||||
struct ffblk fb;
|
||||
#endif
|
||||
char_u *matchname;
|
||||
int ok;
|
||||
|
||||
@@ -9827,7 +9811,7 @@ dos_expandpath(
|
||||
else if (path_end >= path + wildoff
|
||||
&& vim_strchr((char_u *)"*?[~", *path_end) != NULL)
|
||||
e = p;
|
||||
#ifdef FEAT_MBYTE
|
||||
# ifdef FEAT_MBYTE
|
||||
if (has_mbyte)
|
||||
{
|
||||
len = (*mb_ptr2len)(path_end);
|
||||
@@ -9836,7 +9820,7 @@ dos_expandpath(
|
||||
path_end += len;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
# endif
|
||||
*p++ = *path_end++;
|
||||
}
|
||||
e = p;
|
||||
@@ -9897,7 +9881,6 @@ dos_expandpath(
|
||||
|
||||
/* Scan all files in the directory with "dir/ *.*" */
|
||||
STRCPY(s, "*.*");
|
||||
#ifdef WIN3264
|
||||
# ifdef FEAT_MBYTE
|
||||
if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
|
||||
{
|
||||
@@ -9921,24 +9904,15 @@ dos_expandpath(
|
||||
# endif
|
||||
hFind = FindFirstFile((LPCSTR)buf, &fb);
|
||||
ok = (hFind != INVALID_HANDLE_VALUE);
|
||||
#else
|
||||
/* If we are expanding wildcards we try both files and directories */
|
||||
ok = (findfirst((char *)buf, &fb,
|
||||
(*path_end != NUL || (flags & EW_DIR)) ? FA_DIREC : 0) == 0);
|
||||
#endif
|
||||
|
||||
while (ok)
|
||||
{
|
||||
#ifdef WIN3264
|
||||
# ifdef FEAT_MBYTE
|
||||
if (wn != NULL)
|
||||
p = utf16_to_enc(wfb.cFileName, NULL); /* p is allocated here */
|
||||
else
|
||||
# endif
|
||||
p = (char_u *)fb.cFileName;
|
||||
#else
|
||||
p = (char_u *)fb.ff_name;
|
||||
#endif
|
||||
/* Ignore entries starting with a dot, unless when asked for. Accept
|
||||
* all entries found with "matchname". */
|
||||
if ((p[0] != '.' || starts_with_dot
|
||||
@@ -9950,11 +9924,7 @@ dos_expandpath(
|
||||
|| ((flags & EW_NOTWILD)
|
||||
&& fnamencmp(path + (s - buf), p, e - s) == 0)))
|
||||
{
|
||||
#ifdef WIN3264
|
||||
STRCPY(s, p);
|
||||
#else
|
||||
namelowcpy(s, p);
|
||||
#endif
|
||||
len = (int)STRLEN(buf);
|
||||
|
||||
if (starstar && stardepth < 100)
|
||||
@@ -9986,7 +9956,6 @@ dos_expandpath(
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef WIN3264
|
||||
# ifdef FEAT_MBYTE
|
||||
if (wn != NULL)
|
||||
{
|
||||
@@ -9996,16 +9965,12 @@ dos_expandpath(
|
||||
else
|
||||
# endif
|
||||
ok = FindNextFile(hFind, &fb);
|
||||
#else
|
||||
ok = (findnext(&fb) == 0);
|
||||
#endif
|
||||
|
||||
/* If no more matches and no match was used, try expanding the name
|
||||
* itself. Finds the long name of a short filename. */
|
||||
if (!ok && matchname != NULL && gap->ga_len == start_len)
|
||||
{
|
||||
STRCPY(s, matchname);
|
||||
#ifdef WIN3264
|
||||
FindClose(hFind);
|
||||
# ifdef FEAT_MBYTE
|
||||
if (wn != NULL)
|
||||
@@ -10019,21 +9984,15 @@ dos_expandpath(
|
||||
# endif
|
||||
hFind = FindFirstFile((LPCSTR)buf, &fb);
|
||||
ok = (hFind != INVALID_HANDLE_VALUE);
|
||||
#else
|
||||
ok = (findfirst((char *)buf, &fb,
|
||||
(*path_end != NUL || (flags & EW_DIR)) ? FA_DIREC : 0) == 0);
|
||||
#endif
|
||||
vim_free(matchname);
|
||||
matchname = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef WIN3264
|
||||
FindClose(hFind);
|
||||
# ifdef FEAT_MBYTE
|
||||
vim_free(wn);
|
||||
# endif
|
||||
#endif
|
||||
vim_free(buf);
|
||||
vim_regfree(regmatch.regprog);
|
||||
vim_free(matchname);
|
||||
|
||||
@@ -176,11 +176,11 @@ typedef int waitstatus;
|
||||
static pid_t wait4pid(pid_t, waitstatus *);
|
||||
|
||||
static int WaitForChar(long);
|
||||
static int WaitForCharOrMouse(long);
|
||||
static int WaitForCharOrMouse(long, int *break_loop);
|
||||
#if defined(__BEOS__) || defined(VMS)
|
||||
int RealWaitForChar(int, long, int *);
|
||||
int RealWaitForChar(int, long, int *, int *break_loop);
|
||||
#else
|
||||
static int RealWaitForChar(int, long, int *);
|
||||
static int RealWaitForChar(int, long, int *, int *break_loop);
|
||||
#endif
|
||||
|
||||
#ifdef FEAT_XCLIPBOARD
|
||||
@@ -366,7 +366,7 @@ mch_write(char_u *s, int len)
|
||||
{
|
||||
ignored = (int)write(1, (char *)s, len);
|
||||
if (p_wd) /* Unix is too fast, slow down a bit more */
|
||||
RealWaitForChar(read_cmd_fd, p_wd, NULL);
|
||||
RealWaitForChar(read_cmd_fd, p_wd, NULL, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -4762,7 +4762,7 @@ mch_call_shell(
|
||||
* to some terminal (vt52?).
|
||||
*/
|
||||
++noread_cnt;
|
||||
while (RealWaitForChar(fromshell_fd, 10L, NULL))
|
||||
while (RealWaitForChar(fromshell_fd, 10L, NULL, NULL))
|
||||
{
|
||||
len = read_eintr(fromshell_fd, buffer
|
||||
# ifdef FEAT_MBYTE
|
||||
@@ -5343,7 +5343,7 @@ mch_clear_job(job_T *job)
|
||||
void
|
||||
mch_breakcheck(void)
|
||||
{
|
||||
if (curr_tmode == TMODE_RAW && RealWaitForChar(read_cmd_fd, 0L, NULL))
|
||||
if (curr_tmode == TMODE_RAW && RealWaitForChar(read_cmd_fd, 0L, NULL, NULL))
|
||||
fill_input_buf(FALSE);
|
||||
}
|
||||
|
||||
@@ -5360,10 +5360,11 @@ WaitForChar(long msec)
|
||||
#ifdef FEAT_TIMERS
|
||||
long due_time;
|
||||
long remaining = msec;
|
||||
int break_loop = FALSE;
|
||||
|
||||
/* When waiting very briefly don't trigger timers. */
|
||||
if (msec >= 0 && msec < 10L)
|
||||
return WaitForCharOrMouse(msec);
|
||||
return WaitForCharOrMouse(msec, NULL);
|
||||
|
||||
while (msec < 0 || remaining > 0)
|
||||
{
|
||||
@@ -5372,14 +5373,18 @@ WaitForChar(long msec)
|
||||
due_time = check_due_timer();
|
||||
if (due_time <= 0 || (msec > 0 && due_time > remaining))
|
||||
due_time = remaining;
|
||||
if (WaitForCharOrMouse(due_time))
|
||||
if (WaitForCharOrMouse(due_time, &break_loop))
|
||||
return TRUE;
|
||||
if (break_loop)
|
||||
/* Nothing available, but need to return so that side effects get
|
||||
* handled, such as handling a message on a channel. */
|
||||
return FALSE;
|
||||
if (msec > 0)
|
||||
remaining -= due_time;
|
||||
}
|
||||
return FALSE;
|
||||
#else
|
||||
return WaitForCharOrMouse(msec);
|
||||
return WaitForCharOrMouse(msec, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -5390,7 +5395,7 @@ WaitForChar(long msec)
|
||||
* When a GUI is being used, this will never get called -- webb
|
||||
*/
|
||||
static int
|
||||
WaitForCharOrMouse(long msec)
|
||||
WaitForCharOrMouse(long msec, int *break_loop)
|
||||
{
|
||||
#ifdef FEAT_MOUSE_GPM
|
||||
int gpm_process_wanted;
|
||||
@@ -5436,9 +5441,10 @@ WaitForCharOrMouse(long msec)
|
||||
# endif
|
||||
# ifdef FEAT_MOUSE_GPM
|
||||
gpm_process_wanted = 0;
|
||||
avail = RealWaitForChar(read_cmd_fd, msec, &gpm_process_wanted);
|
||||
avail = RealWaitForChar(read_cmd_fd, msec,
|
||||
&gpm_process_wanted, break_loop);
|
||||
# else
|
||||
avail = RealWaitForChar(read_cmd_fd, msec, NULL);
|
||||
avail = RealWaitForChar(read_cmd_fd, msec, NULL, break_loop);
|
||||
# endif
|
||||
if (!avail)
|
||||
{
|
||||
@@ -5457,10 +5463,11 @@ WaitForCharOrMouse(long msec)
|
||||
# ifdef FEAT_XCLIPBOARD
|
||||
|| (!avail && rest != 0)
|
||||
# endif
|
||||
);
|
||||
)
|
||||
;
|
||||
|
||||
#else
|
||||
avail = RealWaitForChar(read_cmd_fd, msec, NULL);
|
||||
avail = RealWaitForChar(read_cmd_fd, msec, NULL, break_loop);
|
||||
#endif
|
||||
return avail;
|
||||
}
|
||||
@@ -5479,7 +5486,7 @@ WaitForCharOrMouse(long msec)
|
||||
#else
|
||||
static int
|
||||
#endif
|
||||
RealWaitForChar(int fd, long msec, int *check_for_gpm UNUSED)
|
||||
RealWaitForChar(int fd, long msec, int *check_for_gpm UNUSED, int *break_loop)
|
||||
{
|
||||
int ret;
|
||||
int result;
|
||||
@@ -5592,6 +5599,8 @@ RealWaitForChar(int fd, long msec, int *check_for_gpm UNUSED)
|
||||
ret = poll(fds, nfd, towait);
|
||||
|
||||
result = ret > 0 && (fds[0].revents & POLLIN);
|
||||
if (break_loop != NULL && ret > 0)
|
||||
*break_loop = TRUE;
|
||||
|
||||
# ifdef FEAT_MZSCHEME
|
||||
if (ret == 0 && mzquantum_used)
|
||||
@@ -5723,6 +5732,8 @@ select_eintr:
|
||||
result = ret > 0 && FD_ISSET(fd, &rfds);
|
||||
if (result)
|
||||
--ret;
|
||||
if (break_loop != NULL && ret > 0)
|
||||
*break_loop = TRUE;
|
||||
|
||||
# ifdef EINTR
|
||||
if (ret == -1 && errno == EINTR)
|
||||
|
||||
@@ -1027,6 +1027,8 @@ qf_add_entry(
|
||||
/* first element in the list */
|
||||
{
|
||||
qi->qf_lists[qi->qf_curlist].qf_start = qfp;
|
||||
qi->qf_lists[qi->qf_curlist].qf_ptr = qfp;
|
||||
qi->qf_lists[qi->qf_curlist].qf_index = 0;
|
||||
qfp->qf_prev = qfp; /* first element points to itself */
|
||||
}
|
||||
else
|
||||
@@ -4113,7 +4115,8 @@ set_errorlist(
|
||||
else
|
||||
qi->qf_lists[qi->qf_curlist].qf_nonevalid = FALSE;
|
||||
qi->qf_lists[qi->qf_curlist].qf_ptr = qi->qf_lists[qi->qf_curlist].qf_start;
|
||||
qi->qf_lists[qi->qf_curlist].qf_index = 1;
|
||||
if (qi->qf_lists[qi->qf_curlist].qf_count > 0)
|
||||
qi->qf_lists[qi->qf_curlist].qf_index = 1;
|
||||
|
||||
#ifdef FEAT_WINDOWS
|
||||
qf_update_buffer(qi);
|
||||
|
||||
@@ -1221,6 +1221,15 @@ struct dictitem_S
|
||||
};
|
||||
typedef struct dictitem_S dictitem_T;
|
||||
|
||||
/* A dictitem with a 16 character key (plus NUL). */
|
||||
struct dictitem16_S
|
||||
{
|
||||
typval_T di_tv; /* type and value of the variable */
|
||||
char_u di_flags; /* flags (only used for variable) */
|
||||
char_u di_key[17]; /* key */
|
||||
};
|
||||
typedef struct dictitem16_S dictitem16_T;
|
||||
|
||||
#define DI_FLAGS_RO 1 /* "di_flags" value: read-only variable */
|
||||
#define DI_FLAGS_RO_SBX 2 /* "di_flags" value: read-only in the sandbox */
|
||||
#define DI_FLAGS_FIX 4 /* "di_flags" value: fixed: no :unlet or remove() */
|
||||
|
||||
@@ -85,7 +85,6 @@ SCRIPTS_ALL = \
|
||||
test102.out \
|
||||
test103.out \
|
||||
test104.out \
|
||||
test105.out \
|
||||
test107.out \
|
||||
test108.out \
|
||||
test_autocmd_option.out \
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
Test filename modifiers vim: set ft=vim :
|
||||
|
||||
STARTTEST
|
||||
:source small.vim
|
||||
:%delete _
|
||||
:set shell=sh
|
||||
:set shellslash
|
||||
:let tab="\t"
|
||||
:command -nargs=1 Put :let expr=<q-args> | $put =expr.tab.strtrans(string(eval(expr)))
|
||||
:let $HOME=fnamemodify('.', ':p:h:h')
|
||||
:Put fnamemodify('.', ':p' )[-1:]
|
||||
:Put fnamemodify('.', ':p:h' )[-1:]
|
||||
:Put fnamemodify('test.out', ':p' )[-1:]
|
||||
:Put fnamemodify('test.out', ':.' )
|
||||
:Put fnamemodify('../testdir/a', ':.' )
|
||||
:Put fnamemodify('test.out', ':~' )
|
||||
:Put fnamemodify('../testdir/a', ':~' )
|
||||
:Put fnamemodify('../testdir/a', ':t' )
|
||||
:Put fnamemodify('.', ':p:t' )
|
||||
:Put fnamemodify('test.out', ':p:t' )
|
||||
:Put fnamemodify('test.out', ':p:e' )
|
||||
:Put fnamemodify('test.out', ':p:t:e' )
|
||||
:Put fnamemodify('abc.fb2.tar.gz', ':r' )
|
||||
:Put fnamemodify('abc.fb2.tar.gz', ':r:r' )
|
||||
:Put fnamemodify('abc.fb2.tar.gz', ':r:r:r' )
|
||||
:Put substitute(fnamemodify('abc.fb2.tar.gz', ':p:r:r'), '.*\(testdir/.*\)', '\1', '')
|
||||
:Put fnamemodify('abc.fb2.tar.gz', ':e' )
|
||||
:Put fnamemodify('abc.fb2.tar.gz', ':e:e' )
|
||||
:Put fnamemodify('abc.fb2.tar.gz', ':e:e:e' )
|
||||
:Put fnamemodify('abc.fb2.tar.gz', ':e:e:e:e')
|
||||
:Put fnamemodify('abc.fb2.tar.gz', ':e:e:r' )
|
||||
:Put fnamemodify('abc def', ':S' )
|
||||
:Put fnamemodify('abc" "def', ':S' )
|
||||
:Put fnamemodify('abc"%"def', ':S' )
|
||||
:Put fnamemodify('abc'' ''def', ':S' )
|
||||
:Put fnamemodify('abc''%''def', ':S' )
|
||||
:Put fnamemodify("abc\ndef", ':S' )
|
||||
:Put expand('%:r:S') == shellescape(expand('%:r'))
|
||||
:Put join([expand('%:r'), expand('%:r:S'), expand('%')], ',')
|
||||
:set shell=tcsh
|
||||
:Put fnamemodify("abc\ndef", ':S' )
|
||||
:$put ='vim: ts=8'
|
||||
:1 delete _
|
||||
:w! test.out
|
||||
:qa!
|
||||
ENDTEST
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
fnamemodify('.', ':p' )[-1:] '/'
|
||||
fnamemodify('.', ':p:h' )[-1:] 'r'
|
||||
fnamemodify('test.out', ':p' )[-1:] 't'
|
||||
fnamemodify('test.out', ':.' ) 'test.out'
|
||||
fnamemodify('../testdir/a', ':.' ) 'a'
|
||||
fnamemodify('test.out', ':~' ) '~/testdir/test.out'
|
||||
fnamemodify('../testdir/a', ':~' ) '~/testdir/a'
|
||||
fnamemodify('../testdir/a', ':t' ) 'a'
|
||||
fnamemodify('.', ':p:t' ) ''
|
||||
fnamemodify('test.out', ':p:t' ) 'test.out'
|
||||
fnamemodify('test.out', ':p:e' ) 'out'
|
||||
fnamemodify('test.out', ':p:t:e' ) 'out'
|
||||
fnamemodify('abc.fb2.tar.gz', ':r' ) 'abc.fb2.tar'
|
||||
fnamemodify('abc.fb2.tar.gz', ':r:r' ) 'abc.fb2'
|
||||
fnamemodify('abc.fb2.tar.gz', ':r:r:r' ) 'abc'
|
||||
substitute(fnamemodify('abc.fb2.tar.gz', ':p:r:r'), '.*\(testdir/.*\)', '\1', '') 'testdir/abc.fb2'
|
||||
fnamemodify('abc.fb2.tar.gz', ':e' ) 'gz'
|
||||
fnamemodify('abc.fb2.tar.gz', ':e:e' ) 'tar.gz'
|
||||
fnamemodify('abc.fb2.tar.gz', ':e:e:e' ) 'fb2.tar.gz'
|
||||
fnamemodify('abc.fb2.tar.gz', ':e:e:e:e') 'fb2.tar.gz'
|
||||
fnamemodify('abc.fb2.tar.gz', ':e:e:r' ) 'tar'
|
||||
fnamemodify('abc def', ':S' ) '''abc def'''
|
||||
fnamemodify('abc" "def', ':S' ) '''abc" "def'''
|
||||
fnamemodify('abc"%"def', ':S' ) '''abc"%"def'''
|
||||
fnamemodify('abc'' ''def', ':S' ) '''abc''\'''' ''\''''def'''
|
||||
fnamemodify('abc''%''def', ':S' ) '''abc''\''''%''\''''def'''
|
||||
fnamemodify("abc\ndef", ':S' ) '''abc^@def'''
|
||||
expand('%:r:S') == shellescape(expand('%:r')) 1
|
||||
join([expand('%:r'), expand('%:r:S'), expand('%')], ',') 'test105,''test105'',test105.in'
|
||||
fnamemodify("abc\ndef", ':S' ) '''abc\^@def'''
|
||||
vim: ts=8
|
||||
@@ -589,15 +589,6 @@ endfunction
|
||||
endfunction
|
||||
:call TestExists()
|
||||
:"
|
||||
:function TestHas()
|
||||
redir >> test.out
|
||||
for pl in ['6.9.999', '7.1.999', '7.4.123', '9.1.0', '9.9.1']
|
||||
echo 'has patch ' . pl . ': ' . has('patch-' . pl)
|
||||
endfor
|
||||
redir END
|
||||
endfunc
|
||||
:call TestHas()
|
||||
:"
|
||||
:delfunc TestExists
|
||||
:delfunc RunTest
|
||||
:delfunc TestFuncArg
|
||||
|
||||
@@ -204,8 +204,3 @@ OK
|
||||
g:footest#x = 1
|
||||
footest#F() 0
|
||||
UndefFun() 0
|
||||
has patch 6.9.999: 1
|
||||
has patch 7.1.999: 1
|
||||
has patch 7.4.123: 1
|
||||
has patch 9.1.0: 0
|
||||
has patch 9.9.1: 0
|
||||
|
||||
@@ -2,12 +2,14 @@
|
||||
" This makes testing go faster, since Vim doesn't need to restart.
|
||||
|
||||
source test_assign.vim
|
||||
source test_autocmd.vim
|
||||
source test_cursor_func.vim
|
||||
source test_delete.vim
|
||||
source test_ex_undo.vim
|
||||
source test_expr.vim
|
||||
source test_expand.vim
|
||||
source test_feedkeys.vim
|
||||
source test_fnamemodify.vim
|
||||
source test_file_perm.vim
|
||||
source test_glob2regpat.vim
|
||||
source test_help_tagjump.vim
|
||||
|
||||
@@ -57,14 +57,26 @@ func Test_compare_fail()
|
||||
call assert_equal(s:w, '')
|
||||
catch
|
||||
call assert_exception('E724:')
|
||||
call assert_true(v:errors[0] =~ "Expected NULL but got ''")
|
||||
call assert_match("Expected NULL but got ''", v:errors[0])
|
||||
call remove(v:errors, 0)
|
||||
endtry
|
||||
endfunc
|
||||
|
||||
func Test_match()
|
||||
call assert_match('^f.*b.*r$', 'foobar')
|
||||
|
||||
call assert_match('bar.*foo', 'foobar')
|
||||
call assert_match("Pattern 'bar.*foo' does not match 'foobar'", v:errors[0])
|
||||
call remove(v:errors, 0)
|
||||
|
||||
call assert_match('bar.*foo', 'foobar', 'wrong')
|
||||
call assert_match('wrong', v:errors[0])
|
||||
call remove(v:errors, 0)
|
||||
endfunc
|
||||
|
||||
func Test_assert_fail_fails()
|
||||
call assert_fails('xxx', {})
|
||||
call assert_true(v:errors[0] =~ "Expected {} but got 'E731:")
|
||||
call assert_match("Expected {} but got 'E731:", v:errors[0])
|
||||
call remove(v:errors, 0)
|
||||
endfunc
|
||||
|
||||
|
||||
8
src/testdir/test_autocmd.vim
Normal file
8
src/testdir/test_autocmd.vim
Normal file
@@ -0,0 +1,8 @@
|
||||
" Tests for autocommands
|
||||
|
||||
func Test_vim_did_enter()
|
||||
call assert_false(v:vim_did_enter)
|
||||
|
||||
" This script will never reach the main loop, can't check if v:vim_did_enter
|
||||
" becomes one.
|
||||
endfunc
|
||||
@@ -73,6 +73,11 @@ class ThreadedTCPRequestHandler(socketserver.BaseRequestHandler):
|
||||
print("sending: {0}".format(cmd))
|
||||
self.request.sendall(cmd.encode('utf-8'))
|
||||
response = "ok"
|
||||
elif decoded[1] == 'bad command':
|
||||
cmd = '["ex","foo bar"]'
|
||||
print("sending: {0}".format(cmd))
|
||||
self.request.sendall(cmd.encode('utf-8'))
|
||||
response = "ok"
|
||||
elif decoded[1] == 'do normal':
|
||||
# Send a normal command.
|
||||
cmd = '["normal","G$s more\u001b"]'
|
||||
@@ -85,16 +90,28 @@ class ThreadedTCPRequestHandler(socketserver.BaseRequestHandler):
|
||||
print("sending: {0}".format(cmd))
|
||||
self.request.sendall(cmd.encode('utf-8'))
|
||||
response = "ok"
|
||||
elif decoded[1] == 'eval-special':
|
||||
# Send an eval request. We ignore the response.
|
||||
cmd = '["expr","\\"foo\x7f\x10\x01bar\\"", -2]'
|
||||
print("sending: {0}".format(cmd))
|
||||
self.request.sendall(cmd.encode('utf-8'))
|
||||
response = "ok"
|
||||
elif decoded[1] == 'eval-getline':
|
||||
# Send an eval request. We ignore the response.
|
||||
cmd = '["expr","getline(3)", -3]'
|
||||
print("sending: {0}".format(cmd))
|
||||
self.request.sendall(cmd.encode('utf-8'))
|
||||
response = "ok"
|
||||
elif decoded[1] == 'eval-fails':
|
||||
# Send an eval request that will fail.
|
||||
cmd = '["expr","xxx", -2]'
|
||||
cmd = '["expr","xxx", -4]'
|
||||
print("sending: {0}".format(cmd))
|
||||
self.request.sendall(cmd.encode('utf-8'))
|
||||
response = "ok"
|
||||
elif decoded[1] == 'eval-error':
|
||||
# Send an eval request that works but the result can't
|
||||
# be encoded.
|
||||
cmd = '["expr","function(\\"tr\\")", -3]'
|
||||
cmd = '["expr","function(\\"tr\\")", -5]'
|
||||
print("sending: {0}".format(cmd))
|
||||
self.request.sendall(cmd.encode('utf-8'))
|
||||
response = "ok"
|
||||
|
||||
@@ -151,6 +151,11 @@ func s:communicate(port)
|
||||
call assert_equal('added1', getline(line('$') - 1))
|
||||
call assert_equal('added2', getline('$'))
|
||||
|
||||
" Request command "foo bar", which fails silently.
|
||||
call assert_equal('ok', ch_evalexpr(handle, 'bad command'))
|
||||
call s:waitFor('v:errmsg =~ "E492"')
|
||||
call assert_match('E492:.*foo bar', v:errmsg)
|
||||
|
||||
call assert_equal('ok', ch_evalexpr(handle, 'do normal', {'timeout': 100}))
|
||||
call s:waitFor('"added more" == getline("$")')
|
||||
call assert_equal('added more', getline('$'))
|
||||
@@ -192,20 +197,31 @@ func s:communicate(port)
|
||||
sleep 10m
|
||||
call assert_equal([-1, 'foo123'], ch_evalexpr(handle, 'eval-result'))
|
||||
|
||||
" Send an eval request with special characters.
|
||||
call assert_equal('ok', ch_evalexpr(handle, 'eval-special'))
|
||||
sleep 10m
|
||||
call assert_equal([-2, "foo\x7f\x10\x01bar"], ch_evalexpr(handle, 'eval-result'))
|
||||
|
||||
" Send an eval request to get a line with special characters.
|
||||
call setline(3, "a\nb\<CR>c\x01d\x7fe")
|
||||
call assert_equal('ok', ch_evalexpr(handle, 'eval-getline'))
|
||||
sleep 10m
|
||||
call assert_equal([-3, "a\nb\<CR>c\x01d\x7fe"], ch_evalexpr(handle, 'eval-result'))
|
||||
|
||||
" Send an eval request that fails.
|
||||
call assert_equal('ok', ch_evalexpr(handle, 'eval-fails'))
|
||||
sleep 10m
|
||||
call assert_equal([-2, 'ERROR'], ch_evalexpr(handle, 'eval-result'))
|
||||
call assert_equal([-4, 'ERROR'], ch_evalexpr(handle, 'eval-result'))
|
||||
|
||||
" Send an eval request that works but can't be encoded.
|
||||
call assert_equal('ok', ch_evalexpr(handle, 'eval-error'))
|
||||
sleep 10m
|
||||
call assert_equal([-3, 'ERROR'], ch_evalexpr(handle, 'eval-result'))
|
||||
call assert_equal([-5, 'ERROR'], ch_evalexpr(handle, 'eval-result'))
|
||||
|
||||
" Send a bad eval request. There will be no response.
|
||||
call assert_equal('ok', ch_evalexpr(handle, 'eval-bad'))
|
||||
sleep 10m
|
||||
call assert_equal([-3, 'ERROR'], ch_evalexpr(handle, 'eval-result'))
|
||||
call assert_equal([-5, 'ERROR'], ch_evalexpr(handle, 'eval-result'))
|
||||
|
||||
" Send an expr request
|
||||
call assert_equal('ok', ch_evalexpr(handle, 'an expr'))
|
||||
|
||||
@@ -21,3 +21,18 @@ func Test_equal()
|
||||
|
||||
call assert_fails('echo base.method > instance.method')
|
||||
endfunc
|
||||
|
||||
func Test_version()
|
||||
call assert_true(has('patch-7.4.001'))
|
||||
call assert_true(has('patch-7.4.01'))
|
||||
call assert_true(has('patch-7.4.1'))
|
||||
call assert_true(has('patch-6.9.999'))
|
||||
call assert_true(has('patch-7.1.999'))
|
||||
call assert_true(has('patch-7.4.123'))
|
||||
|
||||
call assert_false(has('patch-7'))
|
||||
call assert_false(has('patch-7.4'))
|
||||
call assert_false(has('patch-7.4.'))
|
||||
call assert_false(has('patch-9.1.0'))
|
||||
call assert_false(has('patch-9.9.1'))
|
||||
endfunc
|
||||
|
||||
49
src/testdir/test_fnamemodify.vim
Normal file
49
src/testdir/test_fnamemodify.vim
Normal file
@@ -0,0 +1,49 @@
|
||||
" Test filename modifiers.
|
||||
|
||||
func Test_fnamemodify()
|
||||
let $HOME = fnamemodify('.', ':p:h:h')
|
||||
set shell=sh
|
||||
|
||||
call assert_equal('/', fnamemodify('.', ':p')[-1:])
|
||||
call assert_equal('r', fnamemodify('.', ':p:h')[-1:])
|
||||
call assert_equal('t', fnamemodify('test.out', ':p')[-1:])
|
||||
call assert_equal('test.out', fnamemodify('test.out', ':.'))
|
||||
call assert_equal('a', fnamemodify('../testdir/a', ':.'))
|
||||
call assert_equal('~/testdir/test.out', fnamemodify('test.out', ':~'))
|
||||
call assert_equal('~/testdir/a', fnamemodify('../testdir/a', ':~'))
|
||||
call assert_equal('a', fnamemodify('../testdir/a', ':t'))
|
||||
call assert_equal('', fnamemodify('.', ':p:t'))
|
||||
call assert_equal('test.out', fnamemodify('test.out', ':p:t'))
|
||||
call assert_equal('out', fnamemodify('test.out', ':p:e'))
|
||||
call assert_equal('out', fnamemodify('test.out', ':p:t:e'))
|
||||
call assert_equal('abc.fb2.tar', fnamemodify('abc.fb2.tar.gz', ':r'))
|
||||
call assert_equal('abc.fb2', fnamemodify('abc.fb2.tar.gz', ':r:r'))
|
||||
call assert_equal('abc', fnamemodify('abc.fb2.tar.gz', ':r:r:r'))
|
||||
call assert_equal('testdir/abc.fb2', substitute(fnamemodify('abc.fb2.tar.gz', ':p:r:r'), '.*\(testdir/.*\)', '\1', ''))
|
||||
call assert_equal('gz', fnamemodify('abc.fb2.tar.gz', ':e'))
|
||||
call assert_equal('tar.gz', fnamemodify('abc.fb2.tar.gz', ':e:e'))
|
||||
call assert_equal('fb2.tar.gz', fnamemodify('abc.fb2.tar.gz', ':e:e:e'))
|
||||
call assert_equal('fb2.tar.gz', fnamemodify('abc.fb2.tar.gz', ':e:e:e:e'))
|
||||
call assert_equal('tar', fnamemodify('abc.fb2.tar.gz', ':e:e:r'))
|
||||
|
||||
call assert_equal('''abc def''', fnamemodify('abc def', ':S'))
|
||||
call assert_equal('''abc" "def''', fnamemodify('abc" "def', ':S'))
|
||||
call assert_equal('''abc"%"def''', fnamemodify('abc"%"def', ':S'))
|
||||
call assert_equal('''abc''\'''' ''\''''def''', fnamemodify('abc'' ''def', ':S'))
|
||||
call assert_equal('''abc''\''''%''\''''def''', fnamemodify('abc''%''def', ':S'))
|
||||
call assert_equal(expand('%:r:S'), shellescape(expand('%:r')))
|
||||
sp test_alot.vim
|
||||
call assert_equal('test_alot,''test_alot'',test_alot.vim', join([expand('%:r'), expand('%:r:S'), expand('%')], ','))
|
||||
quit
|
||||
|
||||
call assert_equal("'abc\ndef'", fnamemodify("abc\ndef", ':S'))
|
||||
set shell=tcsh
|
||||
call assert_equal("'abc\\\ndef'", fnamemodify("abc\ndef", ':S'))
|
||||
set shell&
|
||||
endfunc
|
||||
|
||||
func Test_expand()
|
||||
new
|
||||
call assert_equal("", expand('%:S'))
|
||||
quit
|
||||
endfunc
|
||||
@@ -193,3 +193,30 @@ func Test_tostring()
|
||||
call assert_true(v:false, v:exception)
|
||||
endtry
|
||||
endfunc
|
||||
|
||||
func Test_redefine_dict_func()
|
||||
let d = {}
|
||||
function d.test4()
|
||||
endfunction
|
||||
let d.test4 = d.test4
|
||||
try
|
||||
function! d.test4(name)
|
||||
endfunction
|
||||
catch
|
||||
call assert_true(v:errmsg, v:exception)
|
||||
endtry
|
||||
endfunc
|
||||
|
||||
func Test_bind_in_python()
|
||||
if has('python')
|
||||
let g:d = {}
|
||||
function g:d.test2()
|
||||
endfunction
|
||||
python import vim
|
||||
try
|
||||
call assert_equal(pyeval('vim.bindeval("g:d.test2")'), g:d.test2)
|
||||
catch
|
||||
call assert_true(v:false, v:exception)
|
||||
endtry
|
||||
endif
|
||||
endfunc
|
||||
|
||||
@@ -679,3 +679,16 @@ function Test_quickfix_was_changed_by_autocmd()
|
||||
call XquickfixChangedByAutocmd('c')
|
||||
call XquickfixChangedByAutocmd('l')
|
||||
endfunction
|
||||
|
||||
func Test_caddbuffer_to_empty()
|
||||
helpgr quickfix
|
||||
call setqflist([], 'r')
|
||||
cad
|
||||
try
|
||||
cn
|
||||
catch
|
||||
" number of matches is unknown
|
||||
call assert_true(v:exception =~ 'E553:')
|
||||
endtry
|
||||
quit!
|
||||
endfunc
|
||||
|
||||
@@ -30,3 +30,16 @@ func Test_repeat_many()
|
||||
call assert_true(s:val > 1)
|
||||
call assert_true(s:val < 5)
|
||||
endfunc
|
||||
|
||||
func Test_with_partial_callback()
|
||||
let s:val = 0
|
||||
let s:meow = {}
|
||||
function s:meow.bite(...)
|
||||
let s:val += 1
|
||||
endfunction
|
||||
|
||||
call timer_start(50, s:meow.bite)
|
||||
sleep 200m
|
||||
call assert_equal(1, s:val)
|
||||
endfunc
|
||||
" vim: ts=2 sw=0 et
|
||||
|
||||
@@ -748,6 +748,44 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
1663,
|
||||
/**/
|
||||
1662,
|
||||
/**/
|
||||
1661,
|
||||
/**/
|
||||
1660,
|
||||
/**/
|
||||
1659,
|
||||
/**/
|
||||
1658,
|
||||
/**/
|
||||
1657,
|
||||
/**/
|
||||
1656,
|
||||
/**/
|
||||
1655,
|
||||
/**/
|
||||
1654,
|
||||
/**/
|
||||
1653,
|
||||
/**/
|
||||
1652,
|
||||
/**/
|
||||
1651,
|
||||
/**/
|
||||
1650,
|
||||
/**/
|
||||
1649,
|
||||
/**/
|
||||
1648,
|
||||
/**/
|
||||
1647,
|
||||
/**/
|
||||
1646,
|
||||
/**/
|
||||
1645,
|
||||
/**/
|
||||
1644,
|
||||
/**/
|
||||
|
||||
Reference in New Issue
Block a user