Skip to content

Commit

Permalink
feat(cmp): try new config
Browse files Browse the repository at this point in the history
  • Loading branch information
CharlesChiuGit committed Jun 21, 2024
1 parent 73e897e commit 4c20675
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 46 deletions.
60 changes: 29 additions & 31 deletions lua/modules/configs/completion/cmp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ return function()
local use_copilot = require("core.settings").use_copilot
local comparators = use_copilot == true
and {
require("copilot_cmp.comparators").prioritize,
require("copilot_cmp.comparators").score,
-- require("copilot_cmp.comparators").prioritize,
-- require("copilot_cmp.comparators").score,
-- require("cmp_tabnine.compare"),
compare.offset, -- Items closer to cursor will have lower priority
compare.exact,
Expand Down Expand Up @@ -128,38 +128,36 @@ return function()
},
-- You can set mappings if you want
mapping = cmp.mapping.preset.insert({
["<CR>"] = cmp.mapping.confirm({ select = false, behavior = cmp.ConfirmBehavior.Replace }),
["<C-k>"] = cmp.mapping.select_prev_item(),
["<C-j>"] = cmp.mapping.select_next_item(),
["<C-d>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-w>"] = cmp.mapping.close(),
["<C-n>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif require("luasnip").expand_or_locally_jumpable() then
require("luasnip").expand_or_jump()
else
fallback()
end
end, { "i", "s" }),
["<C-p>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif require("luasnip").expand_or_locally_jumpable() then
require("luasnip").expand_or_jump()
else
fallback()
end
end, { "i", "s" }),
["<CR>"] = cmp.mapping(cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Replace,
select = true,
}, { "i", "c" })),
["<C-c>"] = cmp.mapping({
i = cmp.mapping.abort(),
c = cmp.mapping.close(),
}),
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif require("luasnip").expand_or_locally_jumpable() then
require("luasnip").expand_or_jump()
else
fallback()
end
end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif require("luasnip").jumpable(-1) then
require("luasnip").jump(-1)
else
fallback()
end
end, { "i", "s" }),
}),
snippet = {
expand = function(args)
require("luasnip").lsp_expand(args.body)
require("luasnip").expand(args.body)
end,
},
-- You should specify your *installed* sources.
Expand All @@ -180,10 +178,10 @@ return function()
end,
},
},
{ name = "latex_symbols" },
{ name = "copilot" },
{ name = "codeium" },
{ name = "cmp_tabnine" },
-- { name = "latex_symbols" },
-- { name = "copilot" },
-- { name = "codeium" },
-- { name = "cmp_tabnine" },
},
experimental = {
ghost_text = {
Expand Down
30 changes: 15 additions & 15 deletions lua/modules/plugins/completion.lua
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ completion["hrsh7th/nvim-cmp"] = {
{ "hrsh7th/cmp-path" },
{ "f3fora/cmp-spell" },
{ "hrsh7th/cmp-buffer" },
{ "kdheepak/cmp-latex-symbols" },
-- { "kdheepak/cmp-latex-symbols" },
{ "ray-x/cmp-treesitter", commit = "c8e3a74" },
-- { "tzachar/cmp-tabnine", build = "./install.sh", config = require("completion.tabnine") },
-- {
Expand All @@ -77,20 +77,20 @@ completion["hrsh7th/nvim-cmp"] = {
-- },
},
}
if use_copilot then
completion["zbirenbaum/copilot.lua"] = {
lazy = true,
cmd = "Copilot",
event = "InsertEnter",
config = require("completion.copilot"),
dependencies = {
{
"zbirenbaum/copilot-cmp",
config = require("completion.copilot-cmp"),
},
},
}
end
-- if use_copilot then
-- completion["zbirenbaum/copilot.lua"] = {
-- lazy = true,
-- cmd = "Copilot",
-- event = "InsertEnter",
-- config = require("completion.copilot"),
-- dependencies = {
-- {
-- "zbirenbaum/copilot-cmp",
-- config = require("completion.copilot-cmp"),
-- },
-- },
-- }
-- end
-- completion["barreiroleo/ltex_extra.nvim"] = {
-- lazy = true,
-- ft = "tex",
Expand Down

0 comments on commit 4c20675

Please sign in to comment.