vim-markdown icon indicating copy to clipboard operation
vim-markdown copied to clipboard

when inputting `o` in normal mode at a list item, unexpected indentation occurs.

Open poloxue opened this issue 1 year ago • 9 comments

I encountered this bug again.

In normal mode, input o key on Markdown list, and then it will automatically add an indent.

expected

- hello
- hello
- cursor

but the reality is

- hello
- hello
    cursor

After debugging for a while, I find the root cause was the code below:

function! s:IsMkdCode(lnum)
    let name = synIDattr(synID(a:lnum, 1, 0), 'name')
    return (name =~# '^mkd\%(Code$\|Snippet\)' || name !=# '' && name !~? '^\%(mkd\|html\)')
endfunction

When variablename is mkdListIterm, it returns 0, that is wrong.

poloxue avatar Sep 07 '23 18:09 poloxue

I temporaliy modified the code as follows:

function! s:IsMkdCode(lnum)
    let name = synIDattr(synID(a:lnum, 1, 0), 'name')
    return (name =~# '^mkd\%(Code$\|Snippet\)' || name !=# '' && name !~? '^\%(mkd\|html\)') || name == 'mkdListItem'
endfunction

I know this is not a nice way, but I don't understand its details. However, it's fixed. 😄

poloxue avatar Sep 07 '23 18:09 poloxue

I'm not able to duplicate this problem. What version of VIM are you running and what other plugins do you have that might be affecting this?

alerque avatar Sep 20 '23 10:09 alerque

Here @alerque.

macvim: mvim -v

VIM - Vi IMproved ~ ~ version 9.0.1677 ~ by Bram Moolenaar et al. ~ Vim is open source and freely distributable

poloxue avatar Sep 22 '23 11:09 poloxue

Hm. I'm on NeoVIM, so that's a major difference.

Anybody else able to confirm this on VIM 9? VIM 8? Or other NeoVIM users that can confirm/deny?

alerque avatar Sep 22 '23 12:09 alerque

@poloxue I guessed that vim-markdown is incompatible with the code "filetype indent on", when I comment the code "filetype indent on" in the .vimrc, the problem solved

burninghg avatar Oct 07 '23 01:10 burninghg

@burninghg Of course if you disable all syntax-aware indentation the unexpected indentation will stop happening, but I don't think that's a resolution. This plugin should work with indentation features enabled even if it doesn't use them any/much. I'd consider this a bug and like to see it fixed, but I'm still at the point of not being able to replicate it.

alerque avatar Oct 12 '23 07:10 alerque

@alerque, I have this bug too. Neovim 0.9.4. No other plugins, almost empty config, my init.lua:

require("lazy").setup({
    {
        "preservim/vim-markdown",
        ft = "markdown",
        dependencies = "godlygeek/tabular",
    },
})

vim.o.keymap = "russian-jcukenwin"

ruffe972 avatar Dec 16 '23 06:12 ruffe972

I had this behavior as well. I un-installed the vim-polyglot plug-in and this solved the problem.

ShrubberRi avatar Jan 31 '24 12:01 ShrubberRi

  1. Isn't this feature expected? See Adjust new list item indent
  2. If your not interested with this feature, you could probably do let g:vim_markdown_new_list_item_indent = 0

x0urc3 avatar Feb 11 '24 13:02 x0urc3