feat: add detach provider field and vim.g.preview config support
Problem: viewer processes launched via a string[] `open` command were always killed on buffer deletion with no way to opt out. Configuring the plugin also required an explicit `setup()` call in a `config` hook, preventing config from being declared before the plugin loads. Solution: add a `detach` boolean to `ProviderConfig` that skips SIGTERM on buffer unload. Auto-call `setup()` from `vim.g.preview` at module load time, enabling config via lazy.nvim's `init` hook. Update vimdoc and README accordingly.
This commit is contained in:
parent
bb9ca987e1
commit
b95493ddee
4 changed files with 40 additions and 7 deletions
|
|
@ -291,7 +291,9 @@ function M.compile(bufnr, name, provider, ctx, opts)
|
|||
callback = function()
|
||||
M.stop(bufnr)
|
||||
stop_open_watcher(bufnr)
|
||||
close_viewer(bufnr)
|
||||
if not provider.detach then
|
||||
close_viewer(bufnr)
|
||||
end
|
||||
last_output[bufnr] = nil
|
||||
end,
|
||||
})
|
||||
|
|
@ -404,7 +406,9 @@ function M.compile(bufnr, name, provider, ctx, opts)
|
|||
once = true,
|
||||
callback = function()
|
||||
M.stop(bufnr)
|
||||
close_viewer(bufnr)
|
||||
if not provider.detach then
|
||||
close_viewer(bufnr)
|
||||
end
|
||||
last_output[bufnr] = nil
|
||||
end,
|
||||
})
|
||||
|
|
@ -507,7 +511,9 @@ function M.toggle(bufnr, name, provider, ctx_builder)
|
|||
callback = function()
|
||||
M.unwatch(bufnr)
|
||||
stop_open_watcher(bufnr)
|
||||
close_viewer(bufnr)
|
||||
if not provider.detach then
|
||||
close_viewer(bufnr)
|
||||
end
|
||||
opened[bufnr] = nil
|
||||
end,
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue