feat(treesitter-context): which-key toggle (#4059)
## Description Add a which-key toggle for treesitter-context ## Screenshots  ## Checklist - [x] I've read the [CONTRIBUTING](https://github.com/LazyVim/LazyVim/blob/main/CONTRIBUTING.md) guidelines.
This commit is contained in:
@ -1,21 +1,22 @@
|
||||
-- Show context of the current function
|
||||
return {
|
||||
"nvim-treesitter/nvim-treesitter-context",
|
||||
event = "LazyFile",
|
||||
opts = { mode = "cursor", max_lines = 3 },
|
||||
keys = {
|
||||
{
|
||||
"<leader>ut",
|
||||
function()
|
||||
local tsc = require("treesitter-context")
|
||||
tsc.toggle()
|
||||
if LazyVim.inject.get_upvalue(tsc.toggle, "enabled") then
|
||||
LazyVim.info("Enabled Treesitter Context", { title = "Option" })
|
||||
event = "VeryLazy",
|
||||
opts = function()
|
||||
local tsc = require("treesitter-context")
|
||||
|
||||
LazyVim.toggle.map("<leader>ut", {
|
||||
name = "Treesitter Context",
|
||||
get = tsc.enabled,
|
||||
set = function(state)
|
||||
if state then
|
||||
tsc.enable()
|
||||
else
|
||||
LazyVim.warn("Disabled Treesitter Context", { title = "Option" })
|
||||
tsc.disable()
|
||||
end
|
||||
end,
|
||||
desc = "Toggle Treesitter Context",
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
return { mode = "cursor", max_lines = 3 }
|
||||
end,
|
||||
}
|
||||
|
Reference in New Issue
Block a user