ixru / nvim-markdown

Markdown Vim Mode
http://plasticboy.com/markdown-vim-mode/
80 stars 11 forks source link

Add more functionality to `<CR>` for lists in insert mode. #19

Open Ketan194 opened 1 month ago

Ketan194 commented 1 month ago

First of all I want to thank you for the amazing plugin, it is a lot better than any of the other Markdown plugins I have found/used and I love almost everything about it.

The only issue I have is in lists when a child list item is indented but empty hitting <CR> just deletes the list item and creates a new line. If possible I would love to see a feature added when pressing <CR> on an empty indented list item will demote it (unindent it one level) unit it no longer can and then pressing <CR> again will then remove the list item entirely.

In case my above explanation was unclear I included a visual description bellow.

- Parent List Item 
    - Child List Item 
    - (Empty Child List Item)

When <CR> is pressed on the (Empty List Item) I want the list to look like this:

- Parent List Item
    - Child List Item 
- New Parent List Item 

I believe someone else made a request to add <Shift-Tab> to have the same functionality, but I believe more editors use <CR> to unindent an empty list item so adding this (as well) would make transitioning to and from NeoVim easier.

ixru commented 1 month ago

Removing the list item is meant as an unobtrusive way to end lists so you can continue writing below them without delay. You can indent and deindent in insert mode with Ctrl-T and Ctrl-D so I feel like something like this would be redundant even though the key bindings are somewhat unknown.

Ketan194 commented 1 month ago

Removing the list item is meant as an unobtrusive way to end lists so you can continue writing below them without delay. You can indent and deindent in insert mode with Ctrl-T and Ctrl-D so I feel like something like this would be redundant even though the key bindings are somewhat unknown.

Honestly removing the list item is what is causing delays for me. Maybe its because I am relatively new to neovim (started using about 3 months ago) but not being able to just press <CR> to demote a list item has really slowed me down. Now I need to either remember to use <Ctrl-D> or I need to go back to the line I want to be on then create a new list item there.

If you do ever think of adding this functionality then you can possibly keep it off on default so only those who want/need it can turn it on in their configs. (Or if you know of a way I can do it my self let me know and I can give it a try when I am more free).

ixru commented 1 month ago

Yes I think you are right. Ctrl-D is annoying to remember as this is the only place you'd ever use it, and seeing as most lists are 2 levels deep, maybe 3, it wouldn't be too cumbersome just hitting CR a couple of times to remove it. https://github.com/ixru/nvim-markdown/blob/75639723c1a3a44366f80cff11383baf0799bcb5/lua/markdown.lua#L367 this is the relevant function if you want to change it, but it's maybe not so easy. It shares code with 'o' (see), and I want to keep the current functionality when using that. I imagine the change is just to feed Ctrl-D if the bullet has indentation, and just do what it already does when there is none.