MeanderingProgrammer / render-markdown.nvim

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

bug: conceal/render without actually entering a buffer #210

Open petobens opened 1 week ago

petobens commented 1 week ago

Neovim version (nvim -v)

NVIM v0.11.0-dev-774+g3b54adc6c6

Neovim distribution

N/A

Operating system

Arch

Terminal emulator / GUI

Kitty

Describe the bug

If a buffer is loaded but the cursor is not inside the window the rendering doesn't actually happen. For instance in the GIF below I switch between different ChatGPT sessions and unless I actually get into the output window/buffer there is no rendering.

Similary I was wondering whether it was possible to have rendering in telescope preview buffer.

Peek 2024-10-19 11-26

Expected behavior

Have rendering when the buffer/window is shown. Dunnno if this is problem with ChatGPT and telecope plugins per se.

Healthcheck output

render-markdown:                     require("render-markdown.health").check()

render-markdown.nvim [version] ~
- OK plugin 7.4.5
- OK neovim >= 0.10

render-markdown.nvim [configuration] ~
- OK valid

render-markdown.nvim [nvim-treesitter] ~
- OK installed
- OK markdown: parser installed
- OK markdown: highlight enabled
- OK markdown_inline: parser installed
- OK markdown_inline: highlight enabled

render-markdown.nvim [executables] ~
- OK none to check

render-markdown.nvim [conflicts] ~
- OK headlines: not installed
- OK obsidian: not installed

Plugin configuration

require('render-markdown').setup({
    enabled = true,
    file_types = { 'markdown', 'chatgpt', 'chatgpt-input' },
    render_modes = true,
    win_options = {
        conceallevel = { rendered = 2 },
        concealcursor = { rendered = 'nc' },
    },
    anti_conceal = {
        -- Preserve glyphs in normal mode but make them "anti_conceal" in insert mode to
        -- replicate concealcursor behaviour
        ignore = {
            bullet = { 'n' },
            callout = { 'n' },
            check_icon = { 'n' },
            check_scope = { 'n' },
            code_language = { 'n' },
            dash = { 'n' },
            head_icon = { 'n' },
            link = { 'n' },
            quote = { 'n' },
            table_border = { 'n' },
        },
    },
    dash = {
        width = 80,
    },
    heading = {
        sign = false,
        icons = { '󰪥', '󰺕', '', '', '', '' },
        position = 'inline',
    },
    bullet = {
        icons = { '', '•', '', '-', '-' },
    },
    checkbox = {
        unchecked = { icon = '' },
        checked = { icon = '', scope_highlight = '@markup.strikethrough' },
        custom = {
            doing = {
                raw = '[_]',
                rendered = '󰄮',
                highlight = 'RenderMarkdownDoing',
            },
            wontdo = {
                raw = '[~]',
                rendered = '󰅗',
                highlight = 'RenderMarkdownWontdo',
            },
        },
    },
    code = {
        sign = false,
        width = 'block',
        border = 'thick',
        min_width = 80,
        highlight_language = 'LineNr',
        language_name = false,
    },
    quote = { icon = '▐' },
    pipe_table = { cell = 'raw' },
    link = {
        wiki = { icon = '󱗖 ', highlight = 'RenderMarkdownWikiLink' },
    },
    latex = { enabled = false },
})

Plugin error log

-

Confirmations

Additional information

No response

MeanderingProgrammer commented 1 week ago

For instance in the GIF below I switch between different ChatGPT sessions and unless I actually get into the output window/buffer there is no rendering.

Are you able to re-create this using some standard commands to reproduce it? I don't exactly want to figure something out specific to a plugin. But if it only occurs in the ChatGPT preview window I can take a look at some point.

Similary I was wondering whether it was possible to have rendering in telescope preview buffer.

Telescope buffers are a special case that there is no way to get working. Some more details on that here: https://github.com/MeanderingProgrammer/render-markdown.nvim/blob/main/doc/limitations.md#does-not-run-in-telescope-preview

MeanderingProgrammer commented 1 week ago

To fix the ChatGPT issue I needed to make a change on my side which was merged here: https://github.com/MeanderingProgrammer/render-markdown.nvim/commit/5137b5e198ddff8a26f88df7000ff8ca336e6fcd.

However there is another change needed from the ChatGPT plugin, just some way for me to know that the preview buffer contents have been changed so I opened a PR for that here: https://github.com/jackMort/ChatGPT.nvim/pull/474.

petobens commented 1 week ago

This so good. Thanks :)