import { jobstart } from "https://deno.land/x/denops_std@v3.9.0/function/nvim/mod.ts";
Spawns {cmd} as a job. If {cmd} is a List it runs directly (no 'shell'). If {cmd} is a String it runs in the 'shell', like this: :call jobstart(split(&shell) + split(&shellcmdflag) + ['{cmd}']) (See |shell-unquoting| for details.) Example: :call jobstart('nvim -h', {'on_stdout':{j,d,e->append(line('.'),d)}}) Returns |job-id| on success, 0 on invalid arguments (or job table is full), -1 if {cmd}[0] or 'shell' is not executable. The returned job-id is a valid |channel-id| representing the job's stdio streams. Use |chansend()| (or |rpcnotify()| and |rpcrequest()| if "rpc" was enabled) to send data to stdin and |chanclose()| to close the streams without stopping the job. See |job-control| and |RPC|. NOTE: on Windows if {cmd} is a List:
- cmd[0] must be an executable (not a "built-in"). If it is in $PATH it can be called by name, without an extension: :call jobstart(['ping', 'neovim.io']) If it is a full or partial path, extension is required: :call jobstart(['System32\ping.exe', 'neovim.io'])
- {cmd} is collapsed to a string of quoted args as expected
by CommandLineToArgvW https://msdn.microsoft.com/bb776391
unless cmd[0] is some form of "cmd.exe".
{opts} is a dictionary with these keys:
clear_env: (boolean)
env
defines the job environment exactly, instead of merging current environment. cwd: (string, default=|current-directory|) Working directory of the job. detach: (boolean) Detach the job process: it will not be killed when Nvim exits. If the process exits before Nvim,on_exit
will be invoked. env: (dict) Map of environment variable name:value pairs extending (or replacing if |clear_env|) the current environment. height: (number) Height of thepty
terminal. |on_exit|: (function) Callback invoked when the job exits. |on_stdout|: (function) Callback invoked when the job emits stdout data. |on_stderr|: (function) Callback invoked when the job emits stderr data. overlapped: (boolean) Set FILE_FLAG_OVERLAPPED for the standard input/output passed to the child process. Normally you do not need to set this. (Only available on MS-Windows, On other platforms, this option is silently ignored.) pty: (boolean) Connect the job to a new pseudo terminal, and its streams to the master file descriptor. Thenon_stderr
is ignored,on_stdout
receives all output. rpc: (boolean) Use |msgpack-rpc| to communicate with the job over stdio. Thenon_stdout
is ignored, buton_stderr
can still be used. stderr_buffered: (boolean) Collect data until EOF (stream closed) before invokingon_stderr
. |channel-buffered| stdout_buffered: (boolean) Collect data until EOF (stream closed) before invokingon_stdout
. |channel-buffered| stdin: (string) Either "pipe" (default) to connect the job's stdin to a channel or "null" to disconnect stdin. width: (number) Width of thepty
terminal. {opts} is passed as |self| dictionary to the callback; the caller may set other keys to pass application-specific data. Returns: - |channel-id| on success
- 0 on invalid arguments
- -1 if {cmd}[0] is not executable. See also |job-control|, |channel|, |msgpack-rpc|.