You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## Details
Adds a new wrapper `render` API accessible via:
`require('render-markdown').render`, built to integrate with other
plugins, be more user friendly, have sane defaults, and a more powerful
and extensible set of features.
This is meant to (eventually) replace all existing usage of the bare
`ui` module's `update` method. This is currently used by picker plugins
like `fzf-lua` and `snacks.nvim`.
Rather than taking multiple parameters the method accepts a single table
as input, with most fields now being optional, only `buf` is mandatory.
This method supports taking an input configuration as well, allowing
callers of the method to modify rendering settings for buffers owned by
them. The majority of the implementation is based on `snacks.nvim`.
In the future the current logic:
```lua
local UI = require("render-markdown.core.ui")
local State = require("render-markdown.state")
local s = State.get(buf)
s.render_modes = true
s.resolved.modes = true
local wins = vim.fn.win_findbuf(buf)
for _, win in ipairs(wins) do
UI.update(buf, win, "Snacks", true)
end
```
Can be replaced with the following:
```lua
require("render-markdown").render({
buf = buf,
event = "Snacks",
config = { render_modes = true },
})
```
Where the `event` value can be removed, defaults to `Api`.
> [!NOTE]
> While this is added under the API umbrella it cannot be called via the
> command line, only through lua code.
As part of this change some related changes were made:
- The deferred initialization of several components, like completions
sources, is moved outside of `manger` and into `state` to handle the
case where the API is the first buffer being rendered by this plugin.
- Handling preview buffer overrides is now part of the main `config`
module rather than partially in `state`.
Mostly unrelated changes:
- Added `ensure` helper method to `list` module, improves common
handling of getting a single value from multiple kinds of input.
- Fix presets in preview override, reduce number of empty tables
returned by `presets.get`.
- Improve type inference in `resolved` module, still not perfect but
fewer warnings.
- `max_file_size` is no longer a buffer local configuration, decision
making on what buffers to attach to should be global, anything more
granular should use the `ignore` callback instead.
0 commit comments