coq_nvim
coq_nvim copied to clipboard
[bug] Cursor is not at the end of completion in (){}[]...
Hi @ms-jpq , I run into this bug where my cursor is not at the end of the completion in pairs of (), {}, []
. I'm not sure if this is intended or not
https://user-images.githubusercontent.com/1514823/134123953-7f41cf76-d189-4c85-9296-615808378958.mov
I Don't know if this can be related, but my custom snippets aren't working properly. After completion it puts me at the end of the snippet instead of putting my cursor at the placeholders.
Example:
Hi @babygau , it looks like you are using some plugin that automatically inserts ending braces/brackets. To my knowledge, coq doesn't do that by itself. Could you perhaps provide an init.vim
or init.lua
that would let us reproduce the bug? (Let me know if you're not sure how to do that).
@n0ks , I ran into this issue as well. The issue is that the LSP specification for snippets specifies that placeholder numbering must start at 0. But the first placeholder starts with 1 (the 1 in class ${1:ClassName} extends StatefulWidget
). I don't remember which issue @ms-jpq commented on, but she said that coq
would strictly abide by that specification.
@davidatbu I'm using auto-pairs and have keymap setup following instructions at README. The closing parenthese is expected but in my example, cursor position should be at (module_pattern|)
.
You seem to have a space before the closing parenthesis. Did you press Space to finish completion? Does this also happen if you print some other key (e.g. Enter, or a punctuation, or a letter) to finish completion?
Yes, I used SPC to complete the suggestion, and there was no space before the closing parenthese, the space was inserted after that key trigger. This did not happen with CR key though.
Does the bug still exist if you disable auto pairs?
@babygau , have you customized the keybinding to use space as the key to select a completion item from the completion menu as per the directions here?
If you haven't, what is happening is that neovim is assuming you are typing some other letter, and it is therefore typing that letter (in this case space) after inserting the completion.
Does the bug still exist if you disable auto pairs?
@zeertzjq, no, it doesn't, without the closing parenthese, SPC
to trigger completion working for me. FYI, CR
worked OK
@babygau , have you customized the keybinding to use space as the key to select a completion item from the completion menu as per the directions here?
If you haven't, what is happening is that neovim is assuming you are typing some other letter, and it is therefore typing that letter (in this case space) after inserting the completion.
@davidatbu, I do have custom keymap following the instruction:
local remap = vim.api.nvim_set_keymap
local npairs = require('nvim-autopairs')
npairs.setup({ map_bs = false })
vim.g.coq_settings = { keymap = { recommended = false } }
-- these mappings are coq recommended mappings unrelated to nvim-autopairs
remap('i', '<esc>', [[pumvisible() ? "<c-e><esc>" : "<esc>"]], { expr = true, noremap = true })
remap('i', '<c-c>', [[pumvisible() ? "<c-e><c-c>" : "<c-c>"]], { expr = true, noremap = true })
remap('i', '<tab>', [[pumvisible() ? "<c-n>" : "<tab>"]], { expr = true, noremap = true })
remap('i', '<s-tab>', [[pumvisible() ? "<c-p>" : "<bs>"]], { expr = true, noremap = true })
-- skip it, if you use another global object
_G.MUtils= {}
MUtils.CR = function()
if vim.fn.pumvisible() ~= 0 then
if vim.fn.complete_info({ 'selected' }).selected ~= -1 then
return npairs.esc('<c-y>')
else
-- you can change <c-g><c-g> to <c-e> if you don't use other i_CTRL-X modes
return npairs.esc('<c-g><c-g>') .. npairs.autopairs_cr()
end
else
return npairs.autopairs_cr()
end
end
remap('i', '<cr>', 'v:lua.MUtils.CR()', { expr = true, noremap = true })
MUtils.BS = function()
if vim.fn.pumvisible() ~= 0 and vim.fn.complete_info({ 'mode' }).mode == 'eval' then
return npairs.esc('<c-e>') .. npairs.autopairs_bs()
else
return npairs.autopairs_bs()
end
end
remap('i', '<bs>', 'v:lua.MUtils.BS()', { expr = true, noremap = true })
@babygau , have you customized the keybinding to use space as the key to select a completion item from the completion menu as per the directions here?
If you haven't, what is happening is that neovim is assuming you are typing some other letter, and it is therefore typing that letter (in this case space) after inserting the completion.
I don't think this will happen. coq
uses buf_set_text
to insert the completion, which will move the cursor, but in the recording above the cursor is not moved at all. The only possibility I can think of is that there are some other plugins changing the cursor position.
I don't think this will happen. coq uses buf_set_text to insert the completion, which will move the cursor, but in the recording above the cursor is not moved at all. The only possibility I can think of is that there are some other plugins changing the cursor position.
@zeertzjq , you're absolutely right. I somehow thought that the problem was that the cursor was after the space character, but it didn't move at all.
@bangedorrunt sorry for asking a question off the topic, but could you tell me what font are you using in the video above?