Skip to content

Error thrown when using omnicompletion #53

@casr

Description

@casr

With the following plugins installed:

  • L3MON4D3/LuaSnip
  • hrsh7th/cmp-nvim-lsp
  • hrsh7th/nvim-cmp
  • neovim/nvim-lspconfig
  • saadparwaiz1/cmp_luasnip

And an init.lua of:

local cmp = require("cmp")
local lspconfig = require("lspconfig")

-- set only to present the error unobscured
vim.opt.pumheight = 10

cmp.setup({
  snippet = {
    expand = function(args)
      require("luasnip").lsp_expand(args.body)
    end,
  },
  mapping = cmp.mapping.preset.insert(),
  sources = cmp.config.sources({
    { name = "nvim_lsp" },
    { name = "luasnip" },
  }),
})

local capabilities = require("cmp_nvim_lsp").default_capabilities()

lspconfig.tsserver.setup({ capabilities = capabilities })

I can trigger an error by running this sequence:

  • nvim a.js
  • id<C-x><C-o>

In other words, open a JavaScript file and type id to go to insert mode and add 'd' to the buffer. This triggers nvim-cmp's completion menu to appear. If you follow up with Ctrl-x Ctrl-o to trigger omnicompletion then the error throws like below. It seems to be triggered by passing on capabilities to the client from cmp-nvim-lsp.

Screenshot 2023-04-15 at 17 52 24

And in text to help for searching issues:

Error executing vim.schedule lua callback: /opt/local/share/nvim/runtime/lua/vim/lsp.lua:2087: attempt to in
dex field 'range' (a nil value)
stack traceback:
        /opt/local/share/nvim/runtime/lua/vim/lsp.lua:2087: in function 'adjust_start_col'
        /opt/local/share/nvim/runtime/lua/vim/lsp.lua:2163: in function 'handler'
        /opt/local/share/nvim/runtime/lua/vim/lsp.lua:1394: in function ''
        vim/_editor.lua: in function <vim/_editor.lua:0>
$ nvim --version
NVIM v0.9.0
Build type: Release
LuaJIT 2.1.0-beta3

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/opt/local/share/nvim"

Run :checkhealth for more info

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions