Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can't see suggestions together with Lsp #100

Open
sekomer opened this issue Nov 26, 2023 · 13 comments
Open

can't see suggestions together with Lsp #100

sekomer opened this issue Nov 26, 2023 · 13 comments

Comments

@sekomer
Copy link

sekomer commented Nov 26, 2023

this is my packer.lua file

...

    use {
        "zbirenbaum/copilot.lua",
        cmd = "Copilot",
        event = "InsertEnter",
        config = function()
            require("copilot").setup({
                suggestion = { enabled = false },
                panel = { enabled = false },
            })
        end,
    }

    use {
        "zbirenbaum/copilot-cmp",
        after = { "copilot.lua" },
        config = function ()
            require("copilot_cmp").setup({
                event = { "InsertEnter", "LspAttach" },
                fix_pairs = true,
            })
        end
    }

...

this is my cmp_config.lua file

local cmp = require('cmp')

print("Loading Copilot-cmp")

cmp.setup({
  sources = {
    { name = "copilot", group_index = 1, keyword_pattern = "." },
    { name = "nvim_lsp", group_index = 2 },
    { name = "buffer", group_index = 3 },
  },

  completion = {
    keyword_length = 2,
  },

  experimental = {
      ghost_text = true,
  }
})

when I'm writing code, only lsp suggestions showed, like in the next photo.
image

when there is no suggestions left, like the following
image

if I press tab, the copilot suggestions appear.
image

what's the problem, how can I get all suggestions together, without pressing tab explicitly and when there are other suggestions.

@command-z-z
Copy link

command-z-z commented Jan 9, 2024

same problem.

@Jagholin
Copy link

I think I have the same problem with no copilot suggestions appearing in the cmp menu

@kackerx
Copy link

kackerx commented Mar 28, 2024

My phenomenon is that sometimes only copilot appears in the menu, and everything else I need is cleared

@h4rldev
Copy link

h4rldev commented Apr 6, 2024

My phenomenon is that it doesn't appear at all

@FelipeMarcelino
Copy link

Same here!

@sakithb
Copy link

sakithb commented Apr 13, 2024

Same here

@praveendhawan
Copy link

same here

@ek234
Copy link

ek234 commented Apr 24, 2024

for me, cmp never contains suggestions from copilot (if I turn on suggestions and auto_trigger, I can see the ghost text containing the copilot autocompletion). tried solutions from all the issues with this problem but nothing works. I'm using nvchad, if that is relevant.

the output of my LSPInfo

Language client log: /home/ek234/.local/state/nvim/lsp.log
Detected filetype:   cpp

2 client(s) attached to this buffer:

Client: clangd (id: 1, bufnr: [1])
 filetypes:       c, cpp, objc, objcpp, cuda, proto
 autostart:       true
 root directory:  /home/ek234/hobby/opengl/shapes
 cmd:             /usr/bin/clangd --offset-encoding=utf-16

Client: copilot (id: 2, bufnr: [1])
 filetypes:
 autostart:       false
 root directory:  /home/ek234/hobby/opengl/shapes
 cmd:             node /home/ek234/.local/share/nvim/lazy/copilot.lua/copilot/index.js

Configured servers list: pyright, eslint, clangd, lua_ls

edit: this seems relevant- the output of CmpStatus is:

# ready source names       
- luasnip                  
- buffer                   
- path                     
- nvim_lsp:clangd          
# unavailable source names 
- nvim_lua                 
# unused source names      
- copilot                  

@ek234
Copy link

ek234 commented Apr 24, 2024

for me, cmp never contains suggestions from copilot (if I turn on suggestions and auto_trigger, I can see the ghost text containing the copilot autocompletion). tried solutions from all the issues with this problem but nothing works. I'm using nvchad, if that is relevant.

NVM solved it. I was not setting the nvim-cmp options correctly. solved it by doing:

  {
    "hrsh7th/nvim-cmp",
    event = "VeryLazy",
    config = function()
      local opts = require "plugins.configs.nvim-cmp"
      require("cmp").setup(opts)
    end
  },

Now I am having the OP's problem- I can only see either copilot's suggestions or other suggestions. 🥲

@praveendhawan
Copy link

So whats happening with me is when I type, suggestions from other sources come, later on copilots inserts suggestions. When those come, the other suggestions from previous sources are gone.

Kleinjohann added a commit to Kleinjohann/dotfiles that referenced this issue Jul 19, 2024
zbirenbaum/copilot-cmp#100 caused only copilot OR other suggestions to
show up in cmp, never both at the same time
@djm30
Copy link

djm30 commented Jul 23, 2024

Still happening

@sekomer
Copy link
Author

sekomer commented Jul 23, 2024

wow, its been a year but there isn't any solution

I switched to copilot.vim, and suggest all the people here the same, cuz maintainer doesn't care this issue 🤣

@lilian-lilifox
Copy link

lilian-lilifox commented Jan 7, 2025

@ek234
I use NvChad too. I tried for two hours and successfully got it run as expected. Here's my configurations.

  {
    "zbirenbaum/copilot.lua",
    cmd = "Copilot",
    event = "InsertEnter",
    config = function()
      require("copilot").setup {
        panel = {
          enabled = true,
          auto_refresh = true,
          keymap = {
            jump_prev = "[[",
            jump_next = "]]",
            accept = "<CR>",
            refresh = "gr",
            open = "<C-CR>",
          },
          layout = {
            position = "bottom", -- | top | left | right
            ratio = 0.4,
          },
        },
        suggestion = {
          enabled = true,
          auto_trigger = true,
          debounce = 75,
          keymap = {
            accept = "<C-]>",
            accept_word = "<C-Right>",
            accept_line = "<C-End>",
            next = "<M-]>",
            prev = "<M-[>",
            dismiss = "<C-[>",
          },
        },
      }
    end,
  },

  {
    "zbirenbaum/copilot-cmp",
    dependencies = { "copilot.lua" },
    event = { "InsertEnter", "LspAttach" },
    fix_pairs = true,
    config = function()
      require("copilot_cmp").setup()
      -- attach cmp source whenever copilot attaches
      -- fixes lazy-loading issues with the copilot cmp source
      vim.api.nvim_create_autocmd("LspAttach", {
        callback = function(args)
          local buffer = args.buf ---@type number
          local client = vim.lsp.get_client_by_id(args.data.client_id)
          if client and (not "copilot" or client.name == "copilot") then
            return require("copilot_cmp")._on_insert_enter(client, buffer)
          end
        end,
      })
      local cmp = require "cmp"
      local current_sources = cmp.get_config().sources or {}
      table.insert(current_sources, {
        name = "copilot",
        priority = 100,
      })
      cmp.setup {
        sources = current_sources,
      }
    end,
  },

250108_06h04m05s_screenshot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests