Compare commits
46 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ea6553bec3 | ||
|
|
4f3f668c84 | ||
|
|
c4dcd60c76 | ||
|
|
fa8b2e173d | ||
|
|
819821c5a9 | ||
|
|
e1581307d2 | ||
|
|
1473551a44 | ||
|
|
8fdd721047 | ||
|
|
92e35efaf6 | ||
|
|
1e7885abe8 | ||
|
|
52c6eaffd4 | ||
|
|
da64ab322a | ||
|
|
610cc1b9b3 | ||
|
|
780d4c3fff | ||
|
|
f68f1d7079 | ||
|
|
aedfcbe1e6 | ||
|
|
bee6c0cf86 | ||
|
|
8b20179c65 | ||
|
|
4c90861e9f | ||
|
|
c5fbe8af4c | ||
|
|
24c77a1e3a | ||
|
|
d4caf5c16a | ||
|
|
6a08454b93 | ||
|
|
5ca84ce4aa | ||
|
|
ffec3c5349 | ||
|
|
5f436fcf99 | ||
|
|
e4eb6ff089 | ||
|
|
6c0e984f26 | ||
|
|
6135d0d803 | ||
|
|
6a06363861 | ||
|
|
8e08125d3a | ||
|
|
b763eba7ae | ||
|
|
6098957458 | ||
|
|
573e445664 | ||
|
|
d63aff0a65 | ||
|
|
b86f10ee10 | ||
|
|
3f3fbd3fdb | ||
|
|
75f7265dd4 | ||
|
|
580984e026 | ||
|
|
e18c0b3981 | ||
|
|
be6aa46c4d | ||
|
|
03602ec28e | ||
|
|
e9d6a298df | ||
|
|
17b56c9f83 | ||
|
|
a63cdb5ed6 | ||
|
|
4077b33a83 |
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 14
|
||||
*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
|
||||
@@ -153,15 +142,10 @@ Use |ch_status()| to see if the channel could be opened.
|
||||
excluding the NL.
|
||||
When "mode" is "raw" the "msg" argument is the whole message
|
||||
as a string.
|
||||
*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.
|
||||
|
||||
For all callbacks: Use |function()| to bind it to arguments
|
||||
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: >
|
||||
@@ -175,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.
|
||||
@@ -212,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.
|
||||
@@ -323,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" ~
|
||||
|
||||
@@ -425,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*
|
||||
|
||||
@@ -521,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().
|
||||
@@ -539,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 15
|
||||
*eval.txt* For Vim version 7.4. Last change: 2016 Mar 27
|
||||
|
||||
|
||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||
@@ -753,7 +753,12 @@ recursively. Ignoring case means case is ignored when comparing item values.
|
||||
|
||||
*E693* *E694*
|
||||
A |Funcref| can only be compared with a |Funcref| and only "equal" and "not
|
||||
equal" can be used. Case is never ignored.
|
||||
equal" can be used. Case is never ignored. Whether arguments or a Dictionary
|
||||
are bound (with a partial) is ignored. This is so that when a function is
|
||||
made a member of a Dictionary it is still considered to be the same function.
|
||||
To compare partials to see if they bind the same argument and Dictionary
|
||||
values use string(): >
|
||||
echo string(Partial1) == string(Partial2)
|
||||
|
||||
When using "is" or "isnot" with a |List| or a |Dictionary| this checks if the
|
||||
expressions are referring to the same |List| or |Dictionary| instance. A copy
|
||||
@@ -1757,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.
|
||||
|
||||
@@ -1796,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}
|
||||
@@ -1822,6 +1832,7 @@ ch_evalraw( {handle}, {string} [, {options}])
|
||||
any evaluate {string} on raw {handle}
|
||||
ch_getbufnr( {handle}, {what}) Number get buffer number for {handle}/{what}
|
||||
ch_getjob( {channel}) Job get the Job of {channel}
|
||||
ch_info( {handle}) String info about channel {handle}
|
||||
ch_log( {msg} [, {handle}]) none write {msg} in the channel log file
|
||||
ch_logfile( {fname} [, {mode}]) none start logging channel activity
|
||||
ch_open( {address} [, {options}]) Channel open a channel to {address}
|
||||
@@ -1832,7 +1843,7 @@ ch_sendexpr( {handle}, {expr} [, {options}])
|
||||
ch_sendraw( {handle}, {string} [, {options}])
|
||||
any send {string} over raw {handle}
|
||||
ch_setoptions( {handle}, {options}) none set options for {handle}
|
||||
ch_status( {handle}) String status of {handle}
|
||||
ch_status( {handle}) String status of channel {handle}
|
||||
changenr() Number current change number
|
||||
char2nr( {expr}[, {utf8}]) Number ASCII/UTF8 value of first char in {expr}
|
||||
cindent( {lnum}) Number C indent for line {lnum}
|
||||
@@ -2305,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()|.
|
||||
@@ -2706,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()*
|
||||
@@ -2722,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
|
||||
@@ -2759,6 +2784,32 @@ ch_getjob({channel}) *ch_getjob()*
|
||||
{only available when compiled with the |+channel| and
|
||||
|+job| features}
|
||||
|
||||
ch_info({handle}) *ch_info()*
|
||||
Returns a Dictionary with information about {handle}. The
|
||||
items are:
|
||||
"id" number of the channel
|
||||
"status" "open" (any part is open) or "closed"
|
||||
When opened with ch_open():
|
||||
"hostname" the hostname of the address
|
||||
"port" the port of the address
|
||||
"sock_status" "open" or "closed"
|
||||
"sock_mode" "NL", "RAW", "JSON" or "JS"
|
||||
"sock_io" "socket"
|
||||
"sock_timeout" timeout in msec
|
||||
When opened with job_start():
|
||||
"out_status" "open" or "closed"
|
||||
"out_mode" "NL", "RAW", "JSON" or "JS"
|
||||
"out_io" "null", "pipe", "file" or "buffer"
|
||||
"out_timeout" timeout in msec
|
||||
"err_status" "open" or "closed"
|
||||
"err_mode" "NL", "RAW", "JSON" or "JS"
|
||||
"err_io" "out", "null", "pipe", "file" or "buffer"
|
||||
"err_timeout" timeout in msec
|
||||
"in_status" "open" or "closed"
|
||||
"in_mode" "NL", "RAW", "JSON" or "JS"
|
||||
"in_io" "null", "pipe", "file" or "buffer"
|
||||
"in_timeout" timeout in msec
|
||||
|
||||
ch_log({msg} [, {handle}]) *ch_log()*
|
||||
Write {msg} in the channel log file, if it was opened with
|
||||
|ch_logfile()|.
|
||||
@@ -2780,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()*
|
||||
@@ -3594,6 +3614,18 @@ function({name} [, {arglist}] [, {dict}])
|
||||
< Invokes the function as with: >
|
||||
call Callback('one', 'two', 'name')
|
||||
|
||||
< The function() call can be nested to add more arguments to the
|
||||
Funcref. The extra arguments are appended to the list of
|
||||
arguments. Example: >
|
||||
func Callback(arg1, arg2, name)
|
||||
...
|
||||
let Func = function('Callback', ['one'])
|
||||
let Func2 = function(Func, ['two'])
|
||||
...
|
||||
call Func2('name')
|
||||
< Invokes the function as with: >
|
||||
call Callback('one', 'two', 'name')
|
||||
|
||||
< The Dictionary is only useful when calling a "dict" function.
|
||||
In that case the {dict} is passed in as "self". Example: >
|
||||
function Callback() dict
|
||||
@@ -6627,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()*
|
||||
@@ -7050,6 +7086,10 @@ timer_start({time}, {callback} [, {options}])
|
||||
intervals.
|
||||
{only available when compiled with the |+timers| feature}
|
||||
|
||||
timer_stop({timer}) *timer_stop()*
|
||||
Stop a timer. {timer} is an ID returned by timer_start().
|
||||
The timer callback will no longer be invoked.
|
||||
|
||||
tolower({expr}) *tolower()*
|
||||
The result is a copy of the String given, with all uppercase
|
||||
characters turned into lowercase (just like applying |gu| to
|
||||
@@ -7613,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: 2014 Sep 19
|
||||
*helphelp.txt* For Vim version 7.4. Last change: 2016 Mar 26
|
||||
|
||||
|
||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||
@@ -197,6 +197,9 @@ command: >
|
||||
*E154* *E150* *E151* *E152* *E153* *E670*
|
||||
:helpt[ags] [++t] {dir}
|
||||
Generate the help tags file(s) for directory {dir}.
|
||||
When {dir} is ALL then all "doc" directories in
|
||||
'runtimepath' will be used.
|
||||
|
||||
All "*.txt" and "*.??x" files in the directory and
|
||||
sub-directories are scanned for a help tag definition
|
||||
in between stars. The "*.??x" files are for
|
||||
@@ -205,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
|
||||
|
||||
@@ -410,13 +410,20 @@ This means that Vim will search for the Lua DLL or shared library file only
|
||||
when needed. When you don't use the Lua interface you don't need it, thus
|
||||
you can use Vim without this file.
|
||||
|
||||
On MS-Windows to use the Lua interface the Lua DLL must be in your search path.
|
||||
In a console window type "path" to see what directories are used. The version
|
||||
of the DLL must match the Lua version Vim was compiled with.
|
||||
|
||||
On Unix the 'luadll' option can be used to specify the Lua shared library file
|
||||
instead of DYNAMIC_LUA_DLL file what was specified at compile time. The
|
||||
version of the shared library must match the Lua version Vim was compiled with.
|
||||
MS-Windows ~
|
||||
|
||||
To use the Lua interface the Lua DLL must be in your search path. In a
|
||||
console window type "path" to see what directories are used. The 'luadll'
|
||||
option can be also used to specify the Lua DLL. The version of the DLL must
|
||||
match the Lua version Vim was compiled with.
|
||||
|
||||
|
||||
Unix ~
|
||||
|
||||
The 'luadll' option can be used to specify the Lua shared library file instead
|
||||
of DYNAMIC_LUA_DLL file what was specified at compile time. The version of
|
||||
the shared library must match the Lua version Vim was compiled with.
|
||||
|
||||
|
||||
==============================================================================
|
||||
|
||||
@@ -284,7 +284,8 @@ used for building Vim.
|
||||
To use the Perl interface the Perl DLL must be in your search path.
|
||||
If Vim reports it cannot find the perl512.dll, make sure your $PATH includes
|
||||
the directory where it is located. The Perl installer normally does that.
|
||||
In a console window type "path" to see what directories are used.
|
||||
In a console window type "path" to see what directories are used. The
|
||||
'perldll' option can be also used to specify the Perl DLL.
|
||||
|
||||
The name of the DLL must match the Perl version Vim was compiled with.
|
||||
Currently the name is "perl512.dll". That is for Perl 5.12. To know for
|
||||
|
||||
@@ -686,18 +686,24 @@ This means that Vim will search for the Python DLL or shared library file only
|
||||
when needed. When you don't use the Python interface you don't need it, thus
|
||||
you can use Vim without this file.
|
||||
|
||||
On MS-Windows to use the Python interface the Python DLL must be in your search
|
||||
path. In a console window type "path" to see what directories are used.
|
||||
|
||||
MS-Windows ~
|
||||
|
||||
To use the Python interface the Python DLL must be in your search path. In a
|
||||
console window type "path" to see what directories are used. The 'pythondll'
|
||||
or 'pythonthreedll' option can be also used to specify the Python DLL.
|
||||
|
||||
The name of the DLL must match the Python version Vim was compiled with.
|
||||
Currently the name is "python24.dll". That is for Python 2.4. To know for
|
||||
sure edit "gvim.exe" and search for "python\d*.dll\c".
|
||||
|
||||
On Unix the 'pythondll' or 'pythonthreedll' option can be used to specify the
|
||||
Python shared library file instead of DYNAMIC_PYTHON_DLL or
|
||||
DYNAMIC_PYTHON3_DLL file what were specified at compile time. The version of
|
||||
the shared library must match the Python 2.x or Python 3 version Vim was
|
||||
compiled with.
|
||||
|
||||
Unix ~
|
||||
|
||||
The 'pythondll' or 'pythonthreedll' option can be used to specify the Python
|
||||
shared library file instead of DYNAMIC_PYTHON_DLL or DYNAMIC_PYTHON3_DLL file
|
||||
what were specified at compile time. The version of the shared library must
|
||||
match the Python 2.x or Python 3 version Vim was compiled with.
|
||||
|
||||
==============================================================================
|
||||
10. Python 3 *python3*
|
||||
|
||||
@@ -199,6 +199,7 @@ This means that Vim will search for the Ruby DLL file or shared library only
|
||||
when needed. When you don't use the Ruby interface you don't need it, thus
|
||||
you can use Vim even though this library file is not on your system.
|
||||
|
||||
|
||||
MS-Windows ~
|
||||
|
||||
You need to install the right version of Ruby for this to work. You can find
|
||||
@@ -207,7 +208,8 @@ http://www.garbagecollect.jp/ruby/mswin32/en/download/release.html
|
||||
Currently that is ruby-1.9.1-p429-i386-mswin32.zip
|
||||
|
||||
To use the Ruby interface the Ruby DLL must be in your search path. In a
|
||||
console window type "path" to see what directories are used.
|
||||
console window type "path" to see what directories are used. The 'rubydll'
|
||||
option can be also used to specify the Ruby DLL.
|
||||
|
||||
The name of the DLL must match the Ruby version Vim was compiled with.
|
||||
Currently the name is "msvcrt-ruby191.dll". That is for Ruby 1.9.1. To know
|
||||
@@ -218,6 +220,7 @@ and comment-out the check for _MSC_VER.
|
||||
You may also need to rename the include directory name to match the version,
|
||||
strangely for Ruby 1.9.3 the directory is called 1.9.1.
|
||||
|
||||
|
||||
Unix ~
|
||||
|
||||
The 'rubydll' option can be used to specify the Ruby shared library file
|
||||
|
||||
@@ -526,7 +526,8 @@ can use Vim without this file.
|
||||
MS-Windows ~
|
||||
|
||||
To use the Tcl interface the Tcl DLL must be in your search path. In a
|
||||
console window type "path" to see what directories are used.
|
||||
console window type "path" to see what directories are used. The 'tcldll'
|
||||
option can be also used to specify the Tcl DLL.
|
||||
|
||||
The name of the DLL must match the Tcl version Vim was compiled with.
|
||||
Currently the name is "tcl86.dll". That is for Tcl 8.6. To know for sure
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
*index.txt* For Vim version 7.4. Last change: 2016 Mar 04
|
||||
*index.txt* For Vim version 7.4. Last change: 2016 Mar 12
|
||||
|
||||
|
||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||
@@ -1395,6 +1395,7 @@ tag command action ~
|
||||
|:ounmenu| :ounme[nu] remove menu for Operator-pending mode
|
||||
|:ownsyntax| :ow[nsyntax] set new local syntax highlight for this window
|
||||
|:packadd| :pa[ckadd] add a plugin from 'packpath'
|
||||
|:packloadall| :packl[oadall] load all packages under 'packpath'
|
||||
|:pclose| :pc[lose] close preview window
|
||||
|:pedit| :ped[it] edit file in the preview window
|
||||
|:perl| :pe[rl] execute Perl command
|
||||
|
||||
@@ -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 @@
|
||||
*quickfix.txt* For Vim version 7.4. Last change: 2016 Jan 21
|
||||
*quickfix.txt* For Vim version 7.4. Last change: 2016 Mar 23
|
||||
|
||||
|
||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||
@@ -56,6 +56,14 @@ The following quickfix commands can be used. The location list commands are
|
||||
similar to the quickfix commands, replacing the 'c' prefix in the quickfix
|
||||
command with 'l'.
|
||||
|
||||
*E924*
|
||||
If the current window was closed by an |autocommand| while processing a
|
||||
location list command, it will be aborted.
|
||||
|
||||
*E925* *E926*
|
||||
If the current quickfix or location list was changed by an |autocommand| while
|
||||
processing a quickfix or location list command, it will be aborted.
|
||||
|
||||
*:cc*
|
||||
:cc[!] [nr] Display error [nr]. If [nr] is omitted, the same
|
||||
error is displayed again. Without [!] this doesn't
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
*repeat.txt* For Vim version 7.4. Last change: 2016 Mar 09
|
||||
*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*
|
||||
@@ -249,15 +250,18 @@ For writing a Vim script, see chapter 41 of the user manual |usr_41.txt|.
|
||||
|
||||
Also see |pack-add|.
|
||||
|
||||
*:packl* *:packloadall*
|
||||
:packloadall[!] Load all packages in the "start" directories under
|
||||
'packpath'. The directories found are added to
|
||||
'runtimepath'.
|
||||
This normally done during startup, after loading your
|
||||
.vimrc file. With this command it can be done
|
||||
earlier.
|
||||
This is normally done automatically during startup,
|
||||
after loading your .vimrc file. With this command it
|
||||
can be done earlier.
|
||||
Packages will be loaded only once. After this command
|
||||
it won't happen again. When the optional ! is added
|
||||
this command will load packages even when done before.
|
||||
An Error only causes sourcing the script where it
|
||||
happens to be aborted, further plugins will be loaded.
|
||||
See |packages|.
|
||||
|
||||
:scripte[ncoding] [encoding] *:scripte* *:scriptencoding* *E167*
|
||||
@@ -478,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.
|
||||
|
||||
@@ -513,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
|
||||
@@ -745,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:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
*syntax.txt* For Vim version 7.4. Last change: 2016 Feb 25
|
||||
*syntax.txt* For Vim version 7.4. Last change: 2016 Mar 12
|
||||
|
||||
|
||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||
@@ -4534,9 +4534,9 @@ in their own color.
|
||||
:colo[rscheme] {name} Load color scheme {name}. This searches 'runtimepath'
|
||||
for the file "colors/{name}.vim". The first one that
|
||||
is found is loaded.
|
||||
To see the name of the currently active color scheme: >
|
||||
:colo
|
||||
< The name is also stored in the g:colors_name variable.
|
||||
Also searches all plugins in 'packpath', first below
|
||||
"start" and then under "opt".
|
||||
|
||||
Doesn't work recursively, thus you can't use
|
||||
":colorscheme" in a color scheme script.
|
||||
After the color scheme has been loaded the
|
||||
|
||||
@@ -207,6 +207,8 @@ $VIM_POSIX vi_diff.txt /*$VIM_POSIX*
|
||||
'efm' options.txt /*'efm'*
|
||||
'ei' options.txt /*'ei'*
|
||||
'ek' options.txt /*'ek'*
|
||||
'emo' options.txt /*'emo'*
|
||||
'emoji' options.txt /*'emoji'*
|
||||
'enc' options.txt /*'enc'*
|
||||
'encoding' options.txt /*'encoding'*
|
||||
'endofline' options.txt /*'endofline'*
|
||||
@@ -1286,6 +1288,7 @@ $VIM_POSIX vi_diff.txt /*$VIM_POSIX*
|
||||
+termresponse various.txt /*+termresponse*
|
||||
+textobjects various.txt /*+textobjects*
|
||||
+tgetent various.txt /*+tgetent*
|
||||
+timers various.txt /*+timers*
|
||||
+title various.txt /*+title*
|
||||
+toolbar various.txt /*+toolbar*
|
||||
+user_commands various.txt /*+user_commands*
|
||||
@@ -1634,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*
|
||||
@@ -2620,6 +2624,8 @@ $VIM_POSIX vi_diff.txt /*$VIM_POSIX*
|
||||
:p various.txt /*:p*
|
||||
:pa repeat.txt /*:pa*
|
||||
:packadd repeat.txt /*:packadd*
|
||||
:packl repeat.txt /*:packl*
|
||||
:packloadall repeat.txt /*:packloadall*
|
||||
:pc windows.txt /*:pc*
|
||||
:pclose windows.txt /*:pclose*
|
||||
:pe if_perl.txt /*:pe*
|
||||
@@ -4212,7 +4218,6 @@ E702 eval.txt /*E702*
|
||||
E703 eval.txt /*E703*
|
||||
E704 eval.txt /*E704*
|
||||
E705 eval.txt /*E705*
|
||||
E706 eval.txt /*E706*
|
||||
E707 eval.txt /*E707*
|
||||
E708 eval.txt /*E708*
|
||||
E709 eval.txt /*E709*
|
||||
@@ -4444,6 +4449,13 @@ E917 eval.txt /*E917*
|
||||
E918 channel.txt /*E918*
|
||||
E919 repeat.txt /*E919*
|
||||
E92 message.txt /*E92*
|
||||
E920 channel.txt /*E920*
|
||||
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*
|
||||
@@ -4877,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*
|
||||
@@ -5170,6 +5183,7 @@ ch_evalexpr() eval.txt /*ch_evalexpr()*
|
||||
ch_evalraw() eval.txt /*ch_evalraw()*
|
||||
ch_getbufnr() eval.txt /*ch_getbufnr()*
|
||||
ch_getjob() eval.txt /*ch_getjob()*
|
||||
ch_info() eval.txt /*ch_info()*
|
||||
ch_log() eval.txt /*ch_log()*
|
||||
ch_logfile() eval.txt /*ch_logfile()*
|
||||
ch_open() eval.txt /*ch_open()*
|
||||
@@ -5212,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*
|
||||
@@ -5278,7 +5294,7 @@ clipboard-html options.txt /*clipboard-html*
|
||||
clipboard-unnamed options.txt /*clipboard-unnamed*
|
||||
clipboard-unnamedplus options.txt /*clipboard-unnamedplus*
|
||||
clojure-indent indent.txt /*clojure-indent*
|
||||
close-cb channel.txt /*close-cb*
|
||||
close_cb channel.txt /*close_cb*
|
||||
cmdarg-variable eval.txt /*cmdarg-variable*
|
||||
cmdbang-variable eval.txt /*cmdbang-variable*
|
||||
cmdline-arguments vi_diff.txt /*cmdline-arguments*
|
||||
@@ -5643,10 +5659,11 @@ end intro.txt /*end*
|
||||
end-of-file pattern.txt /*end-of-file*
|
||||
enlightened-terminal syntax.txt /*enlightened-terminal*
|
||||
erlang.vim syntax.txt /*erlang.vim*
|
||||
err-buf channel.txt /*err-buf*
|
||||
err-cb channel.txt /*err-cb*
|
||||
err-name channel.txt /*err-name*
|
||||
err-timeout channel.txt /*err-timeout*
|
||||
err_buf channel.txt /*err_buf*
|
||||
err_cb channel.txt /*err_cb*
|
||||
err_mode channel.txt /*err_mode*
|
||||
err_name channel.txt /*err_name*
|
||||
err_timeout channel.txt /*err_timeout*
|
||||
errmsg-variable eval.txt /*errmsg-variable*
|
||||
error-file-format quickfix.txt /*error-file-format*
|
||||
error-messages message.txt /*error-messages*
|
||||
@@ -6765,10 +6782,11 @@ improved-viminfo version5.txt /*improved-viminfo*
|
||||
improvements-5 version5.txt /*improvements-5*
|
||||
improvements-6 version6.txt /*improvements-6*
|
||||
improvements-7 version7.txt /*improvements-7*
|
||||
in-bot channel.txt /*in-bot*
|
||||
in-buf channel.txt /*in-buf*
|
||||
in-name channel.txt /*in-name*
|
||||
in-top channel.txt /*in-top*
|
||||
in_bot channel.txt /*in_bot*
|
||||
in_buf channel.txt /*in_buf*
|
||||
in_mode channel.txt /*in_mode*
|
||||
in_name channel.txt /*in_name*
|
||||
in_top channel.txt /*in_top*
|
||||
inactive-buffer windows.txt /*inactive-buffer*
|
||||
include-search tagsrch.txt /*include-search*
|
||||
inclusive motion.txt /*inclusive*
|
||||
@@ -6846,21 +6864,23 @@ javascript-indenting indent.txt /*javascript-indenting*
|
||||
job channel.txt /*job*
|
||||
job-callback channel.txt /*job-callback*
|
||||
job-channel-overview channel.txt /*job-channel-overview*
|
||||
job-close-cb channel.txt /*job-close-cb*
|
||||
job-close_cb channel.txt /*job-close_cb*
|
||||
job-control channel.txt /*job-control*
|
||||
job-err-cb channel.txt /*job-err-cb*
|
||||
job-err-io channel.txt /*job-err-io*
|
||||
job-exit-cb channel.txt /*job-exit-cb*
|
||||
job-in-io channel.txt /*job-in-io*
|
||||
job-err_cb channel.txt /*job-err_cb*
|
||||
job-err_io channel.txt /*job-err_io*
|
||||
job-exit_cb channel.txt /*job-exit_cb*
|
||||
job-in_io channel.txt /*job-in_io*
|
||||
job-options channel.txt /*job-options*
|
||||
job-out-cb channel.txt /*job-out-cb*
|
||||
job-out-io channel.txt /*job-out-io*
|
||||
job-out_cb channel.txt /*job-out_cb*
|
||||
job-out_io channel.txt /*job-out_io*
|
||||
job-start channel.txt /*job-start*
|
||||
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()*
|
||||
job_start() eval.txt /*job_start()*
|
||||
job_status() eval.txt /*job_status()*
|
||||
@@ -7511,6 +7531,7 @@ news intro.txt /*news*
|
||||
nextnonblank() eval.txt /*nextnonblank()*
|
||||
nice todo.txt /*nice*
|
||||
no-eval-feature eval.txt /*no-eval-feature*
|
||||
no-type-checking eval.txt /*no-type-checking*
|
||||
no_buffers_menu gui.txt /*no_buffers_menu*
|
||||
non-greedy pattern.txt /*non-greedy*
|
||||
non-zero-arg eval.txt /*non-zero-arg*
|
||||
@@ -7579,12 +7600,14 @@ os_unix.txt os_unix.txt /*os_unix.txt*
|
||||
os_vms.txt os_vms.txt /*os_vms.txt*
|
||||
os_win32.txt os_win32.txt /*os_win32.txt*
|
||||
other-features vi_diff.txt /*other-features*
|
||||
out-buf channel.txt /*out-buf*
|
||||
out-cb channel.txt /*out-cb*
|
||||
out-name channel.txt /*out-name*
|
||||
out-timeout channel.txt /*out-timeout*
|
||||
out_buf channel.txt /*out_buf*
|
||||
out_cb channel.txt /*out_cb*
|
||||
out_mode channel.txt /*out_mode*
|
||||
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*
|
||||
@@ -8199,7 +8222,6 @@ startup-terminal term.txt /*startup-terminal*
|
||||
static-tag tagsrch.txt /*static-tag*
|
||||
status-line windows.txt /*status-line*
|
||||
statusmsg-variable eval.txt /*statusmsg-variable*
|
||||
sticky-type-checking eval.txt /*sticky-type-checking*
|
||||
str2float() eval.txt /*str2float()*
|
||||
str2nr() eval.txt /*str2nr()*
|
||||
strcasestr() eval.txt /*strcasestr()*
|
||||
@@ -8580,6 +8602,8 @@ throw-from-catch eval.txt /*throw-from-catch*
|
||||
throw-variables eval.txt /*throw-variables*
|
||||
throwpoint-variable eval.txt /*throwpoint-variable*
|
||||
time-functions usr_41.txt /*time-functions*
|
||||
timer_start() eval.txt /*timer_start()*
|
||||
timer_stop() eval.txt /*timer_stop()*
|
||||
timestamp editing.txt /*timestamp*
|
||||
timestamps editing.txt /*timestamps*
|
||||
tips tips.txt /*tips*
|
||||
@@ -8751,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_!*
|
||||
@@ -8924,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*
|
||||
@@ -9028,6 +9055,11 @@ win32-term os_win32.txt /*win32-term*
|
||||
win32-vimrun gui_w32.txt /*win32-vimrun*
|
||||
win32-win3.1 os_win32.txt /*win32-win3.1*
|
||||
win32s os_win32.txt /*win32s*
|
||||
win_findbuf() eval.txt /*win_findbuf()*
|
||||
win_getid() eval.txt /*win_getid()*
|
||||
win_gotoid() eval.txt /*win_gotoid()*
|
||||
win_id2tabwin() eval.txt /*win_id2tabwin()*
|
||||
win_id2win() eval.txt /*win_id2win()*
|
||||
winbufnr() eval.txt /*winbufnr()*
|
||||
wincol() eval.txt /*wincol()*
|
||||
window windows.txt /*window*
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
*todo.txt* For Vim version 7.4. Last change: 2016 Mar 11
|
||||
*todo.txt* For Vim version 7.4. Last change: 2016 Mar 26
|
||||
|
||||
|
||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||
@@ -34,29 +34,18 @@ not be repeated below, unless there is extra information.
|
||||
*known-bugs*
|
||||
-------------------- Known bugs and current work -----------------------
|
||||
|
||||
assert_matches('pattern', value)
|
||||
|
||||
+channel:
|
||||
- CHANNEL_PIPES -> FEAT_JOB
|
||||
- FEAT_JOB / FEAT_CHANNEL -> FEAT_JOBCHANNEL ?
|
||||
- move code from eval.c to channel.c
|
||||
- add job_info(): process ID, run/dead, etc.
|
||||
- add ch_info(): in/out/err mode, timeout, callbacks, etc.
|
||||
- Move more details from eval.txt to channel.txt. Add tags in eval.txt.
|
||||
- When receiving malformed json starting with a quote it doesn't get
|
||||
discarded. Any invalid JSON or JSON that isn't a list will block further
|
||||
parsing?
|
||||
- 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.
|
||||
@@ -64,47 +53,13 @@ Later
|
||||
- job_start(): run job in a newly opened terminal.
|
||||
With xterm could use -S{pty}.
|
||||
|
||||
emoji patch from Yasuhiro Matsumoto. Asked Thomas Dickey.
|
||||
|
||||
Remove sticky type checking.
|
||||
Partial:
|
||||
- Maybe we also need VAR_PARTIAL support in if_mzsch.
|
||||
|
||||
Packages:
|
||||
- Add command to update help tags in 'runtimepath'. Pathogen has something
|
||||
like that.
|
||||
- colorscheme command in .vimrc doesn't work.
|
||||
- Also search in 'packpath', both "start" and "opt", don't add dir to 'rtp'
|
||||
- command like :runtime that also search 'packpath'. :packruntime
|
||||
use "ever" or "opt"? both?
|
||||
- command to load packages now?
|
||||
- make package for editexisting, others?
|
||||
|
||||
More plugin support:
|
||||
- Have a way to install a callback from the main loop. Called every second or
|
||||
so.
|
||||
- Need way to uniquely identify a window, no matter how windows are
|
||||
rearranged. Same for tab pages.
|
||||
getwinid() ID of current winow
|
||||
getwinid({nr}) ID of window {nr}
|
||||
getwinid({nr}, {tab}) ID of window {nr} in tab page {tab}
|
||||
getwinnr({id}) window nr of {id} or -1 if not open
|
||||
gettabnr({id}) tab page nr of {id} or -1 if not open
|
||||
gotowin({id})
|
||||
Make it so that the window ID can be used where currently a window nr is used
|
||||
Patch from Anton Lindqvist, 2016 Feb 21, to make bufwinnr() return a list.
|
||||
Perhaps add bufwinid() instead.
|
||||
|
||||
This difference is unexpected:
|
||||
echo v:true == 1
|
||||
1
|
||||
echo [v:true] == [1]
|
||||
0
|
||||
It's because tv_equal() works different.
|
||||
|
||||
Compiler warnings. (John Marriott, Feb 17)
|
||||
|
||||
Compiler warnings in if_ole.cpp. Patch by Ken Takata, Feb 18.
|
||||
|
||||
When running "make install" don't overwrite the doc/tags file, generate it
|
||||
elsewhere, so that the distributed file doesn't change.
|
||||
Make it so that the window ID can be used where currently a window nr is used
|
||||
|
||||
Fix to support --nofork for Windows batch files. (Kevin Cantú, 2016 Feb 23,
|
||||
#658, #659) Also add "setlocal" at top of batch file?
|
||||
@@ -115,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)
|
||||
@@ -164,30 +122,51 @@ 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.
|
||||
|
||||
Also include update_curswant() fix for getcurpos(). (Christian Brabandt, 2016
|
||||
Feb 9)
|
||||
|
||||
Patch to list some messages and clear messages. (Yasuhiro Matsumoto, 2016 Mar
|
||||
12)
|
||||
|
||||
Patch to fix escaping special characters for delete(). (tc-0, 2016 Mar 20,
|
||||
#700) Test fails on MS-Windows.
|
||||
|
||||
Patch to put undo options together in undo window.
|
||||
(Gary Johnson, 2016 Jan 28)
|
||||
|
||||
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)
|
||||
|
||||
Patch for test86 and test87. (Roland Puntaier, #622)
|
||||
|
||||
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)
|
||||
@@ -200,9 +179,14 @@ After 7.5 is released:
|
||||
- Drop support for older MS-Windows systems, before XP.
|
||||
Patch from Ken Takata, 2016 Mar 8.
|
||||
|
||||
Add stronger encryption. Could use libsodium (NaCl).
|
||||
https://github.com/jedisct1/libsodium/
|
||||
Possibly include the needed code so that it can be build everywhere.
|
||||
|
||||
Patch to add setbufline(). (email from Yasuhiro Matsumoto, patch by Ozaki
|
||||
Kiichi, 2016 Feb 28)
|
||||
Update Mar 8: https://gist.github.com/mattn/23c1f50999084992ca98
|
||||
Update Mar 13: https://gist.github.com/mattn/23c1f50999084992ca98
|
||||
|
||||
Need to try out instructions in INSSTALLpc.txt about how to install all
|
||||
interfaces and how to build Vim with them.
|
||||
@@ -210,9 +194,6 @@ Appveyor build with self-installing executable, includes getting most
|
||||
interfaces: https://github.com/k-takata/vim/tree/chrisbra-appveyor-build
|
||||
result: https://ci.appveyor.com/project/k-takata/vim/history
|
||||
|
||||
Still using freed memory after using setloclist(). (lcd, 2014 Jul 23)
|
||||
More info Jul 24. Not clear why.
|
||||
|
||||
Duplication of completion suggestions for ":!hom". Issue 539.
|
||||
Patch by Christian, 2016 Jan 29
|
||||
>
|
||||
@@ -235,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?
|
||||
@@ -242,9 +227,6 @@ Should use /usr/local/share/applications or /usr/share/applications.
|
||||
Or use $XDG_DATA_DIRS.
|
||||
Also need to run update-desktop-database (Kuriyama Kazunobu, 2015 Nov 4)
|
||||
|
||||
Move the README files that are for including in archives to a subdirectory.
|
||||
"readmedir/" ?
|
||||
|
||||
Access to uninitialized memory in match_backref() regexp_nda.c:4882
|
||||
(Dominique Pelle, 2015 Nov 6)
|
||||
|
||||
@@ -256,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,
|
||||
@@ -283,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)
|
||||
@@ -333,6 +319,9 @@ Patch to add :mapgroup, put mappings in a group like augroup.
|
||||
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) Update Mar 21.
|
||||
|
||||
Can we cache the syntax attributes, so that updates for 'relativenumber' and
|
||||
'cursorline'/'cursorcolumn' are a lot faster?
|
||||
|
||||
@@ -412,8 +401,6 @@ Patch to fix checking global option value when not using it.
|
||||
When 'showbreak' is set repeating a Visual operation counts the size of the
|
||||
'showbreak' text as part of the operation. (Axel Bender, 2015 Jul 20)
|
||||
|
||||
Patch to apply 'fileformats' when starting Vim. (Mike Williams, 2015 Jul 22)
|
||||
|
||||
Patch for matchit plugin related to multibyte chars. (Ken Takata, 2015 Jul 22)
|
||||
|
||||
Patch for multi-byte characters in langmap and applying a mapping on them.
|
||||
@@ -471,6 +458,7 @@ Mixup of highlighting when there is a match and SpellBad. (ZyX, 2015 Jan 1)
|
||||
Patch for drag&drop reordering of GUI tab pages reordering.
|
||||
(Ken Takata, 2013 Nov 22, second one, also by Masamichi Abe)
|
||||
Now on Git: https://gist.github.com/nocd5/165286495c782b815b94
|
||||
Update 2016 Mar 15.
|
||||
|
||||
Patch on Issue 72: 'autochdir' causes problems for :vimgrep.
|
||||
|
||||
@@ -3732,7 +3720,7 @@ Syntax highlighting:
|
||||
unprintable char another color. Would be useful for ^M at end of line.
|
||||
|
||||
|
||||
Built-in script language:
|
||||
Vim script language:
|
||||
8 Make the filename and line number available to script functions, so that
|
||||
they can give useful debugging info. The whole call stack would be ideal.
|
||||
At least use this for error messages.
|
||||
@@ -3753,14 +3741,10 @@ Built-in script language:
|
||||
7 ":include" command: just like ":source" but doesn't start a new scriptID?
|
||||
Will be tricky for the list of script names.
|
||||
8 Have a look at VSEL. Would it be useful to include? (Bigham)
|
||||
8 Add ":fungroup" command, to group function definitions together. When
|
||||
encountered, all functions in the group are removed. Suggest using an
|
||||
obscure name to avoid name clashes. Require a ":fungroup END" in the same
|
||||
sourced file? Assume the group ends at the end of the file. Handle
|
||||
nested packages?
|
||||
Alternative: Support packages. {package-name}:{function-name}().
|
||||
Packages are loaded automatically when first used, from
|
||||
$VIMRUNTIME/packages (or use a search path).
|
||||
8 Have a prefix for a function to make it unique. When using packages it
|
||||
can be the plugin name.
|
||||
Perhaps also have a way to remove everything that the package added?
|
||||
including autocommands.
|
||||
7 Pre-parse or compile Vim scripts into a bytecode.
|
||||
1. Put the bytecode with the original script, with an ":if
|
||||
has('bytecode')" around it, so that it's only used with a Vim that
|
||||
@@ -3777,8 +3761,6 @@ Built-in script language:
|
||||
8 Add functions:
|
||||
has(":command") Check if ":command" works. compare function
|
||||
with "ex_ni". E.g. for ":simalt".
|
||||
system() With a List argument. Bypasses the shell, use
|
||||
exec() directly. (Bob Hiestand)
|
||||
escape() Add argument to specify what to escape with.
|
||||
modestack() Instead of just the current mode return the
|
||||
stack of Insert / CTRL-O / :normal things.
|
||||
|
||||
@@ -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_41.txt* For Vim version 7.4. Last change: 2016 Feb 14
|
||||
*usr_41.txt* For Vim version 7.4. Last change: 2016 Mar 15
|
||||
|
||||
VIM USER MANUAL - by Bram Moolenaar
|
||||
|
||||
@@ -889,9 +889,11 @@ Mappings: *mapping-functions*
|
||||
wildmenumode() check if the wildmode is active
|
||||
|
||||
Testing: *test-functions*
|
||||
assert_equal() assert that two expressions values are equal
|
||||
assert_equal() assert that two expressions values are equal
|
||||
assert_false() assert that an expression is false
|
||||
assert_true() assert that an expression is true
|
||||
assert_exception() assert that a command throws an exception
|
||||
assert_fails() assert that a function call fails
|
||||
|
||||
Inter-process communication:
|
||||
ch_open() open a channel
|
||||
@@ -932,7 +934,7 @@ Various: *various-functions*
|
||||
perleval() evaluate Perl expression (|+perl|)
|
||||
py3eval() evaluate Python expression (|+python3|)
|
||||
pyeval() evaluate Python expression (|+python|)
|
||||
wordcount() get byte/word/char count of buffer
|
||||
wordcount() get byte/word/char count of buffer
|
||||
|
||||
==============================================================================
|
||||
*41.7* Defining a function
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
*various.txt* For Vim version 7.4. Last change: 2016 Feb 27
|
||||
*various.txt* For Vim version 7.4. Last change: 2016 Mar 20
|
||||
|
||||
|
||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||
@@ -426,6 +426,7 @@ m *+tcl/dyn* Tcl interface |tcl-dynamic| |/dyn|
|
||||
N *+termresponse* support for |t_RV| and |v:termresponse|
|
||||
N *+textobjects* |text-objects| selection
|
||||
*+tgetent* non-Unix only: able to use external termcap
|
||||
N *+timers* the |timer_start()| function
|
||||
N *+title* Setting the window 'title' and 'icon'
|
||||
N *+toolbar* |gui-toolbar|
|
||||
N *+user_commands* User-defined commands. |user-commands|
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
" These commands create the option window.
|
||||
"
|
||||
" Maintainer: Bram Moolenaar <Bram@vim.org>
|
||||
" Last Change: 2016 Feb 21
|
||||
" Last Change: 2016 Mar 19
|
||||
|
||||
" If there already is an option window, jump to that one.
|
||||
if bufwinnr("option-window") > 0
|
||||
|
||||
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:
|
||||
@@ -50,7 +50,7 @@ class ThreadedTCPRequestHandler(socketserver.BaseRequestHandler):
|
||||
if data == '':
|
||||
print("=== socket closed ===")
|
||||
break
|
||||
print("received: {}".format(data))
|
||||
print("received: {0}".format(data))
|
||||
try:
|
||||
decoded = json.loads(data)
|
||||
except ValueError:
|
||||
@@ -65,7 +65,7 @@ class ThreadedTCPRequestHandler(socketserver.BaseRequestHandler):
|
||||
else:
|
||||
response = "what?"
|
||||
encoded = json.dumps([decoded[0], response])
|
||||
print("sending {}".format(encoded))
|
||||
print("sending {0}".format(encoded))
|
||||
self.request.sendall(encoded.encode('utf-8'))
|
||||
thesocket = None
|
||||
|
||||
@@ -87,7 +87,7 @@ if __name__ == "__main__":
|
||||
server_thread.start()
|
||||
print("Server loop running in thread: ", server_thread.name)
|
||||
|
||||
print("Listening on port {}".format(PORT))
|
||||
print("Listening on port {0}".format(PORT))
|
||||
while True:
|
||||
typed = sys.stdin.readline()
|
||||
if "quit" in typed:
|
||||
@@ -96,7 +96,7 @@ if __name__ == "__main__":
|
||||
if thesocket is None:
|
||||
print("No socket yet")
|
||||
else:
|
||||
print("sending {}".format(typed))
|
||||
print("sending {0}".format(typed))
|
||||
thesocket.sendall(typed.encode('utf-8'))
|
||||
|
||||
server.shutdown()
|
||||
|
||||
@@ -32,8 +32,8 @@ func! ParseFoldProps()
|
||||
if line !~ '^#' && line !~ '^\s*$'
|
||||
let l = split(line, '\s*;\s*', 1)
|
||||
if len(l) != 4
|
||||
echoerr 'Found ' . len(l) . ' items in line ' . lnum . ', expected 4'
|
||||
return
|
||||
echoerr 'Found ' . len(l) . ' items in line ' . lnum . ', expected 4'
|
||||
return
|
||||
endif
|
||||
call add(s:foldprops, l)
|
||||
endif
|
||||
@@ -50,8 +50,8 @@ func! ParseWidthProps()
|
||||
if line !~ '^#' && line !~ '^\s*$'
|
||||
let l = split(line, '\s*;\s*', 1)
|
||||
if len(l) != 2
|
||||
echoerr 'Found ' . len(l) . ' items in line ' . lnum . ', expected 2'
|
||||
return
|
||||
echoerr 'Found ' . len(l) . ' items in line ' . lnum . ', expected 2'
|
||||
return
|
||||
endif
|
||||
call add(s:widthprops, l)
|
||||
endif
|
||||
@@ -72,18 +72,18 @@ func! BuildCaseTable(name, index)
|
||||
let n = ('0x' . p[0]) + 0
|
||||
let nl = ('0x' . p[a:index]) + 0
|
||||
if start >= 0 && add == nl - n && (step == 0 || n - end == step)
|
||||
" continue with same range.
|
||||
let step = n - end
|
||||
let end = n
|
||||
" continue with same range.
|
||||
let step = n - end
|
||||
let end = n
|
||||
else
|
||||
if start >= 0
|
||||
" produce previous range
|
||||
call Range(ranges, start, end, step, add)
|
||||
endif
|
||||
let start = n
|
||||
let end = n
|
||||
let step = 0
|
||||
let add = nl - n
|
||||
if start >= 0
|
||||
" produce previous range
|
||||
call Range(ranges, start, end, step, add)
|
||||
endif
|
||||
let start = n
|
||||
let end = n
|
||||
let step = 0
|
||||
let add = nl - n
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
@@ -115,18 +115,18 @@ func! BuildFoldTable()
|
||||
let n = ('0x' . p[0]) + 0
|
||||
let nl = ('0x' . p[2]) + 0
|
||||
if start >= 0 && add == nl - n && (step == 0 || n - end == step)
|
||||
" continue with same range.
|
||||
let step = n - end
|
||||
let end = n
|
||||
" continue with same range.
|
||||
let step = n - end
|
||||
let end = n
|
||||
else
|
||||
if start >= 0
|
||||
" produce previous range
|
||||
call Range(ranges, start, end, step, add)
|
||||
endif
|
||||
let start = n
|
||||
let end = n
|
||||
let step = 0
|
||||
let add = nl - n
|
||||
if start >= 0
|
||||
" produce previous range
|
||||
call Range(ranges, start, end, step, add)
|
||||
endif
|
||||
let start = n
|
||||
let end = n
|
||||
let step = 0
|
||||
let add = nl - n
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
@@ -160,15 +160,15 @@ func! BuildCombiningTable()
|
||||
if p[2] == 'Mn' || p[2] == 'Mc' || p[2] == 'Me'
|
||||
let n = ('0x' . p[0]) + 0
|
||||
if start >= 0 && end + 1 == n
|
||||
" continue with same range.
|
||||
let end = n
|
||||
" continue with same range.
|
||||
let end = n
|
||||
else
|
||||
if start >= 0
|
||||
" produce previous range
|
||||
call add(ranges, printf("\t{0x%04x, 0x%04x},", start, end))
|
||||
endif
|
||||
let start = n
|
||||
let end = n
|
||||
if start >= 0
|
||||
" produce previous range
|
||||
call add(ranges, printf("\t{0x%04x, 0x%04x},", start, end))
|
||||
endif
|
||||
let start = n
|
||||
let end = n
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
@@ -197,47 +197,57 @@ func! BuildWidthTable(pattern, tableName)
|
||||
for p in s:widthprops
|
||||
if p[1][0] =~ a:pattern
|
||||
if p[0] =~ '\.\.'
|
||||
" It is a range. we don't check for composing char then.
|
||||
let rng = split(p[0], '\.\.')
|
||||
if len(rng) != 2
|
||||
echoerr "Cannot parse range: '" . p[0] . "' in width table"
|
||||
endif
|
||||
let n = ('0x' . rng[0]) + 0
|
||||
let n_last = ('0x' . rng[1]) + 0
|
||||
" It is a range. we don't check for composing char then.
|
||||
let rng = split(p[0], '\.\.')
|
||||
if len(rng) != 2
|
||||
echoerr "Cannot parse range: '" . p[0] . "' in width table"
|
||||
endif
|
||||
let n = ('0x' . rng[0]) + 0
|
||||
let n_last = ('0x' . rng[1]) + 0
|
||||
else
|
||||
let n = ('0x' . p[0]) + 0
|
||||
let n_last = n
|
||||
let n = ('0x' . p[0]) + 0
|
||||
let n_last = n
|
||||
endif
|
||||
" Find this char in the data table.
|
||||
while 1
|
||||
let dn = ('0x' . s:dataprops[dataidx][0]) + 0
|
||||
if dn >= n
|
||||
break
|
||||
endif
|
||||
let dataidx += 1
|
||||
let dn = ('0x' . s:dataprops[dataidx][0]) + 0
|
||||
if dn >= n
|
||||
break
|
||||
endif
|
||||
let dataidx += 1
|
||||
endwhile
|
||||
if dn != n && n_last == n
|
||||
echoerr "Cannot find character " . n . " in data table"
|
||||
echoerr "Cannot find character " . n . " in data table"
|
||||
endif
|
||||
" Only use the char when it's not a composing char.
|
||||
" But use all chars from a range.
|
||||
let dp = s:dataprops[dataidx]
|
||||
if n_last > n || (dp[2] != 'Mn' && dp[2] != 'Mc' && dp[2] != 'Me')
|
||||
if start >= 0 && end + 1 == n
|
||||
" continue with same range.
|
||||
else
|
||||
if start >= 0
|
||||
" produce previous range
|
||||
call add(ranges, printf("\t{0x%04x, 0x%04x},", start, end))
|
||||
endif
|
||||
let start = n
|
||||
endif
|
||||
let end = n_last
|
||||
if start >= 0 && end + 1 == n
|
||||
" continue with same range.
|
||||
else
|
||||
if start >= 0
|
||||
" produce previous range
|
||||
call add(ranges, printf("\t{0x%04x, 0x%04x},", start, end))
|
||||
if a:pattern == 'A'
|
||||
call add(s:ambitable, [start, end])
|
||||
else
|
||||
call add(s:doubletable, [start, end])
|
||||
endif
|
||||
endif
|
||||
let start = n
|
||||
endif
|
||||
let end = n_last
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
if start >= 0
|
||||
call add(ranges, printf("\t{0x%04x, 0x%04x},", start, end))
|
||||
if a:pattern == 'A'
|
||||
call add(s:ambitable, [start, end])
|
||||
else
|
||||
call add(s:doubletable, [start, end])
|
||||
endif
|
||||
endif
|
||||
|
||||
" New buffer to put the result in.
|
||||
@@ -253,21 +263,78 @@ endfunc
|
||||
|
||||
" Build the amoji width table in a new buffer.
|
||||
func! BuildEmojiTable(pattern, tableName)
|
||||
let ranges = []
|
||||
for line in map(filter(filter(getline(1, '$'), 'v:val=~"^[1-9]"'), 'v:val=~a:pattern'), 'matchstr(v:val,"^\\S\\+")')
|
||||
let alltokens = []
|
||||
let widthtokens = []
|
||||
let lines = map(filter(filter(getline(1, '$'), 'v:val=~"^[1-9]"'), 'v:val=~a:pattern'), 'matchstr(v:val,"^\\S\\+")')
|
||||
for n in range(len(lines))
|
||||
let line = lines[n]
|
||||
let token = split(line, '\.\.')
|
||||
let first = ('0x' . token[0]) + 0
|
||||
if len(token) == 1
|
||||
call add(token, token[0])
|
||||
let last = first
|
||||
else
|
||||
let last = ('0x' . token[1]) + 0
|
||||
endif
|
||||
|
||||
let token = [first, last]
|
||||
if len(alltokens) > 0 && (token[0] - 1 == alltokens[-1][1])
|
||||
let alltokens[-1][1] = token[1]
|
||||
else
|
||||
call add(alltokens, token)
|
||||
endif
|
||||
|
||||
" Characters below 1F000 may be considered single width traditionally,
|
||||
" making them double width causes problems.
|
||||
if first < 0x1f000
|
||||
continue
|
||||
endif
|
||||
|
||||
" exclude characters that are in the "ambiguous" or "doublewidth" table
|
||||
for ambi in s:ambitable
|
||||
if first >= ambi[0] && first <= ambi[1]
|
||||
let first = ambi[1] + 1
|
||||
endif
|
||||
if last >= ambi[0] && last <= ambi[1]
|
||||
let last = ambi[0] - 1
|
||||
endif
|
||||
endfor
|
||||
for double in s:doubletable
|
||||
if first >= double[0] && first <= double[1]
|
||||
let first = double[1] + 1
|
||||
endif
|
||||
if last >= double[0] && last <= double[1]
|
||||
let last = double[0] - 1
|
||||
endif
|
||||
endfor
|
||||
|
||||
if first <= last
|
||||
let token = [first, last]
|
||||
if len(widthtokens) > 0 && (token[0] - 1 == widthtokens[-1][1])
|
||||
let widthtokens[-1][1] = token[1]
|
||||
else
|
||||
call add(widthtokens, token)
|
||||
endif
|
||||
endif
|
||||
call add(ranges, printf("\t{0x%04x, 0x%04x},", "0x".token[0], "0x".token[1]))
|
||||
endfor
|
||||
let allranges = map(alltokens, 'printf("\t{0x%04x, 0x%04x},", v:val[0], v:val[1])')
|
||||
let widthranges = map(widthtokens, 'printf("\t{0x%04x, 0x%04x},", v:val[0], v:val[1])')
|
||||
|
||||
" New buffer to put the result in.
|
||||
new
|
||||
exe "file " . a:tableName
|
||||
call setline(1, " static struct interval " . a:tableName . "[] =")
|
||||
exe "file " . a:tableName . '_all'
|
||||
call setline(1, " static struct interval " . a:tableName . "_all[] =")
|
||||
call setline(2, " {")
|
||||
call append('$', ranges)
|
||||
call append('$', allranges)
|
||||
call setline('$', getline('$')[:-2]) " remove last comma
|
||||
call setline(line('$') + 1, " };")
|
||||
wincmd p
|
||||
|
||||
" New buffer to put the result in.
|
||||
new
|
||||
exe "file " . a:tableName . '_width'
|
||||
call setline(1, " static struct interval " . a:tableName . "_width[] =")
|
||||
call setline(2, " {")
|
||||
call append('$', widthranges)
|
||||
call setline('$', getline('$')[:-2]) " remove last comma
|
||||
call setline(line('$') + 1, " };")
|
||||
wincmd p
|
||||
@@ -307,13 +374,16 @@ edit http://www.unicode.org/Public/UNIDATA/EastAsianWidth.txt
|
||||
call ParseWidthProps()
|
||||
|
||||
" Build the double width table.
|
||||
let s:doubletable = []
|
||||
call BuildWidthTable('[WF]', 'doublewidth')
|
||||
|
||||
" Build the ambiguous width table.
|
||||
let s:ambitable = []
|
||||
call BuildWidthTable('A', 'ambiguous')
|
||||
|
||||
" Edit the emoji text file. Requires the netrw plugin.
|
||||
edit http://www.unicode.org/Public/emoji/3.0/emoji-data.txt
|
||||
|
||||
" Build the emoji table. Ver. 1.0 - 6.0
|
||||
" Must come after the "ambiguous" table
|
||||
call BuildEmojiTable('; Emoji\s\+# [1-6]\.[0-9]', 'emoji')
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -415,7 +415,7 @@ WINDRES_CC = $(CC)
|
||||
###########################################################################
|
||||
|
||||
CFLAGS = -Iproto $(DEFINES) -pipe -march=$(ARCH) -Wall
|
||||
CXXFLAGS = -std=c++11
|
||||
CXXFLAGS = -std=gnu++11
|
||||
WINDRES_FLAGS = --preprocessor="$(WINDRES_CC) -E -xc" -DRC_INVOKED
|
||||
EXTRA_LIBS =
|
||||
|
||||
|
||||
39
src/Makefile
39
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)
|
||||
@@ -1972,7 +1980,6 @@ test1 \
|
||||
test_match_conceal \
|
||||
test_nested_function \
|
||||
test_options \
|
||||
test_qf_title \
|
||||
test_ruby \
|
||||
test_search_mbyte \
|
||||
test_signs \
|
||||
@@ -1982,7 +1989,7 @@ test1 \
|
||||
test_wordcount \
|
||||
test_writefile \
|
||||
test2 test3 test4 test5 test6 test7 test8 test9 \
|
||||
test10 test11 test12 test13 test14 test15 test16 test17 test18 test19 \
|
||||
test11 test12 test13 test14 test15 test16 test17 test18 test19 \
|
||||
test20 test21 test22 test23 test24 test25 test26 test27 test28 test29 \
|
||||
test30 test31 test32 test33 test34 test35 test36 test37 test38 test39 \
|
||||
test40 test41 test42 test43 test44 test45 test46 test47 test48 test49 \
|
||||
@@ -1990,8 +1997,8 @@ test1 \
|
||||
test60 test61 test62 test63 test64 test65 test66 test67 test68 test69 \
|
||||
test70 test71 test72 test73 test74 test75 test76 test77 test78 test79 \
|
||||
test80 test81 test82 test83 test84 test85 test86 test87 test88 test89 \
|
||||
test90 test91 test92 test93 test94 test95 test96 test97 test98 test99 \
|
||||
test100 test101 test102 test103 test104 test105 test106 test107 test108:
|
||||
test90 test91 test92 test93 test94 test95 test97 test98 test99 \
|
||||
test100 test101 test102 test103 test104 test105 test107 test108:
|
||||
cd testdir; rm -f $@.out; $(MAKE) -f Makefile $@.out VIMPROG=../$(VIMTARGET) $(GUI_TESTARG) SCRIPTSOURCE=../$(SCRIPTSOURCE)
|
||||
|
||||
# Run individual NEW style test, assuming that Vim was already compiled.
|
||||
@@ -2003,11 +2010,14 @@ test_arglist \
|
||||
test_channel \
|
||||
test_cursor_func \
|
||||
test_delete \
|
||||
test_ex_undo \
|
||||
test_expr \
|
||||
test_expand \
|
||||
test_feedkeys \
|
||||
test_file_perm \
|
||||
test_glob2regpat \
|
||||
test_hardcopy \
|
||||
test_help_tagjump \
|
||||
test_history \
|
||||
test_increment \
|
||||
test_join \
|
||||
@@ -2016,6 +2026,7 @@ test_arglist \
|
||||
test_lispwords \
|
||||
test_menu \
|
||||
test_packadd \
|
||||
test_partial \
|
||||
test_perl \
|
||||
test_quickfix \
|
||||
test_reltime \
|
||||
@@ -2024,11 +2035,13 @@ test_arglist \
|
||||
test_sort \
|
||||
test_syn_attr \
|
||||
test_syntax \
|
||||
test_timers \
|
||||
test_undolevels \
|
||||
test_unlet \
|
||||
test_viminfo \
|
||||
test_viml \
|
||||
test_visual \
|
||||
test_window_id \
|
||||
test_alot:
|
||||
cd testdir; rm -f $@.res test.log messages; $(MAKE) -f Makefile $@.res VIMPROG=../$(VIMTARGET) $(GUI_TESTARG) SCRIPTSOURCE=../$(SCRIPTSOURCE)
|
||||
@if test -f testdir/test.log; then \
|
||||
@@ -2102,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) \
|
||||
@@ -2110,11 +2123,11 @@ installrtbase: $(HELPSOURCE)/vim.1 $(DEST_VIM) $(DEST_RT) \
|
||||
$(DEST_FTP) $(DEST_AUTO) $(DEST_AUTO)/xml $(DEST_PLUG) \
|
||||
$(DEST_TUTOR) $(DEST_SPELL) $(DEST_COMP)
|
||||
-$(SHELL) ./installman.sh install $(DEST_MAN) "" $(INSTALLMANARGS)
|
||||
@echo generating help tags
|
||||
# Generate the help tags with ":helptags" to handle all languages.
|
||||
# Move the distributed tags file aside and restore it, to avoid it being
|
||||
# different from the repository.
|
||||
cd $(HELPSOURCE); mv -f tags tags.dist
|
||||
cd $(HELPSOURCE); if test -f tags; then mv -f tags tags.dist; fi
|
||||
@echo generating help tags
|
||||
-@cd $(HELPSOURCE); $(MAKE) VIMEXE=$(DEST_BIN)/$(VIMTARGET) vimtags
|
||||
cd $(HELPSOURCE); \
|
||||
files=`ls *.txt tags`; \
|
||||
@@ -2124,7 +2137,7 @@ installrtbase: $(HELPSOURCE)/vim.1 $(DEST_VIM) $(DEST_RT) \
|
||||
chmod $(HELPMOD) $$files
|
||||
$(INSTALL_DATA) $(HELPSOURCE)/*.pl $(DEST_HELP)
|
||||
chmod $(SCRIPTMOD) $(DEST_HELP)/*.pl
|
||||
cd $(HELPSOURCE); mv -f tags.dist tags
|
||||
cd $(HELPSOURCE); if test -f tags.dist; then mv -f tags.dist tags; fi
|
||||
# install the menu files
|
||||
$(INSTALL_DATA) $(SCRIPTSOURCE)/menu.vim $(SYS_MENU_FILE)
|
||||
chmod $(VIMSCRIPTMOD) $(SYS_MENU_FILE)
|
||||
@@ -2201,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
|
||||
@@ -2350,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) $@
|
||||
@@ -2496,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)
|
||||
|
||||
@@ -838,6 +838,8 @@ channel_open(
|
||||
|
||||
channel->CH_SOCK_FD = (sock_T)sd;
|
||||
channel->ch_nb_close_cb = nb_close_cb;
|
||||
channel->ch_hostname = (char *)vim_strsave((char_u *)hostname);
|
||||
channel->ch_port = port_in;
|
||||
|
||||
#ifdef FEAT_GUI
|
||||
channel_gui_register_one(channel, PART_SOCK);
|
||||
@@ -1138,6 +1140,10 @@ channel_set_options(channel_T *channel, jobopt_T *opt)
|
||||
ch_logs(channel, "writing err to buffer '%s'",
|
||||
(char *)channel->ch_part[PART_ERR].ch_buffer->b_ffname);
|
||||
}
|
||||
|
||||
channel->ch_part[PART_OUT].ch_io = opt->jo_io[PART_OUT];
|
||||
channel->ch_part[PART_ERR].ch_io = opt->jo_io[PART_ERR];
|
||||
channel->ch_part[PART_IN].ch_io = opt->jo_io[PART_IN];
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1655,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)
|
||||
{
|
||||
@@ -2088,6 +2103,69 @@ channel_status(channel_T *channel)
|
||||
return "closed";
|
||||
}
|
||||
|
||||
static void
|
||||
channel_part_info(channel_T *channel, dict_T *dict, char *name, int part)
|
||||
{
|
||||
chanpart_T *chanpart = &channel->ch_part[part];
|
||||
char namebuf[20];
|
||||
size_t tail;
|
||||
char *s = "";
|
||||
|
||||
STRCPY(namebuf, name);
|
||||
STRCAT(namebuf, "_");
|
||||
tail = STRLEN(namebuf);
|
||||
|
||||
STRCPY(namebuf + tail, "status");
|
||||
dict_add_nr_str(dict, namebuf, 0,
|
||||
(char_u *)(chanpart->ch_fd == INVALID_FD ? "closed" : "open"));
|
||||
|
||||
STRCPY(namebuf + tail, "mode");
|
||||
switch (chanpart->ch_mode)
|
||||
{
|
||||
case MODE_NL: s = "NL"; break;
|
||||
case MODE_RAW: s = "RAW"; break;
|
||||
case MODE_JSON: s = "JSON"; break;
|
||||
case MODE_JS: s = "JS"; break;
|
||||
}
|
||||
dict_add_nr_str(dict, namebuf, 0, (char_u *)s);
|
||||
|
||||
STRCPY(namebuf + tail, "io");
|
||||
if (part == PART_SOCK)
|
||||
s = "socket";
|
||||
else switch (chanpart->ch_io)
|
||||
{
|
||||
case JIO_NULL: s = "null"; break;
|
||||
case JIO_PIPE: s = "pipe"; break;
|
||||
case JIO_FILE: s = "file"; break;
|
||||
case JIO_BUFFER: s = "buffer"; break;
|
||||
case JIO_OUT: s = "out"; break;
|
||||
}
|
||||
dict_add_nr_str(dict, namebuf, 0, (char_u *)s);
|
||||
|
||||
STRCPY(namebuf + tail, "timeout");
|
||||
dict_add_nr_str(dict, namebuf, chanpart->ch_timeout, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
channel_info(channel_T *channel, dict_T *dict)
|
||||
{
|
||||
dict_add_nr_str(dict, "id", channel->ch_id, NULL);
|
||||
dict_add_nr_str(dict, "status", 0, (char_u *)channel_status(channel));
|
||||
|
||||
if (channel->ch_hostname != NULL)
|
||||
{
|
||||
dict_add_nr_str(dict, "hostname", 0, (char_u *)channel->ch_hostname);
|
||||
dict_add_nr_str(dict, "port", channel->ch_port, NULL);
|
||||
channel_part_info(channel, dict, "sock", PART_SOCK);
|
||||
}
|
||||
else
|
||||
{
|
||||
channel_part_info(channel, dict, "out", PART_OUT);
|
||||
channel_part_info(channel, dict, "err", PART_ERR);
|
||||
channel_part_info(channel, dict, "in", PART_IN);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Close channel "channel".
|
||||
* Trigger the close callback if "invoke_close_cb" is TRUE.
|
||||
@@ -2195,6 +2273,8 @@ channel_clear_one(channel_T *channel, int part)
|
||||
channel_clear(channel_T *channel)
|
||||
{
|
||||
ch_log(channel, "Clearing channel");
|
||||
vim_free(channel->ch_hostname);
|
||||
channel->ch_hostname = NULL;
|
||||
channel_clear_one(channel, PART_SOCK);
|
||||
channel_clear_one(channel, PART_OUT);
|
||||
channel_clear_one(channel, PART_ERR);
|
||||
@@ -2294,17 +2374,6 @@ channel_wait(channel_T *channel, sock_T fd, int timeout)
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return a unique ID to be used in a message.
|
||||
*/
|
||||
int
|
||||
channel_get_id(void)
|
||||
{
|
||||
static int next_id = 1;
|
||||
|
||||
return next_id++;
|
||||
}
|
||||
|
||||
/*
|
||||
* Read from channel "channel" for as long as there is something to read.
|
||||
* "part" is PART_SOCK, PART_OUT or PART_ERR.
|
||||
@@ -2787,7 +2856,7 @@ ch_expr_common(typval_T *argvars, typval_T *rettv, int eval)
|
||||
return;
|
||||
}
|
||||
|
||||
id = channel_get_id();
|
||||
id = ++channel->ch_last_msg_id;
|
||||
text = json_encode_nr_expr(id, &argvars[1],
|
||||
ch_mode == MODE_JS ? JSON_JS : 0);
|
||||
if (text == NULL)
|
||||
|
||||
305
src/eval.c
305
src/eval.c
@@ -209,7 +209,9 @@ static hashtab_T func_hashtab;
|
||||
/* The names of packages that once were loaded are remembered. */
|
||||
static garray_T ga_loaded = {0, 0, sizeof(char_u *), 4, NULL};
|
||||
|
||||
/* list heads for garbage collection */
|
||||
/* List heads for garbage collection. Although there can be a reference loop
|
||||
* from partial to dict to partial, we don't need to keep track of the partial,
|
||||
* since it will get freed when the dict is unused and gets freed. */
|
||||
static dict_T *first_dict = NULL; /* list of all dicts */
|
||||
static list_T *first_list = NULL; /* list of all lists */
|
||||
|
||||
@@ -290,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] =
|
||||
{
|
||||
@@ -371,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 */
|
||||
@@ -473,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);
|
||||
@@ -501,6 +504,7 @@ static void f_ch_evalexpr(typval_T *argvars, typval_T *rettv);
|
||||
static void f_ch_evalraw(typval_T *argvars, typval_T *rettv);
|
||||
static void f_ch_getbufnr(typval_T *argvars, typval_T *rettv);
|
||||
static void f_ch_getjob(typval_T *argvars, typval_T *rettv);
|
||||
static void f_ch_info(typval_T *argvars, typval_T *rettv);
|
||||
static void f_ch_log(typval_T *argvars, typval_T *rettv);
|
||||
static void f_ch_logfile(typval_T *argvars, typval_T *rettv);
|
||||
static void f_ch_open(typval_T *argvars, typval_T *rettv);
|
||||
@@ -4102,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.
|
||||
*/
|
||||
@@ -4400,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.
|
||||
@@ -4643,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 */
|
||||
@@ -7129,9 +7145,14 @@ set_ref_in_item(
|
||||
list_T *ll;
|
||||
int abort = FALSE;
|
||||
|
||||
if (tv->v_type == VAR_DICT)
|
||||
if (tv->v_type == VAR_DICT || tv->v_type == VAR_PARTIAL)
|
||||
{
|
||||
dd = tv->vval.v_dict;
|
||||
if (tv->v_type == VAR_DICT)
|
||||
dd = tv->vval.v_dict;
|
||||
else if (tv->vval.v_partial != NULL)
|
||||
dd = tv->vval.v_partial->pt_dict;
|
||||
else
|
||||
dd = NULL;
|
||||
if (dd != NULL && dd->dv_copyID != copyID)
|
||||
{
|
||||
/* Didn't see this dict yet. */
|
||||
@@ -7183,6 +7204,32 @@ set_ref_in_item(
|
||||
return abort;
|
||||
}
|
||||
|
||||
static void
|
||||
partial_free(partial_T *pt, int free_dict)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < pt->pt_argc; ++i)
|
||||
clear_tv(&pt->pt_argv[i]);
|
||||
vim_free(pt->pt_argv);
|
||||
if (free_dict)
|
||||
dict_unref(pt->pt_dict);
|
||||
func_unref(pt->pt_name);
|
||||
vim_free(pt->pt_name);
|
||||
vim_free(pt);
|
||||
}
|
||||
|
||||
/*
|
||||
* Unreference a closure: decrement the reference count and free it when it
|
||||
* becomes zero.
|
||||
*/
|
||||
void
|
||||
partial_unref(partial_T *pt)
|
||||
{
|
||||
if (pt != NULL && --pt->pt_refcount <= 0)
|
||||
partial_free(pt, TRUE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Allocate an empty header for a dictionary.
|
||||
*/
|
||||
@@ -7274,7 +7321,18 @@ dict_free(
|
||||
hash_remove(&d->dv_hashtab, hi);
|
||||
if (recurse || (di->di_tv.v_type != VAR_LIST
|
||||
&& di->di_tv.v_type != VAR_DICT))
|
||||
clear_tv(&di->di_tv);
|
||||
{
|
||||
if (!recurse && di->di_tv.v_type == VAR_PARTIAL)
|
||||
{
|
||||
partial_T *pt = di->di_tv.vval.v_partial;
|
||||
|
||||
/* We unref the partial but not the dict it refers to. */
|
||||
if (pt != NULL && --pt->pt_refcount == 0)
|
||||
partial_free(pt, FALSE);
|
||||
}
|
||||
else
|
||||
clear_tv(&di->di_tv);
|
||||
}
|
||||
vim_free(di);
|
||||
--todo;
|
||||
}
|
||||
@@ -7806,10 +7864,50 @@ echo_string(
|
||||
break;
|
||||
|
||||
case VAR_PARTIAL:
|
||||
*tofree = NULL;
|
||||
/* TODO: arguments */
|
||||
r = tv->vval.v_partial == NULL ? NULL : tv->vval.v_partial->pt_name;
|
||||
break;
|
||||
{
|
||||
partial_T *pt = tv->vval.v_partial;
|
||||
char_u *fname = string_quote(pt == NULL ? NULL
|
||||
: pt->pt_name, FALSE);
|
||||
garray_T ga;
|
||||
int i;
|
||||
char_u *tf;
|
||||
|
||||
ga_init2(&ga, 1, 100);
|
||||
ga_concat(&ga, (char_u *)"function(");
|
||||
if (fname != NULL)
|
||||
{
|
||||
ga_concat(&ga, fname);
|
||||
vim_free(fname);
|
||||
}
|
||||
if (pt != NULL && pt->pt_argc > 0)
|
||||
{
|
||||
ga_concat(&ga, (char_u *)", [");
|
||||
for (i = 0; i < pt->pt_argc; ++i)
|
||||
{
|
||||
if (i > 0)
|
||||
ga_concat(&ga, (char_u *)", ");
|
||||
ga_concat(&ga,
|
||||
tv2string(&pt->pt_argv[i], &tf, numbuf, copyID));
|
||||
vim_free(tf);
|
||||
}
|
||||
ga_concat(&ga, (char_u *)"]");
|
||||
}
|
||||
if (pt != NULL && pt->pt_dict != NULL)
|
||||
{
|
||||
typval_T dtv;
|
||||
|
||||
ga_concat(&ga, (char_u *)", ");
|
||||
dtv.v_type = VAR_DICT;
|
||||
dtv.vval.v_dict = pt->pt_dict;
|
||||
ga_concat(&ga, tv2string(&dtv, &tf, numbuf, copyID));
|
||||
vim_free(tf);
|
||||
}
|
||||
ga_concat(&ga, (char_u *)")");
|
||||
|
||||
*tofree = ga.ga_data;
|
||||
r = *tofree;
|
||||
break;
|
||||
}
|
||||
|
||||
case VAR_LIST:
|
||||
if (tv->vval.v_list == NULL)
|
||||
@@ -7896,50 +7994,6 @@ tv2string(
|
||||
case VAR_FUNC:
|
||||
*tofree = string_quote(tv->vval.v_string, TRUE);
|
||||
return *tofree;
|
||||
case VAR_PARTIAL:
|
||||
{
|
||||
partial_T *pt = tv->vval.v_partial;
|
||||
char_u *fname = string_quote(pt == NULL ? NULL
|
||||
: pt->pt_name, FALSE);
|
||||
garray_T ga;
|
||||
int i;
|
||||
char_u *tf;
|
||||
|
||||
ga_init2(&ga, 1, 100);
|
||||
ga_concat(&ga, (char_u *)"function(");
|
||||
if (fname != NULL)
|
||||
{
|
||||
ga_concat(&ga, fname);
|
||||
vim_free(fname);
|
||||
}
|
||||
if (pt != NULL && pt->pt_argc > 0)
|
||||
{
|
||||
ga_concat(&ga, (char_u *)", [");
|
||||
for (i = 0; i < pt->pt_argc; ++i)
|
||||
{
|
||||
if (i > 0)
|
||||
ga_concat(&ga, (char_u *)", ");
|
||||
ga_concat(&ga,
|
||||
tv2string(&pt->pt_argv[i], &tf, numbuf, copyID));
|
||||
vim_free(tf);
|
||||
}
|
||||
ga_concat(&ga, (char_u *)"]");
|
||||
}
|
||||
if (pt != NULL && pt->pt_dict != NULL)
|
||||
{
|
||||
typval_T dtv;
|
||||
|
||||
ga_concat(&ga, (char_u *)", ");
|
||||
dtv.v_type = VAR_DICT;
|
||||
dtv.vval.v_dict = pt->pt_dict;
|
||||
ga_concat(&ga, tv2string(&dtv, &tf, numbuf, copyID));
|
||||
vim_free(tf);
|
||||
}
|
||||
ga_concat(&ga, (char_u *)")");
|
||||
|
||||
*tofree = ga.ga_data;
|
||||
return *tofree;
|
||||
}
|
||||
case VAR_STRING:
|
||||
*tofree = string_quote(tv->vval.v_string, FALSE);
|
||||
return *tofree;
|
||||
@@ -7952,6 +8006,7 @@ tv2string(
|
||||
case VAR_NUMBER:
|
||||
case VAR_LIST:
|
||||
case VAR_DICT:
|
||||
case VAR_PARTIAL:
|
||||
case VAR_SPECIAL:
|
||||
case VAR_JOB:
|
||||
case VAR_CHANNEL:
|
||||
@@ -8112,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},
|
||||
@@ -8141,6 +8197,7 @@ static struct fst
|
||||
{"ch_evalraw", 2, 3, f_ch_evalraw},
|
||||
{"ch_getbufnr", 2, 2, f_ch_getbufnr},
|
||||
{"ch_getjob", 1, 1, f_ch_getjob},
|
||||
{"ch_info", 1, 1, f_ch_info},
|
||||
{"ch_log", 1, 2, f_ch_log},
|
||||
{"ch_logfile", 1, 2, f_ch_logfile},
|
||||
{"ch_open", 1, 2, f_ch_open},
|
||||
@@ -9252,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);
|
||||
|
||||
@@ -9327,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;
|
||||
@@ -9339,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));
|
||||
@@ -9347,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);
|
||||
}
|
||||
@@ -9378,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);
|
||||
}
|
||||
@@ -9406,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);
|
||||
}
|
||||
@@ -9443,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);
|
||||
}
|
||||
@@ -9475,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);
|
||||
}
|
||||
@@ -9490,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
|
||||
*/
|
||||
@@ -10028,6 +10115,18 @@ f_ch_getjob(typval_T *argvars, typval_T *rettv)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* "ch_info()" function
|
||||
*/
|
||||
static void
|
||||
f_ch_info(typval_T *argvars, typval_T *rettv UNUSED)
|
||||
{
|
||||
channel_T *channel = get_channel_arg(&argvars[0], TRUE);
|
||||
|
||||
if (channel != NULL && rettv_dict_alloc(rettv) != FAIL)
|
||||
channel_info(channel, rettv->vval.v_dict);
|
||||
}
|
||||
|
||||
/*
|
||||
* "ch_log()" function
|
||||
*/
|
||||
@@ -11997,30 +12096,6 @@ f_function(typval_T *argvars, typval_T *rettv)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
partial_free(partial_T *pt)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < pt->pt_argc; ++i)
|
||||
clear_tv(&pt->pt_argv[i]);
|
||||
vim_free(pt->pt_argv);
|
||||
func_unref(pt->pt_name);
|
||||
vim_free(pt->pt_name);
|
||||
vim_free(pt);
|
||||
}
|
||||
|
||||
/*
|
||||
* Unreference a closure: decrement the reference count and free it when it
|
||||
* becomes zero.
|
||||
*/
|
||||
void
|
||||
partial_unref(partial_T *pt)
|
||||
{
|
||||
if (pt != NULL && --pt->pt_refcount <= 0)
|
||||
partial_free(pt);
|
||||
}
|
||||
|
||||
/*
|
||||
* "garbagecollect()" function
|
||||
*/
|
||||
@@ -13807,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]))
|
||||
@@ -19224,7 +19299,8 @@ f_string(typval_T *argvars, typval_T *rettv)
|
||||
char_u numbuf[NUMBUFLEN];
|
||||
|
||||
rettv->v_type = VAR_STRING;
|
||||
rettv->vval.v_string = tv2string(&argvars[0], &tofree, numbuf, 0);
|
||||
rettv->vval.v_string = tv2string(&argvars[0], &tofree, numbuf,
|
||||
get_copyID());
|
||||
/* Make a copy if we have a value but it's not in allocated memory. */
|
||||
if (rettv->vval.v_string != NULL && tofree == NULL)
|
||||
rettv->vval.v_string = vim_strsave(rettv->vval.v_string);
|
||||
@@ -20159,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;
|
||||
@@ -21783,7 +21860,8 @@ handle_subscript(
|
||||
selfdict = NULL;
|
||||
if (rettv->v_type == VAR_FUNC)
|
||||
{
|
||||
/* just a function: use selfdict */
|
||||
/* Just a function: Take over the function name and use
|
||||
* selfdict. */
|
||||
pt->pt_name = rettv->vval.v_string;
|
||||
}
|
||||
else
|
||||
@@ -21791,8 +21869,11 @@ handle_subscript(
|
||||
partial_T *ret_pt = rettv->vval.v_partial;
|
||||
int i;
|
||||
|
||||
/* partial: use selfdict and copy args */
|
||||
/* Partial: copy the function name, use selfdict and copy
|
||||
* args. Can't take over name or args, the partial might
|
||||
* be referenced elsewhere. */
|
||||
pt->pt_name = vim_strsave(ret_pt->pt_name);
|
||||
func_ref(pt->pt_name);
|
||||
if (ret_pt->pt_argc > 0)
|
||||
{
|
||||
pt->pt_argv = (typval_T *)alloc(
|
||||
@@ -21809,7 +21890,6 @@ handle_subscript(
|
||||
}
|
||||
partial_unref(ret_pt);
|
||||
}
|
||||
func_ref(pt->pt_name);
|
||||
rettv->v_type = VAR_PARTIAL;
|
||||
rettv->vval.v_partial = pt;
|
||||
}
|
||||
@@ -23420,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;
|
||||
@@ -26402,7 +26483,13 @@ repeat:
|
||||
|
||||
if (src[*usedlen] == ':' && src[*usedlen + 1] == 'S')
|
||||
{
|
||||
/* vim_strsave_shellescape() needs a NUL terminated string. */
|
||||
c = (*fnamep)[*fnamelen];
|
||||
if (c != NUL)
|
||||
(*fnamep)[*fnamelen] = NUL;
|
||||
p = vim_strsave_shellescape(*fnamep, FALSE, FALSE);
|
||||
if (c != NUL)
|
||||
(*fnamep)[*fnamelen] = c;
|
||||
if (p == NULL)
|
||||
return -1;
|
||||
vim_free(*bufp);
|
||||
|
||||
@@ -1989,6 +1989,7 @@ getcmdline_prompt(
|
||||
char_u *s;
|
||||
struct cmdline_info save_ccline;
|
||||
int msg_col_save = msg_col;
|
||||
int msg_silent_save = msg_silent;
|
||||
|
||||
save_cmdline(&save_ccline);
|
||||
ccline.cmdprompt = prompt;
|
||||
@@ -1998,8 +1999,10 @@ getcmdline_prompt(
|
||||
ccline.xp_arg = xp_arg;
|
||||
ccline.input_fn = (firstc == '@');
|
||||
# endif
|
||||
msg_silent = 0;
|
||||
s = getcmdline(firstc, 1L, 0);
|
||||
restore_cmdline(&save_ccline);
|
||||
msg_silent = msg_silent_save;
|
||||
/* Restore msg_col, the prompt from input() may have changed it.
|
||||
* But only if called recursively and the commandline is therefore being
|
||||
* restored to an old one; if not, the input() prompt stays on the screen,
|
||||
|
||||
@@ -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");
|
||||
|
||||
254
src/mbyte.c
254
src/mbyte.c
@@ -1181,7 +1181,6 @@ struct interval
|
||||
long first;
|
||||
long last;
|
||||
};
|
||||
static int intable(struct interval *table, size_t size, int c);
|
||||
|
||||
/*
|
||||
* Return TRUE if "c" is in "table[size / sizeof(struct interval)]".
|
||||
@@ -1253,6 +1252,11 @@ utf_char2cells(int c)
|
||||
{0xfe68, 0xfe6b},
|
||||
{0xff01, 0xff60},
|
||||
{0xffe0, 0xffe6},
|
||||
{0x1b000, 0x1b001},
|
||||
{0x1f200, 0x1f202},
|
||||
{0x1f210, 0x1f23a},
|
||||
{0x1f240, 0x1f248},
|
||||
{0x1f250, 0x1f251},
|
||||
{0x20000, 0x2fffd},
|
||||
{0x30000, 0x3fffd}
|
||||
};
|
||||
@@ -1436,108 +1440,14 @@ utf_char2cells(int c)
|
||||
{0x100000, 0x10fffd}
|
||||
};
|
||||
|
||||
/* Sorted list of non-overlapping intervals of Emoji characters,
|
||||
/* Sorted list of non-overlapping intervals of Emoji characters that don't
|
||||
* have ambiguous or double width,
|
||||
* based on http://unicode.org/emoji/charts/emoji-list.html */
|
||||
static struct interval emoji[] =
|
||||
static struct interval emoji_width[] =
|
||||
{
|
||||
{0x203c, 0x203c},
|
||||
{0x2049, 0x2049},
|
||||
{0x2122, 0x2122},
|
||||
{0x2139, 0x2139},
|
||||
{0x2194, 0x2199},
|
||||
{0x21a9, 0x21aa},
|
||||
{0x231a, 0x231b},
|
||||
{0x2328, 0x2328},
|
||||
{0x23cf, 0x23cf},
|
||||
{0x23e9, 0x23f3},
|
||||
{0x24c2, 0x24c2},
|
||||
{0x25aa, 0x25ab},
|
||||
{0x25b6, 0x25b6},
|
||||
{0x25c0, 0x25c0},
|
||||
{0x25fb, 0x25fe},
|
||||
{0x2600, 0x2604},
|
||||
{0x260e, 0x260e},
|
||||
{0x2611, 0x2611},
|
||||
{0x2614, 0x2615},
|
||||
{0x2618, 0x2618},
|
||||
{0x261d, 0x261d},
|
||||
{0x2620, 0x2620},
|
||||
{0x2622, 0x2623},
|
||||
{0x2626, 0x2626},
|
||||
{0x262a, 0x262a},
|
||||
{0x262e, 0x262f},
|
||||
{0x2638, 0x263a},
|
||||
{0x2648, 0x2653},
|
||||
{0x2660, 0x2660},
|
||||
{0x2663, 0x2663},
|
||||
{0x2665, 0x2666},
|
||||
{0x2668, 0x2668},
|
||||
{0x267b, 0x267b},
|
||||
{0x267f, 0x267f},
|
||||
{0x2692, 0x2694},
|
||||
{0x2696, 0x2697},
|
||||
{0x2699, 0x2699},
|
||||
{0x269b, 0x269c},
|
||||
{0x26a0, 0x26a1},
|
||||
{0x26aa, 0x26ab},
|
||||
{0x26b0, 0x26b1},
|
||||
{0x26bd, 0x26be},
|
||||
{0x26c4, 0x26c5},
|
||||
{0x26c8, 0x26c8},
|
||||
{0x26ce, 0x26ce},
|
||||
{0x26cf, 0x26cf},
|
||||
{0x26d1, 0x26d1},
|
||||
{0x26d3, 0x26d4},
|
||||
{0x26e9, 0x26ea},
|
||||
{0x26f0, 0x26f5},
|
||||
{0x26f7, 0x26fa},
|
||||
{0x26fd, 0x26fd},
|
||||
{0x2702, 0x2702},
|
||||
{0x2705, 0x2705},
|
||||
{0x2708, 0x2709},
|
||||
{0x270a, 0x270b},
|
||||
{0x270c, 0x270d},
|
||||
{0x270f, 0x270f},
|
||||
{0x2712, 0x2712},
|
||||
{0x2714, 0x2714},
|
||||
{0x2716, 0x2716},
|
||||
{0x271d, 0x271d},
|
||||
{0x2721, 0x2721},
|
||||
{0x2728, 0x2728},
|
||||
{0x2733, 0x2734},
|
||||
{0x2744, 0x2744},
|
||||
{0x2747, 0x2747},
|
||||
{0x274c, 0x274c},
|
||||
{0x274e, 0x274e},
|
||||
{0x2753, 0x2755},
|
||||
{0x2757, 0x2757},
|
||||
{0x2763, 0x2764},
|
||||
{0x2795, 0x2797},
|
||||
{0x27a1, 0x27a1},
|
||||
{0x27b0, 0x27b0},
|
||||
{0x27bf, 0x27bf},
|
||||
{0x2934, 0x2935},
|
||||
{0x2b05, 0x2b07},
|
||||
{0x2b1b, 0x2b1c},
|
||||
{0x2b50, 0x2b50},
|
||||
{0x2b55, 0x2b55},
|
||||
{0x3030, 0x3030},
|
||||
{0x303d, 0x303d},
|
||||
{0x3297, 0x3297},
|
||||
{0x3299, 0x3299},
|
||||
{0x1f004, 0x1f004},
|
||||
{0x1f0cf, 0x1f0cf},
|
||||
{0x1f170, 0x1f171},
|
||||
{0x1f17e, 0x1f17e},
|
||||
{0x1f17f, 0x1f17f},
|
||||
{0x1f18e, 0x1f18e},
|
||||
{0x1f191, 0x1f19a},
|
||||
{0x1f1e6, 0x1f1ff},
|
||||
{0x1f201, 0x1f202},
|
||||
{0x1f21a, 0x1f21a},
|
||||
{0x1f22f, 0x1f22f},
|
||||
{0x1f232, 0x1f23a},
|
||||
{0x1f250, 0x1f251},
|
||||
{0x1f300, 0x1f320},
|
||||
{0x1f330, 0x1f335},
|
||||
{0x1f337, 0x1f37c},
|
||||
@@ -1551,29 +1461,7 @@ utf_char2cells(int c)
|
||||
{0x1f4f9, 0x1f4fc},
|
||||
{0x1f500, 0x1f53d},
|
||||
{0x1f550, 0x1f567},
|
||||
{0x1f5fb, 0x1f5ff},
|
||||
{0x1f600, 0x1f600},
|
||||
{0x1f601, 0x1f610},
|
||||
{0x1f611, 0x1f611},
|
||||
{0x1f612, 0x1f614},
|
||||
{0x1f615, 0x1f615},
|
||||
{0x1f616, 0x1f616},
|
||||
{0x1f617, 0x1f617},
|
||||
{0x1f618, 0x1f618},
|
||||
{0x1f619, 0x1f619},
|
||||
{0x1f61a, 0x1f61a},
|
||||
{0x1f61b, 0x1f61b},
|
||||
{0x1f61c, 0x1f61e},
|
||||
{0x1f61f, 0x1f61f},
|
||||
{0x1f620, 0x1f625},
|
||||
{0x1f626, 0x1f627},
|
||||
{0x1f628, 0x1f62b},
|
||||
{0x1f62c, 0x1f62c},
|
||||
{0x1f62d, 0x1f62d},
|
||||
{0x1f62e, 0x1f62f},
|
||||
{0x1f630, 0x1f633},
|
||||
{0x1f634, 0x1f634},
|
||||
{0x1f635, 0x1f640},
|
||||
{0x1f5fb, 0x1f640},
|
||||
{0x1f645, 0x1f64f},
|
||||
{0x1f680, 0x1f6c5}
|
||||
};
|
||||
@@ -1597,7 +1485,7 @@ utf_char2cells(int c)
|
||||
if (intable(doublewidth, sizeof(doublewidth), c))
|
||||
return 2;
|
||||
#endif
|
||||
if (p_emoji && intable(emoji, sizeof(emoji), c))
|
||||
if (p_emoji && intable(emoji_width, sizeof(emoji_width), c))
|
||||
return 2;
|
||||
}
|
||||
|
||||
@@ -2675,6 +2563,123 @@ utf_class(int c)
|
||||
{0x2b740, 0x2b81f, 0x4e00}, /* CJK Ideographs */
|
||||
{0x2f800, 0x2fa1f, 0x4e00}, /* CJK Ideographs */
|
||||
};
|
||||
|
||||
/* Sorted list of non-overlapping intervals of all Emoji characters,
|
||||
* based on http://unicode.org/emoji/charts/emoji-list.html */
|
||||
static struct interval emoji_all[] =
|
||||
{
|
||||
{0x203c, 0x203c},
|
||||
{0x2049, 0x2049},
|
||||
{0x2122, 0x2122},
|
||||
{0x2139, 0x2139},
|
||||
{0x2194, 0x2199},
|
||||
{0x21a9, 0x21aa},
|
||||
{0x231a, 0x231b},
|
||||
{0x2328, 0x2328},
|
||||
{0x23cf, 0x23cf},
|
||||
{0x23e9, 0x23f3},
|
||||
{0x24c2, 0x24c2},
|
||||
{0x25aa, 0x25ab},
|
||||
{0x25b6, 0x25b6},
|
||||
{0x25c0, 0x25c0},
|
||||
{0x25fb, 0x25fe},
|
||||
{0x2600, 0x2604},
|
||||
{0x260e, 0x260e},
|
||||
{0x2611, 0x2611},
|
||||
{0x2614, 0x2615},
|
||||
{0x2618, 0x2618},
|
||||
{0x261d, 0x261d},
|
||||
{0x2620, 0x2620},
|
||||
{0x2622, 0x2623},
|
||||
{0x2626, 0x2626},
|
||||
{0x262a, 0x262a},
|
||||
{0x262e, 0x262f},
|
||||
{0x2638, 0x263a},
|
||||
{0x2648, 0x2653},
|
||||
{0x2660, 0x2660},
|
||||
{0x2663, 0x2663},
|
||||
{0x2665, 0x2666},
|
||||
{0x2668, 0x2668},
|
||||
{0x267b, 0x267b},
|
||||
{0x267f, 0x267f},
|
||||
{0x2692, 0x2694},
|
||||
{0x2696, 0x2697},
|
||||
{0x2699, 0x2699},
|
||||
{0x269b, 0x269c},
|
||||
{0x26a0, 0x26a1},
|
||||
{0x26aa, 0x26ab},
|
||||
{0x26b0, 0x26b1},
|
||||
{0x26bd, 0x26be},
|
||||
{0x26c4, 0x26c5},
|
||||
{0x26c8, 0x26c8},
|
||||
{0x26ce, 0x26cf},
|
||||
{0x26d1, 0x26d1},
|
||||
{0x26d3, 0x26d4},
|
||||
{0x26e9, 0x26ea},
|
||||
{0x26f0, 0x26f5},
|
||||
{0x26f7, 0x26fa},
|
||||
{0x26fd, 0x26fd},
|
||||
{0x2702, 0x2702},
|
||||
{0x2705, 0x2705},
|
||||
{0x2708, 0x270d},
|
||||
{0x270f, 0x270f},
|
||||
{0x2712, 0x2712},
|
||||
{0x2714, 0x2714},
|
||||
{0x2716, 0x2716},
|
||||
{0x271d, 0x271d},
|
||||
{0x2721, 0x2721},
|
||||
{0x2728, 0x2728},
|
||||
{0x2733, 0x2734},
|
||||
{0x2744, 0x2744},
|
||||
{0x2747, 0x2747},
|
||||
{0x274c, 0x274c},
|
||||
{0x274e, 0x274e},
|
||||
{0x2753, 0x2755},
|
||||
{0x2757, 0x2757},
|
||||
{0x2763, 0x2764},
|
||||
{0x2795, 0x2797},
|
||||
{0x27a1, 0x27a1},
|
||||
{0x27b0, 0x27b0},
|
||||
{0x27bf, 0x27bf},
|
||||
{0x2934, 0x2935},
|
||||
{0x2b05, 0x2b07},
|
||||
{0x2b1b, 0x2b1c},
|
||||
{0x2b50, 0x2b50},
|
||||
{0x2b55, 0x2b55},
|
||||
{0x3030, 0x3030},
|
||||
{0x303d, 0x303d},
|
||||
{0x3297, 0x3297},
|
||||
{0x3299, 0x3299},
|
||||
{0x1f004, 0x1f004},
|
||||
{0x1f0cf, 0x1f0cf},
|
||||
{0x1f170, 0x1f171},
|
||||
{0x1f17e, 0x1f17f},
|
||||
{0x1f18e, 0x1f18e},
|
||||
{0x1f191, 0x1f19a},
|
||||
{0x1f1e6, 0x1f1ff},
|
||||
{0x1f201, 0x1f202},
|
||||
{0x1f21a, 0x1f21a},
|
||||
{0x1f22f, 0x1f22f},
|
||||
{0x1f232, 0x1f23a},
|
||||
{0x1f250, 0x1f251},
|
||||
{0x1f300, 0x1f320},
|
||||
{0x1f330, 0x1f335},
|
||||
{0x1f337, 0x1f37c},
|
||||
{0x1f380, 0x1f393},
|
||||
{0x1f3a0, 0x1f3c4},
|
||||
{0x1f3c6, 0x1f3ca},
|
||||
{0x1f3e0, 0x1f3f0},
|
||||
{0x1f400, 0x1f43e},
|
||||
{0x1f440, 0x1f440},
|
||||
{0x1f442, 0x1f4f7},
|
||||
{0x1f4f9, 0x1f4fc},
|
||||
{0x1f500, 0x1f53d},
|
||||
{0x1f550, 0x1f567},
|
||||
{0x1f5fb, 0x1f640},
|
||||
{0x1f645, 0x1f64f},
|
||||
{0x1f680, 0x1f6c5}
|
||||
};
|
||||
|
||||
int bot = 0;
|
||||
int top = sizeof(classes) / sizeof(struct clinterval) - 1;
|
||||
int mid;
|
||||
@@ -2701,6 +2706,10 @@ utf_class(int c)
|
||||
return (int)classes[mid].class;
|
||||
}
|
||||
|
||||
/* emoji */
|
||||
if (intable(emoji_all, sizeof(emoji_all), c))
|
||||
return 3;
|
||||
|
||||
/* most other characters are "word" characters */
|
||||
return 2;
|
||||
}
|
||||
@@ -3289,6 +3298,7 @@ static convertStruct toUpper[] =
|
||||
{0x10cc0,0x10cf2,1,-64},
|
||||
{0x118c0,0x118df,1,-32}
|
||||
};
|
||||
|
||||
/*
|
||||
* Return the upper-case equivalent of "a", which is a UCS-4 character. Use
|
||||
* simple case folding.
|
||||
|
||||
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);
|
||||
|
||||
@@ -5783,6 +5783,8 @@ do_addsub(
|
||||
theend:
|
||||
if (visual)
|
||||
curwin->w_cursor = save_cursor;
|
||||
else if (did_change)
|
||||
curwin->w_set_curswant = TRUE;
|
||||
|
||||
return did_change;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -5214,11 +5214,11 @@ mch_start_job(char **argv, job_T *job, jobopt_T *options UNUSED)
|
||||
job->jv_channel = channel; /* ch_refcount was set above */
|
||||
|
||||
/* child stdin, stdout and stderr */
|
||||
if (!use_file_for_in)
|
||||
if (!use_file_for_in && fd_in[0] >= 0)
|
||||
close(fd_in[0]);
|
||||
if (!use_file_for_out)
|
||||
if (!use_file_for_out && fd_out[1] >= 0)
|
||||
close(fd_out[1]);
|
||||
if (!use_out_for_err && !use_file_for_err)
|
||||
if (!use_out_for_err && !use_file_for_err && fd_err[1] >= 0)
|
||||
close(fd_err[1]);
|
||||
if (channel != NULL)
|
||||
{
|
||||
@@ -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)
|
||||
|
||||
@@ -20,14 +20,14 @@ int channel_collapse(channel_T *channel, int part);
|
||||
int channel_can_write_to(channel_T *channel);
|
||||
int channel_is_open(channel_T *channel);
|
||||
char *channel_status(channel_T *channel);
|
||||
void channel_info(channel_T *channel, dict_T *dict);
|
||||
void channel_close(channel_T *channel, int invoke_close_cb);
|
||||
char_u *channel_peek(channel_T *channel, int part);
|
||||
void channel_clear(channel_T *channel);
|
||||
void channel_free_all(void);
|
||||
int channel_get_id(void);
|
||||
void channel_read(channel_T *channel, int part, char *func);
|
||||
char_u *channel_read_block(channel_T *channel, int part, int timeout);
|
||||
int channel_read_json_block(channel_T *channel, int part, int timeout, int id, typval_T **rettv);
|
||||
int channel_read_json_block(channel_T *channel, int part, int timeout_arg, int id, typval_T **rettv);
|
||||
void common_channel_read(typval_T *argvars, typval_T *rettv, int raw);
|
||||
channel_T *channel_fd2channel(sock_T fd, int *partp);
|
||||
void channel_handle_events(void);
|
||||
|
||||
@@ -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
|
||||
@@ -1412,6 +1414,33 @@ qf_guess_filepath(char_u *filename)
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* When loading a file from the quickfix, the auto commands may modify it.
|
||||
* This may invalidate the current quickfix entry. This function checks
|
||||
* whether a entry is still present in the quickfix.
|
||||
* Similar to location list.
|
||||
*/
|
||||
static int
|
||||
is_qf_entry_present(qf_info_T *qi, qfline_T *qf_ptr)
|
||||
{
|
||||
qf_list_T *qfl;
|
||||
qfline_T *qfp;
|
||||
int i;
|
||||
|
||||
qfl = &qi->qf_lists[qi->qf_curlist];
|
||||
|
||||
/* Search for the entry in the current list */
|
||||
for (i = 0, qfp = qfl->qf_start; i < qfl->qf_count;
|
||||
++i, qfp = qfp->qf_next)
|
||||
if (qfp == qf_ptr)
|
||||
break;
|
||||
|
||||
if (i == qfl->qf_count) /* Entry is not found */
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* jump to a quickfix line
|
||||
* if dir == FORWARD go "errornr" valid entries forward
|
||||
@@ -1794,18 +1823,34 @@ win_found:
|
||||
}
|
||||
else
|
||||
{
|
||||
int old_qf_curlist = qi->qf_curlist;
|
||||
int is_abort = FALSE;
|
||||
|
||||
ok = buflist_getfile(qf_ptr->qf_fnum,
|
||||
(linenr_T)1, GETF_SETMARK | GETF_SWITCH, forceit);
|
||||
if (qi != &ql_info && !win_valid(oldwin))
|
||||
{
|
||||
EMSG(_("E924: Current window was closed"));
|
||||
is_abort = TRUE;
|
||||
opened_window = FALSE;
|
||||
}
|
||||
else if (old_qf_curlist != qi->qf_curlist
|
||||
|| !is_qf_entry_present(qi, qf_ptr))
|
||||
{
|
||||
if (qi == &ql_info)
|
||||
EMSG(_("E925: Current quickfix was changed"));
|
||||
else
|
||||
EMSG(_("E926: Current location list was changed"));
|
||||
is_abort = TRUE;
|
||||
}
|
||||
|
||||
if (is_abort)
|
||||
{
|
||||
ok = FALSE;
|
||||
qi = NULL;
|
||||
qf_ptr = NULL;
|
||||
opened_window = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (ok == OK)
|
||||
@@ -4070,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() */
|
||||
@@ -1319,6 +1328,14 @@ typedef enum
|
||||
MODE_JS
|
||||
} ch_mode_T;
|
||||
|
||||
typedef enum {
|
||||
JIO_PIPE, /* default */
|
||||
JIO_NULL,
|
||||
JIO_FILE,
|
||||
JIO_BUFFER,
|
||||
JIO_OUT
|
||||
} job_io_T;
|
||||
|
||||
/* Ordering matters, it is used in for loops: IN is last, only SOCK/OUT/ERR
|
||||
* are polled. */
|
||||
#define PART_SOCK 0
|
||||
@@ -1351,6 +1368,7 @@ typedef struct {
|
||||
#endif
|
||||
|
||||
ch_mode_T ch_mode;
|
||||
job_io_T ch_io;
|
||||
int ch_timeout; /* request timeout in msec */
|
||||
|
||||
readq_T ch_head; /* header for circular raw read queue */
|
||||
@@ -1380,9 +1398,13 @@ struct channel_S {
|
||||
channel_T *ch_prev;
|
||||
|
||||
int ch_id; /* ID of the channel */
|
||||
int ch_last_msg_id; /* ID of the last message */
|
||||
|
||||
chanpart_T ch_part[4]; /* info for socket, out, err and in */
|
||||
|
||||
char *ch_hostname; /* only for socket, allocated */
|
||||
int ch_port; /* only for socket */
|
||||
|
||||
int ch_error; /* When TRUE an error was reported. Avoids
|
||||
* giving pages full of error messages when
|
||||
* the other side has exited, only mention the
|
||||
@@ -1442,14 +1464,6 @@ struct channel_S {
|
||||
(JO_CALLBACK + JO_OUT_CALLBACK + JO_ERR_CALLBACK + JO_CLOSE_CALLBACK)
|
||||
#define JO_TIMEOUT_ALL (JO_TIMEOUT + JO_OUT_TIMEOUT + JO_ERR_TIMEOUT)
|
||||
|
||||
typedef enum {
|
||||
JIO_PIPE, /* default */
|
||||
JIO_NULL,
|
||||
JIO_FILE,
|
||||
JIO_BUFFER,
|
||||
JIO_OUT
|
||||
} job_io_T;
|
||||
|
||||
/*
|
||||
* Options for job and channel commands.
|
||||
*/
|
||||
|
||||
@@ -85,7 +85,6 @@ SCRIPTS_ALL = \
|
||||
test102.out \
|
||||
test103.out \
|
||||
test104.out \
|
||||
test105.out \
|
||||
test107.out \
|
||||
test108.out \
|
||||
test_autocmd_option.out \
|
||||
|
||||
@@ -1,45 +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' )
|
||||
:set shell=tcsh
|
||||
:Put fnamemodify("abc\ndef", ':S' )
|
||||
:$put ='vim: ts=8'
|
||||
:1 delete _
|
||||
:w! test.out
|
||||
:qa!
|
||||
ENDTEST
|
||||
|
||||
@@ -1,29 +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'''
|
||||
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
|
||||
@@ -35,7 +35,7 @@ class ThreadedTCPRequestHandler(socketserver.BaseRequestHandler):
|
||||
if received == '':
|
||||
print("=== socket closed ===")
|
||||
break
|
||||
print("received: {}".format(received))
|
||||
print("received: {0}".format(received))
|
||||
|
||||
# We may receive two messages at once. Take the part up to the
|
||||
# matching "]" (recognized by finding "][").
|
||||
@@ -49,7 +49,7 @@ class ThreadedTCPRequestHandler(socketserver.BaseRequestHandler):
|
||||
used = todo[:splitidx + 1]
|
||||
todo = todo[splitidx + 1:]
|
||||
if used != received:
|
||||
print("using: {}".format(used))
|
||||
print("using: {0}".format(used))
|
||||
|
||||
try:
|
||||
decoded = json.loads(used)
|
||||
@@ -70,48 +70,65 @@ class ThreadedTCPRequestHandler(socketserver.BaseRequestHandler):
|
||||
# replying to the request.
|
||||
cmd = '["ex","call append(\\"$\\",\\"added1\\")"]'
|
||||
cmd += '["ex","call append(\\"$\\",\\"added2\\")"]'
|
||||
print("sending: {}".format(cmd))
|
||||
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"]'
|
||||
print("sending: {}".format(cmd))
|
||||
print("sending: {0}".format(cmd))
|
||||
self.request.sendall(cmd.encode('utf-8'))
|
||||
response = "ok"
|
||||
elif decoded[1] == 'eval-works':
|
||||
# Send an eval request. We ignore the response.
|
||||
cmd = '["expr","\\"foo\\" . 123", -1]'
|
||||
print("sending: {}".format(cmd))
|
||||
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]'
|
||||
print("sending: {}".format(cmd))
|
||||
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]'
|
||||
print("sending: {}".format(cmd))
|
||||
cmd = '["expr","function(\\"tr\\")", -5]'
|
||||
print("sending: {0}".format(cmd))
|
||||
self.request.sendall(cmd.encode('utf-8'))
|
||||
response = "ok"
|
||||
elif decoded[1] == 'eval-bad':
|
||||
# Send an eval request missing the third argument.
|
||||
cmd = '["expr","xxx"]'
|
||||
print("sending: {}".format(cmd))
|
||||
print("sending: {0}".format(cmd))
|
||||
self.request.sendall(cmd.encode('utf-8'))
|
||||
response = "ok"
|
||||
elif decoded[1] == 'malformed1':
|
||||
cmd = '["ex",":"]wrong!["ex","smi"]'
|
||||
print("sending: {}".format(cmd))
|
||||
print("sending: {0}".format(cmd))
|
||||
self.request.sendall(cmd.encode('utf-8'))
|
||||
response = "ok"
|
||||
elif decoded[1] == 'malformed2':
|
||||
cmd = '"unterminated string'
|
||||
print("sending: {}".format(cmd))
|
||||
print("sending: {0}".format(cmd))
|
||||
self.request.sendall(cmd.encode('utf-8'))
|
||||
response = "ok"
|
||||
# Need to wait for Vim to give up, otherwise the double
|
||||
@@ -119,7 +136,7 @@ class ThreadedTCPRequestHandler(socketserver.BaseRequestHandler):
|
||||
time.sleep(0.2)
|
||||
elif decoded[1] == 'malformed3':
|
||||
cmd = '["ex","missing ]"'
|
||||
print("sending: {}".format(cmd))
|
||||
print("sending: {0}".format(cmd))
|
||||
self.request.sendall(cmd.encode('utf-8'))
|
||||
response = "ok"
|
||||
# Need to wait for Vim to give up, otherwise the ]
|
||||
@@ -127,37 +144,37 @@ class ThreadedTCPRequestHandler(socketserver.BaseRequestHandler):
|
||||
time.sleep(0.2)
|
||||
elif decoded[1] == 'split':
|
||||
cmd = '["ex","let '
|
||||
print("sending: {}".format(cmd))
|
||||
print("sending: {0}".format(cmd))
|
||||
self.request.sendall(cmd.encode('utf-8'))
|
||||
time.sleep(0.01)
|
||||
cmd = 'g:split = 123"]'
|
||||
print("sending: {}".format(cmd))
|
||||
print("sending: {0}".format(cmd))
|
||||
self.request.sendall(cmd.encode('utf-8'))
|
||||
response = "ok"
|
||||
elif decoded[1] == 'an expr':
|
||||
# Send an expr request.
|
||||
cmd = '["expr","setline(\\"$\\", [\\"one\\",\\"two\\",\\"three\\"])"]'
|
||||
print("sending: {}".format(cmd))
|
||||
print("sending: {0}".format(cmd))
|
||||
self.request.sendall(cmd.encode('utf-8'))
|
||||
response = "ok"
|
||||
elif decoded[1] == 'call-func':
|
||||
cmd = '["call","MyFunction",[1,2,3], 0]'
|
||||
print("sending: {}".format(cmd))
|
||||
print("sending: {0}".format(cmd))
|
||||
self.request.sendall(cmd.encode('utf-8'))
|
||||
response = "ok"
|
||||
elif decoded[1] == 'redraw':
|
||||
cmd = '["redraw",""]'
|
||||
print("sending: {}".format(cmd))
|
||||
print("sending: {0}".format(cmd))
|
||||
self.request.sendall(cmd.encode('utf-8'))
|
||||
response = "ok"
|
||||
elif decoded[1] == 'redraw!':
|
||||
cmd = '["redraw","force"]'
|
||||
print("sending: {}".format(cmd))
|
||||
print("sending: {0}".format(cmd))
|
||||
self.request.sendall(cmd.encode('utf-8'))
|
||||
response = "ok"
|
||||
elif decoded[1] == 'empty-request':
|
||||
cmd = '[]'
|
||||
print("sending: {}".format(cmd))
|
||||
print("sending: {0}".format(cmd))
|
||||
self.request.sendall(cmd.encode('utf-8'))
|
||||
response = "ok"
|
||||
elif decoded[1] == 'eval-result':
|
||||
@@ -165,17 +182,17 @@ class ThreadedTCPRequestHandler(socketserver.BaseRequestHandler):
|
||||
response = last_eval
|
||||
elif decoded[1] == 'call me':
|
||||
cmd = '[0,"we called you"]'
|
||||
print("sending: {}".format(cmd))
|
||||
print("sending: {0}".format(cmd))
|
||||
self.request.sendall(cmd.encode('utf-8'))
|
||||
response = "ok"
|
||||
elif decoded[1] == 'call me again':
|
||||
cmd = '[0,"we did call you"]'
|
||||
print("sending: {}".format(cmd))
|
||||
print("sending: {0}".format(cmd))
|
||||
self.request.sendall(cmd.encode('utf-8'))
|
||||
response = ""
|
||||
elif decoded[1] == 'send zero':
|
||||
cmd = '[0,"zero index"]'
|
||||
print("sending: {}".format(cmd))
|
||||
print("sending: {0}".format(cmd))
|
||||
self.request.sendall(cmd.encode('utf-8'))
|
||||
response = "sent zero"
|
||||
elif decoded[1] == 'close me':
|
||||
@@ -199,7 +216,7 @@ class ThreadedTCPRequestHandler(socketserver.BaseRequestHandler):
|
||||
print("no response")
|
||||
else:
|
||||
encoded = json.dumps([decoded[0], response])
|
||||
print("sending: {}".format(encoded))
|
||||
print("sending: {0}".format(encoded))
|
||||
self.request.sendall(encoded.encode('utf-8'))
|
||||
|
||||
# Negative numbers are used for "eval" responses.
|
||||
@@ -212,7 +229,7 @@ class ThreadedTCPServer(socketserver.ThreadingMixIn, socketserver.TCPServer):
|
||||
def writePortInFile(port):
|
||||
# Write the port number in Xportnr, so that the test knows it.
|
||||
f = open("Xportnr", "w")
|
||||
f.write("{}".format(port))
|
||||
f.write("{0}".format(port))
|
||||
f.close()
|
||||
|
||||
if __name__ == "__main__":
|
||||
@@ -238,7 +255,7 @@ if __name__ == "__main__":
|
||||
|
||||
writePortInFile(port)
|
||||
|
||||
print("Listening on port {}".format(port))
|
||||
print("Listening on port {0}".format(port))
|
||||
|
||||
# Main thread terminates, but the server continues running
|
||||
# until server.shutdown() is called.
|
||||
|
||||
@@ -120,9 +120,16 @@ func s:communicate(port)
|
||||
return
|
||||
endif
|
||||
if has('job')
|
||||
" check that no job is handled correctly
|
||||
" check that getjob without a job is handled correctly
|
||||
call assert_equal('no process', string(ch_getjob(handle)))
|
||||
endif
|
||||
let dict = ch_info(handle)
|
||||
call assert_true(dict.id != 0)
|
||||
call assert_equal('open', dict.status)
|
||||
call assert_equal(a:port, string(dict.port))
|
||||
call assert_equal('open', dict.sock_status)
|
||||
call assert_equal('socket', dict.sock_io)
|
||||
|
||||
" Simple string request and reply.
|
||||
call assert_equal('got it', ch_evalexpr(handle, 'hello!'))
|
||||
|
||||
@@ -144,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('$'))
|
||||
@@ -185,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'))
|
||||
@@ -678,6 +701,9 @@ func Run_test_pipe_to_buffer(use_name)
|
||||
call ch_sendraw(handle, "quit\n")
|
||||
sp pipe-output
|
||||
call s:waitFor('line("$") >= 6')
|
||||
if getline('$') == 'DETACH'
|
||||
$del
|
||||
endif
|
||||
call assert_equal([firstline, 'line one', 'line two', 'this', 'AND this', 'Goodbye!'], getline(1, '$'))
|
||||
bwipe!
|
||||
finally
|
||||
@@ -987,6 +1013,39 @@ func Test_reuse_channel()
|
||||
endtry
|
||||
endfunc
|
||||
|
||||
func Test_out_cb()
|
||||
if !has('job')
|
||||
return
|
||||
endif
|
||||
call ch_log('Test_out_cb()')
|
||||
|
||||
let dict = {'thisis': 'dict: '}
|
||||
func dict.outHandler(chan, msg) dict
|
||||
let s:outmsg = self.thisis . a:msg
|
||||
endfunc
|
||||
func dict.errHandler(chan, msg) dict
|
||||
let s:errmsg = self.thisis . a:msg
|
||||
endfunc
|
||||
let job = job_start(s:python . " test_channel_pipe.py",
|
||||
\ {'out_cb': dict.outHandler,
|
||||
\ 'out_mode': 'json',
|
||||
\ 'err_cb': dict.errHandler,
|
||||
\ 'err_mode': 'json'})
|
||||
call assert_equal("run", job_status(job))
|
||||
try
|
||||
let s:outmsg = ''
|
||||
let s:errmsg = ''
|
||||
call ch_sendraw(job, "echo [0, \"hello\"]\n")
|
||||
call ch_sendraw(job, "echoerr [0, \"there\"]\n")
|
||||
call s:waitFor('s:outmsg != ""')
|
||||
call assert_equal("dict: hello", s:outmsg)
|
||||
call s:waitFor('s:errmsg != ""')
|
||||
call assert_equal("dict: there", s:errmsg)
|
||||
finally
|
||||
call job_stop(job)
|
||||
endtry
|
||||
endfunc
|
||||
|
||||
""""""""""
|
||||
|
||||
let s:unletResponse = ''
|
||||
|
||||
@@ -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
|
||||
@@ -727,4 +727,13 @@ func Test_normal_increment_01()
|
||||
call assert_equal("002", getline(1))
|
||||
endfunc
|
||||
|
||||
" Test a regression of patch 7.4.1087 fixed.
|
||||
func Test_normal_increment_02()
|
||||
call setline(1, ["hello 10", "world"])
|
||||
exec "norm! ggl\<C-A>jx"
|
||||
call assert_equal(["hello 11", "worl"], getline(1, '$'))
|
||||
call assert_equal([0, 2, 4, 0], getpos('.'))
|
||||
endfunc
|
||||
|
||||
|
||||
" vim: tabstop=2 shiftwidth=2 expandtab
|
||||
|
||||
@@ -170,3 +170,53 @@ func Test_partial_string()
|
||||
let F = function('MyFunc', ['foo'], d)
|
||||
call assert_equal("function('MyFunc', ['foo'], {'one': 1})", string(F))
|
||||
endfunc
|
||||
|
||||
func Test_func_unref()
|
||||
let obj = {}
|
||||
function! obj.func() abort
|
||||
endfunction
|
||||
let funcnumber = matchstr(string(obj.func), '^function(''\zs.\{-}\ze''')
|
||||
call assert_true(exists('*{' . funcnumber . '}'))
|
||||
unlet obj
|
||||
call assert_false(exists('*{' . funcnumber . '}'))
|
||||
endfunc
|
||||
|
||||
func Test_tostring()
|
||||
let d = {}
|
||||
let d.d = d
|
||||
function d.test3()
|
||||
echo 42
|
||||
endfunction
|
||||
try
|
||||
call string(d.test3)
|
||||
catch
|
||||
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
|
||||
|
||||
@@ -504,7 +504,7 @@ function Test_locationlist_curwin_was_closed()
|
||||
autocmd BufReadCmd t call R(expand("<amatch>"))
|
||||
augroup END
|
||||
|
||||
function R(n)
|
||||
function! R(n)
|
||||
quit
|
||||
endfunc
|
||||
|
||||
@@ -637,3 +637,58 @@ function! Test_efm1()
|
||||
call delete('Xerrorfile2')
|
||||
call delete('Xtestfile')
|
||||
endfunction
|
||||
|
||||
function XquickfixChangedByAutocmd(cchar)
|
||||
let Xolder = a:cchar . 'older'
|
||||
let Xgetexpr = a:cchar . 'getexpr'
|
||||
let Xrewind = a:cchar . 'rewind'
|
||||
if a:cchar == 'c'
|
||||
let Xsetlist = 'setqflist('
|
||||
let ErrorNr = 'E925'
|
||||
function! ReadFunc()
|
||||
colder
|
||||
cgetexpr []
|
||||
endfunc
|
||||
else
|
||||
let Xsetlist = 'setloclist(0,'
|
||||
let ErrorNr = 'E926'
|
||||
function! ReadFunc()
|
||||
lolder
|
||||
lgetexpr []
|
||||
endfunc
|
||||
endif
|
||||
|
||||
augroup testgroup
|
||||
au!
|
||||
autocmd BufReadCmd t call ReadFunc()
|
||||
augroup END
|
||||
|
||||
bwipe!
|
||||
let words = [ "a", "b" ]
|
||||
let qflist = []
|
||||
for word in words
|
||||
call add(qflist, {'filename': 't'})
|
||||
exec "call " . Xsetlist . "qflist, '')"
|
||||
endfor
|
||||
exec "call assert_fails('" . Xrewind . "', '" . ErrorNr . ":')"
|
||||
|
||||
augroup! testgroup
|
||||
endfunc
|
||||
|
||||
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,94 @@ 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,
|
||||
/**/
|
||||
1643,
|
||||
/**/
|
||||
1642,
|
||||
/**/
|
||||
1641,
|
||||
/**/
|
||||
1640,
|
||||
/**/
|
||||
1639,
|
||||
/**/
|
||||
1638,
|
||||
/**/
|
||||
1637,
|
||||
/**/
|
||||
1636,
|
||||
/**/
|
||||
1635,
|
||||
/**/
|
||||
1634,
|
||||
/**/
|
||||
1633,
|
||||
/**/
|
||||
1632,
|
||||
/**/
|
||||
1631,
|
||||
/**/
|
||||
1630,
|
||||
/**/
|
||||
1629,
|
||||
/**/
|
||||
1628,
|
||||
/**/
|
||||
1627,
|
||||
/**/
|
||||
1626,
|
||||
/**/
|
||||
1625,
|
||||
/**/
|
||||
1624,
|
||||
/**/
|
||||
1623,
|
||||
/**/
|
||||
1622,
|
||||
/**/
|
||||
1621,
|
||||
/**/
|
||||
1620,
|
||||
/**/
|
||||
1619,
|
||||
/**/
|
||||
|
||||
Reference in New Issue
Block a user