Skip to content

Commit 2491326

Browse files
committed
fix: Support OptionSet as an event
1 parent ee438c3 commit 2491326

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

lua/wrapping/init.lua

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,9 @@ local function get_excluded_treesitter()
220220
return tree_lines, tree_chars
221221
end
222222

223-
local function auto_heuristic()
224-
log("Testing for auto heuristic...")
223+
---@param reason string
224+
local function auto_heuristic(reason)
225+
log("Testing for auto heuristic because of event " .. reason)
225226

226227
if vim.b.wrapmode ~= nil then
227228
log("wrapmode already set for this buffer")
@@ -422,7 +423,16 @@ M.setup = function(o)
422423
-- we can use what's in there.
423424
vim.api.nvim_create_autocmd("BufWinEnter", {
424425
group = vim.api.nvim_create_augroup("wrapping", {}),
425-
callback = auto_heuristic,
426+
callback = function()
427+
auto_heuristic("BufWinEnter")
428+
end,
429+
})
430+
431+
vim.api.nvim_create_autocmd("OptionSet", {
432+
pattern = "filetype",
433+
callback = function()
434+
auto_heuristic("OptionSet")
435+
end,
426436
})
427437
end
428438
end

0 commit comments

Comments
 (0)