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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
|
-- Setup nvim-cmp.
vim.opt.completeopt = "menu,menuone,noselect"
--vim.g.completeopt = "menu,menuone,noselect,noinsert"
local cmp_status_ok, cmp = pcall(require, "cmp")
if not cmp_status_ok then
return
end
--local WIDE_HEIGHT = 40
local opts = {
-- whether to highlight the currently hovered symbol
-- disable if your cpu usage is higher than you want it
-- or you just hate the highlight
-- default: true
highlight_hovered_item = true,
show_guides = true,
}
require("symbols-outline").setup(opts)
--local snippets_paths = function()
-- local plugins = { "friendly-snippets" }
-- local paths = {}
-- local path
-- local root_path = vim.env.HOME .. "/.vim/plugged/"
-- for _, plug in ipairs(plugins) do
-- path = root_path .. plug
-- if vim.fn.isdirectory(path) ~= 0 then
-- table.insert(paths, path)
-- end
-- end
-- return paths
--end
--
--require("luasnip.loaders.from_vscode").lazy_load({
-- paths = snippets_paths(),
-- include = nil, -- Load all languages
-- exclude = {},
--})
--require("luasnip.loaders.from_vscode").lazy_load()
local lspkind = require("lspkind")
local kind_icons = {
Text = "",
Method = "m", --"",
Function = "",
Constructor = "", --"⚙️",
Field = "",
Variable = "",
Class = "ﴯ",
Interface = "",
Module = "",
Property = "",
Unit = "",
Value = "",
Enum = "",
Keyword = "",
Snippet = "",
Color = "",
File = "",
Reference = "",
Folder = "",
EnumMember = "",
Constant = "",
Struct = "",
Event = "",
Operator = "",
TypeParameter = "",
}
cmp.setup({
snippet = {
--expand = function(args)
-- require("luasnip").lsp_expand(args.body)
--end,
expand = function(args)
local luasnip = require("luasnip")
if not luasnip then
return
end
luasnip.lsp_expand(args.body)
end,
},
mapping = cmp.mapping.preset.insert({
-- ["<CR>"] = cmp.mapping.confirm({
-- behavior = cmp.ConfirmBehavior.Replace,
-- select = true,
-- }),
--["<C-k>"] = cmp.mapping(cmp.mapping.select_prev_item(), { 'i', 'c' }),
--["<C-j>"] = cmp.mapping(cmp.mapping.select_next_item(), { 'i', 'c' }),
["<C-y>"] = cmp.mapping.confirm({ select = true }),
--["<C-e>"] = cmp.mapping.close(),
--['<C-e>'] = cmp.mapping({
-- i = cmp.mapping.abort(),
-- c = cmp.mapping.close(),
--}),
["<C-e>"] = cmp.mapping({
i = function()
if cmp.visible() then
cmp.abort()
require("user.mods").toggle_completion()
require("notify")("completion off")
else
cmp.complete()
require("user.mods").toggle_completion()
require("notify")("completion on")
end
end,
}),
--["<CR>"] = cmp.mapping({
-- i = function(fallback)
-- if cmp.visible() then
-- cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = false })
-- require("user.mods").toggle_completion()
-- else
-- fallback()
-- end
-- end,
--}),
-- ["<C-e>"] = cmp.mapping({
-- i = function()
-- if cmp.visible() then
-- require("notify")("visible")
-- cmp.abort()
-- else
-- require("notify")("not visible")
-- cmp.complete()
-- end
-- end,
-- c = function()
-- if cmp.visible() then
-- require("notify")("visible")
-- cmp.close()
-- else
-- require("notify")("not visible")
-- cmp.complete()
-- end
-- end,
-- }),
--['<CR>'] = cmp.config.disable,
["<C-u>"] = cmp.mapping.scroll_docs(-4),
["<C-d>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete(),
--['<C-o>'] = function(fallback)
-- if cmp.visible() then
-- cmp.mapping.confirm({ select = true })(fallback)
-- else
-- cmp.mapping.complete()(fallback)
-- end
--end
}),
sources = cmp.config.sources({
--{ name = "nvim_lua" },
{ name = "luasnip" },
--{ name = 'luasnip', option = { use_show_condition = false } },
{ name = "gh_issues" },
{ name = "nvim_lsp", max_item_count = 6 },
{ name = "nvim_lua" },
--{ name = "luasnip" },
--{ name = "luasnip", keyword_length = 4 },
--{ name = "buffer", keyword_length = 3 },
{ name = "path" },
{ name = "buffer", max_item_count = 6 },
--{ name = "buffer", option = { get_bufnrs = function()
-- return vim.api.nvim_list_bufs()
--end
--}},
{ name = "cmp_git" },
{ name = "spell" },
{ name = "zsh" },
{ name = "treesitter" },
{ name = "calc" },
{ name = "nvim_lsp_signature_help" },
--{ name = "cmdline" },
--{ name = 'treesitter' },
--{ name = "cmdline", keyword_pattern = [=[[^[:blank:]\!]*]=] }, --exclamation mark hangs a bit without this
--{name = 'luasnip', keyword_length = 2},
}),
formatting = {
--formatting = {
--local icons = kind_icons
--format = function(entry, vim_item)
----vim_item.kind = string.format("%s", kind_icons[vim_item.kind])
----vim_item.kind = lspkind.presets.default[vim_item.kind]
--vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind], vim_item.kind) -- This concatonates the icons with the name of the item kind
----vim_item.kind = string.format("%s %s", icons[vim_item.kind], vim_item.kind)
--vim_item.menu = ({
----nvim_lsp = "LSP",
----luasnip = "snip",
----buffer = "buf",
----path = "path",
----cmdline = "cmd",
--buffer = "[buf]",
--nvim_lsp = "[LSP]",
--nvim_lua = "[api]",
--path = "[path]",
--luasnip = "[snip]",
--cmdline = "[cmd]",
--gh_issues = "[issues]",
--})[entry.source.name]
--return vim_item
--end,
format = lspkind.cmp_format({
with_text = true,
menu = {
nvim_lsp = "[LSP]",
luasnip = "[snip]",
buffer = "[buf]",
nvim_lua = "[api]",
path = "[path]",
gh_issues = "[issues]",
spell = "[spell]",
zsh = "[zsh]",
treesitter = "[treesitter]",
calc = "[calc]",
nvim_lsp_signature_help = "[signature]",
cmdline = "[cmd]",
},
}),
--},
--
--
--fields = { "abbr", "kind", "menu" },
-- format = lspkind.cmp_format({
-- mode = 'symbol_text', -- show only symbol annotations
-- maxwidth = 50, -- prevent the popup from showing more than provided characters (e.g 50 will not show more than 50 characters)
-- })
--format = require('lspkind').cmp_format {
-- with_text = true,
-- menu = {
-- luasnip = "Snip",
-- buffer = "Buf",
-- nvim_lsp = "LSP",
-- path = "Path",
-- cmdline = "Cmd",
-- cmp_git = "Git",
-- },
--},
},
--format = function(entry, vim_item)
-- -- Kind icons
-- --vim_item.kind = string.format("%s", kind_icons[vim_item.kind])
-- vim_item.kind = lspkind.presets.default[vim_item.kind]
-- -- vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind], vim_item.kind) -- This concatonates the icons with the name of the item kind
-- vim_item.menu = ({
-- nvim_lsp = "LSP",
-- luasnip = "Snip",
-- buffer = "Buf",
-- path = "Path",
-- cmdline = "Cmd",
-- })[entry.source.name]
-- return vim_item
--end,
confirm_opts = {
behavior = cmp.ConfirmBehavior.Replace,
select = false,
},
event = {},
experimental = {
ghost_text = true, -- this feature conflicts with copilot.vim's preview.
hl_group = "Nontext",
--native_menu = false,
},
view = {
entries = { name = "custom", selection_order = "top_down" },
},
window = {
--completion = cmp.config.window.bordered(),
completion = {
border = { "", "", "", " ", "", "", "", " " },
--border = { "╭", "─", "╮", "│", "╯", "─", "╰", "│" },
--border = { '', '', '', '', '', '', '', '' },
--border = "CmpBorder",
winhighlight = "Normal:Pmenu,FloatBorder:Pmenu,CursorLine:PmenuSel,Search:None",
--winhighlight = "Normal:CmpPmenu,CursorLine:PmenuSel,Search:None",
},
--documentation = cmp.config.window.bordered(),
documentation = {
--max_height = math.floor(WIDE_HEIGHT * (WIDE_HEIGHT / vim.o.lines)),
--max_width = math.floor((WIDE_HEIGHT * 2) * (vim.o.columns / (WIDE_HEIGHT * 2 * 16 / 9))),
border = { "", "", "", " ", "", "", "", " " },
--border = { "╭", "─", "╮", "│", "╯", "─", "╰", "│" },
winhighlight = "FloatBorder:NormalFloat",
},
},
})
cmp.setup.cmdline({ "/", "?" }, {
mapping = cmp.mapping.preset.cmdline(),
sources = {
{ name = "buffer" },
},
})
cmp.setup.cmdline(":", {
mapping = {
["<C-p>"] = cmp.mapping(cmp.mapping.select_prev_item(), { "i", "c" }),
["<C-n>"] = cmp.mapping(cmp.mapping.select_next_item(), { "i", "c" }),
["<C-y>"] = cmp.mapping(cmp.mapping.confirm({ select = true }), { "i", "c" }),
["<C-e>"] = cmp.mapping(cmp.mapping.close(), { "i", "c" }),
["<C-u>"] = cmp.mapping(cmp.mapping.scroll_docs(-4), { "i", "c" }),
["<C-d>"] = cmp.mapping(cmp.mapping.scroll_docs(4), { "i", "c" }),
["<C-Space>"] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }),
--["<C-k>"] = cmp.mapping.select_prev_item(),
--["<C-j>"] = cmp.mapping.select_next_item(),
--['<C-y>'] = cmp.mapping.confirm({ select = true }),
--["<C-e>"] = cmp.mapping.close(),
----['<CR>'] = cmp.config.disable,
--["<C-u>"] = cmp.mapping.scroll_docs(-4),
--["<C-d>"] = cmp.mapping.scroll_docs(4),
--["<C-Space>"] = cmp.mapping.complete(),
},
sources = cmp.config.sources({
{ name = "path" },
}, {
--{ name = "cmdline" },
{ name = "cmdline", keyword_pattern = [=[[^[:blank:]\!]*]=], keyword_length = 3 },
}),
})
return {
"micangl/cmp-vimtex",
config = function()
require("cmp_vimtex").setup({
additional_information = {
info_in_menu = true,
info_in_window = true,
info_max_length = 60,
match_against_info = true,
symbols_in_menu = true,
},
bibtex_parser = {
enabled = true,
},
search = {
browser = "xdg-open",
default = "google_scholar",
search_engines = {
google_scholar = {
name = "Google Scholar",
get_url = require("cmp_vimtex").url_default_format("https://scholar.google.com/scholar?hl=en&q=%s"),
},
-- Other search engines.
},
},
})
end,
}
|