leap.nvim icon indicating copy to clipboard operation
leap.nvim copied to clipboard

Disable concealing when using leap.nvim

Open n-shift opened this issue 2 years ago • 10 comments

When I have used lightspeed.nvim, it was disabling concealing of current buffer. Meanwhile with leap.nvim concealing is still present. It would be much better to have an option to disable concealing while using leap.

n-shift avatar Mar 23 '22 14:03 n-shift

Yes, that is on the todo list. The problem is that window-local options (like conceallevel) are not trivial to handle when doing cross-window motions, so I decided not doing any automagical/buggy thing for the moment, before thinking it through. You could use autocommands, disable conceal on LeapEnter, and restore on LeapLeave by yourself though, that will probably work fine most of the time.

ggandor avatar Mar 23 '22 15:03 ggandor

I see, thanks for pointing out at augroups. I don't know whether i should keep this issue open though.

n-shift avatar Mar 23 '22 16:03 n-shift

Alright, I've tried to use LeapEnter and LeapLeave events, but they don't work. Neovim does not recognise them. I tried to register those autocmds after loading leap.nvim, so it is not loading order issue.

n-shift avatar Mar 23 '22 17:03 n-shift

Oh, this is my bad, I forgot that I need to append User before custom vim events

n-shift avatar Mar 23 '22 17:03 n-shift

Using autocmds for this pretty weird because LeapEnter is being executed after I have typed sre (for example). I had to map using a Lua function that turns conceal off, calls leap, and then on LeapLeave (yes, it works perfectly) enable conceal.

n-shift avatar Mar 23 '22 17:03 n-shift

LeapEnter is triggered right after s, I don't know why you don't see the effect... maybe you could share the autocmd snippet you used, possibly there's some trivial mistake somewhere.

ggandor avatar Mar 23 '22 17:03 ggandor

vim.api.nvim_create_autocmd("User LeapEnter", {
    group = "Conceal",
    callback = function()
        vim.opt.conceallevel = 0
    end
})

Conceal augroup was created before. When I put some print statements there I can see them only after I have finished my jumping sequence. I believe that leap somehow stops screen redraw right after it has been triggered. So conceallevel just can't be applied at the right time

n-shift avatar Mar 24 '22 06:03 n-shift

After a couple of tests I realized that the problem is in LeapLeave event. When I disable LeapLeave autocmd, that looks like this:

vim.api.nvim_create_autocmd("User LeapLeave", {
    group = "Conceal",
    callback = function()
        vim.opt.conceallevel = 2
    end,
})

Concealing is being disable as it should. So, the problem is inside LeapLeave event, maybe it is being executed at the wrong moment, not after s sequence was executed?

n-shift avatar Mar 24 '22 06:03 n-shift

Oh, I get it. The event is User, and LeapEnter/LeapLeave are patterns for that event. You have to call it like this:

vim.api.nvim_create_autocmd('User', { pattern = 'LeapEnter', ... }

I also tripped upon this first! (And probably lots of others.)

ggandor avatar Mar 24 '22 07:03 ggandor

Oh, this makes sense now. Thanks for support, it works as expected now!

n-shift avatar Mar 24 '22 10:03 n-shift