Skip to content

Commit 9406896

Browse files
2026-01-29 19:17:56
1 parent 9853af5 commit 9406896

File tree

3 files changed

+315
-6
lines changed

3 files changed

+315
-6
lines changed

lazy-lock.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"comment-box.nvim": { "branch": "main", "commit": "06bb771690bc9df0763d14769b779062d8f12bc5" },
3434
"conform.nvim": { "branch": "master", "commit": "c2526f1cde528a66e086ab1668e996d162c75f4f" },
3535
"copilot-cmp": { "branch": "master", "commit": "15fc12af3d0109fa76b60b5cffa1373697e261d1" },
36-
"copilot.lua": { "branch": "master", "commit": "2ede0808fa8dace39ea2a0f09b7bc6583655b730" },
36+
"copilot.lua": { "branch": "master", "commit": "9b8d77c6c847c83c784c05f5f86b4821ed90d3a1" },
3737
"copilot.vim": { "branch": "release", "commit": "a12fd5672110c8aa7e3c8419e28c96943ca179be" },
3838
"dashboard-nvim": { "branch": "master", "commit": "0775e567b6c0be96d01a61795f7b64c1758262f6" },
3939
"diffview.nvim": { "branch": "main", "commit": "4516612fe98ff56ae0415a259ff6361a89419b0a" },
@@ -67,16 +67,16 @@
6767
"noice.nvim": { "branch": "main", "commit": "7bfd942445fb63089b59f97ca487d605e715f155" },
6868
"nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" },
6969
"nvim-alt-substitute": { "branch": "main", "commit": "f0e6ef3a656187108d695a0115c09eda62474971" },
70-
"nvim-autopairs": { "branch": "master", "commit": "fbbd7a49f7a82eb1f7f04651b624ab976ed941d6" },
70+
"nvim-autopairs": { "branch": "master", "commit": "007047febaa3681a8d2f3dd5126fdb9c6e81f393" },
7171
"nvim-cmp": { "branch": "main", "commit": "da88697d7f45d16852c6b2769dc52387d1ddc45f" },
7272
"nvim-comment-frame": { "branch": "main", "commit": "5719db5d3b15b451f89db409ce9164a716ecbef6" },
73-
"nvim-dap": { "branch": "master", "commit": "085386b9359ddf8d76ad89b98973b8e332dc5ba3" },
73+
"nvim-dap": { "branch": "master", "commit": "e47878dcf1ccc30136b30d19ab19fe76946d61cd" },
7474
"nvim-dap-ui": { "branch": "master", "commit": "cf91d5e2d07c72903d052f5207511bf7ecdb7122" },
7575
"nvim-dap-virtual-text": { "branch": "master", "commit": "fbdb48c2ed45f4a8293d0d483f7730d24467ccb6" },
7676
"nvim-devdocs": { "branch": "master", "commit": "1ab982d3e069d191d9157b897c8b70cf48b7f77a" },
7777
"nvim-highlight-colors": { "branch": "main", "commit": "e2cb22089cc2358b2b995c09578224f142de6039" },
7878
"nvim-jdtls": { "branch": "master", "commit": "291dad797b5427ca0c9b7e0dd261279c7c3823e1" },
79-
"nvim-lint": { "branch": "master", "commit": "ca6ea12daf0a4d92dc24c5c9ae22a1f0418ade37" },
79+
"nvim-lint": { "branch": "master", "commit": "b3292aac30b935d4cccf0904053d1c7930df8a20" },
8080
"nvim-lspconfig": { "branch": "master", "commit": "5fef3b4a5f1057553b78d048322782c3a9ae69c6" },
8181
"nvim-navic": { "branch": "master", "commit": "f5eba192f39b453675d115351808bd51276d9de5" },
8282
"nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" },
@@ -98,7 +98,7 @@
9898
"popup.nvim": { "branch": "master", "commit": "b7404d35d5d3548a82149238289fa71f7f6de4ac" },
9999
"project_notes": { "branch": "main", "commit": "53eab5041bd8c7021c699f7fdf93b6dd3708a3b3" },
100100
"rainbow-delimiters.nvim": { "branch": "master", "commit": "d6b802552cbe7d643a3b6b31f419c248d1f1e220" },
101-
"render-markdown.nvim": { "branch": "main", "commit": "8314d14b9f56306bc876fb3b386f31dc8c5a2711" },
101+
"render-markdown.nvim": { "branch": "main", "commit": "99bfa5d61381a29eedc75810898cb9c0fc755064" },
102102
"rest.nvim": { "branch": "main", "commit": "714d5512aaec5565d55652480c16c26f8d95645d" },
103103
"smart-splits.nvim": { "branch": "master", "commit": "5442c06d2003a342c27213e580f58af8ddd577c4" },
104104
"snacks.nvim": { "branch": "main", "commit": "fe7cfe9800a182274d0f868a74b7263b8c0c020b" },

