mirror of
https://github.com/cap153/nvim.git
synced 2025-12-26 19:25:01 +08:00
更新blink.cmp命令行相关配置
This commit is contained in:
parent
5528ddf7d2
commit
1a430bf24b
11 changed files with 161 additions and 235 deletions
|
|
@ -4,7 +4,7 @@
|
|||
if vim.g.neovide then
|
||||
-- Put anything you want to happen only in Neovide here
|
||||
vim.o.guifont = "Source Code Pro:h16" -- text below applies for VimScript
|
||||
vim.g.neovide_transparency = 0.75
|
||||
vim.g.neovide_opacity = 0.75
|
||||
-- 全屏,在i3和sway的配置中设置了并且速度更快
|
||||
-- vim.g.neovide_fullscreen = true
|
||||
end
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@ vim.opt.rtp:prepend(vim.env.LAZY or lazypath)
|
|||
-- 启动Lazy插件管理快捷键
|
||||
vim.keymap.set("n", "<leader>l", ":Lazy<CR>", { noremap = true })
|
||||
require("lazy").setup({
|
||||
-- 用Neovim打开kitty滚动缓冲
|
||||
require("lazy.plugins.kittyscroll"),
|
||||
-- 自动补全插件
|
||||
require("lazy.plugins.blinkcmp"),
|
||||
-- lsp配置,全局的错误和警告提示,修复建议,重命名变量,格式化代码等等
|
||||
|
|
@ -27,8 +29,6 @@ require("lazy").setup({
|
|||
require("lazy.plugins.fittencode"),
|
||||
-- 免费大语言模型 (LLM) 支持
|
||||
require("lazy.plugins.llm"),
|
||||
-- 顶部的winbar,可以鼠标点击
|
||||
require("lazy.plugins.winbar"),
|
||||
-- command line浮动弹窗
|
||||
require("lazy.plugins.cmdline"),
|
||||
-- 代码函数名称浏览时固定,`[c`可以跳转到上下文
|
||||
|
|
@ -59,8 +59,6 @@ require("lazy").setup({
|
|||
require("lazy.plugins.pairs"),
|
||||
-- flutter
|
||||
require("lazy.plugins.flutter"),
|
||||
-- 用于改进在 Neovim 中查看 Markdown 文件的插件
|
||||
require("lazy.plugins.render-markdown"),
|
||||
-- 底部状态栏+主题 themes
|
||||
require("lazy.plugins.themes"),
|
||||
-- 注释插件
|
||||
|
|
@ -85,10 +83,14 @@ require("lazy").setup({
|
|||
require("lazy.plugins.multicursor"),
|
||||
-- which-key使用多个字母快捷键停留时会提示
|
||||
require("lazy.plugins.whichkey"),
|
||||
-- 用于改进在 Neovim 中查看 Markdown 文件的插件
|
||||
-- require("lazy.plugins.render-markdown"),
|
||||
-- 顶部的winbar,可以鼠标点击
|
||||
-- require("lazy.plugins.winbar"),
|
||||
-- cw推荐的indent缩进线hlchunk,可以根据线条的款式来分辨缩进
|
||||
-- require("lazy.plugins.indent"),
|
||||
-- ai编程助手supermaven
|
||||
-- require("lazy.plugins.supermaven"),
|
||||
-- 自动补全插件nvim-cmp
|
||||
-- require("lazy.plugins.autocomplete").config,
|
||||
-- mcp server插件
|
||||
-- require("lazy.plugins.mcphub"),
|
||||
-- 像cursor一样使用neovim
|
||||
-- require("lazy.plugins.avante"),
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,205 +0,0 @@
|
|||
local M = {}
|
||||
|
||||
M.config = {
|
||||
-- 使用nvim-cmp
|
||||
'hrsh7th/nvim-cmp',
|
||||
after = "SirVer/ultisnips",
|
||||
dependencies = {
|
||||
{ 'hrsh7th/cmp-nvim-lsp' },
|
||||
{ 'hrsh7th/cmp-buffer' }, -- 缓冲区字符
|
||||
{ 'hrsh7th/cmp-path' }, -- 补全路径
|
||||
{ 'hrsh7th/cmp-cmdline' },
|
||||
{
|
||||
"onsails/lspkind.nvim", -- 补全的图标
|
||||
lazy = false,
|
||||
config = function()
|
||||
require("lspkind").init()
|
||||
end
|
||||
},
|
||||
-- 代码片段来源
|
||||
{ 'SirVer/ultisnips', dependencies = { "honza/vim-snippets" }, },
|
||||
{ 'quangnguyen30192/cmp-nvim-ultisnips' },
|
||||
},
|
||||
|
||||
-- 使用coq_nvim补全
|
||||
-- 自动启动默认情况下无法运行,索性懒加载,或者见lazy.nvim中的init
|
||||
-- { 'ms-jpq/coq_nvim', build = 'python3 -m coq deps', lazy = true },
|
||||
-- { 'ms-jpq/coq.artifacts' },
|
||||
-- { 'ms-jpq/coq.thirdparty' },
|
||||
|
||||
config = function()
|
||||
-- Set up nvim-cmp.
|
||||
local cmp = require 'cmp'
|
||||
local cmp_ultisnips_mappings = require("cmp_nvim_ultisnips.mappings")
|
||||
local has_words_before = function()
|
||||
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
||||
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
|
||||
end
|
||||
cmp.setup({
|
||||
snippet = {
|
||||
-- REQUIRED - you must specify a snippet engine
|
||||
-- 目录nvim/snippets/*: snippets using snipMate format
|
||||
-- 目录nvim/UltiSnips/*: snippets using UltiSnips format
|
||||
expand = function(args)
|
||||
vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users.
|
||||
end,
|
||||
},
|
||||
-- 和cw补全同一种风格样式
|
||||
window = {
|
||||
completion = {
|
||||
-- winhighlight = "Normal:Pmenu,FloatBorder:Pmenu,Search:None",
|
||||
col_offset = -3,
|
||||
side_padding = 0,
|
||||
},
|
||||
},
|
||||
formatting = {
|
||||
fields = { "kind", "abbr", "menu" },
|
||||
format = function(entry, vim_item)
|
||||
local kind = require("lspkind").cmp_format({ mode = "symbol_text", maxwidth = 50 })(entry, vim_item)
|
||||
local strings = vim.split(kind.kind, "%s", { trimempty = true })
|
||||
kind.kind = " " .. (strings[1] or "") .. " "
|
||||
kind.menu = " (" .. (strings[2] or "") .. ")"
|
||||
|
||||
return kind
|
||||
end,
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
-- 召唤代码补全
|
||||
['<c-o>'] = cmp.mapping.complete(),
|
||||
['<c-space>'] = cmp.mapping.complete(),
|
||||
-- 代码片段下一处位置
|
||||
["<c-h>"] = cmp.mapping(
|
||||
function()
|
||||
cmp_ultisnips_mappings.compose { "expand", "jump_forwards" } (function() end)
|
||||
end,
|
||||
{ "i", "s", --[[ "c" (to enable the mapping in command mode) ]] }
|
||||
),
|
||||
-- 代码片段上一处位置
|
||||
["<c-l>"] = cmp.mapping(
|
||||
function(fallback)
|
||||
cmp_ultisnips_mappings.jump_backwards(fallback)
|
||||
end,
|
||||
{ "i", "s", --[[ "c" (to enable the mapping in command mode) ]] }
|
||||
),
|
||||
-- 关闭代码补全,和telescope冲突
|
||||
['<c-f>'] = cmp.mapping({
|
||||
i = function(fallback)
|
||||
cmp.close()
|
||||
fallback()
|
||||
end
|
||||
}),
|
||||
['<c-y>'] = cmp.mapping({ i = function(fallback) fallback() end }),
|
||||
-- cw的回车配置不会默认补全第一个,在:输入命令的时候比较合适
|
||||
-- ['<CR>'] = cmp.mapping({
|
||||
-- i = function(fallback)
|
||||
-- if cmp.visible() and cmp.get_active_entry() then
|
||||
-- cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true })
|
||||
-- else
|
||||
-- fallback()
|
||||
-- end
|
||||
-- end
|
||||
-- }),
|
||||
['<CR>'] = cmp.mapping({
|
||||
i = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true }),
|
||||
c = function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true })
|
||||
cmp.confirm({ behavior = cmp.ConfirmBehavior.Insert, select = false })
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end
|
||||
}),
|
||||
["<Tab>"] = cmp.mapping({
|
||||
i = function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item({ behavior = cmp.SelectBehavior.Insert })
|
||||
elseif has_words_before() then
|
||||
cmp.complete()
|
||||
else
|
||||
cmp_ultisnips_mappings.compose { "jump_forwards" } (function() end) -- 添加跳转代码片段下一处的功能
|
||||
fallback()
|
||||
end
|
||||
end,
|
||||
}),
|
||||
["<S-Tab>"] = cmp.mapping({
|
||||
i = function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item({ behavior = cmp.SelectBehavior.Insert })
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end,
|
||||
}),
|
||||
}),
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'path' }, -- 本地路径补全
|
||||
{ name = 'nvim_lsp' },
|
||||
{ name = 'ultisnips' }, -- For ultisnips users.
|
||||
{ name = 'fittencode', group_index = 1 },
|
||||
}, {
|
||||
{ name = 'buffer' },
|
||||
})
|
||||
})
|
||||
|
||||
-- Set configuration for specific filetype.
|
||||
cmp.setup.filetype('gitcommit', {
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'git' }, -- You can specify the `git` source if [you were installed it](https://github.com/petertriho/cmp-git).
|
||||
}, {
|
||||
{ name = 'buffer' },
|
||||
})
|
||||
})
|
||||
|
||||
-- 实现查找单词时根据上下文的补全,要输入多次回车,不太实用
|
||||
-- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore).
|
||||
-- cmp.setup.cmdline({ '/', '?' }, {
|
||||
-- mapping = cmp.mapping.preset.cmdline(),
|
||||
-- sources = {
|
||||
-- { name = 'buffer' }
|
||||
-- }
|
||||
-- })
|
||||
|
||||
-- cmdline模式下的补全,可以自动纠正大小写
|
||||
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
|
||||
cmp.setup.cmdline(':', {
|
||||
mapping = cmp.mapping.preset.cmdline(),
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'path' }
|
||||
}, {
|
||||
{ name = 'cmdline' }
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
-- ===
|
||||
-- === 自动补全coq,更改跳转代码片段快捷键,和idea一样,可以使用ctrl+space召唤补全窗口
|
||||
-- ===
|
||||
-- 代码补全自定义片段放在~/.config/nvim/coq-user-snippets目录下面,格式和snipMate一致除了后缀名是snip结尾
|
||||
-- local lspconfig = require('lspconfig')
|
||||
-- vim.g.coq_settings = {
|
||||
-- auto_start = 'shut-up',
|
||||
-- keymap = {
|
||||
-- jump_to_mark = '<c-e>', -- 跳转至代码片段的下一个占位
|
||||
-- pre_select = true -- 当有补全时预先选择第一个
|
||||
-- }
|
||||
-- }
|
||||
-- -- Enable some language servers with the additional completion capabilities offered by coq_nvim
|
||||
-- -- 具体查看https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md
|
||||
-- local servers = {
|
||||
-- -- 'lua_ls',
|
||||
-- -- 'marksman',
|
||||
-- 'dartls',
|
||||
-- 'pyright',
|
||||
-- 'clangd',
|
||||
-- 'gopls',
|
||||
-- }
|
||||
-- for _, lsp in ipairs(servers) do
|
||||
-- lspconfig[lsp].setup(require('coq').lsp_ensure_capabilities({
|
||||
-- -- on_attach = my_custom_on_attach,
|
||||
-- }))
|
||||
-- end
|
||||
end
|
||||
}
|
||||
|
||||
return M
|
||||
81
lua/lazy/plugins/avante.lua
Normal file
81
lua/lazy/plugins/avante.lua
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
return {
|
||||
"yetone/avante.nvim",
|
||||
event = "VeryLazy",
|
||||
version = false, -- Never set this value to "*"! Never!
|
||||
opts = {
|
||||
-- behaviour = {
|
||||
-- enable_cursor_planning_mode = true, -- enable cursor planning mode!
|
||||
-- },
|
||||
provider = "openrouter",
|
||||
vendors = {
|
||||
openrouter = {
|
||||
__inherited_from = "openai",
|
||||
disable_tools = true,
|
||||
endpoint = "https://openrouter.ai/api/v1",
|
||||
api_key_name = "OPENROUTER_API_KEY",
|
||||
model = "deepseek/deepseek-chat-v3-0324:free",
|
||||
},
|
||||
},
|
||||
-- provider = "deepseek",
|
||||
-- vendors = {
|
||||
-- deepseek = {
|
||||
-- __inherited_from = "openai",
|
||||
-- api_key_name = "DEEPSEEK_API_KEY",
|
||||
-- endpoint = "https://api.deepseek.com",
|
||||
-- model = "deepseek-chat",
|
||||
-- },
|
||||
-- },
|
||||
-- The system_prompt type supports both a string and a function that returns a string. Using a function here allows dynamically updating the prompt with mcphub
|
||||
system_prompt = function()
|
||||
local hub = require("mcphub").get_hub_instance()
|
||||
return hub:get_active_servers_prompt()
|
||||
end,
|
||||
-- The custom_tools type supports both a list and a function that returns a list. Using a function here prevents requiring mcphub before it's loaded
|
||||
custom_tools = function()
|
||||
return {
|
||||
require("mcphub.extensions.avante").mcp_tool(),
|
||||
}
|
||||
end,
|
||||
},
|
||||
-- if you want to build from source then do `make BUILD_FROM_SOURCE=true`
|
||||
build = "make",
|
||||
-- build = "powershell -ExecutionPolicy Bypass -File Build.ps1 -BuildFromSource false" -- for windows
|
||||
dependencies = {
|
||||
"ravitemer/mcphub.nvim",
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
"stevearc/dressing.nvim",
|
||||
"nvim-lua/plenary.nvim",
|
||||
"MunifTanjim/nui.nvim",
|
||||
--- The below dependencies are optional,
|
||||
"echasnovski/mini.pick", -- for file_selector provider mini.pick
|
||||
"nvim-telescope/telescope.nvim", -- for file_selector provider telescope
|
||||
"ibhagwan/fzf-lua", -- for file_selector provider fzf
|
||||
"nvim-tree/nvim-web-devicons", -- or echasnovski/mini.icons
|
||||
"zbirenbaum/copilot.lua", -- for providers='copilot'
|
||||
{
|
||||
-- support for image pasting
|
||||
"HakonHarnes/img-clip.nvim",
|
||||
event = "VeryLazy",
|
||||
opts = {
|
||||
-- recommended settings
|
||||
default = {
|
||||
embed_image_as_base64 = false,
|
||||
prompt_for_file_name = false,
|
||||
drag_and_drop = {
|
||||
insert_mode = true,
|
||||
},
|
||||
-- required for Windows users
|
||||
use_absolute_path = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
-- {
|
||||
-- -- Make sure to set this up properly if you have lazy=true
|
||||
-- "MeanderingProgrammer/render-markdown.nvim",
|
||||
-- opts = {
|
||||
-- file_types = { "markdown", "Avante" },
|
||||
-- },
|
||||
-- ft = { "markdown", "Avante" },
|
||||
-- },
|
||||
},
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@ return {
|
|||
"saghen/blink.cmp",
|
||||
dependencies = {
|
||||
"rafamadriz/friendly-snippets",
|
||||
"Kaiser-Yang/blink-cmp-avante",
|
||||
"mikavilpas/blink-ripgrep.nvim",
|
||||
},
|
||||
version = "*",
|
||||
|
|
@ -14,8 +15,14 @@ return {
|
|||
["<CR>"] = { "select_and_accept", "fallback" },
|
||||
},
|
||||
completion = {
|
||||
-- 自动显示补全窗口
|
||||
menu = { auto_show = true },
|
||||
-- 自动显示补全窗口,仅在输入命令时显示菜单,而搜索或使用其他输入菜单时则不显示
|
||||
menu = {
|
||||
auto_show = function(ctx)
|
||||
return vim.fn.getcmdtype() == ":"
|
||||
-- enable for inputs as well, with:
|
||||
-- or vim.fn.getcmdtype() == '@'
|
||||
end,
|
||||
},
|
||||
-- 不在当前行上显示所选项目的预览
|
||||
ghost_text = { enabled = false },
|
||||
},
|
||||
|
|
@ -63,6 +70,7 @@ return {
|
|||
-- 已定义启用的提供程序的默认列表,以便您可以扩展它
|
||||
sources = {
|
||||
default = {
|
||||
"avante",
|
||||
"buffer",
|
||||
"ripgrep",
|
||||
"lsp",
|
||||
|
|
@ -71,6 +79,11 @@ return {
|
|||
},
|
||||
providers = {
|
||||
-- score_offset设置优先级数字越大优先级越高
|
||||
avante = {
|
||||
module = "blink-cmp-avante",
|
||||
name = "Avante",
|
||||
score_offset = 6,
|
||||
},
|
||||
buffer = { score_offset = 5 },
|
||||
ripgrep = {
|
||||
module = "blink-ripgrep",
|
||||
|
|
@ -80,6 +93,15 @@ return {
|
|||
path = { score_offset = 3 },
|
||||
lsp = { score_offset = 2 },
|
||||
snippets = { score_offset = 1 },
|
||||
cmdline = {
|
||||
min_keyword_length = function(ctx)
|
||||
-- when typing a command, only show when the keyword is 3 characters or longer
|
||||
if ctx.mode == "cmdline" and string.find(ctx.line, " ") == nil then
|
||||
return 3
|
||||
end
|
||||
return 0
|
||||
end,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ return {
|
|||
search = {
|
||||
-- when `true`, flash will be activated during regular search by default.
|
||||
-- You can always toggle when searching with `require("flash").toggle()`
|
||||
enabled = true,
|
||||
enabled = false,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
16
lua/lazy/plugins/kittyscroll.lua
Normal file
16
lua/lazy/plugins/kittyscroll.lua
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
return {
|
||||
"mikesmithgh/kitty-scrollback.nvim",
|
||||
enabled = true,
|
||||
lazy = true,
|
||||
cmd = {
|
||||
"KittyScrollbackGenerateKittens",
|
||||
"KittyScrollbackCheckHealth",
|
||||
"KittyScrollbackGenerateCommandLineEditing",
|
||||
},
|
||||
event = { "User KittyScrollbackLaunch" },
|
||||
-- version = '*', -- latest stable version, may have breaking changes if major version changed
|
||||
-- version = '^6.0.0', -- pin major version, include fixes and features that do not have breaking changes
|
||||
config = function()
|
||||
require("kitty-scrollback").setup()
|
||||
end,
|
||||
}
|
||||
|
|
@ -19,9 +19,9 @@ return {
|
|||
local servers = {
|
||||
'marksman', -- 任意标题<space>aw打开code action可以开头生成目录;超链接可以链接到同一个git项目的其他markdown文件#指定标题<space>h可以预览
|
||||
'lua_ls',
|
||||
'rust_analyzer',
|
||||
'pylsp', -- Mason对应的安装名称是python-lsp-server
|
||||
-- 'gopls',
|
||||
'rust_analyzer',
|
||||
}
|
||||
-- lsp_zero的相关配置
|
||||
local lsp_zero = require('lsp-zero')
|
||||
|
|
|
|||
20
lua/lazy/plugins/mcphub.lua
Normal file
20
lua/lazy/plugins/mcphub.lua
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
return {
|
||||
"ravitemer/mcphub.nvim",
|
||||
dependencies = {
|
||||
"nvim-lua/plenary.nvim", -- Required for Job and HTTP requests
|
||||
},
|
||||
-- comment the following line to ensure hub will be ready at the earliest
|
||||
cmd = "MCPHub", -- lazy load by default
|
||||
build = "npm install -g mcp-hub@latest", -- Installs required mcp-hub npm module
|
||||
-- uncomment this if you don't want mcp-hub to be available globally or can't use -g
|
||||
build = "bundled_build.lua", -- Use this and set use_bundled_binary = true in opts (see Advanced configuration)
|
||||
config = function()
|
||||
require("mcphub").setup({
|
||||
use_bundled_binary = true,
|
||||
auto_approve = true, -- Auto approve mcp tool calls
|
||||
extensions = {
|
||||
avante = {},
|
||||
},
|
||||
})
|
||||
end,
|
||||
}
|
||||
|
|
@ -1,6 +1,11 @@
|
|||
return {
|
||||
'MeanderingProgrammer/render-markdown.nvim',
|
||||
dependencies = { 'nvim-treesitter/nvim-treesitter', 'echasnovski/mini.nvim' }, -- if you use the mini.nvim suite
|
||||
"MeanderingProgrammer/render-markdown.nvim",
|
||||
ft = { "markdown" },
|
||||
cond = function()
|
||||
return vim.bo.filetype ~= "kitty-scrollback"
|
||||
end,
|
||||
event = "VeryLazy",
|
||||
dependencies = { "nvim-treesitter/nvim-treesitter", "echasnovski/mini.nvim" }, -- if you use the mini.nvim suite
|
||||
---@module 'render-markdown'
|
||||
---@type render.md.UserConfig
|
||||
opts = {
|
||||
|
|
|
|||
|
|
@ -1,15 +0,0 @@
|
|||
-- ===
|
||||
-- === 一个ai编程助手,号称是最快的copilot
|
||||
-- ===
|
||||
return {
|
||||
"supermaven-inc/supermaven-nvim",
|
||||
config = function()
|
||||
require("supermaven-nvim").setup({
|
||||
keymaps = {
|
||||
accept_suggestion = "<S-CR>",
|
||||
clear_suggestion = "<C-n>",
|
||||
accept_word = "<C-i>",
|
||||
},
|
||||
})
|
||||
end
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue