-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompletion.lua
More file actions
133 lines (128 loc) · 3.8 KB
/
Copy pathcompletion.lua
File metadata and controls
133 lines (128 loc) · 3.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
--- Autocompletion configuration for Neovim using nvim-cmp and various sources
---
--- Author: @lararosekelley
--- Last Modified: August 27th, 2025
---
--- Bugs: https://github.com/folke/noice.nvim/issues/1142
return {
{
"hrsh7th/nvim-cmp",
event = { "InsertEnter", "CmdlineEnter" },
dependencies = {
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-nvim-lua",
"hrsh7th/cmp-path",
"hrsh7th/cmp-emoji",
"garyhurtz/cmp_kitty",
"hrsh7th/cmp-cmdline",
"zbirenbaum/copilot-cmp",
{
"MattiasMTS/cmp-dbee",
dependencies = {
{ "kndndrj/nvim-dbee" },
},
ft = "sql",
opts = {}, -- needed
},
{
"garymjr/nvim-snippets",
opts = {
friendly_snippets = true,
},
dependencies = { "rafamadriz/friendly-snippets" },
},
},
opts = function()
vim.api.nvim_set_hl(0, "CmpGhostText", { link = "Comment", default = true })
local cmp = require("cmp")
local defaults = require("cmp.config.default")()
-- search and help
cmp.setup.cmdline({ "/", "?" }, {
mapping = cmp.mapping.preset.cmdline(),
sources = {
{ name = "buffer" },
},
})
-- vim command line
cmp.setup.cmdline(":", {
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({
{ name = "path" },
}, {
{ name = "cmdline" },
}),
})
-- main setup
return {
-- https://github.com/hrsh7th/nvim-cmp/wiki/List-of-sources
sources = {
{ name = "copilot" },
{ name = "nvim_lsp" },
{ name = "nvim_lua" },
{ name = "snippets" },
{ name = "path" },
{ name = "emoji" },
{ name = "cmp-dbee" },
{ name = "kitty" },
{ name = "buffer" },
{ name = "lazydev", group_index = 0 }, -- skip loading LuaLS completions
},
completion = {
auto_brackets = true,
completeopt = "menu,menuone,noinsert",
},
window = {
documentation = cmp.config.window.bordered(),
completion = cmp.config.window.bordered(),
},
snippet = {
expand = function(item)
vim.snippet.expand(item.body)
end,
},
preselect = cmp.PreselectMode.Item or cmp.PreselectMode.None,
mapping = cmp.mapping.preset.insert({
["<C-b>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
-- C-n both opens the menu and walks it: it used to only walk, with
-- C-Space as the manual trigger, but herdr now takes ctrl+space
-- (no prefix) for its session navigator and grabs it before the pane.
["<C-n>"] = cmp.mapping(function()
if cmp.visible() then
cmp.select_next_item({ behavior = cmp.SelectBehavior.Insert })
else
cmp.complete()
end
end, { "i", "s" }),
["<C-p>"] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }),
["<S-CR>"] = cmp.mapping.confirm({ select = true }),
["<C-y>"] = cmp.mapping.confirm({ select = true }),
["<C-e>"] = cmp.mapping.abort(),
}),
experimental = {
ghost_text = {
hl_group = "CmpGhostText",
},
},
sorting = defaults.sorting,
}
end,
},
{
"garyhurtz/cmp_kitty",
cond = not vim.env.TMUX,
event = { "InsertEnter", "LspAttach" },
init = function()
require("cmp_kitty"):setup()
end,
},
{
"zbirenbaum/copilot-cmp",
event = { "InsertEnter", "LspAttach" },
opts = {},
config = function(_, opts)
require("copilot_cmp").setup(opts)
end,
},
}