I’m not familiar with NVChad, but in my init.vim
I’m using vim-plug as plugin manager, lsp and nvim-cmp for completion. Relevant bits:
The following Plug
lines go between the call plug#begin()
and call plug#end()
lines.
Zig syntax, formatting, etc.
Plug 'ziglang/zig.vim'
for LSP / nvim-cmp completion:
Plug 'neovim/nvim-lspconfig'
Plug 'hrsh7th/nvim-cmp'
Plug 'hrsh7th/cmp-nvim-lsp'
Plug 'hrsh7th/cmp-buffer'
Plug 'hrsh7th/cmp-path'
Plug 'hrsh7th/cmp-nvim-lua'
Plug 'hrsh7th/cmp-vsnip'
Plug 'hrsh7th/vim-vsnip'
Do a :PlugInstall
and restart nvim for plugins ti kick-in.
Then for LSP to work with ZLS (installed separately):
lua <<EOF
-- Setup nvim-cmp.
local cmp = require'cmp'
cmp.setup({
snippet = {
expand = function(args)
vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
end,
},
mapping = {
['<Tab>'] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }),
['<S-Tab>'] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }),
['<C-d>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.close(),
['<CR>'] = cmp.mapping.confirm({ select = true }),
},
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'vsnip' }, -- For vsnip users.
}, {
{ name = 'path' },
{ name = 'buffer', keyword_length = 3 },
})
})
-- Setup lspconfig.
local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())
require('lspconfig').zls.setup {
capabilities = capabilities
}
EOF
I cloned the ZLS repo and compiled it locally. Then I put a symlink to the zls
binary in /usr/local/bin
so it’s in the executable PATH. Hope this helps.
PS- I’m on macos by the way. It should also work on Linux.