refactor(config): replace array preset syntax with preset_name = true (#3)
* refactor(config): replace array preset syntax with preset_name = true Problem: setup() mixed array entries (preset names) and hash entries (custom providers keyed by filetype), requiring verbose vim.tbl_deep_extend boilerplate to override presets. Solution: unify under a single key=value model. Keys are preset names or filetypes; true registers the preset as-is, a table deep-merges with the matching preset (or registers a custom provider if no preset matches), and false is a no-op. Array entries are dropped. Also adds -f gfm to presets.github args so pandoc parses input as GFM. * ci: format * fix(presets): parenthesize gsub output to suppress redundant-return-value
This commit is contained in:
parent
673573044f
commit
2d212aa220
6 changed files with 73 additions and 56 deletions
13
README.md
13
README.md
|
|
@ -55,23 +55,20 @@ require('preview').setup({
|
|||
**Q: How do I override a preset?**
|
||||
|
||||
```lua
|
||||
local presets = require('preview.presets')
|
||||
require('preview').setup({
|
||||
typst = vim.tbl_deep_extend('force', presets.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?**
|
||||
|
||||
Set `open = true` on your provider (all built-in presets have this enabled) to
|
||||
open the output with `vim.ui.open()` after the first successful compilation.
|
||||
For a specific application, pass a command table:
|
||||
open the output with `vim.ui.open()` after the first successful compilation. For
|
||||
a specific application, pass a command table:
|
||||
|
||||
```lua
|
||||
typst = vim.tbl_deep_extend('force', presets.typst, {
|
||||
open = { 'sioyek', '--new-instance' },
|
||||
require('preview').setup({
|
||||
typst = { open = { 'sioyek', '--new-instance' } },
|
||||
})
|
||||
```
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue