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

feat: Add blink.cmp completion source #264

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

aliaksandr-trush
Copy link
Contributor

blink.cmp: https://github.com/Saghen/blink.cmp

Created on top of PR #251

Add possibility to enable/disable Codeium completion
simplify Server implementation by using OOP style. Now it's better work
with LSPs
@glawe
Copy link

glawe commented Nov 22, 2024

Lovely. Can't wait to until this one is merged!

xiaket added a commit to xiaket/codeium.nvim that referenced this pull request Nov 29, 2024
@aliaksandr-trush aliaksandr-trush force-pushed the blink branch 2 times, most recently from ea755ec to a7e226e Compare December 21, 2024 09:39
@aliaksandr-trush
Copy link
Contributor Author

Updated PR according to changes in v0.8.0 release: https://github.com/Saghen/blink.cmp/tree/v0.8.0

@wojtekgalaj
Copy link

Come on Santa! This will look awesome under my tree.

@aliaksandr-trush aliaksandr-trush force-pushed the blink branch 2 times, most recently from dc83b7a to e72afbc Compare December 23, 2024 21:53
@justicenyaga
Copy link

Apparently you can add nvim-cmp sources such as codeium to blink.cmp using blink.compat. Here's the link to blink compact

@icefed
Copy link

icefed commented Jan 10, 2025

Apparently you can add nvim-cmp sources such as codeium to blink.cmp using blink.compat. Here's the link to blink compact

maybe something wrong, blink compact not works for me.

  {
    "Exafunction/codeium.nvim",
    dependencies = {
      "nvim-lua/plenary.nvim",
    },
    config = function()
      require("codeium").setup({
        enable_cmp_source = false,
        virtual_text = {
          enabled = true,
        }
      })
    end
  },
-- blink-cmp
        default = { 'lsp', 'path', 'snippets', 'buffer', 'emoji', 'codeium' },
        providers = {
          emoji = {
            module = "blink-emoji",
            name = "Emoji",
            score_offset = 15,        -- Tune by preference
            opts = { insert = true }, -- Insert emoji (default) or complete its name
          },
          codeium = {
            score_offset = 3,
            name = "codeium",
            module = 'blink.compat.source',
          },
        },

@Davenchy
Copy link

Davenchy commented Jan 10, 2025

maybe something wrong, blink compact not works for me.

Set enable_cmp_source to true

This is my config and it works for me.

  {
    "Exafunction/codeium.nvim",
    event = "BufEnter",
    dependencies = { "nvim-lua/plenary.nvim" },
    opts = {
      enable_chat = true,
    },
  },
return {
  "saghen/blink.cmp",
  dependencies = {
    "rafamadriz/friendly-snippets",
    "moyiz/blink-emoji.nvim",
    "mikavilpas/blink-ripgrep.nvim",
    "saghen/blink.compat",
  },
  version = "*",

  ---@module 'blink.cmp'
  ---@type blink.cmp.Config
  opts = {
    keymap = { preset = "enter", cmdline = { preset = "enter" } },
    appearance = {
      use_nvim_cmp_as_default = true,
      -- Set to 'mono' for 'Nerd Font Mono' or 'normal' for 'Nerd Font'
      -- Adjusts spacing to ensure icons are aligned
      nerd_font_variant = "normal",
    },
    completion = {
      keyword = { range = "full" },
      list = {
        selection = function(ctx)
          return ctx.mode == "cmdline" and "auto_insert" or "preselect"
        end,
      },
      documentation = {
        window = { border = "rounded" },
        --   auto_show = true,
        --   auto_show_delay_ms = 500,
      },
      menu = {
        border = "rounded",
        draw = {
          columns = {
            { "label", "label_description", gap = 1 },
            { "kind_icon", "kind" },
          },
        },
      },
      ghost_text = { enabled = true },
    },
    -- Default list of enabled providers defined so that you can extend it
    -- elsewhere in your config, without redefining it, due to `opts_extend`
    sources = {
      default = {
        "codeium",
        "lazydev",
        "lsp",
        "path",
        "snippets",
        "buffer",
        "ripgrep",
        "emoji",
      },
      providers = {
        codeium = {
          name = "codeium",
          module = "blink.compat.source",
        },
        lazydev = {
          name = "LazyDev",
          module = "lazydev.integrations.blink",
          score_offset = 100,
        },
        emoji = {
          name = "Emoji",
          module = "blink-emoji",
        },
        ripgrep = {
          name = "Ripgrep",
          module = "blink-ripgrep",
        },
      },
    },
    signature = { enabled = true, window = { border = "rounded" } },
  },
  opts_extend = { "sources.default" },
}

In Rust projects, the following error message keeps appearing:

Error executing lua callback: ...are/nvim/lazy/blink.cmp/lua/blink/cmp/lib/text_edits.lua:91: index out of range
stack traceback:
	[C]: in function '_str_byteindex_enc'
	...are/nvim/lazy/blink.cmp/lua/blink/cmp/lib/text_edits.lua:91: in function 'get_line_byte_from_position'
	...are/nvim/lazy/blink.cmp/lua/blink/cmp/lib/text_edits.lua:146: in function 'to_utf_8'
	...are/nvim/lazy/blink.cmp/lua/blink/cmp/lib/text_edits.lua:130: in function 'get_from_item'
	...link.cmp/lua/blink/cmp/completion/windows/ghost_text.lua:70: in function 'draw_preview'
	...link.cmp/lua/blink/cmp/completion/windows/ghost_text.lua:33: in function <...link.cmp/lua/blink/cmp/completion/windows/ghost_text.lua:32>
Error executing lua callback: ...are/nvim/lazy/blink.cmp/lua/blink/cmp/lib/text_edits.lua:91: index out of range
stack traceback:
	[C]: in function '_str_byteindex_enc'
	...are/nvim/lazy/blink.cmp/lua/blink/cmp/lib/text_edits.lua:91: in function 'get_line_byte_from_position'
	...are/nvim/lazy/blink.cmp/lua/blink/cmp/lib/text_edits.lua:146: in function 'to_utf_8'
	...are/nvim/lazy/blink.cmp/lua/blink/cmp/lib/text_edits.lua:130: in function 'get_from_item'
	...link.cmp/lua/blink/cmp/completion/windows/ghost_text.lua:70: in function 'draw_preview'
	...link.cmp/lua/blink/cmp/completion/windows/ghost_text.lua:33: in function <...link.cmp/lua/blink/cmp/completion/windows/ghost_text.lua:32>

Update:
Disabling ghost_text resolved the issue, and the error no longer appears.

@icefed
Copy link

icefed commented Jan 11, 2025

@Davenchy 😂
i forgot enable_cmp_source, it works now, thanks.

@hkhrithik007
Copy link

mine idk it works or not but it dosnt show codeium icon or any blank icon
both
Screenshot 2025-02-16 at 4 40 00 PM

@hkhrithik007
Copy link

but i dont think its working as it dosnt show any suggestions

@aemonge
Copy link

aemonge commented Feb 17, 2025

No merge yet ?

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

Successfully merging this pull request may close these issues.

8 participants