Make Treesitter interpret a Heading text inside a List item as a normal Heading title

98 views Asked by At

I want to make Neovim Treesitter to interpret the following markdown list item line as a title line. Is this possible?

- ## Heading title in a List item

I need this because there is another plugin called telescope-heading.nvim that allows me to navigate headings. All my heading titles are embedded inside list items because I keep all these markdown files as Logseq documents. And Logseq by default enforces me to structure the markdown text as list items to treat all the text as a tree outline.

1

There are 1 answers

0
Mert Nuhoglu On

I solved the problem through some other way. Instead of making Treesitter interpret "List items" as "Markdown headings", I edited the code of crispgm/telescope-heading.nvim where the plugin matches the headings.

Edit ~/.local/share/nvim/lazy/telescope-heading.nvim/lua/telescope/_extensions/heading/format/markdown.lua

Add the following lines to "matches" array:

    local matches = {
        '- ',
        '- # ',
        '- ## ',
        '- ### ',
        '# ',
        ...
    }