LSP config error: module lspconfig not found

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)

    settings = {
        ["rust-analyzer"] = {
            assist = {
                importGranularity = "module",
                importPrefix = "by_self",
            cargo = {
                loadOutDirsFromCheck = true
            procMacro = {
                enable = true

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 ?

Seems like you don’t have lspconfig installed.

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

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?

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!