Neovim lspconfig plugin: attempt to call field 'nvim_multiline_command` (a nil value)

7k Views Asked by At

Recently I'm getting this error when opening a file for which I have language server installed:

(this is in neovim :messages)

Error detected while processing BufEnter Autocommands for "<buffer=403>":
E5108: Error executing lua [string ":lua"]:47: attempt to call field 'nvim_multiline_command' (a nil value)

So I went searching for nvim_multiline_command in my init.vim and surely enough I found this:

136   -- Set autocommands conditional on server_capabilities
  1   if client.resolved_capabilities.document_highlight then
  2     require('lspconfig').util.nvim_multiline_command [[
  3       :hi LspReferenceRead cterm=bold ctermbg=red guibg=LightYellow
  4       :hi LspReferenceText cterm=bold ctermbg=red guibg=LightYellow
  5       :hi LspReferenceWrite cterm=bold ctermbg=red guibg=LightYellow
  6       augroup lsp_document_highlight
  7         autocmd!
  8         autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight()
  9         autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references()
  10       augroup END
  11     ]]                                                                                                                                                                                                      12   end                                                                                                                                                                                                       13 end

(yes I copied from the terminal because my clipboard stopped working, don't show this to emacs users)

I clearly remember copying this from the official readme. Not sure why this stopped working.

1

There are 1 best solutions below

1
On

Using util_nvim_multiline_command seems to have been deprecated (Link to github commit)

I recommend going to the most recent nvim-lspconfig readme, and replacing the old version of the --Set autocommands conditional on server_capabilities section with the new one.