anuvyklack / pretty-fold.nvim

Foldtext customization in Neovim
Apache License 2.0
441 stars 21 forks source link

Toggle Preview Keybinding #9

Closed axieax closed 2 years ago

axieax commented 2 years ago

Hi, Is it possible to implement behaviour similar to vim.lsp.buf.hover()? i.e. define ONE keybinding to enable the preview - and if a preview window is already active with the same keybinding pressed, that window becomes active (cursor goes into it). User can also move their cursor to exit the preview

anuvyklack commented 2 years ago

Why do you need this feature? Now the buffer in the floating window is not original, but temporary. Thus, if you move inside the floating window and edit the text, the original buffer will not be affected.

axieax commented 2 years ago

You're right, I forgot you could just expand it anyways. I guess the main thing is adding support for toggling the preview using a keybind - personally, I prefer the default behaviour of fold expansion (not preview, but normal open fold).

I personally don't want to learn a new key combination to open fold preview. So I tried to create something that would feel natural.

I know you mentioned that you don't personally like this feature, but perhaps it can be added as an option for those who want it :D

axieax commented 2 years ago

It seems I'm nearly able to achieve my desired behaviour, with the exception that "h" and "l" still seem to expand the fold. Is it possible to disable this behaviour? This is my current config:

require("pretty-fold").setup()
require("pretty-fold.preview").setup({
  default_keybindings = false,
})
local keymap_amend = require("keymap-amend")
local mapping = require("pretty-fold.preview").mapping
keymap_amend("n", "zK", mapping.show_close_preview_open_fold)
wookayin commented 2 years ago

@axieax :help 'foldopen'. You may want to have set foldopen-=hor

axieax commented 2 years ago

Thanks!