Skip to content
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

tracking: breaking changes / regressions with neovim 0.11 #352

Closed
MeanderingProgrammer opened this issue Feb 27, 2025 · 8 comments
Closed

Comments

@MeanderingProgrammer
Copy link
Owner

MeanderingProgrammer commented Feb 27, 2025

Neovim has been overhauling the internal treesitter logic to improve performance as well as adding new extmark options. Both of these are awesome and I'll need to take a closer look into what will be available and see how I can take advantage of these new features!

However, separately from this, due to this plugins assumptions about how treesitter parsing works (sync) and how default highlights behave there are also going to be some breaking changes / regressions in behavior that I'll need to patch. I'll track these regressions as I find out about them as well as the progress on fixing them here.

fenced code block delimiters now hidden with conceal_lines

rendering unfocussed lsp hover docs buffers

async parsing

  • report: NONE
  • related changes:
  • info: Calling parse like we do now should result in synchronous parsing for the specified range, so I don't think any changes are needed, at least for now.
  • status: NO_FIX_REQUIRED
MeanderingProgrammer added a commit that referenced this issue Feb 28, 2025
## Details

This is some of the work needed to better handle the recent
conceal_lines change added to neovim:
#352

In order to better render code blocks, or at least have the ability to,
we first need to figure out which lines are impacted by the change. To
do this update the `conceal` module to process this additional metadata
and store it. Expose this information again through the `context` module.

This change does not include using this information to actually improve
the rendering, but having it ready to go is useful, and the code block
implementation to get around this is going to be pretty tedious.

Some minor refactoring along the way to make these changes a little easier.
@danclave
Copy link

danclave commented Mar 2, 2025

Thanks for the continued effort!

@MeanderingProgrammer MeanderingProgrammer changed the title tracking: breaking change / regressions with neovim 0.11 tracking: breaking changes / regressions with neovim 0.11 Mar 5, 2025
@chiendo97
Copy link

Hi @MeanderingProgrammer,

I stumbled upon this issue from this issue #351

May I ask if we have any good news or updates?

Thank you for your hard work.

@MeanderingProgrammer
Copy link
Owner Author

I have a working implementation but there are still strange behaviors with conceal lines & virtual lines, I'll need to create minimal repros for them and cut issues to neovim but do not have the time ATM.

I'll likely release the change in whatever state it happens to be in when 0.11 is officially released (I believe that's in a month or so).

MeanderingProgrammer added a commit that referenced this issue Mar 28, 2025
## Details

Related issues:

- #351
- #352

This change adds back the code border that currently gets removed by the
default `conceal_lines` highlight that ships with `nvim-treesitter`.

I tried to make this work using virtual lines at first but ran into
quite a few issues with screen offset behavior and was unable to fix the
fact that LSP hover docs are now truncated based on concealed lines
leading to windows that did not take our virtual lines into account.

Ultimately to get around this I've added a new option called `patterns`
which takes a list of directive names & ids and runs the
`disable_pattern` API to turn these off. The default value:

```lua
{
    patterns = {
        markdown = {
            disable = true,
            directives = {
                { id = 17, name = 'conceal_lines' },
                { id = 18, name = 'conceal_lines' },
            },
        },
    },
}
```

Will disable markdown highlight patterns 17 & 18 if they correspond to
a `conceal_lines` directive. There is not any guarantee that the ids
will remain constant and users can override the highlights with their
own which we do not want to break. Hopefully ensuring the ids & names
match will work for most people and I can keep the default value working
with the most common case going forward. This behavior can be disabled
by users by setting `disable = false`.

Since removing these highlight patterns also removes the regular
character level concealing this plugin has been updated to add these for
the delimiter and language nodes itself, rather than relying on the
`nvim-treesitter` behavior.

Disabling patterns can take a while at startup so this instead runs on
just before this plugin actually attaches to a buffer rather than as
part of the startup sequence.

This behavior is specific to `0.11.0` so the logic is appropriately
gated to prevent any older versions from running into errors, we should
still be compatible down to `0.9.0`.

There's also a new `code.border` value called `hide` which is the new
default and applies the `conceal_lines` value to empty fenced code
delimiters. Older versions of neovim will continue to use the `thin`
border style as a fallback. This largely hides the bottom border, but
will also hide the top one if no language icon / name is added or
available.
@MeanderingProgrammer
Copy link
Owner Author

After e6c8081, there should be no more regressions

@chiendo97
Copy link

Thank you @MeanderingProgrammer for the fixes.

For me, I prefer this option to have the same behavior as previously.

    {
        "MeanderingProgrammer/render-markdown.nvim",
        -- enabled = false,
        opts = {
            code = {
                border = "none",
            },
        },
        ft = { "markdown" },
    },

@MeanderingProgrammer
Copy link
Owner Author

@chiendo97 are you saying the behavior changed for border = "none", if so in what way?

@MeanderingProgrammer
Copy link
Owner Author

@chiendo97 I think I see what you mean, the new behavior adds a highlight to the background of languages when border is none.

I added a way to get the old behavior here: a1fc4e5, but its controlled by a new option.

I needed to separate the language section from the border section to accommodate the new hide border value. I like having the language section the same color as the code body and hiding the bottom border, but it's unclear whether that should happen for everyone, and there was no way to change the behavior.

Anyway to get the old behavior use highlight_border = false:

    {
        "MeanderingProgrammer/render-markdown.nvim",
        -- enabled = false,
        opts = {
            code = {
                highlight_border = false,
            },
        },
        ft = { "markdown" },
    },

@chiendo97
Copy link

Thank you @MeanderingProgrammer for the new option. It works well as usual.

hiding the bottom border, but it's unclear whether that should happen for everyone, and there was no way to change the behavior.

Like you said, I prefer not to hide any line from the rendering of my Markdown. Because it would make me confused when I switch between modes or when I move to that line.

What I love about your plugin is that by default, there is no hidden line (aka conceal_lines) with the default config.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants