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
|
-- Setup nvim-cmp.
vim.opt.completeopt = "menu,menuone,noselect"
local cmp_status_ok, cmp = pcall(require, "cmp")
if not cmp_status_ok then
return
end
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,
-- whether to show outline guides
-- default: 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 = {},
})
local lspkind = require("lspkind")
--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 = "",
--}
cmp.setup({
snippet = {
expand = function(args)
require("luasnip").lsp_expand(args.body)
end,
},
mapping = cmp.mapping.preset.insert({
-- ["<CR>"] = cmp.mapping.confirm({
-- behavior = cmp.ConfirmBehavior.Replace,
-- select = true,
-- }),
['<C-y>'] = cmp.mapping.confirm({ select = true }),
["<C-e>"] = cmp.mapping.close(),
["<C-u>"] = cmp.mapping.scroll_docs(-4),
["<C-d>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete(),
}),
formatting = {
fields = { "abbr", "kind", "menu" },
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,
},
sources = cmp.config.sources({
{ name = "path" },
{ name = "nvim_lsp", keyword_length = 3 },
{ name = "luasnip", keyword_length = 4 },
{ name = "buffer", keyword_length = 3 },
--{ name = 'treesitter' },
{ 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},
}),
confirm_opts = {
behavior = cmp.ConfirmBehavior.Replace,
select = false,
},
window = {
completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(),
--documentation = {
-- border = { "╭", "─", "╮", "│", "╯", "─", "╰", "│" },
--},
},
-- experimental = {
-- ghost_text = true,
-- native_menu = true,
-- --native_menu = false,
-- --view = {
-- -- entries = "native"
-- --},
-- },
})
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" },
}),
})
|