From 1373d2d2de15a72c6be5fa3334eeff06dee8093b Mon Sep 17 00:00:00 2001 From: Knyffen Date: Fri, 8 Sep 2023 07:58:24 +0200 Subject: [PATCH] Alternate markdown-preview plugin Improve tables in markdown --- init.vim | 93 +++++++++++++++++++++++++++++++++--------- install_configfiles.sh | 0 2 files changed, 74 insertions(+), 19 deletions(-) mode change 100755 => 100644 install_configfiles.sh diff --git a/init.vim b/init.vim index 9d0afa7..b769640 100644 --- a/init.vim +++ b/init.vim @@ -140,6 +140,12 @@ " Plug 'suan/vim-instant-markdown', {'for': 'markdown'} 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 Plug 'petRUShka/vim-sage' @@ -855,7 +861,7 @@ augroup END "Uncomment to override defaults: let g:instant_markdown_slow = 1 let g:instant_markdown_autostart = 0 - au FileType markdown nnoremap ll :InstantMarkdownPreview + " au FileType markdown nnoremap ll :InstantMarkdownPreview " stop it with :InstantMarkdownStop "let g:instant_markdown_open_to_the_world = 1 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_port = 8888 let g:instant_markdown_autoscroll = 1 - "let g:instant_markdown_python = 1 + " let g:instant_markdown_python = 1 +" }} + +" markdown-preview {{ + au FileType markdown nnoremap ll :MarkdownPreview + " 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 {{ @@ -910,6 +962,9 @@ augroup END " Add a Markdown specific wordlist au FileType markdown setlocal spellfile+=~/.config/nvim/spell/Markdown.utf-8.add " 3zg adds a word to the dictionary + + " Disable spelling in math environments + au FileType markdown syntax match quoteblock /\$[^$]\+\$/ contains=@NoSpell augroup END " }} @@ -1075,24 +1130,24 @@ function! RemoveMarkdownHeaderAnchors() call winrestview(l:winview) " restore cursor position endfunction -function! GenerateMarkdownTOC() - " We need remove the anchors before we run doctoc. Otherwise it would - " include the anchors in the link, and the anchors would become incorrect - " Doctoc also doesn't like folds, so disable them beforehand - set nofoldenable - call RemoveMarkdownHeaderAnchors() - exec ":w" - silent exec "!doctoc " . bufname() - exec ":e" - call GenerateMarkdownHeaderAnchors() - set foldenable - exec ":w" -endfunction +" function! GenerateMarkdownTOC() +" " We need remove the anchors before we run doctoc. Otherwise it would +" " include the anchors in the link, and the anchors would become incorrect +" " Doctoc also doesn't like folds, so disable them beforehand +" set nofoldenable +" call RemoveMarkdownHeaderAnchors() +" exec ":w" +" silent exec "!doctoc " . bufname() +" exec ":e" +" call GenerateMarkdownHeaderAnchors() +" set foldenable +" exec ":w" +" endfunction -augroup MarkdownKeyBinds - autocmd! - autocmd FileType markdown nmap lt :call GenerateMarkdownTOC() -augroup END +" augroup MarkdownKeyBinds +" autocmd! +" autocmd FileType markdown nmap lt :call GenerateMarkdownTOC() +" augroup END " Use ripgrep for vim grepping if executable("rg") diff --git a/install_configfiles.sh b/install_configfiles.sh old mode 100755 new mode 100644