Skip to content

Commit b5e634e

Browse files
committed
Merge remote-tracking branch 'vim/master'
2 parents 5b41cd5 + cbebd48 commit b5e634e

29 files changed

Lines changed: 727 additions & 211 deletions

runtime/doc/channel.txt

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*channel.txt* For Vim version 7.4. Last change: 2016 Feb 06
1+
*channel.txt* For Vim version 7.4. Last change: 2016 Feb 07
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -16,7 +16,7 @@ The Netbeans interface also uses a channel. |netbeans|
1616

1717
1. Demo |channel-demo|
1818
2. Opening a channel |channel-open|
19-
3. Using a JSON channel |channel-use|
19+
3. Using a JSON or JS channel |channel-use|
2020
4. Vim commands |channel-commands|
2121
5. Using a raw channel |channel-use|
2222
6. Job control |job-control|
@@ -77,6 +77,7 @@ To open a channel: >
7777

7878
"mode" can be: *channel-mode*
7979
"json" - Use JSON, see below; most convenient way. Default.
80+
"js" - Use JavaScript encoding, more efficient than JSON.
8081
"raw" - Use raw messages
8182

8283
*channel-callback*
@@ -86,7 +87,7 @@ message. Example: >
8687
func Handle(handle, msg)
8788
echo 'Received: ' . a:msg
8889
endfunc
89-
let handle = ch_open("localhost:8765", 'json', "Handle")
90+
let handle = ch_open("localhost:8765", {"callback": "Handle"})
9091
9192
"waittime" is the time to wait for the connection to be made in milliseconds.
9293
The default is zero, don't wait, which is useful if the server is supposed to
@@ -95,12 +96,12 @@ be running already. A negative number waits forever.
9596
"timeout" is the time to wait for a request when blocking, using
9697
ch_sendexpr(). Again in milliseconds. The default is 2000 (2 seconds).
9798

98-
When "mode" is "json" the "msg" argument is the body of the received message,
99-
converted to Vim types.
99+
When "mode" is "json" or "js" the "msg" argument is the body of the received
100+
message, converted to Vim types.
100101
When "mode" is "raw" the "msg" argument is the whole message as a string.
101102

102-
When "mode" is "json" the "callback" is optional. When omitted it is only
103-
possible to receive a message after sending one.
103+
When "mode" is "json" or "js" the "callback" is optional. When omitted it is
104+
only possible to receive a message after sending one.
104105

105106
The handler can be added or changed later: >
106107
call ch_setcallback(handle, {callback})
@@ -116,19 +117,24 @@ Once done with the channel, disconnect it like this: >
116117
117118
Currently up to 10 channels can be in use at the same time. *E897*
118119

119-
When the channel can't be opened you will get an error message.
120+
When the channel can't be opened you will get an error message. There is a
121+
difference between MS-Windows and Unix: On Unix when the port doesn't exist
122+
ch_open() fails quickly. On MS-Windows "waittime" applies.
120123
*E898* *E899* *E900* *E901* *E902*
121124

122125
If there is an error reading or writing a channel it will be closed.
123126
*E896* *E630* *E631*
124127

125128
==============================================================================
126-
3. Using a JSON channel *channel-use*
129+
3. Using a JSON or JS channel *channel-use*
127130

128131
If {mode} is "json" then a message can be sent synchronously like this: >
129132
let response = ch_sendexpr(handle, {expr})
130133
This awaits a response from the other side.
131134

135+
When {mode} is "js" this works the same, except that the messages use
136+
JavaScript encoding. See |jsencode()| for the difference.
137+
132138
To send a message, without handling a response: >
133139
call ch_sendexpr(handle, {expr}, 0)
134140
@@ -165,6 +171,9 @@ channel does not have a handler the message is dropped.
165171
On read error or ch_close() the string "DETACH" is sent, if still possible.
166172
The channel will then be inactive.
167173

174+
It is also possible to use ch_sendraw() on a JSON or JS channel. The caller
175+
is then completely responsible for correct encoding and decoding.
176+
168177
==============================================================================
169178
4. Vim commands *channel-commands*
170179

@@ -231,7 +240,8 @@ Here {number} is the same as what was in the request. Use a negative number
231240
to avoid confusion with message that Vim sends.
232241

233242
{result} is the result of the evaluation and is JSON encoded. If the
234-
evaluation fails it is the string "ERROR".
243+
evaluation fails or the result can't be encoded in JSON it is the string
244+
"ERROR".
235245

236246

237247
Command "expr" ~
@@ -261,6 +271,8 @@ asynchronously: >
261271
This {string} can also be JSON, use |jsonencode()| to create it and
262272
|jsondecode()| to handle a received JSON message.
263273

274+
It is not possible to use |ch_sendexpr()| on a raw channel.
275+
264276
==============================================================================
265277
6. Job control *job-control*
266278

runtime/doc/eval.txt

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1956,6 +1956,8 @@ job_start({command} [, {options}]) Job start a job
19561956
job_status({job}) String get the status of a job
19571957
job_stop({job} [, {how}]) Number stop a job
19581958
join( {list} [, {sep}]) String join {list} items into one String
1959+
jsdecode( {string}) any decode JS style JSON
1960+
jsencode( {expr}) String encode JS style JSON
19591961
jsondecode( {string}) any decode JSON
19601962
jsonencode( {expr}) String encode JSON
19611963
keys( {dict}) List keys in {dict}
@@ -2439,7 +2441,6 @@ bufwinnr({expr}) *bufwinnr()*
24392441
|:wincmd|.
24402442
Only deals with the current tab page.
24412443

2442-
24432444
byte2line({byte}) *byte2line()*
24442445
Return the line number that contains the character at byte
24452446
count {byte} in the current buffer. This includes the
@@ -2688,7 +2689,7 @@ ch_open({address} [, {argdict}]) *ch_open()*
26882689

26892690
If {argdict} is given it must be a |Dictionary|. The optional
26902691
items are:
2691-
mode "raw" or "json".
2692+
mode "raw", "js" or "json".
26922693
Default "json".
26932694
callback function to call for requests with a zero
26942695
sequence number. See |channel-callback|.
@@ -2702,10 +2703,12 @@ ch_open({address} [, {argdict}]) *ch_open()*
27022703
{only available when compiled with the |+channel| feature}
27032704

27042705
ch_sendexpr({handle}, {expr} [, {callback}]) *ch_sendexpr()*
2705-
Send {expr} over JSON channel {handle}. See |channel-use|.
2706+
Send {expr} over channel {handle}. The {expr} is encoded
2707+
according to the type of channel. The function cannot be used
2708+
with a raw channel. See |channel-use|. *E912*
27062709

27072710
When {callback} is given returns immediately. Without
2708-
{callback} waits for a JSON response and returns the decoded
2711+
{callback} waits for a response and returns the decoded
27092712
expression. When there is an error or timeout returns an
27102713
empty string.
27112714

@@ -2717,8 +2720,10 @@ ch_sendexpr({handle}, {expr} [, {callback}]) *ch_sendexpr()*
27172720
{only available when compiled with the |+channel| feature}
27182721

27192722
ch_sendraw({handle}, {string} [, {callback}]) *ch_sendraw()*
2720-
Send {string} over raw channel {handle}. See |channel-raw|.
2721-
Works like |ch_sendexpr()|, but does not decode the response.
2723+
Send {string} over channel {handle}.
2724+
Works like |ch_sendexpr()|, but does not encode the request or
2725+
decode the response. The caller is responsible for the
2726+
correct contents. See |channel-use|.
27222727

27232728
{only available when compiled with the |+channel| feature}
27242729

@@ -4381,17 +4386,33 @@ join({list} [, {sep}]) *join()*
43814386
converted into a string like with |string()|.
43824387
The opposite function is |split()|.
43834388

