feat: improve cmp source and provider
This commit is contained in:
@@ -27,6 +27,12 @@ for _, item in ipairs(data.keys.misc) do
|
|||||||
add_keymap(item)
|
add_keymap(item)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- ━━━━━━━━━━━━━━━━━━━━━━━━━ Telescope Keybinds ━━━━━━━━━━━━━━━━━━━━━━
|
||||||
|
-- Add keymaps for telescope symbols
|
||||||
|
for _, item in ipairs(data.keys.telescope.symbols) do
|
||||||
|
add_keymap(item)
|
||||||
|
end
|
||||||
|
|
||||||
-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━ Resizing splits ━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━ Resizing splits ━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||||
-- Add keymaps for resizing splits
|
-- Add keymaps for resizing splits
|
||||||
for _, map in ipairs(data.keys.splits.resize) do
|
for _, map in ipairs(data.keys.splits.resize) do
|
||||||
|
|||||||
+18
-2
@@ -1221,7 +1221,15 @@ M.telescope = {
|
|||||||
"<leader>f.",
|
"<leader>f.",
|
||||||
function()
|
function()
|
||||||
require("telescope.builtin").symbols({
|
require("telescope.builtin").symbols({
|
||||||
sources = { "emoji", "kaomoji", "gitmoji", "nerd", "math" },
|
sources = {
|
||||||
|
"nerd",
|
||||||
|
"emoji",
|
||||||
|
"kaomoji",
|
||||||
|
"gitmoji",
|
||||||
|
"math",
|
||||||
|
"latex",
|
||||||
|
"julia",
|
||||||
|
},
|
||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
desc = "Pick Icons",
|
desc = "Pick Icons",
|
||||||
@@ -1230,7 +1238,15 @@ M.telescope = {
|
|||||||
"<C-.>",
|
"<C-.>",
|
||||||
function()
|
function()
|
||||||
require("telescope.builtin").symbols({
|
require("telescope.builtin").symbols({
|
||||||
sources = { "emoji", "kaomoji", "gitmoji", "nerd", "math" },
|
sources = {
|
||||||
|
"nerd",
|
||||||
|
"emoji",
|
||||||
|
"kaomoji",
|
||||||
|
"gitmoji",
|
||||||
|
"math",
|
||||||
|
"latex",
|
||||||
|
"julia",
|
||||||
|
},
|
||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
desc = "Pick Icon",
|
desc = "Pick Icon",
|
||||||
|
|||||||
+23
-16
@@ -5,7 +5,6 @@
|
|||||||
-- ╰─────────────────────────────────────────────────────────╯
|
-- ╰─────────────────────────────────────────────────────────╯
|
||||||
local data = require("data")
|
local data = require("data")
|
||||||
local perf = vim.g.cmp_performance_enabled or false
|
local perf = vim.g.cmp_performance_enabled or false
|
||||||
|
|
||||||
--- Function to return the cmp provider
|
--- Function to return the cmp provider
|
||||||
---@param performance? boolean Whether to use the experimental cmp performance fork
|
---@param performance? boolean Whether to use the experimental cmp performance fork
|
||||||
---@return table provider The cmp provider spec
|
---@return table provider The cmp provider spec
|
||||||
@@ -15,7 +14,8 @@ local function cmp_provider(performance)
|
|||||||
url = "yioneko/nvim-cmp",
|
url = "yioneko/nvim-cmp",
|
||||||
-- Experiemental cmp performance fork
|
-- Experiemental cmp performance fork
|
||||||
dev = true,
|
dev = true,
|
||||||
build = "git clone https://github.com/yioneko/nvim-cmp.git ~/projects/nvim-cmp/",
|
branch = "perf-up",
|
||||||
|
build = "git clone -b perf-up https://github.com/yioneko/nvim-cmp.git ~/projects/nvim-cmp/",
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
return {
|
return {
|
||||||
@@ -24,30 +24,28 @@ local function cmp_provider(performance)
|
|||||||
dev = false,
|
dev = false,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
local cmp_repo = cmp_provider(perf)
|
||||||
return { -- cmp
|
return { -- cmp
|
||||||
cmp_provider(perf).url,
|
url = cmp_repo.url,
|
||||||
build = cmp_provider(perf).build,
|
build = cmp_repo.build,
|
||||||
dev = cmp_provider(perf).dev,
|
branch = cmp_repo.branch,
|
||||||
|
dev = cmp_repo.dev,
|
||||||
event = "VeryLazy",
|
event = "VeryLazy",
|
||||||
dependencies = data.deps.cmp,
|
dependencies = data.deps.cmp,
|
||||||
config = function()
|
config = function()
|
||||||
local cmp = require("cmp")
|
local cmp = require("cmp")
|
||||||
local luasnip = require("luasnip")
|
local luasnip = require("luasnip")
|
||||||
|
|
||||||
cmp.event:on("menu_opened", function()
|
cmp.event:on("menu_opened", function()
|
||||||
if data.cond.neocodeium() == true then
|
if data.cond.neocodeium() == true then
|
||||||
require("neocodeium").clear()
|
require("neocodeium").clear()
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
cmp.event:on("menu_closed", function()
|
cmp.event:on("menu_closed", function()
|
||||||
if data.cond.neocodeium() == true then
|
if data.cond.neocodeium() == true then
|
||||||
require("neocodeium.commands").enable()
|
require("neocodeium.commands").enable()
|
||||||
require("neocodeium").cycle_or_complete()
|
require("neocodeium").cycle_or_complete()
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local border_opts = {
|
local border_opts = {
|
||||||
border = vim.g.completion_borders or "rounded",
|
border = vim.g.completion_borders or "rounded",
|
||||||
}
|
}
|
||||||
@@ -56,7 +54,6 @@ return { -- cmp
|
|||||||
documentation = cmp.config.window.bordered(border_opts),
|
documentation = cmp.config.window.bordered(border_opts),
|
||||||
}
|
}
|
||||||
luasnip.config.setup({})
|
luasnip.config.setup({})
|
||||||
|
|
||||||
local has_words_before = function()
|
local has_words_before = function()
|
||||||
unpack = unpack or table.unpack
|
unpack = unpack or table.unpack
|
||||||
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
||||||
@@ -67,7 +64,6 @@ return { -- cmp
|
|||||||
:match("%s")
|
:match("%s")
|
||||||
== nil
|
== nil
|
||||||
end
|
end
|
||||||
|
|
||||||
cmp.setup({
|
cmp.setup({
|
||||||
snippet = {
|
snippet = {
|
||||||
expand = function(args)
|
expand = function(args)
|
||||||
@@ -137,6 +133,18 @@ return { -- cmp
|
|||||||
fields = { "abbr", "kind", "menu" },
|
fields = { "abbr", "kind", "menu" },
|
||||||
expandable_indicator = true,
|
expandable_indicator = true,
|
||||||
format = function(entry, item)
|
format = function(entry, item)
|
||||||
|
local custom_menu_icon = {
|
||||||
|
calc = " Calculator",
|
||||||
|
math = " Math",
|
||||||
|
nerd = " Glyphs",
|
||||||
|
gitmoji = " Gitmoji",
|
||||||
|
emoji = " Emoji",
|
||||||
|
conventionalcommits = " Commit Message",
|
||||||
|
path = " Path",
|
||||||
|
buffer = " Buffer",
|
||||||
|
dotenv = " Dotenv",
|
||||||
|
cmp_yanky = " History",
|
||||||
|
}
|
||||||
local color_item =
|
local color_item =
|
||||||
require("nvim-highlight-colors").format(entry, { kind = item.kind })
|
require("nvim-highlight-colors").format(entry, { kind = item.kind })
|
||||||
item = require("lspkind").cmp_format({
|
item = require("lspkind").cmp_format({
|
||||||
@@ -146,11 +154,14 @@ return { -- cmp
|
|||||||
item.kind_hl_group = color_item.abbr_hl_group
|
item.kind_hl_group = color_item.abbr_hl_group
|
||||||
item.kind = color_item.abbr
|
item.kind = color_item.abbr
|
||||||
end
|
end
|
||||||
|
-- if entry.source.name is in the custom_menu_icon table, match its icon
|
||||||
|
if custom_menu_icon[entry.source.name] then
|
||||||
|
item.kind = custom_menu_icon[entry.source.name]
|
||||||
|
end
|
||||||
return item
|
return item
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
-- `:` cmdline setup.
|
-- `:` cmdline setup.
|
||||||
cmp.setup.cmdline(":", {
|
cmp.setup.cmdline(":", {
|
||||||
mapping = cmp.mapping.preset.cmdline(),
|
mapping = cmp.mapping.preset.cmdline(),
|
||||||
@@ -167,7 +178,6 @@ return { -- cmp
|
|||||||
name = "cmp-cmdline-prompt",
|
name = "cmp-cmdline-prompt",
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Additional setup for cmdline filetype
|
-- Additional setup for cmdline filetype
|
||||||
cmp.setup.filetype("cmdline", {
|
cmp.setup.filetype("cmdline", {
|
||||||
sources = {
|
sources = {
|
||||||
@@ -177,19 +187,16 @@ return { -- cmp
|
|||||||
{ name = "cmp-cmdline-prompt" },
|
{ name = "cmp-cmdline-prompt" },
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Input filetype
|
-- Input filetype
|
||||||
cmp.setup.filetype("input", {
|
cmp.setup.filetype("input", {
|
||||||
sources = {},
|
sources = {},
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Custom filetype configuration
|
-- Custom filetype configuration
|
||||||
cmp.setup.filetype("config", {
|
cmp.setup.filetype("config", {
|
||||||
sources = vim.tbl_filter(function(source)
|
sources = vim.tbl_filter(function(source)
|
||||||
return source.name ~= "emoji" and source.name ~= "gitmoji"
|
return source.name ~= "emoji" and source.name ~= "gitmoji"
|
||||||
end, cmp.get_config().sources),
|
end, cmp.get_config().sources),
|
||||||
})
|
})
|
||||||
|
|
||||||
-- List of filetypes to disable completion
|
-- List of filetypes to disable completion
|
||||||
local disabled_filetypes = data.types.cmp
|
local disabled_filetypes = data.types.cmp
|
||||||
for _, filetype in ipairs(disabled_filetypes) do
|
for _, filetype in ipairs(disabled_filetypes) do
|
||||||
|
|||||||
Reference in New Issue
Block a user