Skip to content

Commit c7deaa7

Browse files
committed
feat: switch nvim-cmp for blink.cmp
1 parent e947649 commit c7deaa7

File tree

2 files changed

+65
-101
lines changed

2 files changed

+65
-101
lines changed

init.lua

Lines changed: 64 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -486,8 +486,8 @@ require('lazy').setup({
486486
-- Useful status updates for LSP.
487487
{ 'j-hui/fidget.nvim', opts = {} },
488488

489-
-- Allows extra capabilities provided by nvim-cmp
490-
'hrsh7th/cmp-nvim-lsp',
489+
-- Allows extra capabilities provided by blink.cmp
490+
'saghen/blink.cmp',
491491
},
492492
config = function()
493493
-- Brief aside: **What is LSP?**
@@ -654,10 +654,9 @@ require('lazy').setup({
654654

655655
-- LSP servers and clients are able to communicate to each other what features they support.
656656
-- By default, Neovim doesn't support everything that is in the LSP specification.
657-
-- When you add nvim-cmp, luasnip, etc. Neovim now has *more* capabilities.
658-
-- So, we create new capabilities with nvim cmp, and then broadcast that to the servers.
659-
local capabilities = vim.lsp.protocol.make_client_capabilities()
660-
capabilities = vim.tbl_deep_extend('force', capabilities, require('cmp_nvim_lsp').default_capabilities())
657+
-- When you add blink.cmp, luasnip, etc. Neovim now has *more* capabilities.
658+
-- So, we create new capabilities with blink.cmp, and then broadcast that to the servers.
659+
local capabilities = require('blink.cmp').get_lsp_capabilities()
661660

662661
-- Enable the following language servers
663662
-- Feel free to add/remove any LSPs that you want here. They will automatically be installed.
@@ -776,12 +775,14 @@ require('lazy').setup({
776775
},
777776

778777
{ -- Autocompletion
779-
'hrsh7th/nvim-cmp',
780-
event = 'InsertEnter',
778+
'saghen/blink.cmp',
779+
event = 'VimEnter',
780+
version = '1.*',
781781
dependencies = {
782-
-- Snippet Engine & its associated nvim-cmp source
782+
-- Snippet Engine
783783
{
784784
'L3MON4D3/LuaSnip',
785+
version = '2.*',
785786
build = (function()
786787
-- Build Step is needed for regex support in snippets.
787788
-- This step is not supported in many windows environments.
@@ -802,95 +803,66 @@ require('lazy').setup({
802803
-- end,
803804
-- },
804805
},
806+
opts = {},
805807
},
806-
'saadparwaiz1/cmp_luasnip',
807-
808-
-- Adds other completion capabilities.
809-
-- nvim-cmp does not ship with all sources by default. They are split
810-
-- into multiple repos for maintenance purposes.
811-
'hrsh7th/cmp-nvim-lsp',
812-
'hrsh7th/cmp-path',
813-
'hrsh7th/cmp-nvim-lsp-signature-help',
808+
'folke/lazydev.nvim',
814809
},
815-
config = function()
816-
-- See `:help cmp`
817-
local cmp = require 'cmp'
818-
local luasnip = require 'luasnip'
819-
luasnip.config.setup {}
820-
821-
cmp.setup {
822-
snippet = {
823-
expand = function(args)
824-
luasnip.lsp_expand(args.body)
825-
end,
826-
},
827-
completion = { completeopt = 'menu,menuone,noinsert' },
828-
829-
-- For an understanding of why these mappings were
830-
-- chosen, you will need to read `:help ins-completion`
810+
opts = {
811+
keymap = {
812+
-- 'default' (recommended) for mappings similar to built-in completions
813+
-- <c-y> to accept ([y]es) the completion.
814+
-- This will auto-import if your LSP supports it.
815+
-- This will expand snippets if the LSP sent a snippet.
816+
-- 'super-tab' for tab to accept
817+
-- 'enter' for enter to accept
818+
-- 'none' for no mappings
819+
--
820+
-- For an understanding of why the 'default' preset is recommended,
821+
-- you will need to read `:help ins-completion`
831822
--
832823
-- No, but seriously. Please read `:help ins-completion`, it is really good!
833-
mapping = cmp.mapping.preset.insert {
834-
-- Select the [n]ext item
835-
['<C-n>'] = cmp.mapping.select_next_item(),
836-
-- Select the [p]revious item
837-
['<C-p>'] = cmp.mapping.select_prev_item(),
838-
839-
-- Scroll the documentation window [b]ack / [f]orward
840-
['<C-b>'] = cmp.mapping.scroll_docs(-4),
841-
['<C-f>'] = cmp.mapping.scroll_docs(4),
842-
843-
-- Accept ([y]es) the completion.
844-
-- This will auto-import if your LSP supports it.
845-
-- This will expand snippets if the LSP sent a snippet.
846-
['<C-y>'] = cmp.mapping.confirm { select = true },
847-
848-
-- If you prefer more traditional completion keymaps,
849-
-- you can uncomment the following lines
850-
--['<CR>'] = cmp.mapping.confirm { select = true },
851-
--['<Tab>'] = cmp.mapping.select_next_item(),
852-
--['<S-Tab>'] = cmp.mapping.select_prev_item(),
853-
854-
-- Manually trigger a completion from nvim-cmp.
855-
-- Generally you don't need this, because nvim-cmp will display
856-
-- completions whenever it has completion options available.
857-
['<C-Space>'] = cmp.mapping.complete {},
858-
859-
-- Think of <c-l> as moving to the right of your snippet expansion.
860-
-- So if you have a snippet that's like:
861-
-- function $name($args)
862-
-- $body
863-
-- end
864-
--
865-
-- <c-l> will move you to the right of each of the expansion locations.
866-
-- <c-h> is similar, except moving you backwards.
867-
['<C-l>'] = cmp.mapping(function()
868-
if luasnip.expand_or_locally_jumpable() then
869-
luasnip.expand_or_jump()
870-
end
871-
end, { 'i', 's' }),
872-
['<C-h>'] = cmp.mapping(function()
873-
if luasnip.locally_jumpable(-1) then
874-
luasnip.jump(-1)
875-
end
876-
end, { 'i', 's' }),
824+
--
825+
-- All presets have the following mappings:
826+
-- <tab>/<s-tab>: move to right/left of your snippet expansion
827+
-- <c-space>: Open menu or open docs if already open
828+
-- <c-n>/<c-p> or <up>/<down>: Select next/previous item
829+
-- <c-e>: Hide menu
830+
-- <c-k>: Toggle signature help
831+
--
832+
-- See :h blink-cmp-config-keymap for defining your own keymap
833+
preset = 'default',
877834

878-
-- For more advanced Luasnip keymaps (e.g. selecting choice nodes, expansion) see:
879-
-- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps
880-
},
881-
sources = {
882-
{
883-
name = 'lazydev',
884-
-- set group index to 0 to skip loading LuaLS completions as lazydev recommends it
885-
group_index = 0,
886-
},
887-
{ name = 'nvim_lsp' },
888-
{ name = 'luasnip' },
889-
{ name = 'path' },
890-
{ name = 'nvim_lsp_signature_help' },
835+
-- For more advanced Luasnip keymaps (e.g. selecting choice nodes, expansion) see:
836+
-- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps
837+
},
838+
839+
appearance = {
840+
-- 'mono' (default) for 'Nerd Font Mono' or 'normal' for 'Nerd Font'
841+
-- Adjusts spacing to ensure icons are aligned
842+
nerd_font_variant = 'mono',
843+
},
844+
845+
sources = {
846+
default = { 'lsp', 'path', 'snippets', 'lazydev' },
847+
providers = {
848+
lazydev = { module = 'lazydev.integrations.blink', score_offset = 100 },
891849
},
892-
}
893-
end,
850+
},
851+
852+
snippets = { preset = 'luasnip' },
853+
854+
-- Blink.cmp includes an optional, recommended rust fuzzy matcher,
855+
-- which will automatically downloaded a prebuilt binary when enabled.
856+
--
857+
-- By default, we use the Lua implementation instead, but you may enable
858+
-- the rust implementation via `'prefer_rust_with_warning'`
859+
--
860+
-- See :h blink-cmp-config-fuzzy for more information
861+
fuzzy = { implementation = 'lua' },
862+
863+
-- Shows a signature help window while you type arguments for a function
864+
signature = { enabled = true },
865+
},
894866
},
895867

896868
{ -- You can easily change to a different colorscheme.

lua/kickstart/plugins/autopairs.lua

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,5 @@
44
return {
55
'windwp/nvim-autopairs',
66
event = 'InsertEnter',
7-
-- Optional dependency
8-
dependencies = { 'hrsh7th/nvim-cmp' },
9-
config = function()
10-
require('nvim-autopairs').setup {}
11-
-- If you want to automatically add `(` after selecting a function or method
12-
local cmp_autopairs = require 'nvim-autopairs.completion.cmp'
13-
local cmp = require 'cmp'
14-
cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done())
15-
end,
7+
opts = {},
168
}

0 commit comments

Comments
 (0)