Is it possible for custom-configured rendering for single buffer? #489
Replies: 10 comments
-
Kind of, but I wouldn't rely on any of that. In general I would avoid calling this plugin from yours, realistically that's going to make things more complicated and fragile. What I would suggest is simply setting the Then if you have some suggested configuration that you think works really well for your plugin you can suggest users use some specific set of options for my plugin to get results like in your screenshots. I don't think adding a way to force a configuration for specific buffers is a good idea, at least that's my initial impression. If you can provide a specific example, like here's the options I think users should get and here's why they're generally speaking always better, then I'll try to think of some way to accomplish what you're looking for. |
Beta Was this translation helpful? Give feedback.
-
@MeanderingProgrammer thanks for the answer! ![]() and currently i keep that visual structure myself, with space paddings. what i would like to do - is to delegate all that ui madness to something else, that could do a better job than me. nuance of mine here - is that i want content to be aligned like its inside the table, but not having table borders and separators, and thats one custom configuration i want ( now the only one ), and i also don't want all of my users to remove those just because they have my plugin installed... here is link to repo if you want to look around - https://github.com/alex-popov-tech/store.nvim |
Beta Was this translation helpful? Give feedback.
-
Do you create the table as a valid markdown table? My plugin relies on tree-sitter to interact with tables, meaning find the rows / columns, etc. So if the table in the text isn't in markdown table syntax this plugin won't be able to render it at all. |
Beta Was this translation helpful? Give feedback.
-
i render buffer on screen as plain text, but it would be much easier to render them like a valid markdown table, and not make all these counts of spaces here and there |
Beta Was this translation helpful? Give feedback.
-
Ah, gotcha, that makes sense, it is definitely more convoluted then you would think to track all the widths. If your plugin is changed to output a markdown table this plugin will render it, but based on your original question, the rendering will not look quite how you want. I do think the loss of direct control in the output is going to happen if you make this kind of a change, and in this case it's reasonable IMO. You provide the content to render and my plugin renders it based on the user's configuration. If user's don't like exactly how the output looks they can configure table rendering settings through this plugin. I imagine the way they want tables to look in the context of your plugin is the same as how they want tables to look in other markdown files, but I could be wrong here. I'm unsure if it makes sense for other plugins to be able to modify the rendering settings of my plugin for specific buffers. I can kind of see both sides here, but I generally prefer to use what users specify they want when possible. It also seems like we could end up in a place where you add options to modify the options you send to this plugin, when we could just let the user configure this plugin. What do you think? |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
I'm following along, and think I understand what you're looking for. I think there are 2 separate things needed: 1. A way to render tables "like a dataset"By this I mean a set of options that if configured on this plugin tables will look the way your plugin shows them. This means some way to hide separators, maybe not showing the header / delimiter rows. Some of these might be possible with existing options, others will likely require new options to be added. I just have to have a really good idea of this markdown should render like this, will require some and forth with you. 2. A way to use that rendering for your plugin's buffersI'm not sure exactly how I'll end up doing this but here are 2 ways I can think of:
|
Beta Was this translation helpful? Give feedback.
-
thanks for such a passionate response! |
Beta Was this translation helpful? Give feedback.
-
Unfortunately not really, at least if I understand what you mean correctly. Since I do not own / create / update the buffers users are interacting with the concept of an "instance" is a little different. This plugin is more built around "listening" and responding to changes to buffers. I'm also not sure if it would help in this case. By that I mean if this plugin did the equivalent of creating an "instance" per markdown buffer then by default this plugin will automatically attach to the The configuration to use for rendering is computed once per buffer and re-used on all subsequent render calls. So the only hook you need is a way to modify the configuration for buffers created by your plugin.
It can seem hacky for sure, but it's a pretty common pattern for neovim plugins. It's essentially a way that allows the source of a buffer to be easily identified and to handle it differently based on that. Some example: |
Beta Was this translation helpful? Give feedback.
-
okay, no worries! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello! My use case is - I am building a neovim plugin, and i have some data there ( like tables, or README file contents ), which i would like to look nice. But i do not want to mess up config of render-markdown.nvim of users, which already use it and have it configured. Basically i want to have like an separate from global scope instance of 'render-markdown.nvim' for purposes of my neovim plugin, for rendering pretty markdown in floating windows. Is there such ability?
Beta Was this translation helpful? Give feedback.
All reactions