From 15e21f333fe59ba5ff5e624816d73cf35d75f65b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sascha=20L=C3=BCdecke?= Date: Mon, 30 Jun 2025 08:57:18 +0200 Subject: [PATCH] Replaced nvim-cmp with blink.cmp --- lua/config/nvim-cmp.lua | 95 ----------------------------------------- lua/plugins.lua | 82 ++++++++++++++++++++++++++++++----- 2 files changed, 72 insertions(+), 105 deletions(-) delete mode 100644 lua/config/nvim-cmp.lua diff --git a/lua/config/nvim-cmp.lua b/lua/config/nvim-cmp.lua deleted file mode 100644 index b65a104..0000000 --- a/lua/config/nvim-cmp.lua +++ /dev/null @@ -1,95 +0,0 @@ -local has_words_before = function() - unpack = unpack or table.unpack - local line, col = unpack(vim.api.nvim_win_get_cursor(0)) - return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil -end - -local luasnip = require("luasnip") -local cmp = require("cmp") - -cmp.setup({ - snippet = { - -- REQUIRED - you must specify a snippet engine - expand = function(args) - require('luasnip').lsp_expand(args.body) -- For `luasnip` users. - end, - }, - - - window = { - -- completion = cmp.config.window.bordered(), - -- documentation = cmp.config.window.bordered(), - }, - - mapping = cmp.mapping.preset.insert({ - -- Use to scroll the docs - [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.scroll_docs(4), - -- also scroll docs with page up / down - [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.scroll_docs(4), - - -- ESC messes with standard ESC mapping, don't use - -- [''] = cmp.mapping.abort(), - [''] = cmp.mapping.abort(), - - -- Use (Enter) to confirm selection - -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. - [''] = cmp.mapping.confirm({ select = true }), - - -- A super tab - -- sourc: https://github.com/hrsh7th/nvim-cmp/wiki/Example-mappings#luasnip - [""] = cmp.mapping(function(fallback) - -- Hint: if the completion menu is visible select next one - if cmp.visible() then - cmp.select_next_item() - elseif luasnip.jumpable(1) then - luasnip.jump(1) - elseif has_words_before() then - cmp.complete() - else - fallback() - end - end, { "i", "s" }), -- i - insert mode; s - select mode - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_prev_item() - elseif luasnip.jumpable(-1) then - luasnip.jump(-1) - else - fallback() - end - end, { "i", "s" }), - }), - - -- Let's configure the item's appearance - -- source: https://github.com/hrsh7th/nvim-cmp/wiki/Menu-Appearance - formatting = { - -- Set order from left to right - -- kind: single letter indicating the type of completion - -- abbr: abbreviation of "word"; when not empty it is used in the menu instead of "word" - -- menu: extra text for the popup menu, displayed after "word" or "abbr" - fields = { 'abbr', 'menu' }, - - -- customize the appearance of the completion menu - format = function(entry, vim_item) - vim_item.menu = ({ - nvim_lsp = '[Lsp]', - luasnip = '[Luasnip]', - buffer = '[File]', - path = '[Path]', - })[entry.source.name] - return vim_item - end, - }, - - -- Set source precedence - sources = cmp.config.sources({ - { name = 'nvim_lsp' }, -- For nvim-lsp - { name = 'luasnip' }, -- For luasnip user - { name = 'buffer' }, -- For buffer word completion - { name = 'path' }, -- For path completion - { name = 'orgmode' }, -- for nvim-orgmode - { name = 'sonicpi' }, -- for sonic-pi integration - }) -}) diff --git a/lua/plugins.lua b/lua/plugins.lua index c3b5ccb..6bf4b2d 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -14,19 +14,81 @@ vim.opt.rtp:prepend(lazypath) require("lazy").setup({ -- Auto-completion engine { - "hrsh7th/nvim-cmp", - dependencies = { - "hrsh7th/cmp-nvim-lsp", -- lsp auto-completion - "hrsh7th/cmp-buffer", -- buffer auto-completion - "hrsh7th/cmp-path", -- path auto-completion - "hrsh7th/cmp-cmdline", -- cmdline auto-completion - "saadparwaiz1/cmp_luasnip", -- luasnip auto-completion + 'saghen/blink.cmp', + -- optional: provides snippets for the snippet source + dependencies = { 'rafamadriz/friendly-snippets', + { + "L3MON4D3/LuaSnip", + version = "v2.*" + } }, - config = function() - require("config.nvim-cmp") - end, + + -- use a release tag to download pre-built binaries + version = '1.*', + -- AND/OR build from source, requires nightly: https://rust-lang.github.io/rustup/concepts/channels.html#working-with-nightly-rust + -- build = 'cargo build --release', + -- If you use nix, you can build from source using latest nightly rust with: + -- build = 'nix run .#build-plugin', + + ---@module 'blink.cmp' + ---@type blink.cmp.Config + opts = { + -- 'default' (recommended) for mappings similar to built-in completions (C-y to accept) + -- 'super-tab' for mappings similar to vscode (tab to accept) + -- 'enter' for enter to accept + -- 'none' for no mappings + -- + -- All presets have the following mappings: + -- C-space: Open menu or open docs if already open + -- C-n/C-p or Up/Down: Select next/previous item + -- C-e: Hide menu + -- C-k: Toggle signature help (if signature.enabled = true) + -- + -- See :h blink-cmp-config-keymap for defining your own keymap + keymap = { preset = 'enter' }, + signature = { enabled = true }, + + appearance = { + -- 'mono' (default) for 'Nerd Font Mono' or 'normal' for 'Nerd Font' + -- Adjusts spacing to ensure icons are aligned + nerd_font_variant = 'mono' + }, + + -- (Default) Only show the documentation popup when manually triggered + completion = { + documentation = { auto_show = true }, + menu = { + -- show more things in the menu + draw = { + columns = { + { "label", "label_description", gap = 1 }, + { "kind_icon", "kind", gap = 1 }, + { "source_name" }, + }, + } + }, + }, + + -- 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 = { 'lsp', 'path', 'snippets', 'buffer' }, + }, + + snippets = { preset = 'luasnip' }, + + + -- (Default) Rust fuzzy matcher for typo resistance and significantly better performance + -- You may use a lua implementation instead by using `implementation = "lua"` or fallback to the lua implementation, + -- when the Rust fuzzy matcher is not available, by using `implementation = "prefer_rust"` + -- + -- See the fuzzy documentation for more information + fuzzy = { implementation = "prefer_rust_with_warning" } + }, + opts_extend = { "sources.default" } }, + -- Code snippet engine { "L3MON4D3/LuaSnip",