From 5528ddf7d270be9d0f523cc946ec9e966e950168 Mon Sep 17 00:00:00 2001 From: a770 Date: Mon, 24 Mar 2025 17:09:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0blink.cmp=E5=91=BD=E4=BB=A4?= =?UTF-8?q?=E8=A1=8C=E6=A8=A1=E5=BC=8F=E7=9B=B8=E5=85=B3=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/core/init.lua | 2 + lua/lazy/index.lua | 8 +--- lua/lazy/plugins/blinkcmp.lua | 72 ++++++++++++++++++---------- lua/lazy/plugins/image.lua | 43 ----------------- lua/lazy/plugins/lspconfig.lua | 4 +- lua/lazy/plugins/markdownpreview.lua | 16 ------- lua/lazy/plugins/minifiles.lua | 23 --------- lua/lazy/plugins/snacks.lua | 7 +++ 8 files changed, 60 insertions(+), 115 deletions(-) delete mode 100644 lua/lazy/plugins/image.lua delete mode 100644 lua/lazy/plugins/markdownpreview.lua delete mode 100644 lua/lazy/plugins/minifiles.lua create mode 100644 lua/lazy/plugins/snacks.lua diff --git a/lua/core/init.lua b/lua/core/init.lua index 5404cd4..b14155c 100644 --- a/lua/core/init.lua +++ b/lua/core/init.lua @@ -40,6 +40,8 @@ vim.o.mouse = 'a' vim.o.termguicolors = true -- 将updatetime设置为较低的值以提高性能 vim.opt.updatetime = 200 +-- 指定keyword +vim.opt.iskeyword = "_,49-57,A-Z,a-z" -- 设置编码格式 vim.o.fileencodings = 'utf-8,gb2312,gb18030,gbk,ucs-bom,cp936,latin1' diff --git a/lua/lazy/index.lua b/lua/lazy/index.lua index 2d2096c..44702e9 100644 --- a/lua/lazy/index.lua +++ b/lua/lazy/index.lua @@ -17,7 +17,7 @@ vim.opt.rtp:prepend(vim.env.LAZY or lazypath) -- 启动Lazy插件管理快捷键 vim.keymap.set("n", "l", ":Lazy", { noremap = true }) require("lazy").setup({ - -- cmp自动补全 + -- 自动补全插件 require("lazy.plugins.blinkcmp"), -- lsp配置,全局的错误和警告提示,修复建议,重命名变量,格式化代码等等 require("lazy.plugins.lspconfig"), @@ -40,7 +40,7 @@ require("lazy").setup({ -- 粘贴图片 require("lazy.plugins.imgclip"), -- 图片预览 - require("lazy.plugins.image"), + require("lazy.plugins.snacks"), -- 翻译插件gtranslate require("lazy.plugins.translate"), -- git状态 @@ -61,8 +61,6 @@ require("lazy").setup({ require("lazy.plugins.flutter"), -- 用于改进在 Neovim 中查看 Markdown 文件的插件 require("lazy.plugins.render-markdown"), - -- markdown preview - require("lazy.plugins.markdownpreview"), -- 底部状态栏+主题 themes require("lazy.plugins.themes"), -- 注释插件 @@ -71,8 +69,6 @@ require("lazy").setup({ require("lazy.plugins.bufferline"), -- explorer tree 文件列表,现在已使用yazi require("lazy.plugins.filemanager"), - -- minifiles也是文件管理器,功能较少 - require("lazy.plugins.minifiles"), -- crtl+g快捷键在neovim中启动lazygit require("lazy.plugins.lazygit"), -- telescope模糊查找 diff --git a/lua/lazy/plugins/blinkcmp.lua b/lua/lazy/plugins/blinkcmp.lua index b56f223..f1e879e 100644 --- a/lua/lazy/plugins/blinkcmp.lua +++ b/lua/lazy/plugins/blinkcmp.lua @@ -1,29 +1,42 @@ return { - 'saghen/blink.cmp', - dependencies = 'rafamadriz/friendly-snippets', - version = '*', + "saghen/blink.cmp", + dependencies = { + "rafamadriz/friendly-snippets", + "mikavilpas/blink-ripgrep.nvim", + }, + version = "*", ---@module 'blink.cmp' ---@type blink.cmp.Config opts = { + cmdline = { + keymap = { + -- 选择并接受预选择的第一个 + [""] = { "select_and_accept", "fallback" }, + }, + completion = { + -- 自动显示补全窗口 + menu = { auto_show = true }, + -- 不在当前行上显示所选项目的预览 + ghost_text = { enabled = false }, + }, + }, keymap = { - preset = 'none', - [''] = { 'show', 'show_documentation', 'hide_documentation' }, - -- [''] = { 'hide' }, + preset = "none", + [""] = { "show", "show_documentation", "hide_documentation" }, -- fallback命令将运行下一个非闪烁键盘映射(回车键的默认换行等操作需要) - [''] = { 'accept', 'fallback' }, -- 更改成'select_and_accept'会选择第一项插入 - [''] = { 'select_prev', 'snippet_backward', 'fallback' }, - [''] = { 'select_next', 'snippet_forward', 'fallback' }, -- 同时存在补全列表和snippet时,补全列表选择优先级更高 + [""] = { "accept", "fallback" }, -- 更改成'select_and_accept'会选择第一项插入 + [""] = { "select_prev", "snippet_backward", "fallback" }, + [""] = { "select_next", "snippet_forward", "fallback" }, -- 同时存在补全列表和snippet时,补全列表选择优先级更高 - [''] = { 'scroll_documentation_up', 'fallback' }, - [''] = { 'scroll_documentation_down', 'fallback' }, - - [''] = { 'snippet_forward', 'select_next', 'fallback' }, -- 同时存在补全列表和snippet时,snippet跳转优先级更高 - [''] = { 'snippet_backward', 'select_prev', 'fallback' }, + [""] = { "scroll_documentation_up", "fallback" }, + [""] = { "scroll_documentation_down", "fallback" }, + [""] = { "snippet_forward", "select_next", "fallback" }, -- 同时存在补全列表和snippet时,snippet跳转优先级更高 + [""] = { "snippet_backward", "select_prev", "fallback" }, }, completion = { -- 示例:使用'prefix'对于'foo_|_bar'单词将匹配'foo_'(光标前面的部分),使用'full'将匹配'foo__bar'(整个单词) - keyword = { range = 'full' }, + keyword = { range = "full" }, -- 选择补全项目时显示文档(0.5秒延迟) documentation = { auto_show = true, auto_show_delay_ms = 500 }, -- 不预选第一个项目,选中后自动插入该项目文本 @@ -32,11 +45,9 @@ return { -- 指定文件类型启用/禁用 enabled = function() return not vim.tbl_contains({ - -- "lua", - -- "markdown" - }, vim.bo.filetype) - and vim.bo.buftype ~= "prompt" - and vim.b.completion ~= false + -- "lua", + -- "markdown" + }, vim.bo.filetype) and vim.bo.buftype ~= "prompt" and vim.b.completion ~= false end, appearance = { @@ -46,21 +57,32 @@ return { use_nvim_cmp_as_default = true, -- 将“Nerd Font Mono”设置为“mono”,将“Nerd Font”设置为“normal” -- 调整间距以确保图标对齐 - nerd_font_variant = 'mono' + nerd_font_variant = "mono", }, -- 已定义启用的提供程序的默认列表,以便您可以扩展它 sources = { - default = { 'buffer', 'lsp', 'path', 'snippets', }, + default = { + "buffer", + "ripgrep", + "lsp", + "path", + "snippets", + }, providers = { -- score_offset设置优先级数字越大优先级越高 - buffer = { score_offset = 4 }, + buffer = { score_offset = 5 }, + ripgrep = { + module = "blink-ripgrep", + name = "Ripgrep", + score_offset = 4, + }, path = { score_offset = 3 }, lsp = { score_offset = 2 }, snippets = { score_offset = 1 }, - } + }, }, }, -- 由于“opts_extend”,您的配置中的其他位置无需重新定义它 - opts_extend = { "sources.default" } + opts_extend = { "sources.default" }, } diff --git a/lua/lazy/plugins/image.lua b/lua/lazy/plugins/image.lua deleted file mode 100644 index 2745374..0000000 --- a/lua/lazy/plugins/image.lua +++ /dev/null @@ -1,43 +0,0 @@ -return { - "3rd/image.nvim", - dependencies = { - "vhyrro/luarocks.nvim", - priority = 1001, -- this plugin needs to run before anything else - opts = { - rocks = { "magick" }, - }, - }, - config = function() - -- default config - require("image").setup({ - backend = "kitty", - -- backend = "ueberzug", - integrations = { - markdown = { - enabled = true, - clear_in_insert_mode = false, -- 插入模式的时候隐藏 - download_remote_images = true, - only_render_image_at_cursor = false, - filetypes = { "markdown", "vimwiki" }, -- markdown extensions (ie. quarto) can go here - }, - neorg = { - enabled = true, - clear_in_insert_mode = true, - download_remote_images = true, - only_render_image_at_cursor = false, - filetypes = { "norg" }, - }, - }, - max_width = nil, - max_height = nil, - max_width_window_percentage = nil, - max_height_window_percentage = 50, - window_overlap_clear_enabled = true, -- 当打开重叠的浮动窗口时隐藏图片 - window_overlap_clear_ft_ignore = { "cmp_menu", "cmp_docs", "" }, - editor_only_render_when_focused = false, -- auto show/hide images when the editor gains/looses focus - tmux_show_only_in_active_window = false, -- auto show/hide images in the correct Tmux window (needs visual-activity off) - hijack_file_patterns = { "*.png", "*.jpg", "*.jpeg", "*.gif", "*.webp", "*.avif" }, -- render image files as images when opened - }) - end -} - diff --git a/lua/lazy/plugins/lspconfig.lua b/lua/lazy/plugins/lspconfig.lua index d2c5902..bf66e10 100644 --- a/lua/lazy/plugins/lspconfig.lua +++ b/lua/lazy/plugins/lspconfig.lua @@ -19,8 +19,8 @@ return { local servers = { 'marksman', -- 任意标题aw打开code action可以开头生成目录;超链接可以链接到同一个git项目的其他markdown文件#指定标题h可以预览 'lua_ls', - 'pyright', - 'gopls', + 'pylsp', -- Mason对应的安装名称是python-lsp-server + -- 'gopls', 'rust_analyzer', } -- lsp_zero的相关配置 diff --git a/lua/lazy/plugins/markdownpreview.lua b/lua/lazy/plugins/markdownpreview.lua deleted file mode 100644 index c7264ce..0000000 --- a/lua/lazy/plugins/markdownpreview.lua +++ /dev/null @@ -1,16 +0,0 @@ --- === --- === markdown preview --- === - -return { - "iamcco/markdown-preview.nvim", - build = "cd app && npm install", - init = function() vim.g.mkdp_filetypes = { "markdown" } end, - ft = { "markdown" }, - lazy = true, - config = function() - -- 设置使用谷歌浏览器进行预览 - vim.g.mkdp_browser = '/usr/bin/google-chrome-stable' - end -} - diff --git a/lua/lazy/plugins/minifiles.lua b/lua/lazy/plugins/minifiles.lua deleted file mode 100644 index 075cdb9..0000000 --- a/lua/lazy/plugins/minifiles.lua +++ /dev/null @@ -1,23 +0,0 @@ -return { - 'echasnovski/mini.files', - config = function() - require('mini.files').setup{ - mappings = { - close = 'q', - go_in = 'I', - go_in_plus = 'i', - go_out = 'N', - go_out_plus = 'n', - mark_goto = "'", - mark_set = 'm', - reset = '', - reveal_cwd = '@', - show_help = 'g?', - synchronize = '=', - trim_left = '<', - trim_right = '>', - } - } - end -} - diff --git a/lua/lazy/plugins/snacks.lua b/lua/lazy/plugins/snacks.lua new file mode 100644 index 0000000..c46f291 --- /dev/null +++ b/lua/lazy/plugins/snacks.lua @@ -0,0 +1,7 @@ +return { + "folke/snacks.nvim", + ---@type snacks.Config + opts = { + image = { } + } +}