aboutsummaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2019-11-10 14:46:14 +0100
committerGitHub <noreply@github.com>2019-11-10 14:46:14 +0100
commit3a075ce3dc97926f5aabc027b77a80c26c65de61 (patch)
tree7c3563d5feb002bc79d8c92a09cc7eed50572d18 /runtime
parentece3d19b026b80c933e650c4422f8b1a4ab4bde9 (diff)
parent474d0bcbf724c7eed740f60391a0ed35d651e1d3 (diff)
downloadrneovim-3a075ce3dc97926f5aabc027b77a80c26c65de61.tar.gz
rneovim-3a075ce3dc97926f5aabc027b77a80c26c65de61.tar.bz2
rneovim-3a075ce3dc97926f5aabc027b77a80c26c65de61.zip
Merge pull request #11310 from bfredl/luarpc
lua: add vim.rpcrequest, vim.rpcnotify and vim.NIL
Diffstat (limited to 'runtime')
-rw-r--r--runtime/doc/if_lua.txt23
-rw-r--r--runtime/lua/vim/inspect.lua2
2 files changed, 24 insertions, 1 deletions
diff --git a/runtime/doc/if_lua.txt b/runtime/doc/if_lua.txt
index 97d851a20f..bba43ea32c 100644
--- a/runtime/doc/if_lua.txt
+++ b/runtime/doc/if_lua.txt
@@ -587,6 +587,26 @@ vim.in_fast_event() *vim.in_fast_event()*
for input. When this is `false` most API functions are callable (but
may be subject to other restrictions such as |textlock|).
+vim.NIL *vim.NIL*
+ Special value used to represent NIL in msgpack-rpc and |v:null| in
+ vimL interaction, and similar cases. Lua `nil` cannot be used as
+ part of a lua table representing a Dictionary or Array, as it
+ is equivalent to a missing value: `{"foo", nil}` is the same as
+ `{"foo"}`
+
+vim.rpcnotify({channel}, {method}[, {args}...]) *vim.rpcnotify()*
+ Sends {event} to {channel} via |RPC| and returns immediately.
+ If {channel} is 0, the event is broadcast to all channels.
+
+ This function also works in a fast callback |lua-loop-callbacks|.
+
+vim.rpcrequest({channel}, {method}[, {args}...]) *vim.rpcrequest()*
+ Sends a request to {channel} to invoke {method} via
+ |RPC| and blocks until a response is received.
+
+ Note: NIL values as part of the return value is represented as
+ |vim.NIL| special value
+
vim.stricmp({a}, {b}) *vim.stricmp()*
Compares strings case-insensitively. Returns 0, 1 or -1 if strings
are equal, {a} is greater than {b} or {a} is lesser than {b},
@@ -624,6 +644,9 @@ vim.fn.{func}({...}) *vim.fn*
be represented directly as a Lua number. Empty lists and dictionaries
both are represented by an empty table.
+ Note: |v:null| values as part of the return value is represented as
+ |vim.NIL| special value
+
Note: vim.fn keys are generated lazily, thus `pairs(vim.fn)` only
enumerates functions that were called at least once.
diff --git a/runtime/lua/vim/inspect.lua b/runtime/lua/vim/inspect.lua
index 7cb40ca64d..0f3b908dc1 100644
--- a/runtime/lua/vim/inspect.lua
+++ b/runtime/lua/vim/inspect.lua
@@ -289,7 +289,7 @@ function Inspector:putValue(v)
if tv == 'string' then
self:puts(smartQuote(escape(v)))
elseif tv == 'number' or tv == 'boolean' or tv == 'nil' or
- tv == 'cdata' or tv == 'ctype' then
+ tv == 'cdata' or tv == 'ctype' or (vim and v == vim.NIL) then
self:puts(tostring(v))
elseif tv == 'table' then
self:putTable(v)