Skip to content

help: How to apply padding to list for all levels? #349

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

Closed
Nishanth-2024 opened this issue Feb 25, 2025 · 2 comments
Closed

help: How to apply padding to list for all levels? #349

Nishanth-2024 opened this issue Feb 25, 2025 · 2 comments
Labels
question Further information is requested

Comments

@Nishanth-2024
Copy link

Neovim version (nvim -v)

0.10.4

Neovim distribution

N/A

Description

bullet = { left_pad = 4 }
applies padding to only first level not other levels

for exact calculation I want, (left_pad + 1 + right_pad)*(n-1) + left_pad for level n
if I configure left_pad = 4, right_pad = 0,

level 1 - indentation of 4
level 2 - indentation of 9
level 3 - indentation of 14 ...

Is there a way we can add this calculation as a function inside bullet configuration and make it work like I intend to?

@Nishanth-2024 Nishanth-2024 added the question Further information is requested label Feb 25, 2025
@MeanderingProgrammer
Copy link
Owner

So currently the padding is being applied to all list levels. It's just a uniform padding, i.e. 4 across all items. You want level dependent padding support?

MeanderingProgrammer added a commit that referenced this issue Feb 25, 2025
## Details

Request: #349

This allows both `bullet.left_pad` & `bullet.right_pad` to be a `function`
that returns an `integer` in addition to the basic `integer` value.

The input is the same `ctx` object that is provided to the `icon`
`function` and currently contains the following fields:

- `level`: how deeply nested the current list item is
- `index`: the index of the list item within its bottom most list
- `value`: the text value of the marker node, useful for ordered lists

Unrelated change: `Base:padding_text()` -> `Base:pad()`
@MeanderingProgrammer
Copy link
Owner

Should be possible after this change: 98a3b7d

I'm not sure if I fully understood what you meant but this change lets left_pad & right_pad be functions with access to information like the level, as well as the index and the marker value.

From your example I believe this is what you want:

require('render-markdown').setup({
    bullet = {
        left_pad = function(ctx)
            return 5 * (ctx.level - 1) + 4
        end,
    },
})

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

No branches or pull requests

2 participants