mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
doc: v:servername, serverstart()
This commit is contained in:
parent
64c7a36933
commit
84443f176e
@ -1583,7 +1583,9 @@ v:scrollstart String describing the script or function that caused the
|
|||||||
hit-enter prompt.
|
hit-enter prompt.
|
||||||
|
|
||||||
*v:servername* *servername-variable*
|
*v:servername* *servername-variable*
|
||||||
v:servername The resulting registered |x11-clientserver| name if any.
|
v:servername Default {Nvim} server address. Equivalent to
|
||||||
|
|$NVIM_LISTEN_ADDRESS| on startup, but may differ if the
|
||||||
|
latter is modified or unset. |serverstop()|
|
||||||
Read-only.
|
Read-only.
|
||||||
|
|
||||||
|
|
||||||
@ -2366,8 +2368,8 @@ char2nr({expr}[, {utf8}]) *char2nr()*
|
|||||||
char2nr("ABC") returns 65
|
char2nr("ABC") returns 65
|
||||||
< When {utf8} is omitted or zero, the current 'encoding' is used.
|
< When {utf8} is omitted or zero, the current 'encoding' is used.
|
||||||
Example for "utf-8": >
|
Example for "utf-8": >
|
||||||
char2nr("á") returns 225
|
char2nr("á") returns 225
|
||||||
char2nr("á"[0]) returns 195
|
char2nr("á"[0]) returns 195
|
||||||
< With {utf8} set to 1, always treat as utf-8 characters.
|
< With {utf8} set to 1, always treat as utf-8 characters.
|
||||||
A combining character is a separate character.
|
A combining character is a separate character.
|
||||||
|nr2char()| does the opposite.
|
|nr2char()| does the opposite.
|
||||||
@ -5379,20 +5381,26 @@ serverlist() *serverlist()*
|
|||||||
When there are no servers an empty string is returned.
|
When there are no servers an empty string is returned.
|
||||||
Example: >
|
Example: >
|
||||||
:echo serverlist()
|
:echo serverlist()
|
||||||
|
< *--serverlist*
|
||||||
|
The Vim command-line option `--serverlist` can be imitated: >
|
||||||
|
nvim --cmd "echo serverlist()" --cmd "q"
|
||||||
|
<
|
||||||
|
serverstart([{address}]) *serverstart()*
|
||||||
|
Opens a named pipe or TCP socket at {address} for clients to
|
||||||
|
connect to and returns {address}. If no address is given, it
|
||||||
|
is equivalent to: >
|
||||||
|
:call serverstart(tempname())
|
||||||
|
< |$NVIM_LISTEN_ADDRESS| is set to {address} if not already set.
|
||||||
|
*--servername*
|
||||||
|
The Vim command-line option `--servername` can be imitated: >
|
||||||
|
nvim --cmd "let g:server_addr = serverstart('foo')"
|
||||||
<
|
<
|
||||||
serverlisten([{address}]) *serverlisten()*
|
|
||||||
Opens a Unix or TCP socket at {address} for clients to connect
|
|
||||||
to and returns {address}. If no address is given, it is
|
|
||||||
equivalent to >
|
|
||||||
:call serverlisten(tempname())
|
|
||||||
< If |$NVIM_LISTEN_ADDRESS| is not set, it will be set to
|
|
||||||
{address}.
|
|
||||||
|
|
||||||
serverstop({address}) *serverstop()*
|
serverstop({address}) *serverstop()*
|
||||||
Closes the Unix or TCP socket at {address}. Does nothing if
|
Closes the pipe or socket at {address}. Does nothing if
|
||||||
{address} is empty, or does not refer to a server. If
|
{address} is empty or invalid.
|
||||||
{address} equals |$NVIM_LISTEN_ADDRESS|, the listen address
|
If |$NVIM_LISTEN_ADDRESS| is stopped it is unset.
|
||||||
will be unset.
|
If |v:servername| is stopped it is set to the next available
|
||||||
|
address returned by |serverlist()|.
|
||||||
|
|
||||||
setbufvar({expr}, {varname}, {val}) *setbufvar()*
|
setbufvar({expr}, {varname}, {val}) *setbufvar()*
|
||||||
Set option or local variable {varname} in buffer {expr} to
|
Set option or local variable {varname} in buffer {expr} to
|
||||||
|
@ -81,6 +81,8 @@ There are four ways to open msgpack-rpc streams to nvim:
|
|||||||
>
|
>
|
||||||
:echo $NVIM_LISTEN_ADDRESS
|
:echo $NVIM_LISTEN_ADDRESS
|
||||||
<
|
<
|
||||||
|
See also |v:servername|.
|
||||||
|
|
||||||
4. Through a TCP/IP socket. To make nvim listen on a TCP/IP socket, set the
|
4. Through a TCP/IP socket. To make nvim listen on a TCP/IP socket, set the
|
||||||
|$NVIM_LISTEN_ADDRESS| environment variable in a shell before starting:
|
|$NVIM_LISTEN_ADDRESS| environment variable in a shell before starting:
|
||||||
>
|
>
|
||||||
|
@ -56,11 +56,6 @@ The following command line arguments are available:
|
|||||||
*--remote-tab-wait-silent*
|
*--remote-tab-wait-silent*
|
||||||
--remote-tab-wait-silent Like --remote-wait-silent but open each file
|
--remote-tab-wait-silent Like --remote-wait-silent but open each file
|
||||||
in a new tabpage.
|
in a new tabpage.
|
||||||
*--servername*
|
|
||||||
--servername {name} Become the server {name}. When used together
|
|
||||||
with one of the --remote commands: connect to
|
|
||||||
server {name} instead of the default (see
|
|
||||||
below).
|
|
||||||
*--remote-send*
|
*--remote-send*
|
||||||
--remote-send {keys} Send {keys} to server and exit. The {keys}
|
--remote-send {keys} Send {keys} to server and exit. The {keys}
|
||||||
are not mapped. Special key names are
|
are not mapped. Special key names are
|
||||||
@ -69,9 +64,6 @@ The following command line arguments are available:
|
|||||||
*--remote-expr*
|
*--remote-expr*
|
||||||
--remote-expr {expr} Evaluate {expr} in server and print the result
|
--remote-expr {expr} Evaluate {expr} in server and print the result
|
||||||
on stdout.
|
on stdout.
|
||||||
*--serverlist*
|
|
||||||
--serverlist Output a list of server names.
|
|
||||||
|
|
||||||
|
|
||||||
Examples ~
|
Examples ~
|
||||||
|
|
||||||
|
@ -365,7 +365,7 @@ static struct vimvar {
|
|||||||
} vimvars[VV_LEN] =
|
} vimvars[VV_LEN] =
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* The order here must match the VV_ defines in vim.h!
|
* The order here must match the VV_ defines in eval.h!
|
||||||
* Initializing a union does not work, leave tv.vval empty to get zero's.
|
* Initializing a union does not work, leave tv.vval empty to get zero's.
|
||||||
*/
|
*/
|
||||||
{VV_NAME("count", VAR_NUMBER), VV_COMPAT+VV_RO},
|
{VV_NAME("count", VAR_NUMBER), VV_COMPAT+VV_RO},
|
||||||
@ -13356,7 +13356,7 @@ static void f_serverlist(typval_T *argvars, typval_T *rettv)
|
|||||||
static void f_serverstart(typval_T *argvars, typval_T *rettv)
|
static void f_serverstart(typval_T *argvars, typval_T *rettv)
|
||||||
{
|
{
|
||||||
rettv->v_type = VAR_STRING;
|
rettv->v_type = VAR_STRING;
|
||||||
rettv->vval.v_string = NULL; // Will hold the address of the new server.
|
rettv->vval.v_string = NULL; // Address of the new server
|
||||||
|
|
||||||
if (check_restricted() || check_secure()) {
|
if (check_restricted() || check_secure()) {
|
||||||
return;
|
return;
|
||||||
|
@ -28,13 +28,13 @@ typedef enum {
|
|||||||
} ServerType;
|
} ServerType;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
// The address of a pipe, or string value of a tcp address.
|
// Pipe/socket path, or TCP address string
|
||||||
char addr[ADDRESS_MAX_SIZE];
|
char addr[ADDRESS_MAX_SIZE];
|
||||||
|
|
||||||
// Type of the union below
|
// Type of the union below
|
||||||
ServerType type;
|
ServerType type;
|
||||||
|
|
||||||
// This is either a tcp server or unix socket(named pipe on windows)
|
// TCP server or unix socket (named pipe on Windows)
|
||||||
union {
|
union {
|
||||||
struct {
|
struct {
|
||||||
uv_tcp_t handle;
|
uv_tcp_t handle;
|
||||||
@ -144,7 +144,7 @@ int server_start(const char *endpoint)
|
|||||||
size_t addr_len = (size_t)(ip_end - addr);
|
size_t addr_len = (size_t)(ip_end - addr);
|
||||||
|
|
||||||
if (addr_len > sizeof(ip) - 1) {
|
if (addr_len > sizeof(ip) - 1) {
|
||||||
// Maximum length of an IP address buffer is 15(eg: 255.255.255.255)
|
// Maximum length of an IPv4 address buffer is 15 (eg: 255.255.255.255)
|
||||||
addr_len = sizeof(ip) - 1;
|
addr_len = sizeof(ip) - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -245,7 +245,7 @@ void server_stop(char *endpoint)
|
|||||||
// Trim to `ADDRESS_MAX_SIZE`
|
// Trim to `ADDRESS_MAX_SIZE`
|
||||||
xstrlcpy(addr, endpoint, sizeof(addr));
|
xstrlcpy(addr, endpoint, sizeof(addr));
|
||||||
|
|
||||||
int i = 0; // The index of the server whose address equals addr.
|
int i = 0; // Index of the server whose address equals addr.
|
||||||
for (; i < servers.ga_len; i++) {
|
for (; i < servers.ga_len; i++) {
|
||||||
server = ((Server **)servers.ga_data)[i];
|
server = ((Server **)servers.ga_data)[i];
|
||||||
if (strcmp(addr, server->addr) == 0) {
|
if (strcmp(addr, server->addr) == 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user