refactor: remove PreviewWatch* events and clean up docs
Problem: PreviewWatchStarted/PreviewWatchStopped were redundant with the status() API, and the doc had a wrong author, stale INSTALLATION format, and "watch mode" language left over from the watch → toggle rename. Solution: Remove the events and their tests. Fix the doc author, rename INSTALLATION → SETUP to match sibling plugins, replace "watch mode" with "auto-compile" throughout, and drop the events from EVENTS.
This commit is contained in:
parent
6e48c6716b
commit
50580ecde5
3 changed files with 8 additions and 80 deletions
|
|
@ -1,6 +1,6 @@
|
|||
*preview.nvim.txt* Async document compilation for Neovim
|
||||
|
||||
Author: Raphael
|
||||
Author: Barrett Ruth <br.barrettruth@gmail.com>
|
||||
License: MIT
|
||||
|
||||
==============================================================================
|
||||
|
|
@ -20,19 +20,14 @@ REQUIREMENTS *preview.nvim-requirements
|
|||
- A compiler binary for each configured provider (e.g. `typst`, `latexmk`)
|
||||
|
||||
==============================================================================
|
||||
INSTALLATION *preview.nvim-installation*
|
||||
SETUP *preview.nvim-setup*
|
||||
|
||||
With luarocks (recommended):
|
||||
>
|
||||
:Rocks install preview.nvim
|
||||
<
|
||||
|
||||
With lazy.nvim:
|
||||
>lua
|
||||
Load preview.nvim with your package manager. For example, with lazy.nvim: >lua
|
||||
{
|
||||
'barrettruth/preview.nvim',
|
||||
}
|
||||
<
|
||||
Call |preview.setup()| to configure providers before use.
|
||||
|
||||
==============================================================================
|
||||
CONFIGURATION *preview.nvim-configuration*
|
||||
|
|
@ -161,7 +156,7 @@ COMMANDS *preview.nvim-commands*
|
|||
`stop` Kill active compilation for the current buffer.
|
||||
`clean` Run the provider's clean command.
|
||||
`toggle` Toggle auto-compile on save for the current buffer.
|
||||
`status` Echo compilation status (idle, compiling, watching).
|
||||
`status` Echo compilation status (idle, compiling, toggled).
|
||||
|
||||
==============================================================================
|
||||
API *preview.nvim-api*
|
||||
|
|
@ -176,9 +171,9 @@ preview.clean({bufnr?}) *preview.clean()*
|
|||
Run the provider's clean command for the buffer.
|
||||
|
||||
preview.toggle({bufnr?}) *preview.toggle()*
|
||||
Toggle watch mode for the buffer. When enabled, the buffer is
|
||||
Toggle auto-compile for the buffer. When enabled, the buffer is
|
||||
immediately compiled and automatically recompiled on each save
|
||||
(`BufWritePost`). Call again to stop watching.
|
||||
(`BufWritePost`). Call again to stop.
|
||||
|
||||
preview.status({bufnr?}) *preview.status()*
|
||||
Returns a |preview.Status| table.
|
||||
|
|
@ -187,7 +182,7 @@ preview.status({bufnr?}) *preview.status()*
|
|||
Status fields:~
|
||||
|
||||
`compiling` boolean Whether compilation is active.
|
||||
`watching` boolean Whether watch mode is active.
|
||||
`watching` boolean Whether auto-compile is active.
|
||||
`provider` string? Name of the active provider.
|
||||
`output_file` string? Path to the output file.
|
||||
|
||||
|
|
@ -208,12 +203,6 @@ preview.nvim fires User autocmds with structured data:
|
|||
`PreviewCompileFailed` Compilation failed (non-zero exit).
|
||||
data: `{ bufnr, provider, code, stderr }`
|
||||
|
||||
`PreviewWatchStarted` Watch mode enabled for a buffer.
|
||||
data: `{ bufnr, provider }`
|
||||
|
||||
`PreviewWatchStopped` Watch mode disabled for a buffer.
|
||||
data: `{ bufnr }`
|
||||
|
||||
Example:~
|
||||
>lua
|
||||
vim.api.nvim_create_autocmd('User', {
|
||||
|
|
|
|||
|
|
@ -188,11 +188,6 @@ function M.toggle(bufnr, name, provider, ctx_builder)
|
|||
end,
|
||||
})
|
||||
|
||||
vim.api.nvim_exec_autocmds('User', {
|
||||
pattern = 'PreviewWatchStarted',
|
||||
data = { bufnr = bufnr, provider = name },
|
||||
})
|
||||
|
||||
M.compile(bufnr, name, provider, ctx_builder(bufnr))
|
||||
end
|
||||
|
||||
|
|
@ -205,11 +200,6 @@ function M.unwatch(bufnr)
|
|||
vim.api.nvim_del_autocmd(au_id)
|
||||
watching[bufnr] = nil
|
||||
log.dbg('unwatched buffer %d', bufnr)
|
||||
|
||||
vim.api.nvim_exec_autocmds('User', {
|
||||
pattern = 'PreviewWatchStopped',
|
||||
data = { bufnr = bufnr },
|
||||
})
|
||||
end
|
||||
|
||||
---@param bufnr integer
|
||||
|
|
|
|||
|
|
@ -190,31 +190,6 @@ describe('compiler', function()
|
|||
helpers.delete_buffer(bufnr)
|
||||
end)
|
||||
|
||||
it('fires PreviewWatchStarted event', function()
|
||||
local bufnr = helpers.create_buffer({ 'hello' }, 'text')
|
||||
vim.api.nvim_buf_set_name(bufnr, '/tmp/preview_test_watch_event.txt')
|
||||
|
||||
local fired = false
|
||||
vim.api.nvim_create_autocmd('User', {
|
||||
pattern = 'PreviewWatchStarted',
|
||||
once = true,
|
||||
callback = function()
|
||||
fired = true
|
||||
end,
|
||||
})
|
||||
|
||||
local provider = { cmd = { 'echo', 'ok' } }
|
||||
local ctx_builder = function(b)
|
||||
return { bufnr = b, file = '/tmp/preview_test_watch_event.txt', root = '/tmp', ft = 'text' }
|
||||
end
|
||||
|
||||
compiler.toggle(bufnr, 'echo', provider, ctx_builder)
|
||||
assert.is_true(fired)
|
||||
|
||||
compiler.unwatch(bufnr)
|
||||
helpers.delete_buffer(bufnr)
|
||||
end)
|
||||
|
||||
it('toggles off when called again', function()
|
||||
local bufnr = helpers.create_buffer({ 'hello' }, 'text')
|
||||
vim.api.nvim_buf_set_name(bufnr, '/tmp/preview_test_watch_toggle.txt')
|
||||
|
|
@ -233,32 +208,6 @@ describe('compiler', function()
|
|||
helpers.delete_buffer(bufnr)
|
||||
end)
|
||||
|
||||
it('fires PreviewWatchStopped on unwatch', function()
|
||||
local bufnr = helpers.create_buffer({ 'hello' }, 'text')
|
||||
vim.api.nvim_buf_set_name(bufnr, '/tmp/preview_test_watch_stop.txt')
|
||||
|
||||
local stopped = false
|
||||
vim.api.nvim_create_autocmd('User', {
|
||||
pattern = 'PreviewWatchStopped',
|
||||
once = true,
|
||||
callback = function()
|
||||
stopped = true
|
||||
end,
|
||||
})
|
||||
|
||||
local provider = { cmd = { 'echo', 'ok' } }
|
||||
local ctx_builder = function(b)
|
||||
return { bufnr = b, file = '/tmp/preview_test_watch_stop.txt', root = '/tmp', ft = 'text' }
|
||||
end
|
||||
|
||||
compiler.toggle(bufnr, 'echo', provider, ctx_builder)
|
||||
compiler.unwatch(bufnr)
|
||||
assert.is_true(stopped)
|
||||
assert.is_nil(compiler._test.watching[bufnr])
|
||||
|
||||
helpers.delete_buffer(bufnr)
|
||||
end)
|
||||
|
||||
it('stop_all clears watches', function()
|
||||
local bufnr = helpers.create_buffer({ 'hello' }, 'text')
|
||||
vim.api.nvim_buf_set_name(bufnr, '/tmp/preview_test_watch_stopall.txt')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue