Home Explore Blog CI



neovim

6th chunk of `runtime/doc/starting.txt`
1495772a18b4b05dbbca291e3411578916af7ca51ed726200000000100000fa3
 |--embed|: >
		    nvim --embed --listen addr

<		See also: |ui-startup| |channel-stdio|

							*--headless*
--headless	Start without UI, and do not wait for `nvim_ui_attach`. The
		builtin TUI is not used, so stdio works as an arbitrary
		communication channel. |channel-stdio|

		Also useful for scripting (tests) to see messages that would
		not be printed by |-es|.

		To detect if a UI is available, check if |nvim_list_uis()| is
		empty during or after |VimEnter|.

		To read stdin as text, "-" must be given explicitly:
		--headless cannot assume that stdin is just text. >
			echo foo | nvim --headless +"%print" +"q!" -
<
		See also |--embed|.
		See also |-es|, which also disables most messages.

--listen {addr}						*--listen*
		Start |RPC| server on pipe or TCP address {addr}. Sets the
		primary listen address |v:servername| to {addr}. |serverstart()|

		To start the server on-demand with systemd, use a systemd
		socket unit and associated service unit running: >
		systemd-socket-proxyd --exit-idle-time
<
==============================================================================
Initialization					*initialization* *startup*

At startup, Nvim checks environment variables and files and sets values
accordingly, proceeding as follows:

1. Set the 'shell' option			*SHELL* *COMSPEC*
	The environment variable SHELL, if it exists, is used to set the
	'shell' option.  On Win32, the COMSPEC variable is used
	if SHELL is not set.

2. Process the arguments
	The options and file names from the command that start Vim are
	inspected.
	The |-V| argument can be used to display or log what happens next,
	useful for debugging the initializations.
	The |--cmd| arguments are executed.
	Buffers are created for all files (but not loaded yet).

3. Start a server (unless |--listen| was given) and set |v:servername|.

4. Wait for UI to connect.
	Nvim started with |--embed| waits for the UI to connect before
	proceeding to load user configuration.

5. Setup |default-mappings| and |default-autocmds|.  Create |popup-menu|.

6. Enable filetype and indent plugins.
	This does the same as the command: >
		:runtime! ftplugin.vim indent.vim
<	Skipped if the "-u NONE" command line argument was given.

7. Load user config (execute Ex commands from files, environment, …).
	$VIMINIT environment variable is read as one Ex command line (separate
	multiple commands with '|' or <NL>).
					*config* *init.vim* *init.lua* *vimrc* *exrc*
	A file containing initialization commands is generically called
	a "vimrc" or config file.  It can be either Vimscript ("init.vim") or
	Lua ("init.lua"), but not both. *E5422*
	See also |vimrc-intro| and |base-directories|.

	The config file is located at:
	Unix			~/.config/nvim/init.vim		(or init.lua)
	Windows			~/AppData/Local/nvim/init.vim	(or init.lua)
	|$XDG_CONFIG_HOME|	$XDG_CONFIG_HOME/nvim/init.vim	(or init.lua)

	If Nvim was started with "-u {file}" then {file} is used as the config
	and all initializations until 8. are skipped. $MYVIMRC is not set.
	"nvim -u NORC" can be used to skip these initializations without
	reading a file.  "nvim -u NONE" also skips plugins and syntax
	highlighting.  |-u|

	If Nvim was started with |-es| or |-Es| or |-l| all initializations until 8.
	are skipped.
						*system-vimrc* *sysinit.vim*
     a. The system vimrc file is read for initializations.  If
	nvim/sysinit.vim file exists in one of $XDG_CONFIG_DIRS, it will be
	used.  Otherwise the system vimrc file is used. The path of this file
	is given by the |:version| command.  Usually it's "$VIM/sysinit.vim".

						*VIMINIT* *EXINIT* *$MYVIMRC*
     b. Locations searched for initializations, in order of preference:
	-  $VIMINIT environment variable (Ex command line).
	-  User |config|: $XDG_CONFIG_HOME/nvim/init.vim (or init.lua).
	-  Other config: {dir}/nvim/init.vim (or init.lua) where {dir} is any
	   directory in $XDG_CONFIG_DIRS.
	-  $EXINIT environment variable (Ex command line).
	|$MYVIMRC| is set to the first valid location unless

Title: Nvim Startup Options: Headless Mode, Listening, and Initialization Process
Summary
This section details the `--headless` and `--listen` Nvim startup options. Headless mode allows running Nvim without a UI, useful for scripting and testing. The `--listen` option starts an RPC server to listen for connections. The section also outlines the Nvim initialization process, including setting the 'shell' option, processing arguments, waiting for UI connections, enabling plugins, and loading user configurations.