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: do not auto index lists if numbered manually #254

Closed
2 tasks done
NikolaM-Dev opened this issue Dec 7, 2024 · 3 comments
Closed
2 tasks done

feature: do not auto index lists if numbered manually #254

NikolaM-Dev opened this issue Dec 7, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@NikolaM-Dev
Copy link

Neovim version (nvim -v)

0.10.2

Neovim distribution

N/A

Operating system

Linux

Terminal emulator / GUI

Wezterm

Describe the bug

Description

When I use dashed line --- in the render, change the order I set to the order list and recalculate the order list

Text used

# Example

1. one

---

2. two

---

3. three
4. four
5. five
6. six
7. seven
8. eight

How is rendered

image

Expected behavior

Description

I expected to still the previous behavior and respect the way in that I structure the order list.

Healthcheck output

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

render-markdown.nvim [version] ~
- OK plugin 7.6.12
- 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: installed but should not conflict

Plugin configuration

---@type LazySpec
return {
	'MeanderingProgrammer/markdown.nvim',
	enabled = true,

	cmd = 'RenderMarkdown',
	main = 'render-markdown',
	name = 'render-markdown',
	ft = { 'markdown' },

	opts = function()
		local disabled = { enabled = false }

		---@type render.md.UserConfig
		return {
			heading = disabled,
			sign = disabled,

			bullet = {
				icons = { '' },
			},
			callout = {
				quote = {
					rendered = ' Quote',
				},
			},
			checkbox = {
				checked = {
					icon = '',
				},
				unchecked = {
					icon = '',
				},
				custom = {
					thirty_three = { raw = '[3]', rendered = '󰪠 ', highlight = 'RenderMarkdownTodo' },
					sixty_six = { raw = '[6]', rendered = '󰪢 ', highlight = 'RenderMarkdownTodo' },
					ninety_nine = { raw = '[9]', rendered = '󰪤 ', highlight = 'RenderMarkdownTodo' },
				},
			},
			link = {
				image = '󰈟 ',
				custom = {
					web = { icon = '' },
					youtube = {
						highlight = 'RenderMarkdownLink',
						icon = '',
						pattern = 'https://www.youtube.com/watch*',
					},
				},
			},
		}
	end,

	---@param opts render.md.UserConfig
	config = function(_, opts)
		local PALETTE = require('catppuccin.palettes').get_palette('mocha')

		vim.api.nvim_set_hl(0, 'RenderMarkdownCode', { bg = PALETTE.crust })
		vim.api.nvim_set_hl(0, 'RenderMarkdownCodeInline', { fg = PALETTE.sky })
		vim.api.nvim_set_hl(0, 'RenderMarkdownDash', { fg = PALETTE.blue })

		local colors = {
			PALETTE.red,
			PALETTE.peach,
			PALETTE.green,
			PALETTE.teal,
			PALETTE.lavender,
			PALETTE.mauve,
		}

		for i = 1, 6, 1 do
			local background_highlight = 'RenderMarkdownH' .. i .. 'Bg'
			local foreground_highlight = 'RenderMarkdownH' .. i

			local color = colors[i]

			vim.api.nvim_set_hl(0, background_highlight, { fg = color })
			vim.api.nvim_set_hl(0, foreground_highlight, { fg = color })
		end

		require('render-markdown').setup(opts)
	end,
}

Plugin error log

N/A

Confirmations

  • I have updated this plugin to the latest version using my plugin manager
  • I have provided the text contained in all screenshots as raw text in this issue. This means if there is a screenshot below it is the copy pasted contents of the file in the screenshot. I understand that my issue will be closed if I have not.

Additional information

No response

@NikolaM-Dev NikolaM-Dev added the bug Something isn't working label Dec 7, 2024
@MeanderingProgrammer
Copy link
Owner

Not a bug. Ordered lists infer number based on list structure, when you put a dashed line you're starting a new list so the numbers restart. I can update the default behavior to only infer the number if the value is 1.

MeanderingProgrammer added a commit that referenced this issue Dec 7, 2024
## Details

Request: #254

Previously auto indexing was added for ordered lists to generate the
number value based on the items position in the list. This works for
standard lists but sometimes users want to override the number based on
the value actually set. To support this the default value has been
updated to only use the auto value if the user value is <= 1. The icons
function now also takes a third parameter with the text value of the marker.
@MeanderingProgrammer
Copy link
Owner

Auto indexing has been updated to only run when the user specified value is 1: 4ac2804

@NikolaM-Dev
Copy link
Author

Ty @MeanderingProgrammer <3

@MeanderingProgrammer MeanderingProgrammer added enhancement New feature or request and removed bug Something isn't working labels Feb 7, 2025
@MeanderingProgrammer MeanderingProgrammer changed the title bug: Render list structure is not respected after a dashed line feature: do not auto index lists if numbered manually 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