Home Explore Blog CI



neovim

67th chunk of `runtime/doc/vimfn.txt`
f91b9996cc89865b93c0de4e783cacc6ff38a12e1054300c0000000100000fac
 (process id) of |job-id| {job}.

                Parameters: ~
                  • {job} (`integer`)

                Return: ~
                  (`integer`)

jobresize({job}, {width}, {height})                                *jobresize()*
		Resize the pseudo terminal window of |job-id| {job} to {width}
		columns and {height} rows.
		Fails if the job was not started with `"pty":v:true`.

                Parameters: ~
                  • {job} (`integer`)
                  • {width} (`integer`)
                  • {height} (`integer`)

                Return: ~
                  (`any`)

jobstart({cmd} [, {opts}])                                          *jobstart()*
		Note: Prefer |vim.system()| in Lua (unless using `rpc`, `pty`, or `term`).

		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: >vim
		  call jobstart(split(&shell) + split(&shellcmdflag) + ['{cmd}'])
<		(See |shell-unquoting| for details.)

		Example: start a job and handle its output: >vim
		  call jobstart(['nvim', '-h'], {'on_stdout':{j,d,e->append(line('.'),d)}})
<
		Example: start a job in a |terminal| connected to the current buffer: >vim
		  call jobstart(['nvim', '-h'], {'term':v:true})
<
		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: >vim
		      call jobstart(['ping', 'neovim.io'])
<		    If it is a full or partial path, extension is required: >vim
		      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".

							*jobstart-env*
		The job environment is initialized as follows:
		  $NVIM                is set to |v:servername| of the parent Nvim
		  $NVIM_LISTEN_ADDRESS is unset
		  $NVIM_LOG_FILE       is unset
		  $VIM                 is unset
		  $VIMRUNTIME          is unset
		You can set these with the `env` option.

							*jobstart-options*
		{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 replace with "clear_env")
			      the current environment. |jobstart-env|
		  height:     (number) Height of the `pty` 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) Sets FILE_FLAG_OVERLAPPED for the
			      stdio passed to the child process. Only on
			      MS-Windows; ignored on other platforms.
		  pty:	      (boolean) Connect the job to a new pseudo
			      terminal, and its streams to the master file
			      descriptor. `on_stdout` receives all output,
			      `on_stderr` is ignored. |terminal-start|
		  rpc:	      (boolean) Use |msgpack-rpc| to communicate with
			      the job over stdio. Then `on_stdout` is ignored,
			      but `on_stderr` can still be used.
		  stderr_buffered: (boolean) Collect data

Title: jobpid(), jobresize(), and jobstart() Functions Explained
Summary
This section details the `jobpid()`, `jobresize()`, and `jobstart()` functions in Vimscript. `jobpid()` retrieves the process ID of a given job. `jobresize()` resizes the pseudo terminal window of a job, requiring the job to be started with `"pty":v:true`. `jobstart()` spawns a job, with options to execute commands directly or through the shell. It supports handling output, connecting to a terminal, and setting environment variables. It returns a job ID on success and provides notes for Windows usage. The section also lists available options for the `jobstart()` function, including callbacks for exit, stdout, and stderr, as well as options for PTY, RPC, and environment settings.