-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Customize which elements render in certain render modes #269
Comments
You can specify the modes in which the plugin does rendering in general to include insert mode via the |
Great :) I think it would be really nice to have! Let me know if you need help implementing it. |
So I have an implementation that allows all of the You would need to set a subset of the require('render-markdown').setup({
render_modes = { 'n', 'c', 't', 'i' },
heading = { enabled = { 'n', 'c', 't' } },
paragraph = { enabled = { 'n', 'c', 't' } },
dash = { enabled = { 'n', 'c', 't' } },
bullet = { enabled = { 'n', 'c', 't' } },
checkbox = { enabled = { 'n', 'c', 't' } },
quote = { enabled = { 'n', 'c', 't' } },
pipe_table = { enabled = { 'n', 'c', 't' } },
link = { enabled = { 'n', 'c', 't' } },
inline_highlight = { enabled = { 'n', 'c', 't' } },
}) So the plugin will now render in insert mode (because of the Similarly I could add a require('render-markdown').setup({
render_modes = { 'n', 'c', 't', 'i' },
heading = { disabled = { 'i' } },
paragraph = { disabled = { 'i' } },
dash = { disabled = { 'i' } },
bullet = { disabled = { 'i' } },
checkbox = { disabled = { 'i' } },
quote = { disabled = { 'i' } },
pipe_table = { disabled = { 'i' } },
link = { disabled = { 'i' } },
inline_highlight = { disabled = { 'i' } },
}) An alternative to these would be to allow some kind of categorization based on mode and then allow components to specify which categories they're active for. Something like: require('render-markdown').setup({
render_modes = { 'n', 'c', 't' }, -- The default value, only here for reference
categories = {
insert = { 'i' },
},
code = { active = { 'insert' } },
sign = { active = { 'insert' } },
}) So basically if the mode is Curious what your input on these options is and if you have a preference:
I think I'm leaning towards the 3rd one, though it's a little more involved, but i can also see it being difficult to explain / use. |
I like the last idea a lot -- basically, users could set the Instead of the active table, each component could have a This way, you can still mostly follow the default setting and occasionally override it for certain components if you want. Maybe there could be a |
Thanks for the suggestion, I see why this would work well for users. I think I can implement something fairly close to it. I do have 2 open questions:
Notes to self for implementation:
|
|
## 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.
Well took a little bit but added this here: 4d8e991 I decided to just call it |
this looks great, thank you! |
Neovim version (nvim -v)
NVIM v0.11.0-dev-1397+gfd05c7f19d
Neovim distribution
LazyVim (non
extras.lang.markdown
installation)Description
I have set the following in my config:
This works as expected when moving the cursor around in normal mode (very smart feature, by the way!) I'm wondering if it's possible to make signs and code blocks still be "rendered" in insert mode. It's just a bit jarring when I'm editing a code block, and I enter insert mode, and all of a sudden the background highlight disappears. Thanks!
The text was updated successfully, but these errors were encountered: