Skip to content

Commit

Permalink
feat(toggle): add keymap to toggle treesitter context (#1711)
Browse files Browse the repository at this point in the history
* feat: add keymap to toggle treesitter context

* fix: get correct enabled state

---------

Co-authored-by: Folke Lemaitre <folke.lemaitre@gmail.com>
  • Loading branch information
kevintraver and folke committed Oct 14, 2023
1 parent f724eae commit 5e1a86d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lua/lazyvim/plugins/formatting.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ local M = {}
local format_opts = {}

---@param opts ConformOpts
function M.setup(plugin, opts)
function M.setup(_, opts)
local util = require("conform.util")
opts.formatters = opts.formatters or {}
for name, formatter in pairs(opts.formatters) do
Expand Down
16 changes: 16 additions & 0 deletions lua/lazyvim/plugins/treesitter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,22 @@ return {
event = "LazyFile",
enabled = true,
opts = { mode = "cursor" },
keys = {
{
"<leader>ut",
function()
local Util = require("lazyvim.util")
local tsc = require("treesitter-context")
tsc.toggle()
if Util.inject.get_upvalue(tsc.toggle, "enabled") then
Util.info("Enabled Treesitter Context", { title = "Option" })
else
Util.warn("Disabled Treesitter Context", { title = "Option" })
end
end,
desc = "Toggle Treesitter Context",
},
},
},

-- Automatically add closing tags for HTML and JSX
Expand Down

0 comments on commit 5e1a86d

Please sign in to comment.