astro-nvim-v3 - fix conflict tab press between copilot and nvim_cmp

This commit is contained in:
huyjaky
2025-01-13 18:28:03 +07:00
parent c0d55ff45e
commit 7fd986783a
6 changed files with 25 additions and 20 deletions

View File

@@ -19,6 +19,7 @@
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
"cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" },
"code_runner.nvim": { "branch": "main", "commit": "65218f8f646fe61e506090522df357539642ae83" }, "code_runner.nvim": { "branch": "main", "commit": "65218f8f646fe61e506090522df357539642ae83" },
"copilot.vim": { "branch": "release", "commit": "87038123804796ca7af20d1b71c3428d858a9124" },
"cyberdream.nvim": { "branch": "main", "commit": "cd3c2e7955034a5bec0e1beb9d7cb80c639ef5d5" }, "cyberdream.nvim": { "branch": "main", "commit": "cd3c2e7955034a5bec0e1beb9d7cb80c639ef5d5" },
"dressing.nvim": { "branch": "master", "commit": "3a45525bb182730fe462325c99395529308f431e" }, "dressing.nvim": { "branch": "master", "commit": "3a45525bb182730fe462325c99395529308f431e" },
"duplicate.nvim": { "branch": "main", "commit": "ab057af7872c44e6fbd48df9b03983c8e67c50a7" }, "duplicate.nvim": { "branch": "main", "commit": "ab057af7872c44e6fbd48df9b03983c8e67c50a7" },

View File

@@ -27,7 +27,7 @@ return {
jedi_language_server = { jedi_language_server = {
init_options = { init_options = {
completion = { completion = {
disableSnippets = true, disableSnippets = false,
}, },
diagnostics = { diagnostics = {
enable = false, enable = false,
@@ -37,7 +37,7 @@ return {
"numpy", "numpy",
"pandas", "pandas",
"torch", "torch",
"sklearn" "sklearn",
}, },
}, },
}, },
@@ -74,15 +74,18 @@ return {
"D415", "D415",
"E402", "E402",
"E501", "E501",
"ERA001",
"TRY003", "TRY003",
"TD002", "TD002",
"TD003", "TD003",
"T201",
"FIX002", "FIX002",
"N803", "N803",
"PD901", "PD901",
-- "F401", -- "F401",
"I001", "I001",
"RET504", "RET504",
"PLR2004",
}, },
}, },

View File

@@ -5,6 +5,9 @@ return {
symbol_map = require "plugins.configs.ui.lspkind", symbol_map = require "plugins.configs.ui.lspkind",
}, },
}, },
{
"github/copilot.vim",
},
{ {
"hrsh7th/nvim-cmp", "hrsh7th/nvim-cmp",
opts = function(_, opts) opts = function(_, opts)
@@ -18,23 +21,10 @@ return {
cmp.setup.filetype("python", { cmp.setup.filetype("python", {
sources = cmp.config.sources { sources = cmp.config.sources {
{ name = "nvim_lsp", priority = 700}, { name = "nvim_lsp", priority = 1000 },
{ name = "buffer", priority = 500 }, { name = "buffer", priority = 500 },
{ name = "path", priority = 250 }, { name = "path", priority = 250 },
}, },
sorting = {
comparators = {
cmp.config.compare.offset,
cmp.config.compare.exact,
cmp.config.compare.score,
cmp.config.compare.kind,
cmp.config.compare.sort_text,
cmp.config.compare.length,
cmp.config.compare.order,
},
priority_weight = 1000
},
}) })
return require("astrocore").extend_tbl(opts, { return require("astrocore").extend_tbl(opts, {
@@ -65,14 +55,16 @@ return {
mapping = { mapping = {
-- Esc to close completion menu -- Esc to close completion menu
["<Esc>"] = cmp.mapping { i = cmp.mapping.abort(), c = cmp.mapping.close() }, ["<Esc>"] = cmp.mapping { i = cmp.mapping.abort(), c = cmp.mapping.close() },
-- Tab to select completion -- Tab to select completion
["<Tab>"] = cmp.mapping(function(fallback) ["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() and has_words_before() then if cmp.visible() and has_words_before() then
cmp.confirm { select = true } fallback()
else else
fallback() fallback()
end end
end, { "i", "s" }), end, { "i", "s" }),
-- Use <C-n> and <C-p> to select luasnip -- Use <C-n> and <C-p> to select luasnip
["<C-n>"] = cmp.mapping(function(fallback) ["<C-n>"] = cmp.mapping(function(fallback)
if luasnip.jumpable(1) then if luasnip.jumpable(1) then
@@ -88,6 +80,14 @@ return {
fallback() fallback()
end end
end, { "i", "s" }), end, { "i", "s" }),
["<C-f>"] = cmp.mapping(function(fallback)
-- Check if Copilot is suggesting something
if vim.fn["copilot#Accept"]() ~= "" then
vim.api.nvim_set_keymap("i", "<C-f>", "copilot#Accept(“<CR>”)", { expr = true, silent = true })
else
fallback() -- If no suggestion, fallback to default behavior
end
end, { "i", "s" }), -- Enable in insert and command-line mode
}, },
experimental = { experimental = {
ghost_text = false, -- this feature conflict with copilot.vim's preview. ghost_text = false, -- this feature conflict with copilot.vim's preview.

View File

@@ -20,7 +20,7 @@ return {
indexing = false, indexing = false,
inlayHints = { inlayHints = {
variableTypes = true, variableTypes = true,
functionReturnTypes = true, functionReturnTypes = false,
callArgumentNames = false, callArgumentNames = false,
pytestParameters = true, pytestParameters = true,
}, },

View File

@@ -10,12 +10,13 @@ return {
DiagnosticVirtualTextHint = { fg = get_hlgroup("DiagnosticHint").fg, bg = "none" }, DiagnosticVirtualTextHint = { fg = get_hlgroup("DiagnosticHint").fg, bg = "none" },
DiagnosticVirtualTextInfo = { fg = get_hlgroup("DiagnosticInfo").fg, bg = "none" }, DiagnosticVirtualTextInfo = { fg = get_hlgroup("DiagnosticInfo").fg, bg = "none" },
DiagnosticVirtualTextWarn = { fg = get_hlgroup("DiagnosticWarn").fg, bg = "none" }, DiagnosticVirtualTextWarn = { fg = get_hlgroup("DiagnosticWarn").fg, bg = "none" },
CursorLineNr = { fg = "#FFD700", bg = "none", bold = true }, CursorLineNr = { fg = "#FFD700", bg = "none", bold = true },
CursorLine = { fg = "none", bg = "#004C4C", bold = true }, CursorLine = { fg = "none", bg = "#004C4C", bold = true },
Visual = { fg = "#000000", bg = "#FFFFFF", bold = true }, Visual = { fg = "#000000", bg = "#FFFFFF", bold = true },
-- remove background of inlay hints -- remove background of inlay hints
LspInlayHint = { fg = get_hlgroup("LspInlayHint").fg, bg = "none" }, LspInlayHint = { fg = "#FF748B", bg = "none" },
} }
return hl return hl

View File

@@ -34,7 +34,7 @@ return {
{ "echasnovski/mini.move", enabled = true }, { "echasnovski/mini.move", enabled = true },
{ "nvim-neo-tree/neo-tree.nvim", enabled = true }, { "nvim-neo-tree/neo-tree.nvim", enabled = true },
{ "folke/flash.nvim", enabled = true }, { "folke/flash.nvim", enabled = true },
{ "github/copilot.vim", enabled = true },
} }
-- if true then return {} end -- if true then return {} end