LuaSnip icon indicating copy to clipboard operation
LuaSnip copied to clipboard

LSP snippet: end_row out of bounds

Open f3fora opened this issue 3 years ago • 8 comments

<Plug>luasnip-expand-or-jump raises sometimes an error after an expansion of a LSP snippet . It happens "randomly", because actually I haven't found yet a way to reproduce it. The error: LuaSnip/lua/luasnip/nodes/snippet.lua:318: end_row out of bounds

I know that require('luasnip').expand_or_jumpable() returns true.

f3fora avatar May 16 '21 13:05 f3fora

Sounds like something is messing with extmarks and moving them beyond the end of the line (hence 'end_row out of bounds'). I think that can happen if the line is changed with nvim_set_text(), my best guess would be that something (lsp? compe?) is setting the text in the line at some point, which would explain the random nature of the issue. Does this happen on all LSPs? Which version of compe are you on?

L3MON4D3 avatar May 16 '21 14:05 L3MON4D3

nvim-compe master I know it happens with texlab. I don't use other lsp so often in this period.

f3fora avatar May 16 '21 15:05 f3fora

Okay, I didn't experience your error with texlab (so far), but I did notice that, after updating compe (which I didn't do for some time), ccls-Snippet's extmarks get moved around after expansion, while Snippets from other LSPs (rust-analyzer) still work fine. Could you check if you have the same issue with compe@4b3ade1, which is the last version I used. On a side note, does the \begin-Snippet work for you? I just tried it and when entering text into $1 and leaving it, it completely removes the\end-part.

L3MON4D3 avatar May 16 '21 19:05 L3MON4D3

Could you check if you have the same issue with compe@4b3ade1, which is the last version I used.

I tested using master and this commit. I got the same results.

ccls-Snippet's extmarks get moved around after expansion, while Snippets from other LSPs (rust-analyzer) still work fine.

For me they work fine. Actually I used ccls for a few tests, I personally use clangd.

On a side note, does the \begin-Snippet work for you? I just tried it and when entering text into $1 and leaving it, it completely removes the\end-part.

Yes, it works. Actually I discover the issue #20 using this Snippet.

f3fora avatar May 17 '21 07:05 f3fora

Wow, weird... different nvim maybe? I'm on NVIM v0.5.0-dev+1323-gd67dcaba0. Apart from that, have you tried disabling all plugins except compe and luasnip?

L3MON4D3 avatar May 17 '21 09:05 L3MON4D3

Different version of nvim NVIM v0.5.0-dev+1231-g48e805728. But with only compe, luasnip and lspconfig, texlab snippets work correctly.

f3fora avatar May 18 '21 19:05 f3fora

Okay, that's good to know. Do you have any linters or similar tools installed that could set text for the entire buffer? To further debug, you could :lua Luasnip_current_nodes[vim.api.nvim_get_current_buf()].parent:dump() after the misbehaviour to see node boundaries (eg. where extmarks get moved to).

L3MON4D3 avatar May 18 '21 20:05 L3MON4D3

Thanks! If I find a way to reproduce it I will continue this issue! Great plugin however

f3fora avatar May 18 '21 20:05 f3fora