docs: replace all setup() references with vim.g.preview (#43)
This commit is contained in:
parent
f1aed82f42
commit
7895b67c21
2 changed files with 19 additions and 27 deletions
12
README.md
12
README.md
|
|
@ -49,7 +49,7 @@ luarocks install preview.nvim
|
||||||
**Q: How do I define a custom provider?**
|
**Q: How do I define a custom provider?**
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
require('preview').setup({
|
vim.g.preview = {
|
||||||
rst = {
|
rst = {
|
||||||
cmd = { 'rst2html' },
|
cmd = { 'rst2html' },
|
||||||
args = function(ctx)
|
args = function(ctx)
|
||||||
|
|
@ -59,15 +59,15 @@ require('preview').setup({
|
||||||
return ctx.file:gsub('%.rst$', '.html')
|
return ctx.file:gsub('%.rst$', '.html')
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
})
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
**Q: How do I override a preset?**
|
**Q: How do I override a preset?**
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
require('preview').setup({
|
vim.g.preview = {
|
||||||
typst = { env = { TYPST_FONT_PATHS = '/usr/share/fonts' } },
|
typst = { env = { TYPST_FONT_PATHS = '/usr/share/fonts' } },
|
||||||
})
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
**Q: How do I automatically open the output file?**
|
**Q: How do I automatically open the output file?**
|
||||||
|
|
@ -77,7 +77,7 @@ open the output with `vim.ui.open()` after the first successful compilation in
|
||||||
toggle/watch mode. For a specific application, pass a command table:
|
toggle/watch mode. For a specific application, pass a command table:
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
require('preview').setup({
|
vim.g.preview = {
|
||||||
typst = { open = { 'sioyek', '--new-instance' } },
|
typst = { open = { 'sioyek', '--new-instance' } },
|
||||||
})
|
}
|
||||||
```
|
```
|
||||||
|
|
|
||||||
|
|
@ -23,8 +23,7 @@ REQUIREMENTS *preview.nvim-requirements
|
||||||
==============================================================================
|
==============================================================================
|
||||||
SETUP *preview.nvim-setup*
|
SETUP *preview.nvim-setup*
|
||||||
|
|
||||||
With lazy.nvim, set |vim.g.preview| in `init` so configuration is applied
|
Set |vim.g.preview| before the plugin loads: >lua
|
||||||
before the plugin loads: >lua
|
|
||||||
{
|
{
|
||||||
'barrettruth/preview.nvim',
|
'barrettruth/preview.nvim',
|
||||||
init = function()
|
init = function()
|
||||||
|
|
@ -32,19 +31,12 @@ before the plugin loads: >lua
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
<
|
<
|
||||||
Alternatively, call |preview.setup()| directly in a `config` function or
|
|
||||||
anywhere the plugin is already loaded.
|
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
CONFIGURATION *preview.nvim-configuration*
|
CONFIGURATION *preview.nvim-configuration*
|
||||||
|
|
||||||
Configure via `require('preview').setup()`.
|
Configure by setting |vim.g.preview| to a table where keys are preset names
|
||||||
|
or filetypes. For each key `k` with value `v` (excluding `debug`):
|
||||||
*preview.setup()*
|
|
||||||
setup({opts?})
|
|
||||||
|
|
||||||
`opts` is a table where keys are preset names or filetypes. For each
|
|
||||||
key `k` with value `v` (excluding `debug`):
|
|
||||||
|
|
||||||
- If `k` is a preset name and `v` is `true`, the preset is registered
|
- If `k` is a preset name and `v` is `true`, the preset is registered
|
||||||
as-is under its filetype.
|
as-is under its filetype.
|
||||||
|
|
@ -131,30 +123,30 @@ Context fields:~
|
||||||
|
|
||||||
Example enabling presets:~
|
Example enabling presets:~
|
||||||
>lua
|
>lua
|
||||||
require('preview').setup({ typst = true, latex = true, github = true })
|
vim.g.preview = { typst = true, latex = true, github = true }
|
||||||
<
|
<
|
||||||
|
|
||||||
Example overriding a preset field:~
|
Example overriding a preset field:~
|
||||||
>lua
|
>lua
|
||||||
require('preview').setup({
|
vim.g.preview = {
|
||||||
typst = { open = { 'sioyek', '--new-instance' } },
|
typst = { open = { 'sioyek', '--new-instance' } },
|
||||||
})
|
}
|
||||||
<
|
<
|
||||||
|
|
||||||
Example overriding the output path (e.g. latexmk `$out_dir`):~
|
Example overriding the output path (e.g. latexmk `$out_dir`):~
|
||||||
>lua
|
>lua
|
||||||
require('preview').setup({
|
vim.g.preview = {
|
||||||
latex = {
|
latex = {
|
||||||
output = function(ctx)
|
output = function(ctx)
|
||||||
return 'build/' .. vim.fn.fnamemodify(ctx.file, ':t:r') .. '.pdf'
|
return 'build/' .. vim.fn.fnamemodify(ctx.file, ':t:r') .. '.pdf'
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
})
|
}
|
||||||
<
|
<
|
||||||
|
|
||||||
Example with a fully custom provider (key is not a preset name):~
|
Example with a fully custom provider (key is not a preset name):~
|
||||||
>lua
|
>lua
|
||||||
require('preview').setup({
|
vim.g.preview = {
|
||||||
rst = {
|
rst = {
|
||||||
cmd = { 'rst2html' },
|
cmd = { 'rst2html' },
|
||||||
args = function(ctx)
|
args = function(ctx)
|
||||||
|
|
@ -164,7 +156,7 @@ Example with a fully custom provider (key is not a preset name):~
|
||||||
return ctx.file:gsub('%.rst$', '.html')
|
return ctx.file:gsub('%.rst$', '.html')
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
})
|
}
|
||||||
<
|
<
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
|
|
@ -184,14 +176,14 @@ Import them from `preview.presets`:
|
||||||
|
|
||||||
Enable presets with `preset_name = true`:
|
Enable presets with `preset_name = true`:
|
||||||
>lua
|
>lua
|
||||||
require('preview').setup({ typst = true, latex = true, github = true })
|
vim.g.preview = { typst = true, latex = true, github = true }
|
||||||
<
|
<
|
||||||
|
|
||||||
Override individual fields by passing a table instead of `true`:
|
Override individual fields by passing a table instead of `true`:
|
||||||
>lua
|
>lua
|
||||||
require('preview').setup({
|
vim.g.preview = {
|
||||||
typst = { env = { TYPST_FONT_PATHS = '/usr/share/fonts' } },
|
typst = { env = { TYPST_FONT_PATHS = '/usr/share/fonts' } },
|
||||||
})
|
}
|
||||||
<
|
<
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue