[Feature Request] Add a flag to preserve or disable conceallevel
Hello,
I've read through this issue that asked for conceallevel to be disabled.
However, plugins like oil.nvim use conceallevel (for some IDs), which causes leap to look like this:
I would like to request a flag that allows users to either preserve the conceallevel of the target buffer or disable it.
Thank you!
Related: https://github.com/justinmk/vim-sneak/issues/30
Here is a non-perfect workaround:
vim.api.nvim_create_autocmd('User', {
pattern = 'LeapEnter',
callback = function ()
vim.schedule(function()
vim.opt.conceallevel = 3
vim.cmd.redraw()
end)
end,
})
But I find it to be pretty alright, at least until this feature is properly implemented
Thanks @timeopochin for your workaround. Unfortunately, there is a slight "flash" when the conceallevel is set and reset.
Building on your example, I am using:
-- HACK: Temporarily override nvim_win_set_option to prevent leap from setting conceallevel to 0
-- NOTE: Both flash.nvim and mini.jump2d do not set the conceallevel...
-- Leap issues: 1 and 243
--
-- Leap sets conceallevel to 0, intending to prevent incorrect or impossible jumps.
-- As a consequence the text "shifts", especially in markdown and mini.files.
-- I favor an incidental "conceallevel" limitation over losing focus because of shifting text.
local nvim_win_set_option = vim.api.nvim_win_set_option -- NOTE: nvim_win_set_option is deprecated...
local no_conceal_on_leap_enter = function(window, name, value)
if name == "conceallevel" then return end
return nvim_win_set_option(window, name, value)
end
vim.api.nvim_create_autocmd("User", {
group = vim.api.nvim_create_augroup("ak_leap", {}),
pattern = "LeapEnter",
callback = function()
-- Triggers before leap sets the conceal level in its LeapEnter callback:
vim.api.nvim_win_set_option = no_conceal_on_leap_enter
-- Ensure the vim.api override is always restored.
-- Triggers after leap has set the conceal level in its LeapEnter callback:
vim.schedule(function() vim.api.nvim_win_set_option = nvim_win_set_option end)
end,
})
Well, the hack above lasted exactly one day...) As of commit 342d535 leap uses vim.api.nvim_get_option_value.
New version:
-- HACK: Temporarily override nvim_set_option_value to prevent leap from setting conceallevel to 0
-- NOTE: Both flash.nvim and mini.jump2d do not set the conceallevel...
-- Leap issues: 1 and 243
--
-- Leap sets conceallevel to 0, intending to prevent incorrect or impossible jumps.
-- As a consequence the text "shifts", especially in markdown and mini.files.
-- I favor an incidental "conceallevel" limitation over losing focus because of shifting text.
local leap_is_active = false
local nvim_set_option_value = vim.api.nvim_set_option_value
local no_conceal_on_leap_enter = function(name, value, opts)
if leap_is_active and name == "conceallevel" then return end
return nvim_set_option_value(name, value, opts)
end
vim.api.nvim_set_option_value = no_conceal_on_leap_enter
vim.api.nvim_create_autocmd("User", {
group = vim.api.nvim_create_augroup("ak_leap", {}),
pattern = "LeapEnter",
callback = function()
-- Triggers before leap enters its LeapEnter callback to set the conceallevel:
leap_is_active = true
-- Ensure vim.api.nvim_set_option_value operates as before.
-- Triggers after leap has set the conceallevel:
vim.schedule(function() leap_is_active = false end)
end,
})
@ggandor, would you accept a PR adding a flag instructing leap to not set the conceallevel?
I think that setting the conceal level conflicts with the third statement in this section from the readme:
You don't have to be aware of the context: the eyes can keep focusing on the target the whole time.
Yes, I would prefer an option to disable the changing of conceallevel as well. To @abeldekat’s point, it is VERY jarring when the text shifts. I, too, would prefer a static view of the buffer over the small possibility of jumping the wrong place.
See PR
https://github.com/ggandor/leap.nvim/issues/272