jubnzv / virtual-types.nvim

Neovim plugin that shows type annotations as virtual text
MIT License
375 stars 4 forks source link

error: bad argument #1 to pairs, ocamlls #3

Closed aspeddro closed 3 years ago

aspeddro commented 3 years ago

I get the folowing error: image

My config:

local on_attach = function(client, bufnr)

  local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end
  local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end

  require'virtualtypes'.on_attach()
  -- Mappings.
  local opts = { noremap=true, silent=true }

  -- See `:help vim.lsp.*` for documentation on any of the below functions
  buf_set_keymap('n', 'gD', '<Cmd>lua vim.lsp.buf.declaration()<CR>', opts)
  buf_set_keymap('n', 'gd', '<Cmd>lua vim.lsp.buf.definition()<CR>', opts)
  buf_set_keymap('n', 'K', '<Cmd>lua vim.lsp.buf.hover()<CR>', opts)
  buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
  buf_set_keymap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
  buf_set_keymap('n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
  buf_set_keymap('n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
  buf_set_keymap('n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
  buf_set_keymap('n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
  buf_set_keymap('n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
  buf_set_keymap('n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
  buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
  buf_set_keymap('n', '<space>e', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts)
  buf_set_keymap('n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts)
  buf_set_keymap('n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
  buf_set_keymap('n', '<space>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
  buf_set_keymap("n", "<space>f", "<cmd>lua vim.lsp.buf.formatting()<CR>", opts)
end

 Language client log: /home/pedro/.cache/nvim/lsp.log
 Detected filetype:   ocaml

 1 client(s) attached to this buffer: 

 Client: ocamlls (id: 1, pid: 218446, bufnr: [3, 3])
    filetypes:       ocaml, reason
    autostart:       true
    root directory:  /home/pedro/Desktop/learning-ocaml
    cmd:             /home/pedro/.local/share/nvim/lsp_servers/ocamlls/node_modules/.bin/ocaml-language-server --stdio

 Configured servers list: cmake, html, texlab, bashls, sumneko_lua, tsserver, r_language_server, yamlls, rust_analyzer, julials, ocamlls, cssls, vimls, pyright, jsonls, rescriptls
jubnzv commented 3 years ago

Hi @aspeddro,

It seems that ocamlls doesn't support textDocument/codeLens request, which contains information used by this plugin.

Could you please try to use ocaml-lsp instead? It's much more feature-rich, actively maintained by the OCaml community, and it will definitely work with virtual-types.nvim.

You can simply install via opam:

opam install ocaml-lsp-server

And configure nvim-lspconfig almost the same way you did it for ocamlls.