Using old vim configs
Neovim has moved the location of default config under $XDG_CONFIG, but there is a snippet to load them in:set runtimepath^=~/.vim runtimepath+=~/.vim/after let &packpath = &runtimepath source ~/.vim/vimrc
undodir
Neovim has an incompatible undo format with base vim, so override undodir in init.vim. I recommend following XDG in this case:
set undodir=~/.local/state/nvim/undodir
cmdheight = 0
Vim doesn't allow one to hide the command line. I had posted a half working patch to github in 2014: [1]. It was finally fully implemented by a guy from japan in 2022: [2]Trailing Tildes
Vim has forever used ~s as filler characters at the end of the buffer. In neovim, this behavior can be disabled with:set fcs=eob:\With a trailing space, so that space is the character printed instead.
Plugin Ecosystem
Neovim can use vim plugins, but it also supports plugins written in lua. Apparently the most popular plugin manager is packer.nvim To install it, clone the repository into your home directory:git clone --depth 1 https://github.com/wbthomason/packer.nvim\ ~/.local/share/nvim/site/pack/packer/start/packer.nvimYou can then activate it by adding the below to your init.vim:
lua require('plugins')
Language Server Protocol
LSP is an api that allows language-specific IDE features such as jumping to defintions, which largely replaces the tags features in regular vim.
While neovim has a built in client, it does not come with the LSP server nor with any integration with the user interface. More plugins are required.
The below plugins can be installed via packer by adding them to `plugins.lua`:
use { "williamboman/mason.nvim", "williamboman/mason-lspconfig.nvim", "neovim/nvim-lspconfig", }
`mason.vim` is a package manger neovim for installing external editor tools such as LSP servers, debuggers, linters, formatters, and so on that are not themselves vim plugins.
`nvim-lspconfig` is the official if not officially supported set of LSP configuration files for neovim.
`mason-lspconfig.nvim` is an adaptor package to allow mason to install and configure LSP.
After incorporating the above use lines into your config, you can trigger packer using `:PackerSync` in command mode.
From there, you can enable the mason plugins by adding them to the plugins.lua script:
require("mason").setup() require("mason-lspconfig").setup()
Assumming that worked, you can use `:LspInstall` and related commands to download and install a mason packaged version of a LSP server to your local configuration
However, we are not done yet. While you can integrate the LSP into the built-in OmniFunc completion, an autocompletion plugin is recommended. [3]
`nvim-cmp` is the recommended autocomplete plugin. Add the below to install it and it's dependencies:
use { -- Autocompletion 'hrsh7th/nvim-cmp', requires = { 'hrsh7th/cmp-nvim-lsp', 'L3MON4D3/LuaSnip', 'saadparwaiz1/cmp_luasnip' } }Don't forget to re-sync packer.
Next, you have to configure the LSP plugin with the autocompletion capabilities:
local capabilities = require("cmp_nvim_lsp").default_capabilities() require("mason-lspconfig").setup_handlers { -- The first entry (without a key) will be the default handler -- and will be called for each installed server that doesn't have -- a dedicated handler. function (server_name) -- default handler (optional) require("lspconfig")[server_name].setup { capabilities = capabilities } end, }
Each LSP server you install and use will need to be configured in a similar manner.
Finally, I recommend you add the key mappings as mentioned on the Autocompletion wiki page.
NB: Many LSPs are implemented in js and require a new(ish) version of node to function.
If you get "Client Errors" when nvim tries to start an LSP, check the log using :LspLog
and potential upgrading node.