Open JosefLitos opened 2 months ago
I am using your master branch (couldn't open an issue there), and my expectation was that I would be able to see completions on a new line. I may be doing something wrong. Hope you can help
Here is my config for cmp.
`M.cmp = function() local cmp = require("cmp") local luasnip = require("luasnip") local lspkind = require("lspkind")
luasnip.config.setup(M.luasnip)
cmp.setup({
experimental = {
ghost_text = true,
},
sorting = {
priority_weight = 10,
comparators = {
require("cmp_copilot.comparators").prioritize,
-- Below is the default comparitor list and order for nvim-cmp
cmp.config.compare.offset,
-- cmp.config.compare.scopes, --this is commented in nvim-cmp too
cmp.config.compare.exact,
cmp.config.compare.score,
cmp.config.compare.recently_used,
cmp.config.compare.locality,
cmp.config.compare.kind,
cmp.config.compare.sort_text,
cmp.config.compare.length,
cmp.config.compare.order,
},
},
---@diagnostic disable-next-line: missing-fields
formatting = {
format = lspkind.cmp_format({
mode = "symbol",
max_width = 50,
symbol_map = { Copilot = "" },
}),
},
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
end,
},
completion = {
keyword_length = 0,
--keyword_pattern = "",
-- completeopt = "menu,menuone,noinsert,noselect",
},
mapping = require("mappings").cmp(),
sources = {
{ name = "copilot", group_index = 2 },
{ name = "nvim_lsp", group_index = 2 },
{ name = "luasnip", group_index = 2 },
{ name = "path", group_index = 2 },
{ name = "vim-dadbod-completion", group_index = 2 },
},
})`
Plugins:
return {
{
"JosefLitos/cmp-copilot",
opts = {},
config = function()
require("cmp_copilot").setup()
end,
},
{
"zbirenbaum/copilot.lua",
cmd = "Copilot",
config = function()
require("copilot").setup({
suggestion = { enabled = false },
panel = { enabled = false },
})
end,
}}
I forgot to allow issues at the fork - now fixed, thanks.
Can you not get completions from copilot at all, or just not automatically? I got used to having to manually ask/complete() for them, but I agree it should give suggestions on its own. I don't think I can make it work with no text written though - it triggers only when any of trigger chars are pressed.
Unfortunately keyword length seems to only limit how many characters must be pressed before the completion shows in the menu, not when the completion triggers.
Only trigfer char usable for this would be probably the space key, but I will try if messing with isIncomplete helps.
It is working, just not with tab or space. It appears pressing . is what triggers the autocompletions
I've set isIncomplete
to always be true, that way cmp keeps sending requests for results. Copilot seems to detect when the text changes and only then refresh the results, so it doesn't seem to drain the cpu in any way. Without that the completion wouldn't refresh when the user types any text.
The main thing you were probably looking for was adding Space and Tab to the trigger chars - gets triggered immediately when there is any indentation on the new line.
I'm afraid without indentation this is impossible to do (outside seeing an old completion list because of another cmp
bug).
Hi @JosefLitos, thank you for the fix. I have some trouble in using this fork version. After hit the enter key to input the completion text, there is always the markdown code chunk marks around the code. One example:
When enter
The output become:
There are more fixes to be done, but I will leave those just in my fork to not clutter the diff so much.
This is also not the prettiest fix, but it works. Though I do intend (when I have the time) to make it cleaner and simplify the prefix issue.
After digging into these empty line issues a little bit more, I managed to fully fix it. Here are the conclusions I've come to when figuring out what's most likely going on:
get_keyword_pattern()
returned.
-> it requied any charactercmp
seems to consider empty lines as fitting the pattern, but not indented onescmp_tabnine
didn't have this issue and it also turned out that it didn't have this method eithercmp
seems to prohibit changing the text before the cursor, where line indentation iscopilot
atribute was in a deeper nested table, so the comparator was always accessingnil