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
feat: allow individual components to specify additional render modes
## Details
Request: #269
Previously the only level of control users had was what modes to perform
rendering in and what components (headings, code blocks, etc.) should be
rendered when we do this.
This is a good amount of control however some users would prefer to have
a cleaner experience in insert mode while doing a subset of the
rendering done in normal mode.
To make this possible was a decent refactor but actually not too bad
because of how information is centralized in a couple key objects.
For users the way this works is the current top level `render_modes`
value now defines the set of modes where all enabled components are
rendered. Now in addition to this each individual component has its own
`render_modes` config which can specify additional modes (or all with a
boolean) in which only these components will be rendered.
So the workflow to decide rendering is now:
- Is component enabled
- Is the current mode in the top level config
- If not check if the mode is defined in the component level configuration
- Any unmatched components are skipped
Also needed to alter the logic to decide is the current mode rendered or not.
It is now the super set of all modes defined in the top level
configuration plus any defined within components. This does not matter
for the most part but does alter the events we listen on (if a component
needs to be rendered in insert mode we need to listen to insert mode
text changes now) along with the window options we set, most importantly
the conceallevel will remain at the rendered level since this is
important for many rendering features.
Example:
```lua
require('render-markdown').setup({
render_modes = { 'n', 'c', 't' },
heading = { render_modes = { 'i' } },
code = { render_modes = { 'i' } },
})
```
With this configuration all components will be rendered in `normal`,
`command`, and `terminal` modes, additionally headings and code blocks
will be rendered in `insert` mode, but no others.
The default value for every component's `render_modes` is set to
`false`, which is equivalent to the empty list. This means by default
nothing is changed and we continue to render according to only the top
level `render_modes` value.
Some other minor things needed to change but nothing of particular note.
0 commit comments