Alternate markdown-preview plugin

Improve tables in markdown
This commit is contained in:
Knyffen 2023-09-08 07:58:24 +02:00
parent 17f3885e3c
commit 1373d2d2de
2 changed files with 74 additions and 19 deletions

View File

@ -140,6 +140,12 @@
" Plug 'suan/vim-instant-markdown', {'for': 'markdown'} " Plug 'suan/vim-instant-markdown', {'for': 'markdown'}
Plug 'instant-markdown/vim-instant-markdown', {'for': 'markdown', 'do': 'yarn install'} Plug 'instant-markdown/vim-instant-markdown', {'for': 'markdown', 'do': 'yarn install'}
" markdown-preview (alternative to vim-instant-markdown) TODO
Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app && yarn install' }
" Better table handling (for markdown)
Plug 'dhruvasagar/vim-table-mode'
" SageMath " SageMath
Plug 'petRUShka/vim-sage' Plug 'petRUShka/vim-sage'
@ -855,7 +861,7 @@ augroup END
"Uncomment to override defaults: "Uncomment to override defaults:
let g:instant_markdown_slow = 1 let g:instant_markdown_slow = 1
let g:instant_markdown_autostart = 0 let g:instant_markdown_autostart = 0
au FileType markdown nnoremap <buffer> <Leader>ll :InstantMarkdownPreview<CR> " au FileType markdown nnoremap <buffer> <Leader>ll :InstantMarkdownPreview<CR>
" stop it with :InstantMarkdownStop " stop it with :InstantMarkdownStop
"let g:instant_markdown_open_to_the_world = 1 "let g:instant_markdown_open_to_the_world = 1
let g:instant_markdown_allow_unsafe_content = 1 " Allows javascript let g:instant_markdown_allow_unsafe_content = 1 " Allows javascript
@ -865,7 +871,53 @@ augroup END
let g:instant_markdown_browser = "firefox --new-window" let g:instant_markdown_browser = "firefox --new-window"
"let g:instant_markdown_port = 8888 "let g:instant_markdown_port = 8888
let g:instant_markdown_autoscroll = 1 let g:instant_markdown_autoscroll = 1
"let g:instant_markdown_python = 1 " let g:instant_markdown_python = 1
" }}
" markdown-preview {{
au FileType markdown nnoremap <buffer> <Leader>ll :MarkdownPreview<CR>
" See https://github.com/iamcco/markdown-preview.nvim#markdownpreview-config
let g:mkdp_auto_start = 0 " default 0
let g:mkdp_auto_close = 0 " default 1
let g:mkdp_refresh_slow = 0 " default 0
let g:mkdp_command_for_global = 0 " default 0
let g:mkdp_open_to_the_world = 0 " default 0
let g:mkdp_open_ip = '' " default ''
let g:mkdp_browser = '' " default ''
let g:mkdp_echo_preview_url = 1 " default 0
let g:mkdp_browserfunc = '' " default ''
let g:mkdp_preview_options = {
\ 'mkit': {},
\ 'katex': {
\ 'macros': {
\ "\\doubleR": "\\mathbb{R}",
\ "\\doubleN": "\\mathbb{N}",
\ "\\doubleZ": "\\mathbb{Z}",
\ "\\doubleF": "\\mathbb{F}",
\ "\\ds": "\\displaystyle",
\ },
\ },
\ 'uml': {},
\ 'maid': {},
\ 'disable_sync_scroll': 0,
\ 'sync_scroll_type': 'middle',
\ 'hide_yaml_meta': 1,
\ 'sequence_diagrams': {},
\ 'flowchart_diagrams': {},
\ 'content_editable': v:false,
\ 'disable_filename': 0,
\ 'toc': {},
\ }
let g:mkdp_markdown_css = '' " default ''
let g:mkdp_highlight_css = '' " default ''
let g:mkdp_port = '' " default ''
let g:mkdp_page_title = '「${name}」' " default '「${name}」'
let g:mkdp_filetypes = ['markdown'] " default ['markdown']
let g:mkdp_theme = 'dark' " default follows system preferences
" }}
" vim-table-mode {{
let g:table_mode_corner='|' " make the tables work with markdown
" }} " }}
" Add spell checking to LaTeX documents {{ " Add spell checking to LaTeX documents {{
@ -910,6 +962,9 @@ augroup END
" Add a Markdown specific wordlist " Add a Markdown specific wordlist
au FileType markdown setlocal spellfile+=~/.config/nvim/spell/Markdown.utf-8.add au FileType markdown setlocal spellfile+=~/.config/nvim/spell/Markdown.utf-8.add
" 3zg adds a word to the dictionary " 3zg adds a word to the dictionary
" Disable spelling in math environments
au FileType markdown syntax match quoteblock /\$[^$]\+\$/ contains=@NoSpell
augroup END augroup END
" }} " }}
@ -1075,24 +1130,24 @@ function! RemoveMarkdownHeaderAnchors()
call winrestview(l:winview) " restore cursor position call winrestview(l:winview) " restore cursor position
endfunction endfunction
function! GenerateMarkdownTOC() " function! GenerateMarkdownTOC()
" We need remove the anchors before we run doctoc. Otherwise it would " " We need remove the anchors before we run doctoc. Otherwise it would
" include the anchors in the link, and the anchors would become incorrect " " include the anchors in the link, and the anchors would become incorrect
" Doctoc also doesn't like folds, so disable them beforehand " " Doctoc also doesn't like folds, so disable them beforehand
set nofoldenable " set nofoldenable
call RemoveMarkdownHeaderAnchors() " call RemoveMarkdownHeaderAnchors()
exec ":w" " exec ":w"
silent exec "!doctoc " . bufname() " silent exec "!doctoc " . bufname()
exec ":e" " exec ":e"
call GenerateMarkdownHeaderAnchors() " call GenerateMarkdownHeaderAnchors()
set foldenable " set foldenable
exec ":w" " exec ":w"
endfunction " endfunction
augroup MarkdownKeyBinds " augroup MarkdownKeyBinds
autocmd! " autocmd!
autocmd FileType markdown nmap <Leader>lt :call GenerateMarkdownTOC()<CR> " autocmd FileType markdown nmap <Leader>lt :call GenerateMarkdownTOC()<CR>
augroup END " augroup END
" Use ripgrep for vim grepping " Use ripgrep for vim grepping
if executable("rg") if executable("rg")

0
install_configfiles.sh Executable file → Normal file
View File