aboutsummaryrefslogtreecommitdiff
path: root/lua/plugins/cmp-22.10.14-23:39-bak.lua
blob: 3b0a8f5443a2e1d0de3d93ae718b32944a10ab3c (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
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
local cmp_status_ok, cmp = pcall(require, "cmp")
if not cmp_status_ok then
	return
end

vim.o.completeopt = "menu,menuone,noselect"

--require("luasnip/loaders/from_vscode").lazy_load()
--local luasnip = require "luasnip"

cmp.setup {
  snippet = {
    expand = function(args)
      require("luasnip").lsp_expand(args.body)
    end,
  },
  mapping = {
    ['<C-Space>'] = cmp.mapping.complete(),
    ['<C-e>'] = cmp.mapping.close(),
    ['<CR>'] = cmp.mapping.confirm {
      behavior = cmp.ConfirmBehavior.Replace,
      select = true,
    },
    ['<Down>'] = cmp.mapping(cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Select }), {'i'}),
    ['<Up>'] = cmp.mapping(cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Select }), {'i'}),
  },
  sources = {
    { name = 'nvim_lsp' },
    { name = 'treesitter' },
    { name = 'luasnip' },
  }
}
--local lspkind = require("lspkind")
--cmp.setup({
--	formatting = {
--		format = lspkind.cmp_format({
--			mode = "symbol", -- 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)
--			ellipsis_char = "...", -- when popup menu exceed maxwidth, the truncated part would show ellipsis_char instead (must define maxwidth first)
--
--			-- The function below will be called before any actual modifications from lspkind
--			-- so that you can provide more controls on popup customization. (See [#30](https://github.com/onsails/lspkind-nvim/pull/30))
--			before = function(entry, vim_item)
--				--...
--				return vim_item
--			end,
--		}),
--	},
--})
--
--require("luasnip/loaders/from_vscode").lazy_load()
--
----   פּ ﯟ  some other good icons
--local kind_icons = {
--	Text = "",
--	Method = "",
--	Function = "",
--	Constructor = "⚙️",
--	Field = "",
--	Variable = "",
--	Class = "ﴯ",
--	Interface = "",
--	Module = "",
--	Property = "ﰠ",
--	Unit = "",
--	Value = "",
--	Enum = "",
--	Keyword = "",
--	Snippet = "",
--	Color = "",
--	File = "",
--	Reference = "",
--	Folder = "",
--	EnumMember = "",
--	Constant = "",
--	Struct = "",
--	Event = "",
--	Operator = "",
--	TypeParameter = "",
--}
--
---- find more here: https://www.nerdfonts.com/cheat-sheet
--
--cmp.setup({
--	snippet = {
--		expand = function(args)
--			require("luasnip").lsp_expand(args.body)
--		end,
--	},
--	mapping = cmp.mapping.preset.insert({
--		["<C-d>"] = cmp.mapping.scroll_docs(-4),
--		["<C-f>"] = cmp.mapping.scroll_docs(4),
--		["<C-Space>"] = cmp.mapping.complete(),
--		["<C-e>"] = cmp.mapping.close(),
--		["<CR>"] = cmp.mapping.confirm({
--			behavior = cmp.ConfirmBehavior.Replace,
--			select = true,
--		}),
--	}),
--	sources = cmp.config.sources({
--		{ name = "path" },
--		{ name = "nvim_lsp", keyword_length = 3 },
--		{ name = "buffer", keyword_length = 3 },
--		{ name = "luasnip", keyword_length = 4 },
--		{ name = "cmdline", keyword_pattern = [=[[^[:blank:]\!]*]=], keyword_length = 3 },
--		--{ name = "cmdline", keyword_pattern = [=[[^[:blank:]\!]*]=] }, --exclamation mark hangs a bit without this
--		--{name = 'luasnip', keyword_length = 2},
--	}),
--	formatting = {
--		fields = { "kind", "abbr", "menu" },
--		format = function(entry, vim_item)
--			-- Kind icons
--			vim_item.kind = string.format("%s", kind_icons[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 = "[Snippet]",
--				buffer = "[Buffer]",
--				path = "[Path]",
--			})[entry.source.name]
--			return vim_item
--		end,
--	},
--	confirm_opts = {
--		behavior = cmp.ConfirmBehavior.Replace,
--		select = false,
--	},
--	window = {
--		documentation = {
--			border = { "╭", "─", "╮", "│", "╯", "─", "╰", "│" },
--		},
--	},
--	experimental = {
--		ghost_text = true,
--		native_menu = false,
--		--view = {
--		--  entries = "native"
--		--},
--	},
--})
--
----vim.cmd([[
----  set completeopt=menuone,noinsert,noselect
----  highlight! default link CmpItemKind CmpItemMenuDefault
----]])
--
--cmp.setup.cmdline("/", {
--	mapping = cmp.mapping.preset.cmdline(),
--	sources = {
--		{ name = "buffer" },
--	},
--})
--
--cmp.setup.cmdline(":", {
--	mapping = cmp.mapping.preset.cmdline(),
--	sources = cmp.config.sources({
--		{ name = "path" },
--	}, {
--		{ name = "cmdline" },
--	}),
--})