Set default fold level when link_tree_to_folds = true

This commit is contained in:
Steven Arcangeli 2021-07-17 09:22:27 -07:00
parent cffb2a4fd6
commit e641878818
3 changed files with 15 additions and 4 deletions

View file

@ -1,2 +1,3 @@
column_width = 100
indent_type = "Spaces"
indent_width = 2

View file

@ -100,9 +100,13 @@ local function get_option(opt)
if ret == nil then
ret = (vim.g.aerial or {})[opt]
end
-- People are used to using 0 for v:false in vimscript
if ret == 0 and (type(default_options[opt]) == "boolean" or addl_bool_opts[opt]) then
ret = false
-- People are used to using 1/0 for v:true/v:false in vimscript
if type(default_options[opt]) == "boolean" or addl_bool_opts[opt] then
if ret == 0 then
ret = false
elseif ret == 1 then
return true
end
end
if ret == nil then
return default_options[opt]

View file

@ -68,11 +68,17 @@ M.maybe_set_foldmethod = function(bufnr)
for _, winid in ipairs(winids) do
local fdm = vim.api.nvim_win_get_option(winid, "foldmethod")
local fde = vim.api.nvim_win_get_option(winid, "foldexpr")
if manage_folds == true or manage_folds == 1 or (manage_folds == "auto" and fdm == "manual") then
if
not util.is_managing_folds(winid)
and (manage_folds == true or (manage_folds == "auto" and fdm == "manual"))
then
vim.api.nvim_win_set_var(winid, prev_fdm, fdm)
vim.api.nvim_win_set_var(winid, prev_fde, fde)
vim.api.nvim_win_set_option(winid, "foldmethod", "expr")
vim.api.nvim_win_set_option(winid, "foldexpr", "aerial#foldexpr()")
if config.link_tree_to_folds then
vim.api.nvim_win_set_option(winid, "foldlevel", 99)
end
end
end
end