mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-06-21 16:39:06 +02:00
## Description Load treesitter-context on `LazyFile` instead of `VeryLazy`. IMHO it didn't make sense to load the plugin earlier just so that the toggle is available, especially when the toggle won't actually have any effect anything until a file is opened. ~Previously, treesitter-context was loaded on `VeryLazy` and its toggle map in `opt`, which also `require`d it. Now, mapping happens in config, after treesitter-context is setup (also how toggle is handled in other extras, eg for render-markdown).~ ## Checklist - [x] I've read the [CONTRIBUTING](https://github.com/LazyVim/LazyVim/blob/main/CONTRIBUTING.md) guidelines.
20 lines
475 B
Lua
20 lines
475 B
Lua
-- Show context of the current function
|
|
return {
|
|
"nvim-treesitter/nvim-treesitter-context",
|
|
event = "LazyFile",
|
|
opts = function()
|
|
local tsc = require("treesitter-context")
|
|
Snacks.toggle({
|
|
name = "Treesitter Context",
|
|
get = tsc.enabled,
|
|
set = function(state)
|
|
if state then
|
|
tsc.enable()
|
|
else
|
|
tsc.disable()
|
|
end
|
|
end,
|
|
}):map("<leader>ut")
|
|
return { mode = "cursor", max_lines = 3 }
|
|
end,
|
|
}
|