Skip to content
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

feature: inline checkbox position #140

Closed
1 task done
jazzabeanie opened this issue Aug 20, 2024 · 1 comment
Closed
1 task done

feature: inline checkbox position #140

jazzabeanie opened this issue Aug 20, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@jazzabeanie
Copy link

Neovim version (nvim -v)

NVIM v0.10.0

Operating system

Ubuntu 22.04

Terminal emulator / GUI

Terminal

Describe the bug

A checkbox should have the same indentation level as the indentation level of the bullet point it is attached to.

Expected behavior

This code:

# Some file

Some list:

- blah
- bleh
- [ ] checkbox that should be at same indentation level

Generates this:
image

By looking at the code you would expect the checkbox to be at the same alignment as the bullet points, but it is further indented giving the impression that it is an item in a sublist.

Healthcheck output

render-markdown: require("render-markdown.health").check()

render-markdown.nvim [version] ~

  • OK plugin 6.1.8
  • OK neovim >= 0.10

render-markdown.nvim [configuration] ~

  • OK valid

render-markdown.nvim [nvim-treesitter] ~

  • OK installed
  • OK markdown: parser installed
  • OK markdown: highlight enabled
  • OK markdown_inline: parser installed
  • OK markdown_inline: highlight enabled
  • WARNING latex: parser not installed
    • ADVICE:
      • Disable LaTeX support to avoid this warning by setting { latex = { enabled = false } }

render-markdown.nvim [executables] ~

  • WARNING latex2text: not installed
    • ADVICE:
      • Disable LaTeX support to avoid this warning by setting { latex = { enabled = false } }

render-markdown.nvim [conflicts] ~

  • OK headlines: not installed
  • OK obsidian: not installed

Plugin configuration

Default for Lazy.vim

Plugin error log

N/A

Confirmations

  • I have provided markdown text for any screenshots used in my description & understand that my issue will be closed if I have not

Additional information

No response

@jazzabeanie jazzabeanie added the bug Something isn't working label Aug 20, 2024
MeanderingProgrammer added a commit that referenced this issue Aug 20, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
# Details

Submitted as a bug: #140

When checkboxes are rendered they are padded with spaces to fill the
width of the underlying text. This is because most icons have a width of
2, while the text forming the checkbox (like [x]) has a width of 3. If
spaces were not added using overlay virtual text would result in one of
the square brackets poking through depending on the side of the padding.

We can use inline virtual text which was added in neovim 0.10.0 to fully
hide the underlying text and insert the virtual text, shifting text as
needed, however on its own this would remove the feature for users of
older versions of neovim.

To get around this I have added a position property to the checkbox
config which defaults to the new value of 'inline' which results in
nicer alignment of checkboxes. The value 'overlay' is available and will
result in identical behavior to before this change if users prefer it.

Additionally when initializing the config we check the neovim version
and change configuration values that are known to not work with older
versions to availble alternatives. Currently this is done for:

- checkbox position -> 'overlay' so as not to remove the feature and
  require users to manually modify their config if they run neovim <
  0.10.0
- code position -> 'right' since left alignment requires shifting text
  while right does not, adding a feature to users if they did not dive
  too deep into the options available for this plugin

Overall this updates behavior for anyone that can use it and keeps the
old behavior around either out of necessity (version) or personal
preference.
@MeanderingProgrammer
Copy link
Owner

Not a bug. The additional spaces were needed to allow overlay virtual text to hide all of the underlying text. I used overlay for compatibility with neovim 0.9.x.

Added this as a new position property for checkboxes here: 275f289.

The new inline value is the default for users using neovim >= 0.10.0, so updating the plugin for you should result in the desired alignment.

@MeanderingProgrammer MeanderingProgrammer changed the title bug: Checkbox should be at same indentation level as bullet point feature: inline checkbox position Feb 7, 2025
@MeanderingProgrammer MeanderingProgrammer added enhancement New feature or request and removed bug Something isn't working labels Feb 7, 2025
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