Skip to content

Commit

Permalink
fix(concealer): use vim.treesitter.foldexpr for stabler folding
Browse files Browse the repository at this point in the history
  • Loading branch information
champignoom authored and vhyrro committed Dec 28, 2023
1 parent 2e12d18 commit 53cbffb
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions lua/neorg/modules/core/concealer/module.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1341,17 +1341,10 @@ local function handle_init_event(event)
mark_all_lines_changed(event.buffer)

if module.config.public.folds and vim.api.nvim_win_is_valid(event.window) then
local opts = {
scope = "local",
win = event.window,
}
vim.api.nvim_set_option_value("foldmethod", "expr", opts)
vim.api.nvim_set_option_value("foldexpr", "nvim_treesitter#foldexpr()", opts)
vim.api.nvim_set_option_value(
"foldtext",
"v:lua.require'neorg'.modules.get_module('core.concealer').foldtext()",
opts
)
local wo = vim.wo[event.window]
wo.foldmethod = "expr"
wo.foldexpr = "v:lua.vim.treesitter.foldexpr()"
wo.foldtext = "v:lua.require'neorg'.modules.get_module('core.concealer').foldtext()"

local init_open_folds = module.config.public.init_open_folds
local function open_folds()
Expand All @@ -1367,8 +1360,7 @@ local function handle_init_event(event)
log.warn('"init_open_folds" must be "auto", "always", or "never"')
end

local foldlevel = vim.api.nvim_get_option_value("foldlevel", opts)
if foldlevel == 0 then
if wo.foldlevel == 0 then
open_folds()
end
end
Expand Down

0 comments on commit 53cbffb

Please sign in to comment.