SidOfc / mkdx

A vim plugin that adds some nice extra's for working with markdown documents

Home Page:https://www.vim.org/scripts/script.php?script_id=5620

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Lists do not indent as expected

kdallen000 opened this issue · comments

When adding a new item to a list in which the previous item is indented/nested, the new item is unindented. Looking at the example gifs, I don't think this is the expected behavior, but it's completely possible that I'm just not understanding how to use the plugin!

There are other related issues regarding indentation and alignment, but this is the easiest to explain, so I figure it's a good place to start.

OS type:

  • Unix
  • Windows
  • macOS Monterey 12.2.1 running on MacBook Pro with Apple M1, 2020

Vim:

  • vim
  • neovim
  • Other ([SPECIFY])

Vim version:

I have replicated this behavior in both nvim and vim using the following config:

call plug#begin()
Plug 'SidOfc/mkdx'
call plug#end()
let g:mkdx#settings = { 'highlight': { 'enable': 1 },
                        \ 'enter': { 'shift': 1 },
                        \ 'links': { 'external': { 'enable': 1 } },
                        \ 'toc': { 'text': 'Table of Contents', 'update_on_write': 1 },
                        \ 'fold': { 'enable': 1 } }

VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Dec 17 2021 18:32:29)
macOS version - arm64
Included patches: 1-2671, 3402, 3409, 3428, 3489

NVIM v0.6.1
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by brew@HMBRW-A-001-M1-004.local

Reproduce steps:

Example:

  1. Create new file: nvim test.md
  2. Type: i - <Space> x <Enter> x <Enter> x <Esc> <Tab> o y <Esc>

Expected:

- x
- x
        - x
        - y

Actual:

- x
- x
        - x
- y

Any ideas would be extremely appreciated :)

Hi,
I am not a maintainer nor am I affiliated with the project in any way, I am simply a fellow user. I was browsing the latest issues to see if I could find anything related to a completely unrelated problem I am trying to deal with.

Anyway, the "steps to reproduce" sequence you submitted works fine on my vim setup. Maybe you should try enabling enter.o and enter.shifto in your settings. More about these settings in this readme section.

For reference, the related enter settings section in my .vimrc looks like this (the complete default config is in the vim help):

            \ 'enter'          : {  'enable'   : 1, 'shift' : 1,
            \                       'o'        : 1, 'shifto': 1,
            \                       'malformed': 1
            \                    },

Hope it can help, good luck.

Hi @kdallen000!

I think @lyndhurst is on point in mentioning the settings.enter.o and settings.enter.shifto settings, thanks you for helping out Lyndhurst! 👍

Please let me know if you still experience issues after enabling them, I will leave this open for you to confirm @kdallen000 :)

Thanks both for your help here! I performed a quick test with lyndhurst's settings, and I still see the problematic behavior. Didn't have much time to tinker, admittedly, as I'm on my way out the door.

If it's any help, here is another symptom:
When in insert mode, trying to introduce indentation, I get this kind of behavior, where the '-' does not move over, not sure whether this is expected behavior either:

- x
- x
-        y

@kdallen000 there is no list indentation in insert mode as far as i know; this is quite an extensive plugin with a lot of features, imho the best way to understand how the settings work is to really allocate a substantial amount of time playing with it, but above all going through the whole readme carefully. I am afraid it is not the kind of plugin you can try out quickly and get a real feel of what it can do, on the contrary, the level of possible customization will most probably create frustration and confusion. At least that is what happened to me the first time around :) I can assure you that it is worth the time though!

@SidOfc you are very welcome, I thought the issue was within my grasp . I take advantage of the last op question to ask you if you would consider a list indentation in insert mode if I opened a feature request separately.

I tried already to my own mapping using your function to the usual , but I quickly realised that in insert mode it is necessary to keep cursor position for the mapping to be useable. I had a few use cases successfully covered adding some marks, jumps and shiftwidth value compensation, but I need some programmatic logic for some edge cases like EOL for example.

Unfortunately I am not fluent enough yet with vim script to write that kind of function. Sorry for hijacking the thread, but I thought it was related, and I have been meaning to ask you for this feature for a while now.

Hello again @kdallen000, I think I've found the issue. The regular expressions I wrote originally only took into account spaces, thus tab based list indentation was ignored causing it to unindent. It should now work accordingly though. Can you update mkdx and try it out?

And @lyndhurst so just to confirm for my own understanding, you want to request a feature to add support for insert mode indentation while in a list item? If this is indeed the case feel free to open an issue for it and I'll see what I can do 👍

@SidOfc After updating mkdx, the problem is resolved! Thanks so much for the quick fix. Feel free to close out this issue once @lyndhurst 's questions are all sorted out. And I'll echo @lyndhurst, I'd also like to see indentation in insert mode, but it's only like 2 more keystrokes to indent as-is, so not a big deal.

I'll go ahead and close this one already since it has been resolved, cheers for the quick reply! For other issues or feature requests new issues should be opened :)

Thank you both @kdallen000 and @lyndhurst 👍