From c859dd2cd40910fd72793348f40c011f19849096 Mon Sep 17 00:00:00 2001 From: aserowy Date: Tue, 12 Nov 2024 13:33:45 +0100 Subject: [PATCH] language: replace nvim-cmp with blink.cmp for auto completion Signed-off-by: aserowy --- lazy-lock.json | 47 ++++++++++------------- lua/language/init.lua | 3 +- lua/plugins/language.lua | 82 +++------------------------------------- 3 files changed, 29 insertions(+), 103 deletions(-) diff --git a/lazy-lock.json b/lazy-lock.json index 75a135d..46570c5 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,61 +1,56 @@ { "Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" }, - "LuaSnip": { "branch": "master", "commit": "8d7aa7a7b7c0875e4878d1d2590924bc1c229305" }, - "avante.nvim": { "branch": "main", "commit": "f8d80d87c5e2a230ccb29805411bb67aefa1cf96" }, + "LuaSnip": { "branch": "master", "commit": "48a02259693cb7bbbd1092993406773d5ce14664" }, + "avante.nvim": { "branch": "main", "commit": "54896bbc2d9dbebaace86fa8e3e009a796414035" }, "barbecue": { "branch": "main", "commit": "cd7e7da622d68136e13721865b4d919efd6325ed" }, + "blink.cmp": { "branch": "main", "commit": "75cadbcd2657ed01326ca2b0e5e4d78a77127ca3" }, "bluloco.nvim": { "branch": "main", "commit": "07f4b5cca8cfe31aad69ab5c1be0f6a0715a8d2e" }, - "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, - "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, - "cmp-nvim-lua": { "branch": "main", "commit": "f12408bdb54c39c23e67cab726264c10db33ada8" }, - "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, - "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, "copilot.lua": { "branch": "master", "commit": "f8d8d872bb319f640d5177dad5fbf01f7a16d7d0" }, - "dracula.nvim": { "branch": "main", "commit": "94fa7885a06a67f0a8bfa03e064619d05d1ba496" }, - "dressing.nvim": { "branch": "master", "commit": "1b7921eecc65af1baf8ac1dc06f0794934cbcfb2" }, + "dracula.nvim": { "branch": "main", "commit": "e6128ec3923b92bb2b16e81b4a0f04ed0308038e" }, + "dressing.nvim": { "branch": "master", "commit": "43b8f74e0b1e3f41e51f640f8efa3bcd401cea0d" }, "fidget.nvim": { "branch": "main", "commit": "e2a175c2abe2d4f65357da1c98c59a5cfb2b543f" }, "flash.nvim": { "branch": "main", "commit": "34c7be146a91fec3555c33fe89c7d643f6ef5cf1" }, "friendly-snippets": { "branch": "main", "commit": "de8fce94985873666bd9712ea3e49ee17aadb1ed" }, "github-nvim-theme": { "branch": "main", "commit": "0e4636f556880d13c00d8a8f686fae8df7c9845f" }, "gruvbox.nvim": { "branch": "main", "commit": "49d9c0b150ba70efcd831ec7b3cb8ee740067045" }, "img-clip.nvim": { "branch": "main", "commit": "28a32d811d69042f4fa5c3d5fa35571df2bc1623" }, - "indent-blankline.nvim": { "branch": "master", "commit": "04e44b09ee3ff189c69ab082edac1ef7ae2e256c" }, - "lazy.nvim": { "branch": "main", "commit": "cf8ecc2c5e4332760431a33534240b0cbc6680ab" }, + "indent-blankline.nvim": { "branch": "master", "commit": "7871a88056f7144defca9c931e311a3134c5d509" }, + "lazy.nvim": { "branch": "main", "commit": "7967abe55752aa90532e6bb4bd4663fe27a264cb" }, "lsp_signature.nvim": { "branch": "master", "commit": "fc38521ea4d9ec8dbd4c2819ba8126cea743943b" }, "lspkind-nvim": { "branch": "master", "commit": "a700f1436d4a938b1a1a93c9962dc796afbaef4d" }, - "lualine.nvim": { "branch": "master", "commit": "b39f1f02f1799da88d552c522f4cb0c786b14440" }, + "lualine.nvim": { "branch": "master", "commit": "2a5bae925481f999263d6f5ed8361baef8df4f83" }, "lush.nvim": { "branch": "main", "commit": "45a79ec4acb5af783a6a29673a999ce37f00497e" }, "material.nvim": { "branch": "main", "commit": "0bcabb582c31b750428af9dbb0d146c1c2d75d4c" }, - "mellifluous.nvim": { "branch": "main", "commit": "5dcfdfed9153174a28619c022cb22af39135d528" }, + "mellifluous.nvim": { "branch": "main", "commit": "a3ffdc75694620f25e580f74f7f86ef49eeb73f2" }, "monokai-pro.nvim": { "branch": "master", "commit": "4f4133601296881bb2197800bd68d2bba9eaadb9" }, "nightfox.nvim": { "branch": "main", "commit": "7557f26defd093c4e9bc17f28b08403f706f5a44" }, - "none-ls.nvim": { "branch": "main", "commit": "dcc8cd4efdcb29275681a3c95786a816330dbca6" }, + "none-ls.nvim": { "branch": "main", "commit": "fb7acad9e98ad9c617775451c1aea95157e17942" }, "nui.nvim": { "branch": "main", "commit": "b58e2bfda5cea347c9d58b7f11cf3012c7b3953f" }, "numb.nvim": { "branch": "master", "commit": "3f7d4a74bd456e747a1278ea1672b26116e0824d" }, - "nvim": { "branch": "main", "commit": "65bf0b16f57a3db70d6a93ac68882dd9a31d0565" }, - "nvim-cmp": { "branch": "main", "commit": "29fb4854573355792df9e156cb779f0d31308796" }, + "nvim": { "branch": "main", "commit": "637d99e638bc6f1efedac582f6ccab08badac0c6" }, "nvim-colorizer.lua": { "branch": "master", "commit": "a065833f35a3a7cc3ef137ac88b5381da2ba302e" }, - "nvim-dap": { "branch": "master", "commit": "7ff6936010b7222fea2caea0f67ed77f1b7c60dd" }, + "nvim-dap": { "branch": "master", "commit": "8517126e9323e346f6a99b3b594c5a940b914dcd" }, "nvim-dap-ui": { "branch": "master", "commit": "ffa89839f97bad360e78428d5c740fdad9a0ff02" }, "nvim-dap-virtual-text": { "branch": "master", "commit": "76d80c3d171224315b61c006502a1e30c213a9ab" }, - "nvim-lspconfig": { "branch": "master", "commit": "54617a18f4cf46f0c2f6d024fa6feb7515fe036d" }, + "nvim-lspconfig": { "branch": "master", "commit": "d2d153a179ed59aa7134d7ebdf4d7dcb156efa22" }, "nvim-navic": { "branch": "master", "commit": "8649f694d3e76ee10c19255dece6411c29206a54" }, "nvim-nio": { "branch": "master", "commit": "a428f309119086dc78dd4b19306d2d67be884eee" }, - "nvim-treesitter": { "branch": "master", "commit": "fb2d41ec599b68af041f3071ada883718928e279" }, + "nvim-treesitter": { "branch": "master", "commit": "7646c1c12a3121562aa87fd79aace48c728ac096" }, "nvim-ts-rainbow": { "branch": "master", "commit": "ef95c15a935f97c65a80e48e12fe72d49aacf9b9" }, "nvim-web-devicons": { "branch": "master", "commit": "19d257cf889f79f4022163c3fbb5e08639077bd8" }, - "onedark.nvim": { "branch": "master", "commit": "fae34f7c635797f4bf62fb00e7d0516efa8abe37" }, + "onedark.nvim": { "branch": "master", "commit": "67a74c275d1116d575ab25485d1bfa6b2a9c38a6" }, "onenord.nvim": { "branch": "main", "commit": "7f8a7482a1145c1286ee05d46ef4d028a4f7264a" }, "persisted.nvim": { "branch": "main", "commit": "e9a179271b1c7888e0a87448b3cf81652a6606c1" }, "plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" }, - "render-markdown.nvim": { "branch": "main", "commit": "fc05fb7c56795f191b6800799a2ec6ea325ba715" }, + "render-markdown.nvim": { "branch": "main", "commit": "78a2eb7fc273f36790aa390262f390a3265eedff" }, "suda.vim": { "branch": "master", "commit": "b97fab52f9cdeabe2bbb5eb98d82356899f30829" }, - "telescope-dap.nvim": { "branch": "master", "commit": "8c88d9716c91eaef1cdea13cb9390d8ef447dbfe" }, + "telescope-dap.nvim": { "branch": "master", "commit": "783366bd6c1e7fa0a5c59c07db37f49c805a28df" }, "telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" }, - "telescope-undo.nvim": { "branch": "main", "commit": "51be9ae7c42fc27c0b05505e3a0162e0f05fbb6a" }, + "telescope-undo.nvim": { "branch": "main", "commit": "2971cc9f193ec09e0c5de3563f99cbea16b63f10" }, "telescope.nvim": { "branch": "master", "commit": "85922dde3767e01d42a08e750a773effbffaea3e" }, "todo-comments.nvim": { "branch": "main", "commit": "ae0a2afb47cf7395dc400e5dc4e05274bf4fb9e0" }, - "tokyonight.nvim": { "branch": "main", "commit": "2e1daa1d164ad8cc3e99b44ca68e990888a66038" }, - "tree-sitter-nu": { "branch": "main", "commit": "1561a947a5505d373e11ca337898e048ac2e389e" }, - "trouble.nvim": { "branch": "main", "commit": "2f3b537f2207ce32f4459f9d56746ee013b5e01b" }, + "tokyonight.nvim": { "branch": "main", "commit": "ce91ba480070c95f40753e4663e32b4632ac6db3" }, + "tree-sitter-nu": { "branch": "main", "commit": "7e0f16f608a9e804fae61430ade734f9f849fb80" }, + "trouble.nvim": { "branch": "main", "commit": "3dc00c0447c016cd43e03054c3d49436a1f2076d" }, "undotree": { "branch": "master", "commit": "78b5241191852ffa9bb5da5ff2ee033160798c3b" } } diff --git a/lua/language/init.lua b/lua/language/init.lua index 4f0c914..01da60b 100644 --- a/lua/language/init.lua +++ b/lua/language/init.lua @@ -24,7 +24,8 @@ local function on_attach(client, bufnr) vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr }) vim.api.nvim_create_autocmd("BufWritePost", { group = augroup, - buffer = bufnr, callback = function() + buffer = bufnr, + callback = function() vim.lsp.buf.format({ async = false }) end, }) diff --git a/lua/plugins/language.lua b/lua/plugins/language.lua index 7d63765..1a6a01e 100644 --- a/lua/plugins/language.lua +++ b/lua/plugins/language.lua @@ -61,71 +61,6 @@ local function setup_treesitter() }) end -local function setup_cmp() - local ELLIPSIS_CHAR = "…" - local LABEL_WIDTH = 35 - - local cmp = require("cmp") - local cmparer = require("cmp.config.compare") - local handle = require("language.completion") - local lspkind = require("lspkind") - - vim.opt.pumheight = 12 - - cmp.setup({ - completion = { - completeopt = "menu,menuone,noinsert", - }, - formatting = { - format = lspkind.cmp_format({ - maxwidth = LABEL_WIDTH, - mode = "symbol_text", - before = function(_, vim_item) - local ellipsis_char_len = string.len(ELLIPSIS_CHAR) - - local label = vim_item.abbr - if string.len(label) <= LABEL_WIDTH then - local truncated_label = vim.fn.strcharpart(label, 0, LABEL_WIDTH - ellipsis_char_len) - vim_item.abbr = truncated_label .. ELLIPSIS_CHAR - end - - local padding = string.rep(" ", LABEL_WIDTH - string.len(label)) - vim_item.abbr = label .. padding - - return vim_item - end, - }), - }, - mapping = require("mappings").editor_completion(cmp, handle), - snippet = { - expand = function(args) - require("luasnip").lsp_expand(args.body) - end, - }, - sorting = { - priority_weight = 1.0, - comparators = { - cmparer.locality, - cmparer.recently_used, - cmparer.score, - cmparer.offset, - cmparer.order, - }, - }, - sources = { - { name = "luasnip", max_item_count = 3 }, - { name = "nvim_lsp" }, - { name = "nvim_lua" }, - { name = "path", max_item_count = 3 }, - { name = "buffer", max_item_count = 5 }, - }, - window = { - completion = cmp.config.window.bordered(), - documentation = cmp.config.window.bordered(), - }, - }) -end - local function setup_luasnip() local luasnip = require("luasnip") @@ -150,26 +85,21 @@ return { }, build = ":TSUpdate", }, - { - "hrsh7th/nvim-cmp", - config = function() - setup_cmp() - end, + "saghen/blink.cmp", + version = "*", + opts = { + keymap = 'enter', + }, dependencies = { - "hrsh7th/cmp-buffer", - "hrsh7th/cmp-nvim-lsp", - "hrsh7th/cmp-nvim-lua", - "hrsh7th/cmp-path", + "rafamadriz/friendly-snippets", }, }, - "saadparwaiz1/cmp_luasnip", { "L3MON4D3/LuaSnip", config = function() setup_luasnip() end, }, - "rafamadriz/friendly-snippets", "onsails/lspkind-nvim", }