From b2f854ee27c1f4e7325058537f2aafb6c5b934cf Mon Sep 17 00:00:00 2001 From: caprain Date: Mon, 13 Apr 2026 21:54:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=BB=9A=E5=8A=A8=E5=9B=BA=E5=AE=9A=E5=87=BD?= =?UTF-8?q?=E6=95=B0=E5=90=8D=E6=8F=92=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/pack/configs/stickscroll.lua | 37 ++++++++++++++++++++++++++++++++ lua/pack/plugins.lua | 10 +++++---- nvim-pack-lock.json | 4 ++++ 3 files changed, 47 insertions(+), 4 deletions(-) create mode 100644 lua/pack/configs/stickscroll.lua diff --git a/lua/pack/configs/stickscroll.lua b/lua/pack/configs/stickscroll.lua new file mode 100644 index 0000000..85dc5d1 --- /dev/null +++ b/lua/pack/configs/stickscroll.lua @@ -0,0 +1,37 @@ +-- === stick scrool === +if vim.g.vscode then return end + +local P = { + name = "nvim-treesitter-context", +} + +-- 懒加载触发器 +vim.api.nvim_create_autocmd({ + "UIEnter", -- vim.schedule(function() +}, { + callback = function() + vim.schedule(function() + PackUtils.load(P, function() + -- 前往上下文开始处 + vim.keymap.set("n", "[c", function() + require("treesitter-context").go_to_context(vim.v.count1) + end, { silent = true }) + require("treesitter-context").setup({ + enable = true, -- Enable this plugin (Can be enabled/disabled later via commands) + multiwindow = true, -- 固定多个层级. + max_lines = 0, -- How many lines the window should span. Values <= 0 mean no limit. + min_window_height = 0, -- Minimum editor window height to enable context. Values <= 0 mean no limit. + line_numbers = true, + multiline_threshold = 20, -- Maximum number of lines to show for a single context + trim_scope = "outer", -- Which context lines to discard if `max_lines` is exceeded. Choices: 'inner', 'outer' + mode = "cursor", -- Line used to calculate context. Choices: 'cursor', 'topline' + -- Separator between context and content. Should be a single character string, like '-'. + -- When separator is set, the context will only show up when there are at least 2 lines above cursorline. + separator = nil, + zindex = 20, -- The Z-index of the context window + on_attach = nil, -- (fun(buf: integer): boolean) return false to disable attaching + }) + end) + end) + end +}) diff --git a/lua/pack/plugins.lua b/lua/pack/plugins.lua index d098e89..a4f2ef7 100644 --- a/lua/pack/plugins.lua +++ b/lua/pack/plugins.lua @@ -14,6 +14,8 @@ local specs = { 'https://github.com/neovim/nvim-lspconfig', 'https://github.com/williamboman/mason-lspconfig.nvim', 'https://github.com/MysticalDevil/inlay-hints.nvim', + -- conform.lua 格式化工具formatter + "https://github.com/stevearc/conform.nvim", -- treesitter.lua 需要安装tree-sitter-cli工具包 'https://github.com/nvim-treesitter/nvim-treesitter', -- indentblankline.lua 彩虹缩进 @@ -21,8 +23,10 @@ local specs = { -- ufo.lua 折叠插件 "https://github.com/kevinhwang91/nvim-ufo", "https://github.com/kevinhwang91/promise-async", - -- conform.lua 格式化工具formatter - "https://github.com/stevearc/conform.nvim", + -- stickscroll.lua 代码函数名称浏览时固定 + "https://github.com/nvim-treesitter/nvim-treesitter-context", + -- bufferline.lua 顶部状态栏 + 'https://github.com/akinsho/bufferline.nvim', -- noice.lua 取代消息、命令行和弹出菜单的 UI "https://github.com/folke/noice.nvim", "https://github.com/MunifTanjim/nui.nvim", @@ -38,8 +42,6 @@ local specs = { 'https://github.com/CRAG666/code_runner.nvim', -- peek.lua 预览markdown 'https://github.com/cap153/peek.nvim', - -- bufferline.lua 顶部状态栏 - 'https://github.com/akinsho/bufferline.nvim', -- yazi.lua 文件管理器 'https://github.com/mikavilpas/yazi.nvim', -- sudo权限保存文件 diff --git a/nvim-pack-lock.json b/nvim-pack-lock.json index 7df907c..b91f60c 100644 --- a/nvim-pack-lock.json +++ b/nvim-pack-lock.json @@ -64,6 +64,10 @@ "rev": "4916d6592ede8c07973490d9322f187e07dfefac", "src": "https://github.com/nvim-treesitter/nvim-treesitter" }, + "nvim-treesitter-context": { + "rev": "b0c45cefe2c8f7b55fc46f34e563bc428ef99636", + "src": "https://github.com/nvim-treesitter/nvim-treesitter-context" + }, "nvim-ufo": { "rev": "ab3eb124062422d276fae49e0dd63b3ad1062cfc", "src": "https://github.com/kevinhwang91/nvim-ufo"