nvim-cmp
nvim-cmp copied to clipboard
start_col out out of bounds on suggestion select
FAQ
- [X] I have checked the FAQ and it didn't resolve my problem.
Announcement
- [X] I have checked Breaking change announcement.
Minimal reproducible full config
I'm using nvim-cmp via SpaceVim so here's the config
lua <<EOF
-- Setup nvim-cmp.
local cmp = require'cmp'
cmp.setup({
mapping = cmp.mapping.preset.insert({
['<C-d>'] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }),
['<C-f>'] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }),
['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }),
['<C-y>'] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `<C-y>` mapping.
['<C-e>'] = cmp.mapping({
i = cmp.mapping.abort(),
c = cmp.mapping.close(),
}),
['<CR>'] = cmp.mapping.confirm({ select = true }),
['<Tab>'] = function(fallback)
if cmp.visible() then
cmp.select_next_item()
else
fallback()
end
end,
['<S-Tab>'] = function(fallback)
if cmp.visible() then
cmp.select_prev_item()
else
fallback()
end
end,
}),
formatting = {
format = require("lspkind").cmp_format({with_text = true, menu = ({
buffer = "[Buffer]",
})}),
},
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
}, {
{ name = 'buffer' },
}, {
{ name = 'path' },
})
})
-- The nvim-cmp almost supports LSP's capabilities so You should advertise it to LSP servers..
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities)
-- The following example advertise capabilities to `clangd`.
require'lspconfig'.clangd.setup {
capabilities = capabilities,
}
EOF
Description
Often (but unfortunately not with 100% probability) selecting a suggested item by pressing <CR> does not work as expected which causes an error and thus completely disables autocomplete, at least for currently opened buffer. Here's the error:
E5108: Error executing lua /usr/share/nvim/runtime/lua/vim/lsp/util.lua:428: start_col out of bounds
stack traceback:
[C]: in function 'nvim_buf_set_text'
/usr/share/nvim/runtime/lua/vim/lsp/util.lua:428: in function 'apply_text_edits'
...files/repos/github.com/hrsh7th/nvim-cmp/lua/cmp/core.lua:436: in function <...files/repos/github.com/hrsh7th/nvim-cmp/lua/cmp/core.lua:409>
...s/github.com/hrsh7th/nvim-cmp/lua/cmp/utils/feedkeys.lua:47: in function <...s/github.com/hrsh7th/nvim-cmp/lua/cmp/utils/feedkeys.lua:45>
Sometimes it just autocompletes in the wrong place. For example if I want to write new Deposit()
:
- I write
new Dep
which causes suggestion list to drop down. - I select
Deposit
constructor. - Autocomplete result is:
Deposit() new Dep
or smth similar.
So it autocompletes in the wrong place of buffer. Seems like sometimes that place is in buffer(or line) bounds and sometimes is not.
The issue occurs with SpaceVim consisting of neovim + intelephense (php lsp server). And at least happens while autocompleting constructors. I didn't encounter any issues while autocompleting method name (while being called on an object). Maybe it's a coincidence, I don't know.
SpaceVim uses not the latest version of nvim-lsp. I've upgraded to latest 706371f1300e7c0acb98b346f80dad2dd9b5f679 and re-checkd everything. No results - it's repoducable on the latest version too, only line numbers slightly change in stacktrace.
Steps to reproduce
Setup
- neovim.
- it's built-in lsp.
- install intelephense.
- configure neovim's built-in lsp to embrace intelephense for php projects/files.
- completely initialize a php project (incl. installing deps via composer).
- set up nvim-cmp with config provided above.
- try (several times! it's important!) to autocomplete constructor name for any class.
Expected behavior
Autocompletion should be performed after the cursor and without errors
Actual behavior
Autocompletion is happening before cursor, often at the start of line. Sometimes it causes an error (see stacktrace above).
Though actually interconnection of the abovementioned error with cases of autocompletion being performed into the wrong place of line is currently just my suggestion and should be proofed.
Additional context
No response
NVIM v0.7.2
There is the same problem.
![wecom-temp-511a26b4b2c8135a77d95197174e4dd6](https://user-images.githubusercontent.com/4273490/184525916-787787b1-fe01-43b7-926d-e6f2c9b6ffbd.png)
I think PHP omnifunc doesn't support asynchronous behavior. You should not use it.
I think it should be reproduce-able without SpaceVim.
Probably, the reason is that nvim-cmp doesn't support offsetEncoding
spec (that defined in LSP).
Probably, if we support LSP 3.17, this problem will be elliminated.
I am facing the same issue every now and then with Rust and LunarVim.
Same issue here with lunarvim/latex. Has anyone found a solution for that?
I've supported the offsetEncoding
. Could you test with latest master?
I'm closing this at the moment. If the problem still exists, feel free to re-open this.
I'm experiencing this same issue when working with neovim lua scripts. It is seemingly randomly occuring and then appears to completely break nvim-cmp. Completions do not appear any longer unless I reload the plugin or restarting neovim. Is there anything further we could provide to help clear up this?
If you have some problems, please open new issue with detailed information :)