Recently, a new PR was merged in Neovim's repository that adds two new functions to Neovim's API:
vim.lsp.config
vim.lsp.enable
Using these functions together should make basic configuration of LSPs in Neovim much easier with less boilerplate overall. These don't necessary make any other neovim plugins obsolete (like nvim.lspconfig) but they are meant to make the lower level API for configuring/enabling LSPs easier and more intuitive.
NOTE: This change is in master
branch but has NOT yet included in a tagged release!
Here are some notes from the actual PR (found in the link below).
vim.lsp.config
Here is an example of the new vim.lsp.config
function in action.
-- Set default root marker for all clients
vim.lsp.config('*', {
root_markers = { '.git' },
})
-- Set default configuration for clangd but don't enable it
vim.lsp.config.clangd = {
cmd = {
'clangd',
'--clang-tidy',
'--background-index',
'--offset-encoding=utf-8',
},
root_markers = { '.clangd', 'compile_commands.json' },
filetypes = { 'c', 'cpp' },
}
vim.lsp.enable in use
vim.lsp.enable(name)
Used to enable servers of name. Uses configuration defined via vim.lsp.config()
.
Examples:
vim.lsp.enable('clangd')
Client configuration sources lsp/
to resolve configurations.
Only done once per enabled configuration.
Redone if vim.lsp.config[name] is accessed (read or modified).
Check out the link below for more information!