Setup cmp somewhat

This commit is contained in:
pfych 2025-02-26 15:15:00 +11:00
parent 3a5ab74f00
commit eae53e3035

View File

@ -10,6 +10,48 @@ return {
local nvim_lsp = require("lspconfig")
local capabilities = require('cmp_nvim_lsp').default_capabilities()
local cmp = require("cmp")
cmp.setup({
expand = function ()
require("cmp.config").set_onetime({ sources = {} })
end,
window = {
completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered()
},
sources = {
{ name = "path" },
{ name = "nvim_lsp" },
{ name = "buffer" }
},
formatting = {
fields = {"menu", "abbr", "kind"},
format = function(entry, item)
local menu_icon = {
nvim_lsp = 'λ',
buffer = 'Ω',
path = '',
}
item.menu = menu_icon[entry.source.name]
return item
end
},
mapping = cmp.mapping.preset.insert({
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
local entry = cmp.get_selected_entry()
if not entry then
cmp.select_next_item({ behavior = cmp.SelectBehavior.Select })
end
cmp.confirm()
else
fallback()
end
end, {"i","s","c",}),
})
})
nvim_lsp.lua_ls.setup({
capabilities = capabilities,
settings = {