SidOfc / mkdx

A vim plugin that adds some nice extra's for working with markdown documents
https://www.vim.org/scripts/script.php?script_id=5620
MIT License
482 stars 13 forks source link

Mkdx treated vimrc file as markdown #133

Closed Cyperwu closed 3 years ago

Cyperwu commented 3 years ago

OS type:

Vim:

Vim version:

NVIM v0.5.0-nightly Build type: Release LuaJIT 2.0.5

minimal vimrc using vim-plug:

call plug#begin('~/.vim/plugged')
Plug 'sidofc/mkdx'
call plug#end()

filetype plugin indent on
syntax enable

let g:mkdx#settings     = { 'highlight': { 'enable': 1 },
                        \ 'enter': { 'shift': 1 },
                        \ 'links': { 'external': { 'enable': 1 },  'fragment': { 'complete': 0 } } ,
                        \ 'toc': { 'text': 'Table of Contents', 'update_on_write': 1 },
                        \ 'tab': { 'enable': 0},
                        \ 'fold': { 'enable': 1 } }

Reproduce steps:

  1. source the vimrc with source %
  2. :map o
  3. result is n o @(mkdx-o)
SidOfc commented 3 years ago

Interesting indeed, I will look into it @Cyperwu, cheers for the report :+1:

SidOfc commented 3 years ago

I looked into it a bit and found out it was related to auto-update being executed outside of markdown context. auto-update is triggered because of the let g:mkdx#settings = {...} statement in your .vimrc file which, when re-sourced actually applies a deep-merge of new settings over old ones. This in turn executes code to update [markdown] buffers directly for specific settings such as enabling / disabling folding or highlighting.

A bit more difficult is finding the root cause since auto-update does not perform any key mapping, but after preventing its execution the issue no longer occurs :thinking:

In any case can you confirm if this fixes the issue @Cyperwu?

Cyperwu commented 3 years ago

Fixed, thank you for your effort! Closing...