Numbered lists not auto-updated
Ginner opened this issue · 3 comments
Hey Sid.
Still using and loving mkdx! :)
I have to ask you about the following behavior; in the README examples, it seems your numbered lists are updated automatically. However my experience is different, as described below. I suspect it's a bug in my collection of plug-ins, or maybe it is just not a part of the mkdx feature set.
Thanks.
OS type:
- Unix
Vim:
- neovim
Vim version:
nvim v0.8.3
Reproduce steps:
Example:
- Open a markdown file.
- Make a numbered list like:
1. This
2. That
3. The other
- Reorder the list:
2. That
1. This
3. The other
- Maybe enter and exit insert-mode
Expected:
The list numbers will automatically be updated to reflect:
1. That
2. This
3. The other
Actual:
The numbers remains not-sequential:
2. That
1. This
3. The other
Hey @Ginner, been a while!
Indeed this is not a part of the current implementation of that feature, no need to go scavenge through your configuration to figure out what it is :)
I think I saw quite some complexity in trying to get this to work. Most of it likely due to lack of TextChanged
autocommand which would allow for a clean "catch-all" i.e. I'd have to step on my toes to make sure I could override p
, dd
while allowing other plugins to work as intended.
Anyways, I just pushed a commit which updates any numbered list the cursor is on whenever the buffer changes. Could you give it a spin?
Wow! Yeah, it seems to be working!
Thank you so much. I was about to say, if it wasn't part of mkdx, don't bother adding it, as I see you're shifting your focus to Lua (looking forward to whatever that might bring). However this is very much appreciated!
Yeah I did want to clarify that mkdx is in feature freeze indeed. I decided to take a look regardless because it's not a new feature and I remember that back when I initially implemented it I ended up releasing it in a partially unfinished state.
I know this because when I ran the s:util.UpdateNumberedList()
function it already worked for the use-case you mentioned but wasn't "connected" to trigger on various keys for fear of bugs with other plugins.
The change is effectively 3 lines, one for attaching a mkdx#OnChange()
function on TextChanged
and two for moving a call to s:util.UpdateNumberedList()
into this mkdx#OnChange()
:)
As for focussing on Lua, indeed this is what I intend to do at some point, mkdx was my first Vim plugin and my first (and last) encounter with VimL. A lot of mkdx can be made significantly faster in Lua and quite a bit more stable since I've also grown a bit as a developer. I also made a metric F-ton of mistakes with the testing setup for mkdx which are cumbersome to fix 😅
I'm looking forward to the moment at which I take another look at building a better markdown plugin in Lua. Only downside is it'll likely be Neovim only due to me refusing to support two different Lua APIs.
Anyways, cheers for the issue, have a good one!