Skip to content

feature: first-line-indent for paragraphs. #417

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
chaulkie opened this issue May 2, 2025 · 1 comment
Closed

feature: first-line-indent for paragraphs. #417

chaulkie opened this issue May 2, 2025 · 1 comment
Labels
enhancement New feature or request

Comments

@chaulkie
Copy link

chaulkie commented May 2, 2025

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

A somewhat obscure, probably low-priority, and possibly unwanted feature idea. I sometimes write prose in nvim+markdown, and in such a case I like nvim to replicate some properties of standard word processors.

One thing I have been missing (from any plugin, not just this one) is that are paragraphs demarcated by first-line-indentation. For example, instead of:

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla congue, enim id
accumsan feugiat, ex dolor scelerisque risus, sagittis gravida nisi eros eu
ligula. Nunc laoreet arcu ac massa dapibus, vel aliquam lacus scelerisque.

Nulla luctus nisi a dolor consequat, nec maximus justo facilisis. Sed at lorem
in eros sollicitudin rhoncus nec in est. Vestibulum tincidunt ante purus, id
aliquet arcu eleifend sed. Donec.

It would show:

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla congue, enim id
accumsan feugiat, ex dolor scelerisque risus, sagittis gravida nisi eros eu
ligula. Nunc laoreet arcu ac massa dapibus, vel aliquam lacus scelerisque.
    Nulla luctus nisi a dolor consequat, nec maximus justo facilisis. Sed at
lorem in eros sollicitudin rhoncus nec in est. Vestibulum tincidunt ante purus,
id aliquet arcu eleifend sed. Donec.

Describe the solution you'd like

The underlying markdown paragraphs should remain standard; without the indents and separated by empty lines.

In my mind, the render-markdown plugin would conceal the empty line, and add spacing on the first line of each paragraph. (Perhaps with the option to have just one or the other.)

Sounds simple in concept but there might be complications when it comes to how this functionality interacts with other elements like lists.

Describe alternatives you've considered

Perhaps this could be formatter functionality. I don't know of any formatters that can do this however, and this approach would result in non-standard markdown syntax.

The other solution is just to make do with a previewer plugin.

Additional information

No response

@chaulkie chaulkie added the enhancement New feature or request label May 2, 2025
MeanderingProgrammer added a commit that referenced this issue May 2, 2025
## Details

Request: #417

Add `paragraph.indent` configuration option. Functions similarly to
`paragraph.left_margin` but only applies to the first row of each
paragraph, mimicking the behavior of most word processors. By default
set to 0, resulting in no visible change out of the box.

Since we only query for paragraphs directly under sections this should
avoid any edge cases with paragraphs under list items and other ways
paragraphs get nested.

Other changes:

- Add `indent` module for computing line / size / level, create in
  `base` rather than containing all the logic directly.
- Make the separation between `core` and `lib` meaningful. Anything that
  gets `setup` from state or initialized through plugin directory goes
  in `core`. All other modules go in `lib`:
  - colors  : root  -> core
  - command : root  -> core
  - manager : root  -> core
  - config  : root  -> lib
  - presets : root  -> lib
  - buffer  : core  -> lib
  - context : core  -> lib
  - conceal : core  -> lib
  - extmark : core  -> lib
  - range   : core  -> lib
  - ts      : integ -> core
  - icons   : integ -> lib
- As a result the only remaining modules at the root are:
  - api    : in case user requires it
  - health : convention
  - init   : convention
  - state  : LazyVim requires it
  - types  : best location, can move at any time
- Aliases types that get resolved to a concrete value at runtime like
  heading icons now get generic names like `String` or `Integer`, no more
  field specific names like `Icons`.
- `config/custom_handlers.lua` -> `config/handlers.lua`
- add an alias for `string|string[]` in the context of highlights
- `render.md.callback` -> `render.md.on`
- remove `indent` field from code render data, compute where needed
- remove all `require` statements from top of `api` module
- update CHANGELOG
@MeanderingProgrammer
Copy link
Owner

Added here: 57c7f33

Supports indentation at the start of paragraphs, enable via:

require('render-markdown').setup({
    paragraph = { indent = 4 },
})

Concealing empty lines between paragraphs is not something I want to add support for. It's a little too finicky to determine if the previous line is between 2 paragraphs or a paragraph and some other block (heading, code block, etc.).

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