MeanderingProgrammer / render-markdown.nvim

Plugin to improve viewing Markdown files in Neovim
MIT License
1.38k stars 33 forks source link

feature: Allow to disable link conceilment #99

Closed jvanbruegge closed 1 month ago

jvanbruegge commented 1 month ago

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

I find the way that link text is not removed but only hidden very jarring. Ideally the text would reflow but as far as I understand that is not how this plugin works.

Describe the solution you'd like

Add a config option to disable link conceilment independent of link icon rendering.

Describe alternatives you've considered

n/a

Additional information

No response

MeanderingProgrammer commented 1 month ago

The link conceal behavior isn't due to this plugin, it's just how conceallevel and concealcursor behave. We do change these values between the rendered and un-rendered view, but how this looks to the end user is up to neovim. There's not really a way this plugin could implement something smoother that would "reflow" without neovim adding it.

The values we set for conceallevel and concealcursor are configurable under the win_options field which defaults to:

require('render-markdown').setup({
    -- Window options to use that change between rendered and raw view
    win_options = {
        -- See :h 'conceallevel'
        conceallevel = {
            -- Used when not being rendered, get user setting
            default = vim.api.nvim_get_option_value('conceallevel', {}),
            -- Used when being rendered, concealed text is completely hidden
            rendered = 3,
        },
        -- See :h 'concealcursor'
        concealcursor = {
            -- Used when not being rendered, get user setting
            default = vim.api.nvim_get_option_value('concealcursor', {}),
            -- Used when being rendered, disable concealing text in all modes
            rendered = '',
        },
    },
})

Depending on what you want instead you can set different values.

To disable concealing entirely you can set the rendered value for conceallevel to 0, naturally this will stop concealing everything that is currently concealed:

require('render-markdown').setup({
    win_options = {
        conceallevel = { rendered = 0 },
    }
})

To stop unconcealing the link when the cursor enters the line you can set concealcursor to nvic:

require('render-markdown').setup({
    win_options = {
        concealcursor = { rendered = 'nvic' },
    }
})

You can look at the help docs for these options to see what exact values make sense for you, 0 and nvic are just examples to accomplish different things.

The above apply to all the conceal behavior in the buffer. You can't directly target links only with these options. If you want that you'll have to override the default highlights for links provided by nvim-treesitter: https://github.com/nvim-treesitter/nvim-treesitter/blob/master/queries/markdown_inline/highlights.scm#L26-L34.