lua/plugins/cmp.lua

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,10 @@ return {
151151
select = true,
152152
}),
153153
['<Tab>'] = cmp.mapping(function(fallback)
154-
if cmp.visible() then
154+
local copilot_suggestion = require('copilot.suggestion')
155+
if copilot_suggestion.is_visible() then
156+
copilot_suggestion.accept()
157+
elseif cmp.visible() then
155158
cmp.select_next_item()
156159
elseif luasnip.locally_jumpable(1) then
157160
luasnip.jump(1)

lua/plugins/cmp.lua.backup

Lines changed: 306 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,306 @@
1+
-- ╭─────────────────────────────────────────────────────────╮
2+
-- │ CMP CONFIGURATION │
3+
-- ╰─────────────────────────────────────────────────────────╯
4+
return {
5+
'hrsh7th/nvim-cmp',
6+
enabled = true,
7+
event = { 'InsertEnter', 'CmdlineEnter' },
8+
dependencies = {
9+
'hrsh7th/cmp-buffer',
10+
'hrsh7th/cmp-cmdline',
11+
'hrsh7th/cmp-nvim-lsp',
12+
'hrsh7th/cmp-nvim-lsp-signature-help',
13+
'hrsh7th/cmp-nvim-lua',
14+
'hrsh7th/cmp-path',
15+
'mfussenegger/nvim-jdtls',
16+
'octaltree/cmp-look',
17+
'L3MON4D3/cmp-luasnip-choice',
18+
'chrisgrieser/cmp-nerdfont',
19+
'MeanderingProgrammer/render-markdown.nvim',
20+
'ray-x/cmp-treesitter',
21+
'saadparwaiz1/cmp_luasnip',
22+
'lukas-reineke/cmp-rg',
23+
'prabirshrestha/vim-lsp',
24+
'SergioRibera/cmp-dotenv',
25+
'jcha0713/cmp-tw2css',
26+
'dmitmel/cmp-vim-lsp',
27+
'roginfarrer/cmp-css-variables',
28+
'PhilippFeO/cmp-help-tags',
29+
30+
'JMarkin/cmp-diag-codes',
31+
32+
-- 'chrisgrieser/cmp_yanky',
33+
},
34+
config = function()
35+
-- ╭───────────────╮
36+
-- │ LOAD SNIPPETS │
37+
-- ╰───────────────╯
38+
require('luasnip/loaders/from_lua').lazy_load()
39+
require('luasnip.loaders.from_snipmate').lazy_load()
40+
require('luasnip/loaders/from_vscode').lazy_load()
41+
42+
-- ╭────────────────╮
43+
-- │ COMPLETEOPTION │
44+
-- ╰────────────────╯
45+
vim.opt.completeopt = { 'menu', 'menuone', 'noselect', 'preview' }
46+
47+
-- ╭────────────╮
48+
-- │ KIND ICONS │
49+
-- ╰────────────╯
50+
local kind_icons = {
51+
Class = ' ',
52+
Color = ' ',
53+
Comment = '//',
54+
Constant = ' ',
55+
Constructor = ' ',
56+
Enum = ' ',
57+
EnumMember = ' ',
58+
Event = '',
59+
Field = '󰄶 ',
60+
File = ' ',
61+
Folder = ' ',
62+
Function = 'ƒ ',
63+
Interface = ' ',
64+
Keyword = '󰌆 ',
65+
Method = ' ',
66+
Module = '󰏗 ',
67+
Operator = '󰆕 ',
68+
Property = ' ',
69+
Reference = ' ',
70+
Snippet = ' ',
71+
String = '󱌯 ',
72+
Struct = ' ',
73+
Text = ' ',
74+
TypeParameter = '󰅲 ',
75+
Unit = ' ',
76+
Value = '󰎠 ',
77+
Variable = '󰀫',
78+
}
79+
80+
-- ╭──────────────╮
81+
-- │ LOAD LUASNIP │
82+
-- ╰──────────────╯
83+
local luasnip = require('luasnip')
84+
85+
-- ╭──────────╮
86+
-- │ LOAD CMP │
87+
-- ╰──────────╯
88+
local cmp = require('cmp')
89+
90+
-- ╭───────────╮
91+
-- │ CMP SETUP │
92+
-- ╰───────────╯
93+
cmp.setup({
94+
snippet = {
95+
expand = function(args)
96+
require('luasnip').lsp_expand(args.body)
97+
end,
98+
},
99+
window = {
100+
completion = {
101+
border = { '┌', '─', '┐', '│', '┘', '─', '└', '│' },
102+
winhighlight = 'Normal:CmpPmenu,FloatBorder:FloatBorder,CursorLine:PmenuSel,Search:None',
103+
},
104+
documentation = {
105+
border = { '┌', '─', '┐', '│', '┘', '─', '└', '│' },
106+
winhighlight = 'Normal:CmpPmenu,FloatBorder:FloatBorder,CursorLine:PmenuSel,Search:None',
107+
},
108+
},
109+
view = {
110+
entries = {
111+
name = 'custom',
112+
selection_order = 'near_cursor',
113+
follow_cursor = true,
114+
},
115+
},
116+
mapping = cmp.mapping.preset.insert({
117+
-- ['<C-n>'] = cmp.mapping(cmp.mapping.select_next_item(), { 'i', 'c' }),
118+
-- ['<C-p>'] = cmp.mapping(cmp.mapping.select_prev_item(), { 'i', 'c' }),
119+
-- ['<C-b>'] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }),
120+
-- ['<C-f>'] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }),
121+
-- ['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }),
122+
['<C-n>'] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }),
123+
['<C-p>'] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }),
124+
['<C-u>'] = cmp.mapping.scroll_docs(-4),
125+
['<C-d>'] = cmp.mapping.scroll_docs(4),
126+
['<C-Space>'] = cmp.mapping.complete(),
127+
['<C-y>'] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `<C-y>` mapping.
128+
['<C-e>'] = cmp.mapping({
129+
i = cmp.mapping.abort(),
130+
c = cmp.mapping.close(),
131+
}),
132+
['<CR>'] = cmp.mapping.confirm({
133+
behavior = cmp.ConfirmBehavior.Insert,
134+
select = true,
135+
}), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
136+
-- ['<CR>'] = cmp.mapping(function(fallback)
137+
-- if cmp.visible() then
138+
-- if luasnip.expandable() then
139+
-- luasnip.expand()
140+
-- else
141+
-- cmp.confirm({
142+
-- select = true,
143+
-- })
144+
-- end
145+
-- else
146+
-- fallback()
147+
-- end
148+
-- end),
149+
['<C-CR>'] = cmp.mapping.confirm({
150+
behavior = cmp.ConfirmBehavior.Replace,
151+
select = true,
152+
}),
153+
['<Tab>'] = cmp.mapping(function(fallback)
154+
if cmp.visible() then
155+
cmp.select_next_item()
156+
elseif luasnip.locally_jumpable(1) then
157+
luasnip.jump(1)
158+
else
159+
fallback()
160+
end
161+
end, { 'i', 's' }),
162+
['<S-Tab>'] = cmp.mapping(function(fallback)
163+
if cmp.visible() then
164+
cmp.select_prev_item()
165+
elseif luasnip.locally_jumpable(-1) then
166+
luasnip.jump(-1)
167+
else
168+
fallback()
169+
end
170+
end, { 'i', 's' }),
171+
}),
172+
sources = cmp.config.sources({
173+
{ name = 'nvim_lsp' },
174+
{ name = 'nvim_lsp_signature_help' },
175+
{ name = 'luasnip' },
176+
{ name = 'luasnip_choice' },
177+
{ name = 'render-markdown' },
178+
{ name = 'buffer' },
179+
{ name = 'path' },
180+
{ name = 'nvim_lua' },
181+
{ name = 'treesitter' },
182+
{ name = 'vim_lsp' },
183+
{ name = 'dotenv' },
184+
{ name = 'diag-codes' },
185+
{ name = 'css-variables' },
186+
{ name = 'tw2css' },
187+
{
188+
name = 'cmp_help_tags', -- '_' not '-' 😯
189+
-- recommended to avoid cluttering
190+
keyword_length = 5,
191+
},
192+
{
193+
name = 'look',
194+
keyword_length = 3,
195+
option = {
196+
convert_case = true,
197+
loud = true,
198+
},
199+
max_item_count = 5,
200+
},
201+
{
202+
name = 'rg',
203+
-- Try it when you feel cmp performance is poor
204+
-- keyword_length = 3
205+
},
206+
{ name = 'nerdfont' },
207+
}),
208+
formatting = {
209+
fields = { 'abbr', 'kind', 'menu' },
210+
format = function(entry, vim_item)
211+
-- Kind icons
212+
-- This concatenates the icons with the name of the item kind
213+
vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind], vim_item.kind)
214+
-- Trim text function
215+
function trim(text)
216+
local max = 40
217+
if text and text:len(1, max) > max then
218+
text = text:sub(1, max) .. '...'
219+
end
220+
return text
221+
end
222+
vim_item.abbr = trim(vim_item.abbr)
223+
-- Source
224+
vim_item.menu = ({
225+
nvim_lsp = '( LSP )',
226+
nvim_lsp_signature_help = '( Signature )',
227+
luasnip = '( LuaSnip )',
228+
buffer = '( Buffer )',
229+
path = '( Path )',
230+
nvim_lua = '( Lua )',
231+
treesitter = '( Treesitter )',
232+
look = '( Look )',
233+
cmdline = '( CMD )',
234+
})[entry.source.name]
235+
return vim_item
236+
end,
237+
},
238+
sorting = {
239+
comparators = {
240+
cmp.config.compare.score,
241+
cmp.config.compare.offset,
242+
cmp.config.compare.exact,
243+
cmp.config.compare.recently_used,
244+
cmp.config.compare.length,
245+
cmp.config.compare.locality,
246+
cmp.config.compare.kind,
247+
cmp.config.compare.sort_text,
248+
cmp.config.compare.order,
249+
},
250+
},
251+
experimental = {
252+
ghost_text = true,
253+
},
254+
})
255+
256+
-- ╭─────────────────────────╮
257+
-- │ CMP CMDLINE FOR / AND ?│
258+
-- ╰─────────────────────────╯
259+
cmp.setup.cmdline({ '/', '?' }, {
260+
mapping = cmp.mapping.preset.cmdline(),
261+
sources = {
262+
{ name = 'buffer' },
263+
},
264+
})
265+
266+
-- ╭───────────────────╮
267+
-- │ CMP CMDLINE FOR : │
268+
-- ╰───────────────────╯
269+
cmp.setup.cmdline(':', {
270+
mapping = cmp.mapping.preset.cmdline(),
271+
sources = cmp.config.sources({
272+
{ name = 'path', group_index = 1 },
273+
{ name = 'cmdline', group_index = 2 },
274+
}),
275+
matching = { disallow_symbol_nonprefix_matching = false },
276+
})
277+
278+
-- ╭────────────────╮
279+
-- │ NVIM-AUTOPAIRS │
280+
-- ╰────────────────╯
281+
local cmp_autopairs = require('nvim-autopairs.completion.cmp')
282+
local ts_utils = require('nvim-treesitter.ts_utils')
283+
284+
local ts_node_func_parens_disabled = {
285+
-- ecma
286+
named_imports = true,
287+
-- rust
288+
use_declaration = true,
289+
}
290+
291+
local default_handler = cmp_autopairs.filetypes['*']['('].handler
292+
cmp_autopairs.filetypes['*']['('].handler = function(char, item, bufnr, rules, commit_character)
293+
local node_type = ts_utils.get_node_at_cursor():type()
294+
if ts_node_func_parens_disabled[node_type] then
295+
if item.data then
296+
item.data.funcParensDisabled = true
297+
else
298+
char = ''
299+
end
300+
end
301+
default_handler(char, item, bufnr, rules, commit_character)
302+
end
303+
304+
cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done())
305+
end,
306+
}

0 commit comments

Comments
 (0)