feat(commands): add :Preview open subcommand
Problem: after closing a viewer, there was no way to re-open the last compiled output without recompiling. Solution: track the most recent output file per buffer in a `last_output` table that persists after compilation finishes. Add `compiler.open()`, `M.open()`, and wire it into the command dispatch.
This commit is contained in:
parent
0b16ff7178
commit
c0bf5c5ce1
5 changed files with 76 additions and 2 deletions
|
|
@ -39,6 +39,7 @@
|
|||
---@field stop fun(bufnr?: integer)
|
||||
---@field clean fun(bufnr?: integer)
|
||||
---@field toggle fun(bufnr?: integer)
|
||||
---@field open fun(bufnr?: integer)
|
||||
---@field status fun(bufnr?: integer): preview.Status
|
||||
---@field get_config fun(): preview.Config
|
||||
local M = {}
|
||||
|
|
@ -166,6 +167,14 @@ function M.toggle(bufnr)
|
|||
compiler.toggle(bufnr, name, provider, M.build_context)
|
||||
end
|
||||
|
||||
---@param bufnr? integer
|
||||
function M.open(bufnr)
|
||||
bufnr = bufnr or vim.api.nvim_get_current_buf()
|
||||
if not compiler.open(bufnr) then
|
||||
vim.notify('[preview.nvim] no output file available for this buffer', vim.log.levels.WARN)
|
||||
end
|
||||
end
|
||||
|
||||
---@class preview.Status
|
||||
---@field compiling boolean
|
||||
---@field watching boolean
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue