2022-01-22 16:38:51 +01:00
|
|
|
local cmp = require "cmp"
|
|
|
|
|
|
|
|
cmp.setup {
|
|
|
|
snippet = {
|
|
|
|
expand = function(args)
|
|
|
|
require("luasnip").lsp_expand(args.body)
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
|
|
|
|
mapping = {
|
|
|
|
["<C-b>"] = cmp.mapping(cmp.mapping.scroll_docs(-4), { "i", "c" }),
|
|
|
|
["<C-f>"] = cmp.mapping(cmp.mapping.scroll_docs(4), { "i", "c" }),
|
|
|
|
["<C-Space>"] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }),
|
|
|
|
["<Tab>"] = cmp.mapping(cmp.mapping.select_next_item()),
|
|
|
|
["<S-Tab>"] = cmp.mapping(cmp.mapping.select_prev_item()),
|
|
|
|
["<CR>"] = cmp.mapping.confirm { select = true },
|
|
|
|
},
|
|
|
|
|
|
|
|
sources = cmp.config.sources {
|
2022-01-22 23:46:25 +01:00
|
|
|
{ name = "buffer" },
|
2022-01-22 16:54:56 +01:00
|
|
|
{ name = "crates" },
|
2022-01-22 23:46:25 +01:00
|
|
|
{ name = "luasnip" },
|
|
|
|
{ name = "nvim_lsp" },
|
|
|
|
{ name = "path" },
|
2022-01-22 16:57:53 +01:00
|
|
|
{ name = "rg" },
|
2022-01-23 01:25:35 +01:00
|
|
|
{ name = "treesitter" },
|
|
|
|
},
|
|
|
|
|
|
|
|
formatting = {
|
|
|
|
format = function(entry, vim_item)
|
|
|
|
vim_item.menu = ({
|
|
|
|
buffer = " ",
|
|
|
|
crates = " ",
|
|
|
|
luasnip = " ",
|
|
|
|
nvim_lsp = " ",
|
|
|
|
path = " ",
|
|
|
|
rg = " ",
|
|
|
|
treesitter = " ",
|
|
|
|
})[entry.source.name]
|
|
|
|
|
|
|
|
return vim_item
|
|
|
|
end,
|
2022-01-22 16:38:51 +01:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
cmp.setup.cmdline("/", {
|
|
|
|
sources = {
|
|
|
|
{ name = "buffer" },
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
cmp.setup.cmdline(":", {
|
|
|
|
sources = cmp.config.sources({
|
|
|
|
{ name = "path" },
|
|
|
|
}, {
|
|
|
|
{ name = "cmdline" },
|
|
|
|
}),
|
|
|
|
})
|
2022-01-23 13:49:56 +01:00
|
|
|
|
|
|
|
-- define signs
|
|
|
|
local signs = {
|
|
|
|
Error = " ",
|
|
|
|
Warn = " ",
|
|
|
|
Hint = " ",
|
|
|
|
Info = " ",
|
|
|
|
}
|
|
|
|
|
|
|
|
for k, v in pairs(signs) do
|
|
|
|
local hl = "DiagnosticSign" .. k
|
|
|
|
vim.fn.sign_define(hl, { text = v, texthl = hl, numhl = hl })
|
|
|
|
end
|