glow.nvim
glow.nvim copied to clipboard
Open Glow output in the same window as input buffer or split
The branch has two commits with detailed explanations in the commit message.
Commit 8327f2a232beec6a0a421490a72147bf4243c35d adds a global configuration option to allow for the output to be rendered in_place. When in a markdown buffer :Glow<CR> renders the output in the same window as the buffer, and q, <Esc> and :Glow!<cr> restore the original buffer in the window.
Commit 06dc8108b29a15b0a6f0553512a1e9d0b180e058 goes a step further than just adding the "split" functionality (which similarly to before allows the output to be in a new split. It also make the usercommand Glow accept a second argument (identified as type for window type) that overrides the config option and opens the output in the specified window (current, split, preview).
Both commit allow to have multiple markdown buffers be rendered and then closed which wasn't possible before because issuing :Glow<CR> twice would override the global win variable and closing it wouldn't be possible, try:
- open fileA.md ->
:Glow<cr>-><C-w><C-w>-> open fileB.md ->:Glow<cr>->q-> fileB output closes - now
<c-w><c-w>until back on the initial preview window and pressqthe error pops up
E5108: Error executing lua: .../AppData/Local/nvim-data/lazy/glow.nvim/lua/glow.lua:54: Invalid window id: 1013
stack traceback:
[C]: in function 'nvim_win_close'
.../AppData/Local/nvim-data/lazy/glow.nvim/lua/glow.lua:54: in function <.../AppData/Local/nvim-data/lazy/glow.nvim/lua/glow.lua:51>
If I open a render with :Glow keep, am I supposed to return to be able to return to the old buffer? Is app exiting supposed to be mandatory? I'm able to return to it with :e filename.md but now I can't open a new render anymore.
Is the preview window supposed to be able to get the background buffer with :bNext or :bprevious? I can't cycle between them but I can re-render just fine after closing the preview window.
Sorry for the late reply @drjaska.
If I open a render with
:Glow keep, am I supposed to return to be able to return to the old buffer? Is app exiting supposed to be mandatory? I'm able to return to it with:e filename.mdbut now I can't open a new render anymore.
I don't know if I understood properly but since before my PR you can close the rendered view with q or <Esc>. The plugin sets local keymaps to the render buffer at line 111-112 (lines 144-145 in my PR are unchanged)
vim.keymap.set("n", "q", close_window, keymaps_opts)
vim.keymap.set("n", "<Esc>", close_window, keymaps_opts)
so perhaps you should use that instead of reopening buffer with :e filename.md.
Is the preview window supposed to be able to get the background buffer with
:bNextor:bprevious? I can't cycle between them but I can re-render just fine after closing the preview window.
The render buffer is wiped from the buffer list when it is no longer displayed in a window (:h bufhidden with wipe option). If you are inside the preview window bNext/bprevious should open the input buffer in the preview window (assuming there aren't other buffers opened, or you will need to bNext/bprevious more than once), but after that you can't go back to the render buffer since it has been wiped.
I usually used preview as such: Glow preview and then just close it with q/<Esc>, or cycle back to input file with <C-w>w.
If you would like to have the original buffer in the preview window I can work on it. Maybe we can have a keymap that in every render windows toggles to the original markdown file. I'll see what I can do, I think it would actually be a different feature so maybe a future PR.
Hope I was clear
Since 1c35e75 you can press p in every Glow window (split, keep, preview) and it will toggle between the Glow output and a buffer which is a non modifiable copy of the original buffer.
@drjaska check it out!
Would be great to have this merged. I just tried @lnc3l0t branch and it works great :)