MeanderingProgrammer / render-markdown.nvim

Plugin to improve viewing Markdown files in Neovim
MIT License
1.73k stars 38 forks source link

feature: better handle code width "block" in hover #104

Closed kmoschcau closed 3 months ago

kmoschcau commented 3 months ago

Is your feature request related to a problem? Please describe.

Hi, when I set the code block width to "block" and add some left and right padding, it works like a charm in normal files. However it causes hover windows to break up the lines as seen here. image

Describe the solution you'd like

Not quite sure. I don't think its easily possible for this plugin to manipulate the set width of hover windows. So it's probably more feasible to just not add padding in hover windows. Ideally this would be configurable.

Describe alternatives you've considered

Just exclude buftype "nofile", but then the entire plugin is disabled in hover windows.

Additional information

No response

MeanderingProgrammer commented 3 months ago

That makes sense, as you mentioned we don't have direct control over hover windows.

I think this would be a problem for left_pad on its own, whether you use block or full for width.

It seems like generally allowing different settings based on buftype (and potentially other attributes in the future) is what we need. I'll see if there's a way I can add that!

MeanderingProgrammer commented 3 months ago

I've done this refactor here: https://github.com/MeanderingProgrammer/markdown.nvim/commit/9a8a2e5bd204931646f1559235c7c4a7680ecbcd.

Was a little more involved than I'd like but I think the results are good :)

You can now do something like:

require('render-markdown').setup({
    code = { left_pad = 4 },
    overrides = {
        buftype = {
            nofile = {
                code = { left_pad = 0 },
            },
        },
    },
})