Skip to content

added treesitter checking for codeblocks - #345

Open
KirkaigDev wants to merge 3 commits into
jakewvincent:mainfrom
KirkaigDev:main
Open

KirkaigDev wants to merge 3 commits into
jakewvincent:mainfrom
KirkaigDev:main

Conversation

@KirkaigDev

Copy link
Copy Markdown

First file I used this plugin on was fairly big and the regex checker caused the header search to fail somehow. This fixes that.

@jakewvincent

Copy link
Copy Markdown
Owner

Hi @KirkaigDev, thanks for the contribution! Could you share a file, or a smaller example in a comment here, that reproduces the heading navigation failure, plus any steps needed to trigger the failure? I’d like to understand first where the existing code block detection is going wrong.

I’ve intentionally kept mkdnflow’s navigation independent of treesitter since we can’t assume users have treesitter or the Markdown parser installed. I see that you included a fallback, but the unconditional treesitter call can fail before even reaching that fallback if the required parser isn’t available.

Generally I’d prefer to identify a fix to the existing detection before introducing treesitter into navigation. I've considered adding treesitter integration and am not opposed to it, but it would need to be opt-in, with parser availability checks, health diagnostics, and working alternative non-treesitter paths. But that’s a bigger change than I’d want to take on as part of this bug fix.

For now I'm thinking we can start with a reproduction and see if the failure can be addressed without adding that integration. When you can, please share the info I'd need for a minimal repro. Thanks!

@KirkaigDev

Copy link
Copy Markdown
Author

My bad, I forgot to wrap it in a pcall. It should work now. I don't use a lot of markdown so I can't find a smaller file, but the error occurred here https://github.com/neovim/nvim-lspconfig/blob/master/doc/configs.md

@KirkaigDev

Copy link
Copy Markdown
Author

I figured out what caused the issue, it's because there was a leading space in one of the code blocks. It seems like an easy fix to just change the regex matching to '^ *```' but somehow that doesn't work. No idea why, just removing the space fixed the entire file, but for whatever reason I can't get the regex to fix it and yet treesitter does fix it.

Updated is_row_code_block function to use current_value parameter so that the regex flips the value like it did before
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

Successfully merging this pull request may close these issues.

2 participants