♻️ refactor(coding): switch to neocodeium, re-build cmp, move ai and cmp to their own lua files
Change codeium provider to neocodium. Re-build the nvim-cmp configuration to integrate better. Move ai plugins to ai.lua. Move cmp plugin to cmp.lua. This will make the code easier to navigate.
This commit is contained in:
@@ -0,0 +1,50 @@
|
|||||||
|
return {
|
||||||
|
{ -- Neocodeium
|
||||||
|
"monkoose/neocodeium",
|
||||||
|
event = "VeryLazy",
|
||||||
|
opts = {
|
||||||
|
manual = false,
|
||||||
|
silent = true,
|
||||||
|
debounce = false,
|
||||||
|
},
|
||||||
|
init = function()
|
||||||
|
vim.keymap.set("i", "<c-y>", function()
|
||||||
|
require("neocodeium").accept()
|
||||||
|
end)
|
||||||
|
vim.keymap.set("i", "<c-w>", function()
|
||||||
|
require("neocodeium").accept_word()
|
||||||
|
end)
|
||||||
|
vim.keymap.set("i", "<c-l>", function()
|
||||||
|
require("neocodeium").accept_line()
|
||||||
|
end)
|
||||||
|
vim.keymap.set("i", "<c-p>", function()
|
||||||
|
require("neocodeium").cycle_or_complete(-1)
|
||||||
|
end)
|
||||||
|
vim.keymap.set("i", "<c-n>", function()
|
||||||
|
require("neocodeium").cycle_or_complete()
|
||||||
|
end)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
{ -- Copilot
|
||||||
|
import = "lazyvim.plugins.extras.coding.copilot",
|
||||||
|
cond = function()
|
||||||
|
return vim.g.aitool == "copilot"
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
{ -- Tabnine
|
||||||
|
import = "lazyvim.plugins.extras.coding.tabnine",
|
||||||
|
cond = function()
|
||||||
|
return vim.g.aitool == "tabnine"
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
{ -- Minuet-AI
|
||||||
|
"milanglacier/minuet-ai.nvim",
|
||||||
|
dependencies = { { "nvim-lua/plenary.nvim" }, { "hrsh7th/nvim-cmp" } },
|
||||||
|
config = function()
|
||||||
|
require("minuet").setup({ provider = "openai" })
|
||||||
|
end,
|
||||||
|
cond = function()
|
||||||
|
return vim.g.aitool == "minuet"
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -0,0 +1,161 @@
|
|||||||
|
return {
|
||||||
|
{
|
||||||
|
"hrsh7th/nvim-cmp",
|
||||||
|
event = "InsertEnter",
|
||||||
|
dependencies = {
|
||||||
|
{
|
||||||
|
"L3MON4D3/LuaSnip",
|
||||||
|
build = (function()
|
||||||
|
if vim.fn.has("win32") == 1 or vim.fn.executable("make") == 0 then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
return "make install_jsregexp"
|
||||||
|
end)(),
|
||||||
|
dependencies = {
|
||||||
|
{
|
||||||
|
"rafamadriz/friendly-snippets",
|
||||||
|
config = function()
|
||||||
|
require("luasnip.loaders.from_vscode").lazy_load()
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"petertriho/cmp-git",
|
||||||
|
opts = {},
|
||||||
|
config = function()
|
||||||
|
local cmp = require("cmp")
|
||||||
|
cmp.setup.filetype("gitcommit", {
|
||||||
|
sources = cmp.config.sources({
|
||||||
|
{ name = "git", priority = 50 },
|
||||||
|
{ name = "path", priority = 40 },
|
||||||
|
}, {
|
||||||
|
{ name = "buffer", priority = 50 },
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
"saadparwaiz1/cmp_luasnip",
|
||||||
|
"hrsh7th/cmp-nvim-lsp",
|
||||||
|
"hrsh7th/cmp-path",
|
||||||
|
"hrsh7th/cmp-buffer",
|
||||||
|
"onsails/lspkind.nvim",
|
||||||
|
"hrsh7th/cmp-emoji",
|
||||||
|
{
|
||||||
|
"chrisgrieser/cmp_yanky",
|
||||||
|
option = {
|
||||||
|
onlyCurrentFiletype = false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"SergioRibera/cmp-dotenv",
|
||||||
|
"hrsh7th/cmp-calc",
|
||||||
|
"davidsierradz/cmp-conventionalcommits",
|
||||||
|
"Dynge/gitmoji.nvim",
|
||||||
|
},
|
||||||
|
config = function()
|
||||||
|
local cmp = require("cmp")
|
||||||
|
local luasnip = require("luasnip")
|
||||||
|
local lspkind = require("lspkind")
|
||||||
|
local neocodeium = require("neocodeium")
|
||||||
|
local commands = require("neocodeium.commands")
|
||||||
|
|
||||||
|
cmp.event:on("menu_opened", function()
|
||||||
|
neocodeium.clear()
|
||||||
|
end)
|
||||||
|
|
||||||
|
cmp.event:on("menu_closed", function()
|
||||||
|
commands.enable()
|
||||||
|
neocodeium.cycle_or_complete()
|
||||||
|
end)
|
||||||
|
|
||||||
|
local border_opts = {
|
||||||
|
border = "rounded",
|
||||||
|
winhighlight = "Normal:NormalFloat,FloatBorder:FloatBorder,CursorLine:PmenuSel,Search:None",
|
||||||
|
}
|
||||||
|
local window_opts = {
|
||||||
|
completion = cmp.config.window.bordered(border_opts),
|
||||||
|
documentation = cmp.config.window.bordered(border_opts),
|
||||||
|
}
|
||||||
|
luasnip.config.setup({})
|
||||||
|
|
||||||
|
cmp.setup({
|
||||||
|
snippet = {
|
||||||
|
expand = function(args)
|
||||||
|
luasnip.lsp_expand(args.body)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
completion = { completeopt = "menu,menuone,noinsert" },
|
||||||
|
window = vim.g.completion_round_borders_enabled and window_opts or {},
|
||||||
|
mapping = cmp.mapping.preset.insert({
|
||||||
|
["<C-n>"] = cmp.mapping.select_next_item(),
|
||||||
|
["<C-p>"] = cmp.mapping.select_prev_item(),
|
||||||
|
["<Up>"] = cmp.mapping.select_prev_item({
|
||||||
|
behavior = cmp.SelectBehavior.Select,
|
||||||
|
}),
|
||||||
|
["<Down>"] = cmp.mapping.select_next_item({
|
||||||
|
behavior = cmp.SelectBehavior.Select,
|
||||||
|
}),
|
||||||
|
["<C-b>"] = cmp.mapping.scroll_docs(-4),
|
||||||
|
["<C-f>"] = cmp.mapping.scroll_docs(4),
|
||||||
|
["<C-y>"] = cmp.mapping.confirm({ select = true }),
|
||||||
|
["<C-Space>"] = cmp.mapping.complete({}),
|
||||||
|
["<Tab>"] = cmp.mapping(function()
|
||||||
|
if luasnip.expand_or_locally_jumpable() then
|
||||||
|
luasnip.expand_or_jump()
|
||||||
|
end
|
||||||
|
end, { "i", "s" }),
|
||||||
|
["<S-Tab>"] = cmp.mapping(function()
|
||||||
|
if luasnip.locally_jumpable(-1) then
|
||||||
|
luasnip.jump(-1)
|
||||||
|
end
|
||||||
|
end, { "i", "s" }),
|
||||||
|
}),
|
||||||
|
sources = {
|
||||||
|
{ name = "nvim_lsp", priority = 1000 },
|
||||||
|
{ name = "luasnip", priority = 750 },
|
||||||
|
{ name = "path", priority = 250 },
|
||||||
|
{ name = "buffer", priority = 250 },
|
||||||
|
{ name = "cmp_yanky" },
|
||||||
|
{ name = "dotenv" },
|
||||||
|
{ name = "calc" },
|
||||||
|
{ name = "conventionalcommits" },
|
||||||
|
{ name = "gitmoji" },
|
||||||
|
{ name = "emoji" },
|
||||||
|
},
|
||||||
|
formatting = {
|
||||||
|
fields = { "abbr", "kind", "menu" },
|
||||||
|
expandable_indicator = true,
|
||||||
|
format = function(entry, item)
|
||||||
|
local color_item = require("nvim-highlight-colors").format(
|
||||||
|
entry,
|
||||||
|
{ kind = item.kind }
|
||||||
|
)
|
||||||
|
item = require("lspkind").cmp_format({
|
||||||
|
require("tailwind-tools.cmp").lspkind_format,
|
||||||
|
})(entry, item)
|
||||||
|
if color_item.abbr_hl_group then
|
||||||
|
item.kind_hl_group = color_item.abbr_hl_group
|
||||||
|
item.kind = color_item.abbr
|
||||||
|
end
|
||||||
|
return item
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Custom filetype configuration
|
||||||
|
cmp.setup.filetype("config", {
|
||||||
|
sources = vim.tbl_filter(function(source)
|
||||||
|
return source.name ~= "emoji" and source.name ~= "gitmoji"
|
||||||
|
end, cmp.get_config().sources),
|
||||||
|
})
|
||||||
|
|
||||||
|
-- List of filetypes to disable completion
|
||||||
|
local disabled_filetypes = { "dashboard", "qalc" }
|
||||||
|
for _, filetype in ipairs(disabled_filetypes) do
|
||||||
|
cmp.setup.filetype(filetype, {
|
||||||
|
sources = {},
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
}
|
||||||
+14
-100
@@ -9,37 +9,6 @@ return {
|
|||||||
automatic_installation = true,
|
automatic_installation = true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{ -- Codeium
|
|
||||||
import = "lazyvim.plugins.extras.coding.codeium",
|
|
||||||
opts = {
|
|
||||||
enable_chat = true,
|
|
||||||
},
|
|
||||||
cond = function()
|
|
||||||
return vim.g.aitool == "codeium"
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
{ -- Copilot
|
|
||||||
import = "lazyvim.plugins.extras.coding.copilot",
|
|
||||||
cond = function()
|
|
||||||
return vim.g.aitool == "copilot"
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
{ -- Tabnine
|
|
||||||
import = "lazyvim.plugins.extras.coding.tabnine",
|
|
||||||
cond = function()
|
|
||||||
return vim.g.aitool == "tabnine"
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
{ -- Minuet-AI
|
|
||||||
"milanglacier/minuet-ai.nvim",
|
|
||||||
dependencies = { { "nvim-lua/plenary.nvim" }, { "hrsh7th/nvim-cmp" } },
|
|
||||||
config = function()
|
|
||||||
require("minuet").setup({ provider = "openai" })
|
|
||||||
end,
|
|
||||||
cond = function()
|
|
||||||
return vim.g.aitool == "minuet"
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
{ -- Yanky
|
{ -- Yanky
|
||||||
import = "lazyvim.plugins.extras.coding.yanky",
|
import = "lazyvim.plugins.extras.coding.yanky",
|
||||||
},
|
},
|
||||||
@@ -68,79 +37,24 @@ return {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{ -- Completion
|
-- { -- Colorizer
|
||||||
"hrsh7th/nvim-cmp",
|
-- "norcalli/nvim-colorizer.lua",
|
||||||
---@param opts cmp.ConfigSchema
|
-- event = "BufEnter",
|
||||||
opts = function(_, opts)
|
-- config = function()
|
||||||
local cmp = require("cmp")
|
-- require("colorizer").setup()
|
||||||
|
-- end,
|
||||||
-- Global sources
|
-- },
|
||||||
opts.sources = {
|
|
||||||
{ name = "emoji" },
|
|
||||||
{ name = "cmp_yanky" },
|
|
||||||
{ name = "dotenv" },
|
|
||||||
{ name = "calc" },
|
|
||||||
{ name = "conventionalcommits" },
|
|
||||||
{ name = "gitmoji" },
|
|
||||||
}
|
|
||||||
|
|
||||||
-- General setup
|
|
||||||
cmp.setup(opts)
|
|
||||||
|
|
||||||
-- Filetype-specific setup
|
|
||||||
cmp.setup.filetype("config", {
|
|
||||||
sources = vim.tbl_filter(function(source)
|
|
||||||
return source.name ~= "emoji" and source.name ~= "gitmoji"
|
|
||||||
end, opts.sources),
|
|
||||||
})
|
|
||||||
|
|
||||||
-- List of filetypes to disable completion
|
|
||||||
local disabled_filetypes = { "dashboard", "qalc" }
|
|
||||||
for _, filetype in ipairs(disabled_filetypes) do
|
|
||||||
cmp.setup.filetype(filetype, {
|
|
||||||
sources = {},
|
|
||||||
})
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Key mappings
|
|
||||||
cmp.setup({
|
|
||||||
mapping = {
|
|
||||||
["<C-p>"] = cmp.mapping.select_prev_item(),
|
|
||||||
["<C-n>"] = cmp.mapping.select_next_item(),
|
|
||||||
["<S-Tab>"] = cmp.mapping.select_prev_item(),
|
|
||||||
["<Tab>"] = cmp.mapping.select_next_item(),
|
|
||||||
["<C-S-f>"] = cmp.mapping.scroll_docs(-4),
|
|
||||||
["<C-f>"] = cmp.mapping.scroll_docs(4),
|
|
||||||
["<C-Space>"] = cmp.mapping.complete(),
|
|
||||||
["<C-e>"] = cmp.mapping.close(),
|
|
||||||
["<CR>"] = cmp.mapping.confirm({
|
|
||||||
behavior = cmp.ConfirmBehavior.Insert,
|
|
||||||
select = true,
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
})
|
|
||||||
end,
|
|
||||||
dependencies = {
|
|
||||||
"hrsh7th/cmp-emoji",
|
|
||||||
{
|
{
|
||||||
"chrisgrieser/cmp_yanky",
|
"brenoprata10/nvim-highlight-colors",
|
||||||
option = {
|
|
||||||
onlyCurrentFiletype = false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"SergioRibera/cmp-dotenv",
|
|
||||||
"hrsh7th/cmp-calc",
|
|
||||||
"davidsierradz/cmp-conventionalcommits",
|
|
||||||
"Dynge/gitmoji.nvim",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{ -- Colorizer
|
|
||||||
"norcalli/nvim-colorizer.lua",
|
|
||||||
event = "BufEnter",
|
|
||||||
config = function()
|
config = function()
|
||||||
require("colorizer").setup()
|
require("nvim-highlight-colors").setup({})
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"luckasRanarison/tailwind-tools.nvim",
|
||||||
|
dependencies = { "nvim-treesitter/nvim-treesitter" },
|
||||||
|
opts = {}, -- your configuration
|
||||||
|
},
|
||||||
{ -- Substitute
|
{ -- Substitute
|
||||||
"gbprod/substitute.nvim",
|
"gbprod/substitute.nvim",
|
||||||
lazy = true,
|
lazy = true,
|
||||||
|
|||||||
Reference in New Issue
Block a user