Nvim custom LSP Error: INVALID_SERVER_MESSAGE: vim.empty_dict()

Hi,

I have been working on a custom language server and have been getting the following error after opening php files and making actions like textDocument/didOpen or textDocument/didChange

LSP[laravel-language-server]: Error INVALID_SERVER_MESSAGE: vim.empty_dict()

I have included the language-server in my nvim setup like this in .config/nvim/after/ftplugin/php.lua

vim.lsp.start {
  name = 'laravel-language-server',
  cmd = {
    'npx',
    'ts-node',
    vim.fn.expand '~/code/laravel-language-server/server/src/server.ts',
  },
  capabilities = vim.lsp.protocol.make_client_capabilities(),
  settings = {}, -- also tried vim.empty_dict()
  init_options = {}, -- also tried vim.empty_dict()
  root_dir = vim.fn.getcwd(), 
}

I have been initializing the server with the initalize()-response like this:

export const initialize = (message: RequestMessage): InitializeResult => {
  return {
    capabilities: {
      textDocumentSync: {
        save: { includeText: true },
        change: 1, // incremental
        openClose: true,
      },
      completionProvider: {},
      definitionProvider: {},
    },
    serverInfo: {
      name: "laravel-language-server",
      version: "0.0.1",
    },
  };
};

This is the repository: https://github.com/felixele217/laravel-language-server

The LS implementation has to be at least somewhat correct since go to definition behaviour works and the initialize methods are properly logged in the custom implemented log.

Any ideas on how to solve or at least ignore the error?

Thanks in advance :slight_smile: