haskell / lsp

Haskell library for the Microsoft Language Server Protocol
360 stars 89 forks source link

Error in $.params.capabilities: When parsing the constructor ClientCapabilities of type Language.LSP.Types.ClientCapabilities.ClientCapabilities expected Object but got Array #472

Closed Kleidukos closed 1 year ago

Kleidukos commented 1 year ago

Your environment

Which OS do you use?: Fedora 37

Which version of GHC do you use and how did you install it? GHC 9.4.4 with ghcup

How is your project built (alternative: link to the project)? cabal

Which LSP client (editor/plugin) do you use? neovim + haskell-tools

Which version of HLS do you use and how did you install it? haskell-language-server version: 1.9.0.0 (GHC: 9.4.4) compiled from HEAD with ghcup

Have you configured HLS in any way (especially: a hie.yaml file)? no hie.yaml but here is my haskell-tools configuration:

  hls = {
    -- See nvim-lspconfig's  suggested configuration for keymaps, etc.
    on_attach = function(client, bufnr)
      local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end
      local opts = vim.tbl_extend('keep', def_opts, { buffer = bufnr, })
      -- haskell-language-server relies heavily on codeLenses,
      -- so auto-refresh (see advanced configuration) is enabled by default
      -- vim.keymap.set('n', '<space>ca', vim.lsp.codelens.run, opts)
      -- default_on_attach(client, bufnr)  -- if defined, see nvim-lspconfig
      buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
      vim.keymap.set('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
      vim.keymap.set('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
      vim.keymap.set('n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
      vim.keymap.set('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
      vim.keymap.set('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
      vim.keymap.set('n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
      vim.keymap.set('n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
      vim.keymap.set('n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
      vim.keymap.set('n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
      vim.keymap.set('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
      vim.keymap.set('n', '<space>e', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts)
      vim.keymap.set('n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts)
      vim.keymap.set('n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
      vim.keymap.set('n', '<space>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
      vim.keymap.set('n', '<space>f', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)

      vim.keymap.set('n', '<F3>', '<cmd>TroubleToggle<CR>', opts)
      vim.keymap.set('n', '<F4>', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
      vim.keymap.set('n', '<F5>', '<cmd>lua vim.lsp.codelens.run()<CR>', opts)
      vim.keymap.set('n', '<F2>', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
    end,
  },
}

Steps to reproduce

Start HLS and look at the log file

Expected behaviour

There should be no error decoding capabilities

Actual behaviour

2023-02-12T21:13:43.587022Z | Info | Starting LSP server...
  If you are seeing this in a terminal, you probably should have run WITHOUT the --lsp option!
  PluginIds: [ pragmas
             , qualifyImportedNames
             , moduleName
             , splice
             , alternateNumberFormat
             , changeTypeSignature
             , ormolu
             , gadt
             , ghcide-completions
             , cabalfmt
             , retrie
             , ghcide-code-actions-type-signatures
             , ghcide-hover-and-symbols
             , rename
             , codeRange
             , ghcide-code-actions-bindings
             , stylish-haskell
             , refineImports
             , hlint
             , LSPRecorderCallback
             , floskell
             , importLens
             , ghcide-code-actions-imports-exports
             , ghcide-extend-import-action
             , ghcide-code-actions-fill-holes
             , class
             , ghcide-type-lenses
             , fourmolu
             , explicit-fields
             , cabal
             , callHierarchy
             , ghcide-core
             , explicit-fixity ]
2023-02-12T21:13:43.587150Z | Info | Starting server
2023-02-12T21:13:43.587462Z | Error | Got error while decoding initialize:
Error in $.params.capabilities: When parsing the constructor ClientCapabilities of type Language.LSP.Types.ClientCapabilities.ClientCapabilities expected Object but got Array.
michaelpj commented 1 year ago

Should be fixed with the new lsp version.