aboutsummaryrefslogtreecommitdiffstats
path: root/lua/pi/completition
diff options
context:
space:
mode:
Diffstat (limited to 'lua/pi/completition')
-rw-r--r--lua/pi/completition/init.lua74
1 files changed, 37 insertions, 37 deletions
diff --git a/lua/pi/completition/init.lua b/lua/pi/completition/init.lua
index 418c6d2..9ac1216 100644
--- a/lua/pi/completition/init.lua
+++ b/lua/pi/completition/init.lua
@@ -55,28 +55,30 @@ cmp.setup {
["<c-space>"] = cmp.mapping.complete(),
},
sources = {
- { name = "dictionary", keyword_length = 2},
+ { name = "dictionary", keyword_length = 2 },
{ name = "nvim_lua" },
{ name = "nvim_lsp" },
{ name = "path" },
{ name = "luasnip" },
{ name = "copilot" },
- {name = "codeium"},
+ { name = "codeium" },
-- { name = 'cmp_ai' },
- { name = 'html-css',
- option = {
- max_count = {}, -- not ready yet
- enable_on = {
- "html",
- "css"
- }, -- set the file types you want the plugin to work on
- file_extensions = { "css", "sass", "less" }, -- set the local filetypes from which you want to derive classes
- style_sheets = {
- -- example of remote styles, only css no js for now
- "https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css",
- "https://cdn.jsdelivr.net/npm/bulma@0.9.4/css/bulma.min.css",
- }
- }
+ {
+ name = "html-css",
+ option = {
+ spa = {
+ enable = false, -- SPA mode is disabled by default
+ entry_file = "index.html", -- if entry_file is omitted, it defaults to index.html in root dir
+ },
+ max_count = {}, -- not ready yet
+ enable_on = { "html", "css" }, -- set the file types you want the plugin to work on
+ file_extensions = { "css", "sass", "less" }, -- set the local filetypes from which you want to derive classes
+ style_sheets = {
+ -- example of remote styles, only css no js for now
+ "https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css",
+ "https://cdn.jsdelivr.net/npm/bulma@0.9.4/css/bulma.min.css",
+ },
+ },
},
{
name = "buffer",
@@ -104,12 +106,12 @@ cmp.setup {
},
formatting = {
- format = function (entry, vim_item)
+ format = function(entry, vim_item)
if entry.source.name == "html-css" then
- vim_item.menu = entry.completion_item.menu
+ source_mapping["html-css"] = "[" .. entry.completion_item.provider .. "]" or "[html-css]"
end
local KIND_ICONS = {
- Tailwind = '󰹞󰹞󰹞󰹞󰹞󰹞󰹞󰹞',
+ Tailwind = "󰹞󰹞󰹞󰹞󰹞󰹞󰹞󰹞",
Copilot = "",
Ollama = "",
Text = "󰉿",
@@ -140,20 +142,20 @@ cmp.setup {
TypeParameter = "󰜅",
OpenAI = "",
TinyLlama = "󱝊",
- LlamaCPP = ""
+ LlamaCPP = "",
}
- if vim_item.kind == 'Color' and entry.completion_item.documentation then
+ if vim_item.kind == "Color" and entry.completion_item.documentation then
local _, _, r, g, b =
- ---@diagnostic disable-next-line: param-type-mismatch
- string.find(entry.completion_item.documentation, '^rgb%((%d+), (%d+), (%d+)')
+ ---@diagnostic disable-next-line: param-type-mismatch
+ string.find(entry.completion_item.documentation, "^rgb%((%d+), (%d+), (%d+)")
if r and g and b then
- local color = string.format('%02x', r) .. string.format('%02x', g) .. string.format('%02x', b)
- local group = 'Tw_' .. color
+ local color = string.format("%02x", r) .. string.format("%02x", g) .. string.format("%02x", b)
+ local group = "Tw_" .. color
- if vim.api.nvim_call_function('hlID', { group }) < 1 then
- vim.api.nvim_command('highlight' .. ' ' .. group .. ' ' .. 'guifg=#' .. color)
+ if vim.api.nvim_call_function("hlID", { group }) < 1 then
+ vim.api.nvim_command("highlight" .. " " .. group .. " " .. "guifg=#" .. color)
end
vim_item.kind = KIND_ICONS.Tailwind
@@ -165,18 +167,16 @@ cmp.setup {
vim_item.kind = KIND_ICONS[vim_item.kind] or vim_item.kind
-- Add maxwidth and ellipsis_char in the middle
- local maxwidth = 20
- local ellipsis_char = '...'
+ local maxwidth = 50
+ local ellipsis_char = "..."
if #vim_item.abbr > maxwidth then
local half_width = math.floor((maxwidth - #ellipsis_char) / 2)
- vim_item.abbr = string.sub(
- vim_item.abbr,
- 1,
- half_width
- ) .. ellipsis_char .. string.sub(vim_item.abbr, -half_width)
+ vim_item.abbr = string.sub(vim_item.abbr, 1, half_width)
+ .. ellipsis_char
+ .. string.sub(vim_item.abbr, -half_width)
end
return vim_item
- end
+ end,
},
sorting = {
@@ -198,8 +198,8 @@ vim.api.nvim_set_hl(0, "CmpItemKindCopilot", { fg = "#3426C3" })
vim.api.nvim_set_hl(0, "CmpItemKindCodeium", { fg = "#2ACDBA" })
vim.api.nvim_set_hl(0, "CmpItemKindOllama", { fg = "#FDFEFF" })
vim.api.nvim_set_hl(0, "CmpItemKindOpenAI", { fg = "#080808" })
-vim.api.nvim_set_hl(0, "CmpItemKindTinyLlama", { fg = "#DF468C"})
-vim.api.nvim_set_hl(0, "CmpItemKindLlamaCPP", { fg = "#FF8235"})
+vim.api.nvim_set_hl(0, "CmpItemKindTinyLlama", { fg = "#DF468C" })
+vim.api.nvim_set_hl(0, "CmpItemKindLlamaCPP", { fg = "#FF8235" })
-- Set configuration for specific filetype.
cmp.setup.filetype("gitcommit", {