滚动固定函数名插件

This commit is contained in:
caprain 2026-04-13 21:54:22 +08:00
parent 851b1a422d
commit b2f854ee27
3 changed files with 47 additions and 4 deletions

View file

@ -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
})

View file

@ -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权限保存文件

View file

@ -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"