summaryrefslogtreecommitdiff
path: root/.config/nvim/lua/user/plugins/cmp.lua
blob: b4993887db7d49a358afc2b4453e910312d323fb (plain)
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
return {
	'hrsh7th/nvim-cmp',
	event = { 'InsertEnter', 'CmdlineEnter' },
	dependencies = {
		'saadparwaiz1/cmp_luasnip',
		'hrsh7th/cmp-buffer',
		'hrsh7th/cmp-cmdline',
		'hrsh7th/cmp-path',
	},
	opts = function()
		local cmp = require('cmp')

		return {
			snippet = {
				expand = function(args)
					require('luasnip').lsp_expand(args.body)
				end,
			},
			experimental = {
				ghost_text = true,
			},
			mapping = cmp.mapping.preset.insert(),
			sources = cmp.config.sources({
				{ name = 'nvim_lsp' },
				{ name = "luasnip" },
			}, {
				{ name = 'buffer' },
			}, {
				{ name = 'path' },
			}),
			sorting = {
				comparators = {
					cmp.config.compare.offset,
					cmp.config.compare.exact,
					--cmp.config.compare.scopes,
					cmp.config.compare.score,

					cmp.config.compare.locality,
					cmp.config.compare.kind,
					--cmp.config.compare.sort_text,
					cmp.config.compare.length,
					cmp.config.compare.order,
				},
			},
		}
	end,
}