preservim / vim-markdown

Markdown Vim Mode
4.69k stars 523 forks source link

Cannot show math symbols #355

Open CoinCheung opened 6 years ago

CoinCheung commented 6 years ago

I install the plugin with bundle

    $ cd ~/.vim/bundle
    $ git clone https://github.com/plasticboy/vim-markdown.git

Then when I create a new markdown file and type in:

    $x^2$

It does not convert to a variable with a supper-script.

Here is the content of my .vimrc file, did I miss some necessary configuration?


""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => General
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Sets how many lines of history VIM has to remember
set history=500

" Enable filetype plugins
execute pathogen#infect()
syntax on 
filetype plugin on
filetype indent on

" Set to auto read when a file is changed from the outside
set autoread

" With a map leader it's possible to do extra key combinations
" like <leader>w saves the current file
let mapleader = ","
let g:mapleader = ","

" Fast saving
nmap <leader>w :w!<cr>

" :W sudo saves the file 
" (useful for handling the permission-denied error)
command W w !sudo tee % > /dev/null

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => VIM user interface
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Set 7 lines to the cursor - when moving vertically using j/k
set so=7

" Avoid garbled characters in Chinese language windows OS
let $LANG='en' 
set langmenu=en
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim

" Turn on the WiLd menu
set wildmenu

" Ignore compiled files
set wildignore=*.o,*~,*.pyc
if has("win16") || has("win32")
    set wildignore+=.git\*,.hg\*,.svn\*
else
    set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/.DS_Store
endif

"Always show current position
set ruler

" Height of the command bar
set cmdheight=2

" A buffer becomes hidden when it is abandoned
set hid

" Configure backspace so it acts as it should act
set backspace=eol,start,indent
set whichwrap+=<,>,h,l

" Ignore case when searching
set ignorecase

" When searching try to be smart about cases 
set smartcase

" Highlight search results
set hlsearch

" Makes search act like search in modern browsers
set incsearch 

" Don't redraw while executing macros (good performance config)
set lazyredraw 

" For regular expressions turn magic on
set magic

" Show matching brackets when text indicator is over them
set showmatch 

" How many tenths of a second to blink when matching brackets
set mat=2

" Set foldmethod
set fdm=indent
set foldlevel=9

" No annoying sound on errors
set noerrorbells
set novisualbell
set t_vb=
set tm=500

" Add a bit extra margin to the left
set foldcolumn=1

" Dismiss the tab label if buffers are to be used  
set showtabline =0

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Colors and Fonts
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Enable syntax highlighting
syntax enable 
set background=dark
" Enable 256 colors palette in Gnome Terminal
try
    " colorscheme NeoSolarized
    colorscheme solarized
    " colorscheme molokai
    " colorscheme desert

catch
endtry

hi clear SpellBad
hi SpellBad cterm=reverse

" Set extra options when running in GUI mode
if has("gui_running")
    set guioptions-=T
    set guioptions-=e
    set t_Co=256
    set guitablabel=%M\ %t
endif

" Set utf8 as standard encoding and en_US as the standard language
set encoding=utf8

" Use Unix as the standard file type
set ffs=unix,dos,mac

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Files, backups and undo
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Turn backup off, since most stuff is in SVN, git et.c anyway...
set nobackup
set nowb
set noswapfile

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Text, tab and indent related
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Use spaces instead of tabs
set expandtab

" Be smart when using tabs ;)
set smarttab

" Set line numbers
set nu

" Set mouse
set mouse=a

" Set clipboard
set clipboard=unnamedplus

" 1 tab == 4 spaces
set shiftwidth=4
set tabstop=4

" Linebreak on 500 characters
set lbr
"set tw=500

set ai "Auto indent
set si "Smart indent
set wrap "Wrap lines

""""""""""""""""""""""""""""""
" => Visual mode related
""""""""""""""""""""""""""""""
" Visual mode pressing * or # searches for the current selection
" Super useful! From an idea by Michael Naumann

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Moving around, tabs, windows and buffers
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Disable highlight when <leader><cr> is pressed
map <silent> <leader><cr> :noh<cr>

" Smart way to move between windows
map <C-j> <C-W>j
map <C-k> <C-W>k
map <C-h> <C-W>h
map <C-l> <C-W>l

" Opens a new tab with the current buffer's path
" Super useful when editing files in the same directory
map <leader>te :tabedit <c-r>=expand("%:p:h")<cr>/

" Switch CWD to the directory of the open buffer
map cd :cd %:p:h<cr>.<cr>

" Specify the behavior when switching between buffers 
try
  set switchbuf=useopen,usetab,newtab
catch
endtry

" Return to last edit position when opening files (You want this!)
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif

""""""""""""""""""""""""""""""
" => Status line
""""""""""""""""""""""""""""""
" Always show the status line
 set laststatus=2

" Format the status line
" set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %l\ \ Column:\ %c

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Editing mappings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Remap VIM 0 to first non-blank character
map 0 ^

" Move a line of text using ALT+[jk] or Command+[jk] on mac
nmap <M-j> gj
nmap <M-k> gk

" Delete trailing white space on save, useful for some filetypes ;)
fun! CleanExtraSpaces()
    let save_cursor = getpos(".")
    let old_query = getreg('/')
    silent! %s/\s\+$//e
    call setpos('.', save_cursor)
    call setreg('/', old_query)
endfun

if has("autocmd")
    autocmd BufWritePre *.txt,*.js,*.py,*.wiki,*.sh,*.coffee :call CleanExtraSpaces()
endif

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Spell checking
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Pressing ,ss will toggle and untoggle spell checking
set spelllang=en
map ss :setlocal spell!<cr>

" Shortcuts using <leader>
map sn ]s
map sp [s
map <leader>sa zg
map <leader>s? z=

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Misc
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Remove the Windows ^M - when the encodings gets messed up
noremap <Leader>m mmHmt:%s/<C-V><cr>//ge<cr>'tzt'm

" Quickly open a buffer for scribble
map <leader>q :e ~/buffer<cr>

" Quickly open a markdown buffer for scribble
map <leader>x :e ~/buffer.md<cr>

" Toggle paste mode on and off
map <leader>pp :setlocal paste!<cr>

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Helper functions
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Returns true if paste mode is enabled
function! HasPaste()
    if &paste
        return 'PASTE MODE  '
    endif
    return ''
endfunction

" Don't close window, when deleting a buffer
command! Bclose call <SID>BufcloseCloseIt()
function! <SID>BufcloseCloseIt()
   let l:currentBufNum = bufnr("%")
   let l:alternateBufNum = bufnr("#")

   if buflisted(l:alternateBufNum)
     buffer #
   else
     bnext
   endif

   if bufnr("%") == l:currentBufNum
     new
   endif

   if buflisted(l:currentBufNum)
     execute("bdelete! ".l:currentBufNum)
   endif
endfunction

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Plugins used by Coin
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" configurations of netrw.vim
nmap nt :Explore<cr>
let g:netrw_banner=0
let g:netrw_liststyle = 0
let g:netrw_altv = 4
let g:netrw_list_hide = '\(^\|\s\s\)\zs\.\S\+,\(^\|\s\s\)ntuser\.\S\+'

**" Configuration for vim-markdown
set conceallevel=2
let g:tex_conceal=''
let g:vim_markdown_math=1**

" Configuration of NerdCommenter
let g:NERDSpaceDelims = 1
let g:NERDCompactSexyComs = 1
let g:NERDDefaultAlign = 'left'
    " let g:NERDCustomDelimiters = {'python':{'left':'###','right':'###'}}
    " let g:NERDCustomDelimiters = {'python':{'left':'#'}}
let g:NERDCommentEmptyLines = 1
let g:NERDTrimTrailingWhitespace = 1

" Configuration of Ctrlsf.vim
let g:ctrlsf_default_view_mode = 'compact'
let g:ctrlsf_position = 'bottom'
let g:ctrlsf_context = '-B 1 -A 2'
nmap mf :CtrlSF <C-R>=expand("<cword>")<CR><CR>

" Configuration of Tagbar
nmap tb :TagbarToggle<cr>
let g:tagbar_width = 30
let g:tagbar_autofocus = 1

" Configuration of Ale 
" let g:ale_sign_column_always = 0
let g:airline#extensions#ale#enabled = 1
let g:ale_open_list = 0
let g:ale_lint_on_save = 1
let g:ale_lint_on_text_changed = 0
let g:ale_sign_error = 'e'
let g:ale_sign_warning = 'w'
let g:ale_echo_msg_error_str = 'E'
let g:ale_echo_msg_warning_str = 'W'
let g:ale_echo_msg_format = '[%linter%] %s [%severity%]'
let g:ale_set_loclist = 1
let g:ale_set_quickfix = 0
" let g:ale_linters = {'c': ['clang'],'c++': 'all'}
let g:ale_linters = {'cpp': ['g++'], 'c': ['clang']}
map E :ALEDetail<cr>

" Configuration of vim-airline
let g:airline#extensions#tabline#enabled = 1
let g:airline_left_sep ='>'
let g:airline_right_sep ='<'
let g:airline#extensions#branch#displayed_head_limit =7 
    " let g:airline#extensions#tabline#buffer_nr_show = 1
let g:airline#extensions#tabline#buffer_idx_mode = 1
let g:airline_section_error = ''
let g:airline_section_warning = ''

" Configuration of vedebugger
let g:vebugger_leader='d'
let g:vebugger_path_gdb='gdb'
let g:vebugger_path_python='python'
let g:vebugger_breakpoint_text='**'
let g:vebugger_currentline_text='->'
map dk :VBGkill<cr>

" Configuration of the buffers
nmap <leader>b :bp<cr> 
nmap <leader>f :bn<cr>
nmap <leader>d :bd<cr> 
nmap <leader>n :enew<cr> 
nmap <leader>1 <Plug>AirlineSelectTab1
nmap <leader>2 <Plug>AirlineSelectTab2
nmap <leader>3 <Plug>AirlineSelectTab3
nmap <leader>4 <Plug>AirlineSelectTab4
nmap <leader>5 <Plug>AirlineSelectTab5
nmap <leader>6 <Plug>AirlineSelectTab6
nmap <leader>7 <Plug>AirlineSelectTab7
nmap <leader>8 <Plug>AirlineSelectTab8
nmap <leader>9 <Plug>AirlineSelectTab9

" Compile and Debug the program with hot keys
func CompileDebug()
    if &filetype == 'c'
        exec '!gcc -g % -o %<'
        exec '!cgdb ./%<'
    elseif &filetype == 'cpp'
        exec '!g++ -g % -o %<'
        exec '!cgdb ./%<'
    elseif &filetype == 'python'
        exec ':VBGstartPDB %'
    endif
endfunc
nmap <leader>db :call CompileDebug()<cr><cr>

" Compile the program with hot keys
func Compile()
    if &filetype == 'c'
        exec '!gcc % -o %<'
    elseif &filetype == 'cpp'
        exec '!g++ % -std=c++14 -o %<'
    endif
endfunc
nmap <leader>cp :call Compile()<cr>

" Run the program with hot keys
func Run()
    if &filetype == 'c'
        exec '! ./%<'
    elseif &filetype == 'cpp'
        exec '! ./%<'
    elseif &filetype == 'python'
        exec '!python3 %'
    elseif &filetype == 'markdown'
        exec '!pandoc -f markdown -t html -o %<.html %'
    endif
endfunc
nmap <leader>rn :call Run()<cr>

" Auto complete pairs with map
imap <F3>, <><esc>:let leavechar=">"<cr>i
imap <F3>[ []<esc>:let leavechar="]"<cr>i
imap <F3>[[ {}<esc>:let leavechar="}"<cr>i
imap <F3>' ''<esc>:let leavechar="'"<cr>i
imap <F3>'' ""<esc>:let leavechar="""<cr>i
imap <F3>9 ()<esc>:let leavechar=")"<cr>i
imap <F3>; <esc>$a;
imap <F3>: <esc>$a:

nmap <F3> o{<esc>o}<esc>:let leavechar="}"<cr>O
sidequestboy commented 6 years ago

@CoinCheung try :help tex_conceal. The default value enables concealment for math.

let g:tex_conceal="admgs"