4389+
jsdecode({string}) *jsdecode()*
4390+
This is similar to |jsondecode()| with these differences:
4391+
- Object key names do not have to be in quotes.
4392+
- Empty items in an array (between two commas) are allowed and
4393+
result in v:none items.
4394+
4395+
jsencode({expr}) *jsencode()*
4396+
This is similar to |jsonencode()| with these differences:
4397+
- Object key names are not in quotes.
4398+
- v:none items in an array result in an empty item between
4399+
commas.
4400+
For example, the Vim object:
4401+
[1,v:none,{"one":1}],v:none ~
4402+
Will be encoded as:
4403+
[1,,{one:1},,] ~
4404+
While jsonencode() would produce:
4405+
[1,null,{"one":1},null] ~
4406+
This encoding is valid for JavaScript. It is more efficient
4407+
than JSON, especially when using an array with optional items.
4408+
4409+
43844410
jsondecode({string}) *jsondecode()*
43854411
This parses a JSON formatted string and returns the equivalent
43864412
in Vim values. See |jsonencode()| for the relation between
43874413
JSON and Vim values.
43884414
The decoding is permissive:
43894415
- A trailing comma in an array and object is ignored.
4390-
- An empty item in an array, two commas with nothing or white
4391-
space in between, results in v:none.
4392-
- When an object member name is not a string it is converted
4393-
to a string. E.g. the number 123 is used as the string
4394-
"123".
43954416
- More floating point numbers are recognized, e.g. "1." for
43964417
"1.0".
43974418
The result must be a valid Vim type:
@@ -4413,7 +4434,7 @@ jsonencode({expr}) *jsonencode()*
44134434
used recursively: {}
44144435
v:false "false"
44154436
v:true "true"
4416-
v:none nothing
4437+
v:none "null"
44174438
v:null "null"
44184439
Note that using v:none is permitted, although the JSON
44194440
standard does not allow empty items. This can be useful for

