lukas-reineke / headlines.nvim

This plugin adds horizontal highlights for text filetypes, like markdown, orgmode, and neorg.
MIT License
688 stars 28 forks source link

[Feature Request] Have the heading indentation as an option #90

Closed aniketgm closed 1 month ago

aniketgm commented 1 month ago

Description

I use markdown. The heading indentation is an awesome feature, I like it too. But when looking at the text below it. It does not look good. If only the text below would auto indent along with the heading. However, It might be more work than what I suggest below. Let me explain with the screenshot below:

image_2024-07-15_221934814

Request / Suggestion

Can we have this indentation as an option without losing the fancy bullets feature ? For example, one could add the following option:

opts = {
  ....
  headline_indentation = false, -- default is true. Setting false, might result in something like below image.
  ....
}

OR, only for markdown

require("headlines").setup {
    markdown = {
        ....
        headline_indentation = false,
        ....
    },
}

ignore the '#' in heading 3 and 4, I was experimenting a bit.

image

How did I get the above ? NOTE: I don't know lua (Or still a newbie), however, as a programmer, I tried to understand the best I could, experimented a bit, to get the above. Lukas might know what I did.

For others, I removed the space inside string.rep in the line virt_text[1] = { string.rep(" ", level - 1) .. bullet, { hl_group, bullet_hl_group } }. File: headlines.nvim\lua\headlines\init.lua. Doesn't fully get what I wanted though.

aniketgm commented 1 month ago

Well, I got what I wanted, with this change in same file as mentioned above. > indicates new added lines.

> if c.headline_indent then
    virt_text[1] = { string.rep(" ", level - 1) .. bullet, { hl_group, bullet_hl_group } }
> else
>   virt_text[1] = { bullet .. string.rep(" ", level - 1), { hl_group, bullet_hl_group } }
> end

and then set headline_indent = false in opts, which comes up like this, but overall fine.

image