LazyVim.LazyVim/lua/lazyvim/plugins/extras/ui/treesitter-context.lua
Stefan Boca 83017ff28a
fix(extras.treesitter-context): change event back to LazyFile (#4940)
## 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.
2024-12-05 09:11:40 +01:00

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,
}