Skip to content

Commit f74d170

Browse files
committed
Merge upstream kickstart.nvim changes
* feat: switch nvim-cmp for blink.cmp (nvim-lua#1426)
1 parent 106f39f commit f74d170

File tree

4 files changed

+115
-16
lines changed

4 files changed

+115
-16
lines changed

lua/config/lazy.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ require('lazy').setup({
6161

6262
require 'kickstart.plugins.conform',
6363

64-
require 'kickstart.plugins.nvim-cmp',
64+
-- require 'kickstart.plugins.nvim-cmp',
6565

6666
require 'kickstart.plugins.todo-comments',
6767

lua/custom/plugins/blink-cmp.lua

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
return {
2+
{ -- Autocompletion
3+
'saghen/blink.cmp',
4+
event = 'VimEnter',
5+
version = '1.*',
6+
dependencies = {
7+
-- Snippet Engine
8+
{
9+
'L3MON4D3/LuaSnip',
10+
version = '2.*',
11+
build = (function()
12+
-- Build Step is needed for regex support in snippets.
13+
-- This step is not supported in many windows environments.
14+
-- Remove the below condition to re-enable on windows.
15+
if vim.fn.has 'win32' == 1 or vim.fn.executable 'make' == 0 then
16+
return
17+
end
18+
return 'make install_jsregexp'
19+
end)(),
20+
dependencies = {
21+
-- `friendly-snippets` contains a variety of premade snippets.
22+
-- See the README about individual language/framework/plugin snippets:
23+
-- https://github.com/rafamadriz/friendly-snippets
24+
{
25+
'rafamadriz/friendly-snippets',
26+
config = function()
27+
require('luasnip.loaders.from_vscode').lazy_load()
28+
end,
29+
},
30+
},
31+
opts = {},
32+
},
33+
'folke/lazydev.nvim',
34+
},
35+
--- @module 'blink.cmp'
36+
--- @type blink.cmp.Config
37+
opts = {
38+
keymap = {
39+
-- 'default' (recommended) for mappings similar to built-in completions
40+
-- <c-y> to accept ([y]es) the completion.
41+
-- This will auto-import if your LSP supports it.
42+
-- This will expand snippets if the LSP sent a snippet.
43+
-- 'super-tab' for tab to accept
44+
-- 'enter' for enter to accept
45+
-- 'none' for no mappings
46+
--
47+
-- For an understanding of why the 'default' preset is recommended,
48+
-- you will need to read `:help ins-completion`
49+
--
50+
-- No, but seriously. Please read `:help ins-completion`, it is really good!
51+
--
52+
-- All presets have the following mappings:
53+
-- <tab>/<s-tab>: move to right/left of your snippet expansion
54+
-- <c-space>: Open menu or open docs if already open
55+
-- <c-n>/<c-p> or <up>/<down>: Select next/previous item
56+
-- <c-e>: Hide menu
57+
-- <c-k>: Toggle signature help
58+
--
59+
-- See :h blink-cmp-config-keymap for defining your own keymap
60+
preset = 'default',
61+
62+
-- For more advanced Luasnip keymaps (e.g. selecting choice nodes, expansion) see:
63+
-- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps
64+
},
65+
66+
appearance = {
67+
-- 'mono' (default) for 'Nerd Font Mono' or 'normal' for 'Nerd Font'
68+
-- Adjusts spacing to ensure icons are aligned
69+
nerd_font_variant = 'mono',
70+
},
71+
72+
completion = {
73+
-- By default, you may press `<c-space>` to show the documentation.
74+
-- Optionally, set `auto_show = true` to show the documentation after a delay.
75+
documentation = { auto_show = true, auto_show_delay_ms = 500 },
76+
menu = {
77+
draw = {
78+
columns = {
79+
{ 'kind_icon', 'label', 'label_description', gap = 1 },
80+
{ 'kind' },
81+
},
82+
},
83+
},
84+
},
85+
86+
sources = {
87+
default = { 'lsp', 'path', 'snippets', 'lazydev' },
88+
providers = {
89+
lazydev = { module = 'lazydev.integrations.blink', score_offset = 100 },
90+
},
91+
},
92+
93+
snippets = { preset = 'luasnip' },
94+
95+
-- Blink.cmp includes an optional, recommended rust fuzzy matcher,
96+
-- which automatically downloads a prebuilt binary when enabled.
97+
--
98+
-- By default, we use the Lua implementation instead, but you may enable
99+
-- the rust implementation via `'prefer_rust_with_warning'`
100+
--
101+
-- See :h blink-cmp-config-fuzzy for more information
102+
fuzzy = { implementation = 'prefer_rust_with_warning' },
103+
104+
-- Shows a signature help window while you type arguments for a function
105+
signature = { enabled = true },
106+
},
107+
},
108+
}

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
}

lua/kickstart/plugins/lspconfig.lua

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ return {
2727
-- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})`
2828
{ 'j-hui/fidget.nvim', opts = {} },
2929

30-
-- Allows extra capabilities provided by nvim-cmp
31-
'hrsh7th/cmp-nvim-lsp',
30+
-- Allows extra capabilities provided by blink.cmp
31+
'saghen/blink.cmp',
3232
},
3333
config = function()
3434
-- Brief aside: **What is LSP?**
@@ -195,10 +195,9 @@ return {
195195

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

203202
-- Enable the following language servers
204203
-- Feel free to add/remove any LSPs that you want here. They will automatically be installed.

0 commit comments

Comments
 (0)