runtime/doc/tags

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4484,7 +4484,14 @@ E902 channel.txt /*E902*
44844484
E903 channel.txt /*E903*
44854485
E904 channel.txt /*E904*
44864486
E905 channel.txt /*E905*
4487+
E906 channel.txt /*E906*
4488+
E907 eval.txt /*E907*
4489+
E908 eval.txt /*E908*
4490+
E909 eval.txt /*E909*
44874491
E91 options.txt /*E91*
4492+
E910 eval.txt /*E910*
4493+
E911 eval.txt /*E911*
4494+
E912 eval.txt /*E912*
44884495
E92 message.txt /*E92*
44894496
E93 windows.txt /*E93*
44904497
E94 windows.txt /*E94*
@@ -6870,8 +6877,13 @@ java.vim syntax.txt /*java.vim*
68706877
javascript-cinoptions indent.txt /*javascript-cinoptions*
68716878
javascript-indenting indent.txt /*javascript-indenting*
68726879
job-control channel.txt /*job-control*
6880+
job_start() eval.txt /*job_start()*
6881+
job_status() eval.txt /*job_status()*
6882+
job_stop() eval.txt /*job_stop()*
68736883
join() eval.txt /*join()*
68746884
jsbterm-mouse options.txt /*jsbterm-mouse*
6885+
jsdecode() eval.txt /*jsdecode()*
6886+
jsencode() eval.txt /*jsencode()*
68756887
jsondecode() eval.txt /*jsondecode()*
68766888
jsonencode() eval.txt /*jsonencode()*
68776889
jtags tagsrch.txt /*jtags*

runtime/doc/todo.txt

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*todo.txt* For Vim version 7.4. Last change: 2016 Feb 04
1+
*todo.txt* For Vim version 7.4. Last change: 2016 Feb 07
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -81,32 +81,36 @@ Regexp problems:
8181
Patch by Christian, 2016 Jan 29.
8282

8383
+channel:
84-
- use a timeout for connect()
85-
Patch from Yasuhiro Matsumoto, Feb 2
86-
Change connect() second argument to a dict with items:
87-
mode
88-
timeout
89-
callback
84+
- implement job control:
85+
job argument: redirect stdin/stdout
86+
job argument: killonexit
87+
let job = job_maystart('command', {address}, {options})
9088
- When receiving malformed json starting with a quote it doesn't get
9189
discarded.
90+
- add ch_status(): Whether channel is open. Perhaps also mode, timeout.
91+
When channel closes invoke channel callback.
9292
- add ch_setcallback()
9393
- add ch_settimeout()
9494
- cleanup on exit? in mch_getout() and getout().
95-
- Add more contents to channel.txt
95+
- Add a test for the channel callback.
9696
- implement debug log
97-
- implement job control:
98-
let job = job_start('command', {options})
99-
call job_stop(job)
100-
let job = job_maystart('command', {address}, {options})
101-
options:
102-
- keep running when Vim exits
103-
- add remark undo sync, is there a way to force it?
104-
- Add a test with a server that can send canned responses.
97+
- Add timestamp to queued messages and callbacks with ID, remove after a
98+
minute.
99+
- add remark about undo sync, is there a way to force it?
105100
- Add more testing in json_test.c
106101
- make sure errors lead to a useful error msg. ["ex","foobar"]
107-
- set timeout for channel.
108-
- implement check for ID in response.
109102
- json: implement UTF-16 surrogate pair.
103+
- Need way to uniquely identify a window, no matter how windows are
104+
rearranged. Same for tab pages.
105+
getwinid() ID of current winow
106+
getwinid({nr}) ID of window {nr}
107+
getwinid({nr}, {tab}) ID of window {nr} in tab page {tab}
108+
getwinnr({id}) window nr of {id} or -1 if not open
109+
gettabnr({id}) tab page nr of {id} or -1 if not open
110+
gotowin({id})
111+
Make it so that the window ID can be used where currently a window nr is used
112+
- For connection to server, a "keep open" flag would be useful. Retry
113+
connecting in the main loop with zero timeout.
110114

111115
Patch on #608: (Ken Takata)
112116
https://bitbucket.org/k_takata/vim-ktakata-mq/src/479934b94fd56b064c9e4bd8737585c5df69d56a/fix-gvimext-loadlibrary.patch?fileviewer=file-view-default
@@ -217,6 +221,8 @@ Patch to fix display of listchars on the cursorline. (Nayuri Aohime, 2013)
217221
Update suggested by Yasuhiro Matsumoto, 2014 Nov 25:
218222
https://gist.github.com/presuku/d3d6b230b9b6dcfc0477
219223

224+
Patch to add TagNotFound autocommand. (Anton Lindqvist, 2016 Feb 3)
225+
220226
Illegal memory access, requires ASAN to see. (Dominique Pelle, 2015 Jul 28)
221227

222228
Gvim: when both Tab and CTRL-I are mapped, use CTRL-I not for Tab.
@@ -265,6 +271,9 @@ Can we cache the syntax attributes, so that updates for 'relativenumber' and
265271
Build with Python on Mac does not always use the right library.
266272
(Kazunobu Kuriyama, 2015 Mar 28)
267273

274+
Patch to add GTK 3 support. (Kazunobu Kuriyama, 2016 Feb 6)
275+
Does not fully work yet.
276+
268277
Need a Vim equivalent of Python's None and a way to test for it.
269278
Use v:none. var == v:none
270279

@@ -621,6 +630,7 @@ Patch to add ":undorecover", get as much text out of the undo file as
621630
possible. (Christian Brabandt, 2014 Mar 12, update Aug 22)
622631

623632
Include Haiku port? (Adrien Destugues, Siarzhuk Zharski, 2013 Oct 24)
633+
It can replace the BeOS code, which is likely not used anymore.
624634

625635
Updated spec ftplugin. (Matěj Cepl, 2013 Oct 16)
626636

@@ -2607,7 +2617,7 @@ GUI:
26072617
Need better separation of Vim core and GUI code.
26082618
8 When fontset support is enabled, setting 'guifont' to a single font
26092619
doesn't work.
2610-
8 Menu priority for sub-menus for: Amiga, BeOS.
2620+
8 Menu priority for sub-menus for: Amiga.
26112621
8 When translating menus ignore the part after the Tab, the shortcut. So
26122622
that the same menu item with a different shortcut (e.g., for the Mac) are
26132623
still translated.

runtime/ftplugin/man.vim

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
" Vim filetype plugin file
22
" Language: man
33
" Maintainer: SungHyun Nam <[email protected]>
4-
" Last Change: 2015 Nov 24
4+
" Last Change: 2016 Feb 04
55

66
" To make the ":Man" command available before editing a manual page, source
77
" this script from your startup vimrc file.
@@ -160,7 +160,9 @@ func <SID>GetPage(...)
160160

161161
setl ma nonu nornu nofen
162162
silent exec "norm 1GdG"
163-
let $MANWIDTH = winwidth(0)
163+
if empty($MANWIDTH)
164+
let $MANWIDTH = winwidth(0)
165+
endif
164166
silent exec "r!/usr/bin/man ".s:GetCmdArg(sect, page)." | col -b"
165167
" Remove blank lines from top and bottom.
166168
while getline(1) =~ '^\s*$'

0 commit comments

Comments
 (0)