Neovim is the world’s most-loved editor. That’s just science:
Here are some highlights from Neovim 2022 (Nvim 0.8) development.
Eye candy first!
:set laststatus=3
'winbar'
is like an extra statusline at the top of each window. It complements laststatus=3
:
set winbar=%f
set laststatus=3
'winbar'
and 'statusline'
gained support for mouse-click regions (as ‘tabline’ has had since 2016):
:set cmdheight=0
:set mousescroll=ver:5,hor:2
:set rnu nu
:let &stc='%#NonText#%{&nu?v:lnum:""}%=%{&rnu&&(v:lnum%2)?"\ ".v:relnum:""}%#LineNr#%{&rnu&&!(v:lnum%2)?"\ ".v:relnum:""}'
:set jumpoptions=view
vim.lsp.start({ name = 'godot', cmd = vim.lsp.rpc.connect('127.0.0.1', 6008) })
LspAttach
, LspDetach
. Example:
vim.api.nvim_create_autocmd('LspAttach', {
group = yourGroupID,
callback = function(args)
local client = vim.lsp.get_client_by_id(args.data.client_id)
your_callbac_func(client, args.buf)
end
}
vim.lsp.get_active_clients()
learned to filter (this will be a standard pattern in the Lua stdlib):
get_active_clients({id=42})
get_active_clients({bufnr=99})
get_active_clients({name='tsserver'})
:set diffopt+=linematch:60
vim.g.editorconfig_enable = false
'inccommand'
feature (since 2017), which show the effects of :substitute
(:s/foo/bar
) as you type.:normal
and macros:
:normal
, :global, etc.
vim.api.nvim_create_user_command(
'MyCmd',
my_cmd,
{ …, preview = my_cmd_preview })
:write
command gained the ++p
flag, so this creates parent/dir/ if it doesn’t exist:
:edit parent/dir/file.txt
:write ++p
$XDG_STATE_HOME
(~/.local/state) instead of $XDG_CACHE_HOME
(~/.cache). This change only affects macOS/unix, the Windows locations are unchanged.stdpath('log')
to get the recommended location for log files.:help :Man
) shows an outline (table of contents) in the location list. Now the outline also lists the flags.
before:
9.0ms: sourcing …/runtime/filetype.vim
after:
1.3ms: sourcing …/runtime/filetype.lua
nvim --startuptime
now reports Lua require()
times.
000.010 000.010: --- NVIM STARTING ---
000.198 000.188: event init
...
026.333 001.109 001.101: require('vim.lsp.protocol')
028.144 000.423 000.423: require('vim.lsp._snippet')
...
mouse=nvi
Type ":" (cmdline-mode) to temporarily disable mouse. Right-click shows a popup menu.
Try it!
nvim_cmd([list])
and “user cmd-preview”! And super useful for defining custom cmdline (:
) behavior.
:echo nvim_parse_cmd('.,$g/foo/bar', {})
{
'cmd': 'global',
'args': ['/foo/bar'],
'mods': {…},
'magic': {'file': v:false, 'bar': v:false}
}
nvim_cmd()
to call any Vim legacy command in a structured way, like system([...])
.
fnameescape()
: special chars are controlled by the magic
param.
nvim_cmd({cmd='vimgrep', args={'/%s/j', '**'}}, {})
vim.fs.find()
is now the canonical way to find “root files”, common for LSP configuration.vim.cmd
is the Lua nvim_cmd
wrapper. It supports calling Ex commands as functions instead of strings:
vim.cmd.colorscheme('nightfox')
“Lua plugins are basically the same as a vim plugin, except the file extension is
.lua
instead of.vim
and the file contains Lua code instead of Vimscript.”
Automated generation of the online Nvim documentation was rewritten by replacing an old AWK script with Lua + tree-sitter. We can have nice things.
Compare the old layout (left) to the new one (right):
Nvim now sets the $NVIM
environment variable in jobstart()
and :terminal
jobs, so child processes have an unambiguous hint that they are children of Nvim. The old $NVIM_LISTEN_ADDRESS
, which had conflicting “dual purposes”, is no longer passed to children.
Nvim UIs are just (inverted) plugins. And now nvim
itself is a self-hosting UI: when you run nvim
in a terminal, it starts the TUI as a nvim --embed
child process.
Just like Nvim GUIs, you can connect the nvim
TUI to any Nvim server to see its UI! You can try it right now:
./foo
(creates a foo
file in the current directory):
nvim --listen ./foo
./foo
), connect nvim
to the server:
nvim --remote-ui --server ./foo
'insertmode'
option, which was used in Vim to implement “easy vim”.
:help 'insertmode'
.:help lsp
).
Find more updates in the news archive. There's also an RSS feed.
Neovim is a Vim-based text editor engineered for extensibility and usability, to encourage new applications and contributions.
Visit #neovim:matrix.org or #neovim on irc.libera.chat to chat with the team.