From f1e340fa891736c9d8c5737d405c0572a598e1a5 Mon Sep 17 00:00:00 2001 From: Taken Date: Sun, 22 Dec 2024 16:01:13 +0100 Subject: [PATCH] Trying out blink cmp --- lua/taken/plugins/blink.lua | 67 +++++++++++++++++++++++++++++ lua/taken/plugins/lsp/lspconfig.lua | 8 ++-- lua/taken/plugins/nvim-cmp.lua | 1 + 3 files changed, 73 insertions(+), 3 deletions(-) create mode 100644 lua/taken/plugins/blink.lua diff --git a/lua/taken/plugins/blink.lua b/lua/taken/plugins/blink.lua new file mode 100644 index 0000000..4ac3b81 --- /dev/null +++ b/lua/taken/plugins/blink.lua @@ -0,0 +1,67 @@ +return { + "saghen/blink.cmp", + dependencies = "rafamadriz/friendly-snippets", + version = "*", + config = function() + require("blink-cmp").setup({ + appearance = { + use_nvim_cmp_as_default = true, + nerd_font_variant = "mono", + }, + keymap = { + preset = "enter", + + [""] = {}, + [""] = {}, + [""] = { "show", "show_documentation", "hide_documentation" }, + }, + sources = { + default = { "lsp", "luasnip", "snippets", "buffer", "path" }, + providers = { + lsp = { + name = "lsp", + enabled = true, + module = "blink.cmp.sources.lsp", + -- kind = "LSP", + -- fallbacks = { "snippets", "luasnip", "buffer" }, + score_offset = 90, + }, + luasnip = { + name = "luasnip", + enabled = true, + module = "blink.cmp.sources.luasnip", + min_keyword_length = 2, + -- fallbacks = { "snippets" }, + score_offset = 85, + }, + snippets = { + name = "snippets", + enabled = true, + module = "blink.cmp.sources.snippets", + score_offset = 80, + }, + buffer = { + name = "Buffer", + module = "blink.cmp.sources.buffer", + min_keyword_length = 2, + }, + path = { + name = "Path", + module = "blink.cmp.sources.path", + score_offset = 3, + fallbacks = { "snippets", "luasnip", "buffer" }, + opts = { + trailing_slash = false, + label_trailing_slash = true, + get_cwd = function(context) + return vim.fn.expand(("#%d:p:h"):format(context.bufnr)) + end, + show_hidden_files_by_default = true, + }, + }, + }, + }, + }) + end, + opts_extend = { "sources.default" }, +} diff --git a/lua/taken/plugins/lsp/lspconfig.lua b/lua/taken/plugins/lsp/lspconfig.lua index 465d875..ccad216 100644 --- a/lua/taken/plugins/lsp/lspconfig.lua +++ b/lua/taken/plugins/lsp/lspconfig.lua @@ -3,7 +3,8 @@ return { "neovim/nvim-lspconfig", dependencies = { { "antosha417/nvim-lsp-file-operations", config = true }, - "hrsh7th/cmp-nvim-lsp", + -- "hrsh7th/cmp-nvim-lsp", + "saghen/blink.cmp", "nvim-lua/plenary.nvim", "pmizio/typescript-tools.nvim", "dmmulroy/ts-error-translator.nvim", @@ -12,12 +13,13 @@ return { config = function() local lspconfig = require("lspconfig") local tserrortranslator = require("ts-error-translator") - local cmp_nvim_lsp = require("cmp_nvim_lsp") + -- local cmp_nvim_lsp = require("cmp_nvim_lsp") local util = require("lspconfig.util") local path = util.path local on_attach = require("taken.utils.on_attach") - local capabilities = cmp_nvim_lsp.default_capabilities() + -- local capabilities = cmp_nvim_lsp.default_capabilities() + local capabilities = require("blink.cmp").get_lsp_capabilities() local signs = { Error = " ", Warn = " ", Hint = "ﴞ ", Info = " " } for type, icon in pairs(signs) do diff --git a/lua/taken/plugins/nvim-cmp.lua b/lua/taken/plugins/nvim-cmp.lua index 8c65925..f526c50 100644 --- a/lua/taken/plugins/nvim-cmp.lua +++ b/lua/taken/plugins/nvim-cmp.lua @@ -11,6 +11,7 @@ return { "rafamadriz/friendly-snippets", "onsails/lspkind.nvim", }, + enabled = false, event = "InsertEnter", config = function() local cmp = require("cmp")