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
|
|
@ -10,6 +10,7 @@
|
|||
---@field clean? string[]|fun(ctx: preview.Context): string[]
|
||||
---@field open? boolean|string[]
|
||||
---@field reload? boolean|string[]|fun(ctx: preview.Context): string[]
|
||||
---@field detach? boolean
|
||||
|
||||
---@class preview.Config
|
||||
---@field debug boolean|string
|
||||
|
|
@ -101,6 +102,7 @@ function M.setup(opts)
|
|||
end, 'false, "diagnostic", or "quickfix"')
|
||||
vim.validate(prefix .. '.open', provider.open, { 'boolean', 'table' }, true)
|
||||
vim.validate(prefix .. '.reload', provider.reload, { 'boolean', 'table', 'function' }, true)
|
||||
vim.validate(prefix .. '.detach', provider.detach, 'boolean', true)
|
||||
end
|
||||
|
||||
config = vim.tbl_deep_extend('force', default_config, {
|
||||
|
|
@ -246,4 +248,8 @@ M._test = {
|
|||
end,
|
||||
}
|
||||
|
||||
if vim.g.preview then
|
||||
M.setup(vim.g.preview)
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue