mermaid.vim 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. " Vim filetype plugin
  2. " Language: Mermaid
  3. " Maintainer: Craig MacEachern <https://github.com/craigmac/vim-mermaid>
  4. " Last Change: 2022 Oct 13
  5. if exists("b:did_ftplugin")
  6. finish
  7. endif
  8. let s:keepcpo= &cpo
  9. set cpo&vim
  10. " Use mermaid live editor's style
  11. setlocal expandtab
  12. setlocal shiftwidth=2
  13. setlocal softtabstop=-1
  14. setlocal tabstop=4
  15. " TODO: comments, formatlist stuff, based on what?
  16. setlocal comments=b:#,fb:-
  17. setlocal commentstring=#\ %s
  18. setlocal formatoptions+=tcqln formatoptions-=r formatoptions-=o
  19. setlocal formatlistpat=^\\s*\\d\\+\\.\\s\\+\\\|^\\s*[-*+]\\s\\+\\\|^\\[^\\ze[^\\]]\\+\\]:\\&^.\\{4\\}
  20. if exists('b:undo_ftplugin')
  21. let b:undo_ftplugin .= "|setl cms< com< fo< flp< et< ts< sts< sw<"
  22. else
  23. let b:undo_ftplugin = "setl cms< com< fo< flp< et< ts< sts< sw<"
  24. endif
  25. if !exists("g:no_plugin_maps") && !exists("g:no_markdown_maps")
  26. nnoremap <silent><buffer> [[ :<C-U>call search('\%(^#\{1,5\}\s\+\S\\|^\S.*\n^[=-]\+$\)', "bsW")<CR>
  27. nnoremap <silent><buffer> ]] :<C-U>call search('\%(^#\{1,5\}\s\+\S\\|^\S.*\n^[=-]\+$\)', "sW")<CR>
  28. xnoremap <silent><buffer> [[ :<C-U>exe "normal! gv"<Bar>call search('\%(^#\{1,5\}\s\+\S\\|^\S.*\n^[=-]\+$\)', "bsW")<CR>
  29. xnoremap <silent><buffer> ]] :<C-U>exe "normal! gv"<Bar>call search('\%(^#\{1,5\}\s\+\S\\|^\S.*\n^[=-]\+$\)', "sW")<CR>
  30. let b:undo_ftplugin .= '|sil! nunmap <buffer> [[|sil! nunmap <buffer> ]]|sil! xunmap <buffer> [[|sil! xunmap <buffer> ]]'
  31. endif
  32. " if has("folding") && get(g:, "markdown_folding", 0)
  33. " setlocal foldexpr=MarkdownFold()
  34. " setlocal foldmethod=expr
  35. " setlocal foldtext=MarkdownFoldText()
  36. " let b:undo_ftplugin .= "|setl foldexpr< foldmethod< foldtext<"
  37. " endif
  38. let &cpo = s:keepcpo
  39. unlet s:keepcpo
  40. " vim:set sw=2: