SidOfc/mkdx

Undefined variable: g:mkdx#settings

KapilRakh opened this issue ยท 5 comments

OS type:

  • Windows

Vim:

  • vim

Vim version:

VIM - Vi IMproved 8.1 (2018 May 18, compiled Apr 29 2019 04:53:42)

Reproduce steps:

Example:

  1. Launch Vim

Expected:

Vim starts up without any error due to plugin.

Actual:

Error detected while processing /c/Users/username/.vim/plugged/mkdx/after/syntax/markdown.vim:
line 1:
E121: Undefined variable: g:mkdx#settings

@KapilRakh cheers for reporting the issue, do you customize mkdx in your vimrc file? If so, can you share the mkdx configuration you are using?

It seems like you may have done something like let g:mkdx#settings.a.b.c = value in your vimrc, this is not allowed during initialization, instead it must be set like let g:mkdx#settings = { 'a': { 'b': { 'c': value } } }.

I am not customizing mkdx. Below is my .vimrc file.

unlet! skip_defaults_vim
source $VIMRUNTIME/defaults.vim
set nocompatible " Use Vim settings, rather than Vi settings
set t_Co=256   " This is may or may not needed.


set number
set laststatus=2


call plug#begin()

Plug 'junegunn/goyo.vim'
" Plug 'leafgarland/typescript-vim'
Plug 'godlygeek/tabular'
Plug 'preservim/vim-markdown'
Plug 'SidOfc/mkdx'
Plug 'VimOutliner/VimOutliner'
call plug#end()


runtime! plugged/**/*.vim

set softtabstop=2 " Indent by 2 spaces when hitting tab
set shiftwidth=4 " Indent by 4 spaces when auto-indenting
set tabstop=4 " Show existing tab with 4 spaces width
syntax on " Enable syntax highlighting
filetype indent on " Enable indenting for files
set autoindent " Enable auto indenting
set number " Enable line numbers
set nobackup " Disable backup files
set laststatus=2 "show status line
set statusline=%F%m%r%h%w%=(%{&ff}/%Y)\ (line\ %l\/%L,\ col\ %c)\
set wildmenu " Display command line's tab complete options as a menu.
set directory=~/.vimswap
set termguicolors

The line runtime! plugged/**/*.vim seems to be causing the after/syntax/markdown.vim file to be loaded eagerly. This happens before plugin initialization happened. The syntax file depends on mkdx being initialized.

Removing this line fixed the issue for me. It should not be needed when using Vim Plug. Anyways, this is not an issue with mkdx itself as I can't prevent users from actively eager-loading stuff which is intended to be lazy loaded :)

I'm not sure why you'd need this line but you can probably remove it to fix the issue. Closing this since I can't fix this on mkdx' side :)

Removing the line fixed issue on my end as well. Being a newbie to Vim, I got this line from someone else's configuration and I added that without understanding how it works.

Yep, as plugin maintainer I get these kinds of issues every now and then, usually easy enough to resolve :)

Cheers for confirming the fix, happy vimming ๐Ÿ‘