Skip to content

feature: Indent top-level unordered ("bulleted") list items #181

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
proofer opened this issue Sep 24, 2024 · 9 comments
Closed

feature: Indent top-level unordered ("bulleted") list items #181

proofer opened this issue Sep 24, 2024 · 9 comments
Labels
enhancement New feature or request

Comments

@proofer
Copy link

proofer commented Sep 24, 2024

Is your feature request related to a problem? Please describe.

Unordered list items, e.g.,

| <-- left margin, if this were not a github markdown code block in order to render literal hyphens
- first item  
- second item

should be rendered indented, should't they?

Describe the solution you'd like

  • first item
  • second item

--Using github's markdown rendering to show what I'd like; the pre-rendering hyphens are at the left margin

Describe alternatives you've considered

I don't know what other solutions or features to consider, given that I otherwise like render-markdown.nvim a lot.

Additional information

No response

@proofer proofer added the enhancement New feature or request label Sep 24, 2024
@proofer
Copy link
Author

proofer commented Sep 24, 2024

This works

    opts = {
        bullet = {
            left_pad = 4,
        },
    },

except the wrapped portion of a line-wrapped list item now doesn't indent nicely so that its first character is horizontally aligned with the first character of the item.

@MeanderingProgrammer
Copy link
Owner

I'm not trying to render the markdown like github or any other specific software by default. The default is really my personal preference, which is to strike a balance between what I consider looking nice, without shifting the text too much, I more or less like an overlay. That's why all the indentation features are off / set to zero by default. From there it's up to individuals to set the configuration to their preference.

I do have a notion of presets though: https://github.com/MeanderingProgrammer/render-markdown.nvim/blob/main/lua/render-markdown/presets.lua#L15, if you want to offer up a suggested config for github I'd be more than happy to add it :)

It looks like you found the left_pad option, is the issue now just about applying the padding to the entire list item, rather than just the first line?

@proofer
Copy link
Author

proofer commented Sep 24, 2024

is the issue now just about applying the padding to the entire list item, rather than just the first line?
Yes.

I ought to have found left_pad before posting, but I thought I'd leave the post as a lesson to others who don't take sufficient time to read the available opts. Thanks for your understanding.

MeanderingProgrammer added a commit that referenced this issue Sep 24, 2024
## Details

Issue: #181

Currently list item padding only works in and around a bullet point
which causes wrapped lines to be ignored and as a result they end up
offset.

To fix this we need to get the range of the parent list item and apply
padding over its range. However the ranges of list items encompass all
their children. This means a simple approach would stack the padding
resulting in overly indented text. To deal with this we need to base our
end row off of both the list item as well the start of the next list if
one exist.

There was also some prioritization and column handling that needed to
happen to support good interp with indent blank lines. To make this work
the starting column needed to be based off of the starting column of the
top most list for the current item. Then the left padding needs a low
priority to move indent blank lines marks whereas the right padding uses
the default priority so it does not further skew these marks.

As part of this change handling list markers was moved into its own
handler class like we've done to many other components.
@MeanderingProgrammer
Copy link
Owner

MeanderingProgrammer commented Sep 24, 2024

No worries, the configuration for this plugin is not easy to parse though. In general most components should support padding in some form or another.

Applying padding to all lines of list items should work after: 3adb9d5.

@proofer
Copy link
Author

proofer commented Sep 24, 2024

I updated with Lazy and its log now shows 3adb9d5 as the latest commit. I closed and re-opened an .md file that exhibited the wrap issue, but see no change. Is there something else I should do?
image

@proofer
Copy link
Author

proofer commented Sep 24, 2024

I should add that the instances I am seeing are not really dynamically wrapped but are multiple-line items. However, the issue does occur with dynamically-wrapped items, e.g., when resizing a window.

@MeanderingProgrammer
Copy link
Owner

MeanderingProgrammer commented Sep 24, 2024

Ah I thought you were referring to manual line breaks in markdown files, but you're taking about actual wrapped lines.

That's not something I can control in the plugin and is completely up to your neovim config for how line breaks are handled. Checkout:

  • :help 'showbreak'
  • :help 'breakindent'
  • :help 'breakindentopt'

Likely what you want is for me to be able to add padding to line breaks equal to the added padding around the bullet point.

Unfortunately this is basically impossible.

@proofer
Copy link
Author

proofer commented Sep 24, 2024

I think that what I called dynamically wrapped you call actually wrapped -- your suggested :help references are about those; I understand that you can't handle those. And due undoubtedly to some operator error, while the image I posted above was indeed made after updating and closing-re-opening the .md file, now that I've closed-re-opened again I see that the pictured list items are handled perfectly.
image
So in the end I'm glad I made a small contribution the the plugin by posting the issue :)

@proofer proofer closed this as completed Sep 24, 2024
@MeanderingProgrammer
Copy link
Owner

Ah gotcha, I wasn't sure how to describe the difference, maybe manually wrapped?

Anyway, glad we were on the same page and the fix works for you! I imagine there can be many reasons for an update not being picked up immediately.

I agree the new behavior is a much better way to handle padding list items. I think this might be a remanent from when I only handled the literal bullet point of list items.

Thanks for brining up the issue!

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

No branches or pull requests

2 participants