jayaura
December 26, 2021, 7:25pm
#1
Hi, I’m trying to configure rust_analyzer LSP server. As per the docs, I had the following in my ~/.config/nvim/init.vim
, but it isnt working:
lua << EOF
local nvim_lsp = require'lspconfig'
local on_attach = function(client)
require'completion'.on_attach(client)
end
nvim_lsp.rust_analyzer.setup({
on_attach=on_attach,
settings = {
["rust-analyzer"] = {
assist = {
importGranularity = "module",
importPrefix = "by_self",
},
cargo = {
loadOutDirsFromCheck = true
},
procMacro = {
enable = true
},
}
}
})
EOF
Here is a screenshot of the error message I’m getting:
I’m getting the same error if I put these lines in ~/.config/nvim/config/init.vim
. What am I missing ?
mjlbach
December 26, 2021, 8:17pm
#2
Seems like you don’t have lspconfig installed.
jayaura
December 27, 2021, 8:19pm
#3
I think it is installed? Because running :help lspconfig
while in nvim opens up what its supposed to:
I also verified that its installed using DeinUI plugin GitHub - wsdjeg/dein-ui.vim: UI for Shougo's dein.vim
mjlbach
December 27, 2021, 8:32pm
#4
I’m not really familiar with that plugin. What I can tell you, is that our example configuration works fine when installed via vim-plug, packer.nvim, or paq.
Maybe you have lspconfig lazy-loaded?
jayaura
December 27, 2021, 9:23pm
#6
Thats quite possible. I’m able to install the LSP servers using :LspInstall
command. I think I will start with a fresh configuration. Thanks for the responses!
Hello @jayaura , were you able to resolve this issue. I am struggling with same things when I am trying to implement lspconfig
in my init.vim
I found what I was doing wrong.
Any call to a plugin such as lua require('<plugin_name>')
should be after call plug#end()