ms-jpq / coq_nvim

Fast as FUCK nvim completion. SQLite, concurrent scheduler, hundreds of hours of optimization.
GNU General Public License v3.0
3.47k stars 96 forks source link

**github co-pilot** -- MVP ok to use! #379

Closed ms-jpq closed 2 years ago

ms-jpq commented 2 years ago

https://github.com/ms-jpq/coq.thirdparty

require("coq_3p") {
  { src = "copilot", short_name = "COP", tmp_accept_key = "<c-r>" }
}
ms-jpq commented 2 years ago

here is a quick job on getting copilot to co-exist with coq, just got into tech preview today and will take more time to get it to work better.

It's really not ideal, right now to accept co-pilot suggestions, its an additional hotkey. Since I just got the invite to the tech preview this afternoon, I havn't figured out how to do this more elegantly, but its better than nothing. the idea is that you can just use this, and by the time i figure it out, you can just update the git repo and everything will be done better.

aprowe commented 2 years ago

Im trying this out, the only issue I am running into is that if there are completion suggestions as well as a co-pilot suggestion, the co-pilot suggestion disappears after like 0.1 seconds, basically just flickers. If there are no completion suggestions, the co-pilot feature works as intended. Thanks!

kyrisu commented 2 years ago

@aprowe disabling fast_close should help. My understanding is that when the pum window is closed and reopened it re-renders the screen and hides the ghost text:

vim.g.coq_settings = {
  auto_start = true,
  display = {
    pum = {
      fast_close = false
    }
  }
}
yingzhu146 commented 2 years ago

@kyrisu does this work for you still? for me adding your suggested settings to my init.lua doesn't help - still just flickers. @ms-jpq - again thanks a ton for this, you're a legend. any suggestions on the flicker though?

kyrisu commented 2 years ago

@yingzhu146 I'm actually experiencing the same as @aprowe - with no completion suggestions copilot works as expected with then it disappears.

yingzhu146 commented 2 years ago

yep same here!

PlatyPew commented 2 years ago

I'm also experiencing the same issue with the ghost text flickering, would love some suggestions @ms-jpq. Thanks for the amazing work!

ms-jpq commented 2 years ago

I made some updates a few days ago and it should work better now.

The issue remains that copilot is very slow compared to other completion sources and the interm solution is just to add an accept key as normal and in cases where copilot responds fast enough, it will show up in the suggestions menu.

which should be pretty similar to how VScode does it or something.

PlatyPew commented 2 years ago

Not sure if I'm doing anything wrong but ghost text for copilot still flickers

https://user-images.githubusercontent.com/23520617/147941411-4e1c29ff-1fb3-4a6d-bee4-afa4ef91fb97.mov

Here's my config:

-- coq settings
vim.g.coq_settings = {
    auto_start = 'shut-up',
    clients = {
        tabnine = {
            enabled = true,
        },
    },
    keymap = {
        recommended = false,
        jump_to_mark = '<c-e>',
    },
}

local lspconfig = require'lspconfig'
local coq = require'coq'
local coq_3p = require'coq_3p'
local lspinstall = require'nvim-lsp-installer'

-- Snippet support
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities.textDocument.completion.completionItem.snippetSupport = true

-- Loops through installed LSPs
lspinstall.on_server_ready(function(server)
    local config = {
        capabilities = capabilities,
        flags = { debounce_text_changes = 500 },
        on_attach = function(client)
            client.resolved_capabilities.document_formatting = false
            client.resolved_capabilities.document_range_formatting = false
        end,
    }

    server:setup(coq.lsp_ensure_capabilities(config))
end)

coq_3p{
    { src = 'copilot', short_name = 'COP', accept_key = '<C-f>' },
}
Monirzadeh commented 2 years ago

my config is init not lua how should that to work with copilot for now if i active coq copilot not show any suggestion

yavko commented 2 years ago

For me copilot suggestions are always there, but when i open the coq_menu they go away but its very annoying because they always cover my code image