style(nvim): format cmp
This commit is contained in:
parent
5ae9d2d2f8
commit
9f8298fa0a
@ -10,66 +10,29 @@ require("luasnip.loaders.from_vscode").lazy_load()
|
|||||||
cmp.setup({
|
cmp.setup({
|
||||||
formatting = {
|
formatting = {
|
||||||
|
|
||||||
fields = {
|
fields = { cmp.ItemField.Kind, cmp.ItemField.Abbr, cmp.ItemField.Menu },
|
||||||
cmp.ItemField.Kind,
|
|
||||||
cmp.ItemField.Abbr,
|
|
||||||
cmp.ItemField.Menu,
|
|
||||||
},
|
|
||||||
format = function(entry, vim_item)
|
format = function(entry, vim_item)
|
||||||
local selections = {
|
local selections = {
|
||||||
fuzzy_buffer = {
|
fuzzy_buffer = { symbol = " ", name = "Buffer" },
|
||||||
symbol = " ",
|
luasnip = { symbol = " ", name = "Snippet" },
|
||||||
name = "Buffer",
|
path = { symbol = " ", name = "Path" },
|
||||||
},
|
calc = { symbol = " ", name = "Calculator" },
|
||||||
luasnip = {
|
neorg = { symbol = " ", name = "Neorg" },
|
||||||
symbol = " ",
|
emoji = { symbol = "ﲃ ", name = "Emoji" },
|
||||||
name = "Snippet",
|
zsh = { symbol = " ", name = "Zsh" },
|
||||||
},
|
crates = { symbol = " ", name = "Crates" },
|
||||||
path = {
|
cmdline_history = { symbol = " ", name = "Cmd History" },
|
||||||
symbol = " ",
|
rg = { symbol = " ", name = "Ripgrep" },
|
||||||
name = "Path",
|
npm = { symbol = " ", name = "Npm," },
|
||||||
},
|
conventionalcommits = { symbol = " ", name = "Commit" },
|
||||||
calc = {
|
|
||||||
symbol = " ",
|
|
||||||
name = "Calculator",
|
|
||||||
},
|
|
||||||
neorg = {
|
|
||||||
symbol = " ",
|
|
||||||
name = "Neorg",
|
|
||||||
},
|
|
||||||
emoji = {
|
|
||||||
symbol = "ﲃ ",
|
|
||||||
name = "Emoji",
|
|
||||||
},
|
|
||||||
zsh = {
|
|
||||||
symbol = " ",
|
|
||||||
name = "Zsh",
|
|
||||||
},
|
|
||||||
crates = {
|
|
||||||
symbol = " ",
|
|
||||||
name = "Crates",
|
|
||||||
},
|
|
||||||
cmdline_history = {
|
|
||||||
symbol = " ",
|
|
||||||
name = "Cmd History",
|
|
||||||
},
|
|
||||||
rg = {
|
|
||||||
symbol = " ",
|
|
||||||
name = "Ripgrep",
|
|
||||||
},
|
|
||||||
npm = {
|
|
||||||
symbol = " ",
|
|
||||||
name = "Npm,",
|
|
||||||
},
|
|
||||||
conventionalcommits = {
|
|
||||||
symbol = " ",
|
|
||||||
name = "Commit",
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
local selection = selections[entry.source.name]
|
local selection = selections[entry.source.name]
|
||||||
if not selection then
|
if not selection then
|
||||||
local kind = require("lspkind").cmp_format({ mode = "symbol_text", maxwidth = 50 })(entry, vim_item)
|
local kind = require("lspkind").cmp_format({
|
||||||
|
mode = "symbol_text",
|
||||||
|
maxwidth = 50,
|
||||||
|
})(entry, vim_item)
|
||||||
local strings = vim.split(kind.kind, "%s", { trimempty = true })
|
local strings = vim.split(kind.kind, "%s", { trimempty = true })
|
||||||
kind.kind = " " .. strings[1] .. " "
|
kind.kind = " " .. strings[1] .. " "
|
||||||
vim_item.menu = strings[1] .. " " .. strings[2]
|
vim_item.menu = strings[1] .. " " .. strings[2]
|
||||||
@ -95,19 +58,14 @@ cmp.setup({
|
|||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
window = {
|
window = {
|
||||||
documentation = {
|
documentation = { side_padding = 0 },
|
||||||
side_padding = 0,
|
|
||||||
},
|
|
||||||
completion = {
|
completion = {
|
||||||
winhighlight = "Normal:Pmenu,FloatBorder:Pmenu,Search:None",
|
winhighlight = "Normal:Pmenu,FloatBorder:Pmenu,Search:None",
|
||||||
col_offset = -3,
|
col_offset = -3,
|
||||||
side_padding = 0,
|
side_padding = 0,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
experimental = {
|
experimental = { ghost_text = true, native_menu = false },
|
||||||
ghost_text = true,
|
|
||||||
native_menu = false,
|
|
||||||
},
|
|
||||||
snippet = {
|
snippet = {
|
||||||
-- REQUIRED - you must specify a snippet engine
|
-- REQUIRED - you must specify a snippet engine
|
||||||
expand = function(args)
|
expand = function(args)
|
||||||
@ -189,30 +147,20 @@ cmp.setup({
|
|||||||
|
|
||||||
-- Git Commit Completions
|
-- Git Commit Completions
|
||||||
cmp.setup.filetype("gitcommit", {
|
cmp.setup.filetype("gitcommit", {
|
||||||
sources = cmp.config.sources({
|
sources = cmp.config.sources({ { name = "conventionalcommits", priority = 20 } }),
|
||||||
{ name = "conventionalcommits", priority = 20 },
|
|
||||||
}),
|
|
||||||
})
|
})
|
||||||
|
|
||||||
cmp.setup.filetype("toml", {
|
cmp.setup.filetype("toml", { sources = cmp.config.sources({ { name = "crates" } }) })
|
||||||
sources = cmp.config.sources({
|
|
||||||
{ name = "crates" },
|
|
||||||
}),
|
|
||||||
})
|
|
||||||
|
|
||||||
-- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore).
|
-- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore).
|
||||||
cmp.setup.cmdline("/", {
|
cmp.setup.cmdline("/", {
|
||||||
mapping = cmp.mapping.preset.cmdline(),
|
mapping = cmp.mapping.preset.cmdline(),
|
||||||
sources = cmp.config.sources({
|
sources = cmp.config.sources({ { name = "fuzzy_buffer" } }),
|
||||||
{ name = "fuzzy_buffer" },
|
|
||||||
}),
|
|
||||||
})
|
})
|
||||||
|
|
||||||
cmp.setup.cmdline("?", {
|
cmp.setup.cmdline("?", {
|
||||||
mapping = cmp.mapping.preset.cmdline(),
|
mapping = cmp.mapping.preset.cmdline(),
|
||||||
sources = cmp.config.sources({
|
sources = cmp.config.sources({ { name = "fuzzy_buffer" } }),
|
||||||
{ name = "fuzzy_buffer" },
|
|
||||||
}),
|
|
||||||
})
|
})
|
||||||
|
|
||||||
cmp.setup.cmdline("@", {
|
cmp.setup.cmdline("@", {
|
||||||
|
Loading…
Reference in New Issue
Block a user