Problem: :Preview watch only registered a BufWritePost autocmd without
compiling immediately, required boilerplate to open output files after
first compilation, and was misleadingly named.
Solution: Rename watch → toggle throughout. M.toggle now compiles
immediately on activation. Add an open field to ProviderConfig: true
calls vim.ui.open(), a string[] runs the command with the output path
appended, tracked per-buffer so the file opens only once. All presets
default to { 'xdg-open' }. Health check validates opener binaries.
Guard the async compile callback against invalid buffer ids.
45 lines
1.2 KiB
Lua
45 lines
1.2 KiB
Lua
local helpers = require('spec.helpers')
|
|
|
|
describe('commands', function()
|
|
before_each(function()
|
|
helpers.reset_config()
|
|
end)
|
|
|
|
describe('setup', function()
|
|
it('creates the :Preview command', function()
|
|
require('preview.commands').setup()
|
|
local cmds = vim.api.nvim_get_commands({})
|
|
assert.is_not_nil(cmds.Preview)
|
|
end)
|
|
end)
|
|
|
|
describe('dispatch', function()
|
|
it('does not error on :Preview with no provider', function()
|
|
require('preview.commands').setup()
|
|
assert.has_no.errors(function()
|
|
vim.cmd('Preview compile')
|
|
end)
|
|
end)
|
|
|
|
it('does not error on :Preview stop', function()
|
|
require('preview.commands').setup()
|
|
assert.has_no.errors(function()
|
|
vim.cmd('Preview stop')
|
|
end)
|
|
end)
|
|
|
|
it('does not error on :Preview status', function()
|
|
require('preview.commands').setup()
|
|
assert.has_no.errors(function()
|
|
vim.cmd('Preview status')
|
|
end)
|
|
end)
|
|
|
|
it('does not error on :Preview toggle with no provider', function()
|
|
require('preview.commands').setup()
|
|
assert.has_no.errors(function()
|
|
vim.cmd('Preview toggle')
|
|
end)
|
|
end)
|
|
end)
|
|
end)
|