Skip to content

Commit 86fd1cc

Browse files
committed
refactor!: use copilot.vim
1 parent 14a927e commit 86fd1cc

File tree

6 files changed

+161
-168
lines changed

6 files changed

+161
-168
lines changed

root/.config/nvim/lua/plugins/ai.lua

+152-147
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,44 @@
11
if vim.g.avante_provider == "copilot" or vim.g.avante_auto_suggestions_provider == "copilot" then
2-
vim.cmd[[echoerr "DO NOT USE third-party Copilot extensions!!!"]]
2+
vim.cmd(
3+
[[echoerr 'DO NOT USE third-party Copilot extensions!!! See: https://github.com/yetone/avante.nvim/issues/557 and https://github.com/zbirenbaum/copilot-cmp/issues/117']]
4+
)
35
return nil
46
end
7+
-- WARN: DO NOT USE
8+
-- - copilot.lua
9+
-- - copilot-cmp
10+
-- - avante.nvim with copilot provider
11+
-- See: https://support.github.com/ticket/personal/0/3165529
512

6-
local copilot_lua = {
7-
"zbirenbaum/copilot.lua",
8-
event = "InsertEnter",
9-
config = function()
10-
require("copilot").setup({
11-
suggestion = {
12-
enabled = (vim.avante_auto_suggestions_enabled == 0),
13-
auto_trigger = true,
14-
hide_during_completion = false,
15-
debounce = 75,
16-
keymap = {
17-
accept = false,
18-
accept_word = "<M-w>",
19-
accept_line = "<M-l>",
20-
next = "<M-]>",
21-
prev = "<M-[>",
22-
dismiss = "<C-]>",
23-
},
24-
},
25-
})
26-
vim.keymap.set("i", "<Tab>", function()
27-
if require("copilot.suggestion").is_visible() then
28-
require("copilot.suggestion").accept()
29-
else
30-
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("<Tab>", true, false, true), "n", false)
31-
end
32-
end, { desc = "Super Tab" })
33-
end,
34-
}
35-
36-
local copilot_chat = {
37-
"CopilotC-Nvim/CopilotChat.nvim",
38-
lazy = true,
39-
dependencies = {
40-
-- { "github/copilot.vim" }, -- or zbirenbaum/copilot.lua
41-
{ "zbirenbaum/copilot.lua" },
42-
{ "nvim-lua/plenary.nvim", branch = "master" }, -- for curl, log and async functions
43-
},
44-
build = "make tiktoken", -- Only on MacOS or Linux
45-
cmd = {
46-
"CopilotChat",
47-
"CopilotChatAgents",
48-
"CopilotChatClose",
49-
"CopilotChatCommit",
50-
"CopilotChatCommitStaged",
51-
"CopilotChatDebugInfo",
52-
"CopilotChatDocs",
53-
"CopilotChatExplain",
54-
"CopilotChatFix",
55-
"CopilotChatFixDiagnostic",
56-
"CopilotChatLoad",
57-
"CopilotChatModels",
58-
"CopilotChatOpen",
59-
"CopilotChatOptimize",
60-
"CopilotChatReset",
61-
"CopilotChatTests",
62-
"CopilotChatToggle",
63-
},
64-
opts = {
65-
debug = true, -- Enable debugging
66-
-- See Configuration section for rest
67-
},
68-
-- See Commands section for default commands if you want to lazy load on them
69-
}
13+
-- local copilot_lua = {
14+
-- "zbirenbaum/copilot.lua",
15+
-- event = "InsertEnter",
16+
-- config = function()
17+
-- require("copilot").setup({
18+
-- suggestion = {
19+
-- enabled = true,
20+
-- auto_trigger = true,
21+
-- hide_during_completion = false,
22+
-- debounce = 75,
23+
-- keymap = {
24+
-- accept = false,
25+
-- accept_word = "<M-w>",
26+
-- accept_line = "<M-l>",
27+
-- next = "<M-]>",
28+
-- prev = "<M-[>",
29+
-- dismiss = "<C-]>",
30+
-- },
31+
-- },
32+
-- })
33+
-- vim.keymap.set("i", "<Tab>", function()
34+
-- if require("copilot.suggestion").is_visible() then
35+
-- require("copilot.suggestion").accept()
36+
-- else
37+
-- vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("<Tab>", true, false, true), "n", false)
38+
-- end
39+
-- end, { desc = "Super Tab" })
40+
-- end,
41+
-- }
7042

7143
local deepseek_api = {
7244
endpoint = "https://api.deepseek.com/v1",
@@ -76,92 +48,125 @@ local deepseek_api = {
7648
max_tokens = 4096,
7749
}
7850

79-
local plugins = {
80-
copilot = {
81-
copilot_chat,
82-
-- "github/copilot.vim",
83-
copilot_lua,
84-
-- https://github.com/magicalne/nvim.ai
85-
-- {
86-
-- "olimorris/codecompanion.nvim",
87-
-- dependencies = {
88-
-- "nvim-lua/plenary.nvim",
89-
-- "nvim-treesitter/nvim-treesitter",
90-
-- "hrsh7th/nvim-cmp", -- Optional: For using slash commands and variables in the chat buffer
91-
-- "nvim-telescope/telescope.nvim", -- Optional: For working with files with slash commands
92-
-- -- {
93-
-- -- "stevearc/dressing.nvim", -- Optional: Improves the default Neovim UI
94-
-- -- opts = {},
95-
-- -- },
96-
-- },
97-
-- config = true
98-
-- },
51+
return {
52+
{
53+
"CopilotC-Nvim/CopilotChat.nvim",
54+
lazy = true,
55+
cond = vim.g.ai_suggestion == "copilot.vim",
56+
dependencies = {
57+
{ "github/copilot.vim" }, -- or zbirenbaum/copilot.lua
58+
{ "nvim-lua/plenary.nvim", branch = "master" }, -- for curl, log and async functions
59+
},
60+
build = "make tiktoken", -- Only on MacOS or Linux
61+
cmd = {
62+
"CopilotChat",
63+
"CopilotChatAgents",
64+
"CopilotChatClose",
65+
"CopilotChatCommit",
66+
"CopilotChatCommitStaged",
67+
"CopilotChatDebugInfo",
68+
"CopilotChatDocs",
69+
"CopilotChatExplain",
70+
"CopilotChatFix",
71+
"CopilotChatFixDiagnostic",
72+
"CopilotChatLoad",
73+
"CopilotChatModels",
74+
"CopilotChatOpen",
75+
"CopilotChatOptimize",
76+
"CopilotChatReset",
77+
"CopilotChatTests",
78+
"CopilotChatToggle",
79+
},
80+
opts = {
81+
debug = true, -- Enable debugging
82+
-- See Configuration section for rest
83+
},
84+
-- See Commands section for default commands if you want to lazy load on them
9985
},
100-
["avante.nvim"] = {
101-
{
102-
"yetone/avante.nvim",
103-
event = "VeryLazy",
104-
lazy = true,
105-
version = false, -- set this if you want to always pull the latest change
106-
opts = { -- add any opts here
107-
debug = false,
108-
provider = vim.g.avante_provider,
109-
auto_suggestions_provider = vim.g.avante_auto_suggestions_provider,
110-
openai = deepseek_api,
111-
behaviour = {
112-
auto_suggestions = vim.g.avante_auto_suggestions_enabled == 1, -- Experimental stage
113-
},
114-
mappings = {
115-
suggestion = {
116-
accept = "<Tab>",
117-
next = "<M-]>",
118-
prev = "<M-[>",
119-
dismiss = "<C-]>",
120-
},
121-
},
86+
-- https://github.com/magicalne/nvim.ai
87+
-- {
88+
-- "olimorris/codecompanion.nvim",
89+
-- dependencies = {
90+
-- "nvim-lua/plenary.nvim",
91+
-- "nvim-treesitter/nvim-treesitter",
92+
-- "hrsh7th/nvim-cmp", -- Optional: For using slash commands and variables in the chat buffer
93+
-- "nvim-telescope/telescope.nvim", -- Optional: For working with files with slash commands
94+
-- -- {
95+
-- -- "stevearc/dressing.nvim", -- Optional: Improves the default Neovim UI
96+
-- -- opts = {},
97+
-- -- },
98+
-- },
99+
-- config = true
100+
-- },
101+
{
102+
"github/copilot.vim",
103+
cond = vim.g.ai_suggestion == "copilot.vim",
104+
},
105+
{
106+
"yetone/avante.nvim",
107+
event = "VeryLazy",
108+
lazy = true,
109+
version = false, -- set this if you want to always pull the latest change
110+
opts = { -- add any opts here
111+
debug = false,
112+
provider = vim.g.avante_provider,
113+
auto_suggestions_provider = vim.g.avante_auto_suggestions_provider,
114+
openai = deepseek_api,
115+
behaviour = {
116+
auto_suggestions = vim.g.ai_suggestion == "avante.nvim", -- Experimental stage
122117
},
123-
-- if you want to build from source then do `make BUILD_FROM_SOURCE=true`
124-
build = "make",
125-
-- build = "powershell -ExecutionPolicy Bypass -File Build.ps1 -BuildFromSource false" -- for windows
126-
dependencies = {
127-
"stevearc/dressing.nvim",
128-
"nvim-lua/plenary.nvim",
129-
"MunifTanjim/nui.nvim",
130-
--- The below dependencies are optional,
131-
"nvim-tree/nvim-web-devicons", -- or echasnovski/mini.icons
132-
"zbirenbaum/copilot.lua", -- for providers='copilot'
133-
-- {
134-
-- -- support for image pasting
135-
-- "HakonHarnes/img-clip.nvim",
136-
-- event = "VeryLazy",
137-
-- opts = {
138-
-- -- recommended settings
139-
-- default = {
140-
-- embed_image_as_base64 = false,
141-
-- prompt_for_file_name = false,
142-
-- drag_and_drop = {
143-
-- insert_mode = true,
144-
-- },
145-
-- -- required for Windows users
146-
-- use_absolute_path = true,
147-
-- },
148-
-- },
149-
-- },
118+
mappings = {
119+
suggestion = {
120+
accept = "<Tab>",
121+
next = "<M-]>",
122+
prev = "<M-[>",
123+
dismiss = "<C-]>",
124+
},
150125
},
151126
},
152-
copilot_lua,
153-
copilot_chat,
154-
},
155-
fittencode = {
156-
{
157-
"luozhiya/fittencode.nvim",
158-
config = function()
159-
require("fittencode").setup()
160-
end,
127+
-- if you want to build from source then do `make BUILD_FROM_SOURCE=true`
128+
build = "make",
129+
-- build = "powershell -ExecutionPolicy Bypass -File Build.ps1 -BuildFromSource false" -- for windows
130+
dependencies = {
131+
"stevearc/dressing.nvim",
132+
"nvim-lua/plenary.nvim",
133+
"MunifTanjim/nui.nvim",
134+
--- The below dependencies are optional,
135+
"nvim-tree/nvim-web-devicons", -- or echasnovski/mini.icons
136+
-- {
137+
-- -- support for image pasting
138+
-- "HakonHarnes/img-clip.nvim",
139+
-- event = "VeryLazy",
140+
-- opts = {
141+
-- -- recommended settings
142+
-- default = {
143+
-- embed_image_as_base64 = false,
144+
-- prompt_for_file_name = false,
145+
-- drag_and_drop = {
146+
-- insert_mode = true,
147+
-- },
148+
-- -- required for Windows users
149+
-- use_absolute_path = true,
150+
-- },
151+
-- },
152+
-- },
161153
},
162154
},
163-
tabnine = { { "codota/tabnine-nvim", build = "./dl_binaries.sh" } },
164-
codeium = { { "Exafunction/codeium.vim", event = "BufEnter" } },
155+
{
156+
"luozhiya/fittencode.nvim",
157+
cond = vim.g.ai_suggestion == "fittencode",
158+
config = function()
159+
require("fittencode").setup()
160+
end,
161+
},
162+
{
163+
"codota/tabnine-nvim",
164+
cond = vim.g.ai_suggestion == "tabnine-nvim",
165+
build = "./dl_binaries.sh",
166+
},
167+
{
168+
"Exafunction/codeium.vim",
169+
cond = vim.g.ai_suggestion == "codeium.vim",
170+
event = "BufEnter",
171+
},
165172
}
166-
167-
return plugins[vim.g.ai_complete]

root/.config/nvim/lua/plugins/lualine.lua

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
local lualine = {
22
"nvim-lualine/lualine.nvim",
33
event = "UIEnter",
4+
dependencies = {}
45
}
56

6-
if vim.g.ai_complete == "copilot" or vim.g.avante_auto_suggestions_enabled == 0 then
7-
lualine.dependencies = {
8-
"AndreM222/copilot-lualine"
9-
}
10-
end
7+
-- WARN: DO NOT USE AndreM222/copilot-lualine
118

129
if vim.g.vimrc_lsp == "nvim-lsp" then
1310
table.insert(lualine.dependencies, "neovim/nvim-lspconfig")

root/.config/nvim/lua/plugins_setup.lua

+1-8
Original file line numberDiff line numberDiff line change
@@ -159,13 +159,6 @@ function M.lualine()
159159
}
160160
end
161161

162-
local lualine_x = {}
163-
if vim.g.ai_complete == "copilot" or vim.g.avante_auto_suggestions_provider == "copilot" then
164-
lualine_x = {
165-
"copilot",
166-
}
167-
end
168-
169162
local filename = {
170163
"filename",
171164
path = 4,
@@ -204,7 +197,7 @@ function M.lualine()
204197
-- 'diff' is slow
205198
lualine_b = lualine_b,
206199
lualine_c = lualine_c,
207-
lualine_x = lualine_x,
200+
lualine_x = {},
208201
lualine_y = {},
209202
-- file location
210203
lualine_z = { "%l/%L:%v", { "filetype", icons_enabled = false }, "encoding", "fileformat" },

root/.vim/config.vim.example

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
" vim:ft=vim
22
" copy this file to config.vim
33

4-
" copilot (default) | codeium | fittencode
5-
let g:ai_complete = 'copilot'
4+
let g:ai_suggestion = 'copilot.vim'
65
" aiproxy (default) | kimichat | 01ai
76
let g:ai_service = '01ai'
87
let g:clangd_path = '/usr/bin/clangd'

root/.vim/vimrc

+2-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ if has('autocmd') " vim-tiny does not have autocmd
2525
let g:python3_host_prog = get(g:, 'python3_host_prog', '/usr/bin/python3')
2626
let g:avante_provider = get(g:, 'avante_provider', 'openai') " openai, claude
2727
let g:avante_auto_suggestions_provider = get(g:, 'avante_auto_suggestions_provider', 'openai') " openai , claude
28-
let g:avante_auto_suggestions_enabled = get(g:, 'avante_auto_suggestions_enabled ', 0)
2928
runtime clipboard_config.lua
3029
else
3130
let g:vimrc_lsp = get(g:, 'vimrc_lsp', 'coc.nvim')
@@ -75,7 +74,7 @@ if has('autocmd') " vim-tiny does not have autocmd
7574
let g:python_formatter = get(g:, 'python_formatter', 'black')
7675
let g:python_lsp = get(g:, 'python_lsp', 'pyright')
7776
let g:sql_type_default = 'mysql'
78-
let g:ai_complete = get(g:, 'ai_complete', 'copilot')
77+
let g:ai_suggestion = get(g:, 'ai_suggestion', 'copilot.vim')
7978

8079
" gtags-cscope | cscope
8180
let g:tag_system = get(g:, 'tag_system', 'gtags-cscope')
@@ -407,7 +406,7 @@ if has('autocmd') " vim-tiny does not have autocmd
407406
" 左对齐和右对齐的分割点
408407
set statusline+=%=
409408
if show_status
410-
if show_status && g:ai_complete == 'codeium'
409+
if show_status && g:ai_suggestion == 'codeium'
411410
set statusline+=%2*%{winwidth(0)>60?codeium#GetStatusString():''}\ %{%statusline#Right()%}
412411
else
413412
set statusline+=%2*%{%statusline#Right()%}

0 commit comments

Comments
 (0)