keyboard.vim 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. " vim: set fdm=marker et ts=4 sw=4 sts=4:
  2. " Init: {{{1
  3. function! pandoc#keyboard#Init() abort
  4. " set up defaults {{{2
  5. " Enabled submodules {{{3
  6. if !exists('g:pandoc#keyboard#enabled_submodules')
  7. let g:pandoc#keyboard#enabled_submodules = ['lists', 'sections', 'styles', 'references', 'links', 'para', 'checkboxes']
  8. endif
  9. " Use display motions when using soft wrapping {{{3
  10. if !exists('g:pandoc#keyboard#display_motions')
  11. let g:pandoc#keyboard#display_motions = 1
  12. endif
  13. " Allow movement around line boundaries {{{3
  14. if !exists('g:pandoc#keyboard#wrap_cursor')
  15. let g:pandoc#keyboard#wrap_cursor = 0
  16. endif
  17. " Use default mappings? {{{3
  18. if !exists('g:pandoc#keyboard#use_default_mappings')
  19. let g:pandoc#keyboard#use_default_mappings = 1
  20. endif
  21. if !exists('g:pandoc#keyboard#blacklist_submodule_mappings')
  22. let g:pandoc#keyboard#blacklist_submodule_mappings = []
  23. endif
  24. " Display_Motion: {{{2
  25. if g:pandoc#keyboard#display_motions == 1
  26. " these are not useful when using the hard wraps mode.
  27. if exists('g:pandoc#formatting#mode') && stridx(g:pandoc#formatting#mode, 's') > -1
  28. " Remappings that make j and k behave properly with soft wrapping.
  29. nnoremap <buffer> j gj
  30. nnoremap <buffer> k gk
  31. vnoremap <buffer> j gj
  32. vnoremap <buffer> k gk
  33. endif
  34. endif "}}}2
  35. " Onemore: {{{2
  36. if g:pandoc#keyboard#wrap_cursor == 1
  37. set whichwrap+=<,>,b,s,h,l,[,]
  38. augroup pandoc_wrap_cursor
  39. au BufEnter <buffer> set virtualedit+=onemore
  40. au BufLeave <buffer> set virtualedit-=onemore
  41. augroup END
  42. endif "}}}2
  43. "
  44. " Submodules: {{{2
  45. for module in g:pandoc#keyboard#enabled_submodules
  46. exe 'call pandoc#keyboard#'.module.'#Init()'
  47. endfor
  48. "}}}2
  49. endfunction
  50. "}}}1
  51. " Functions: {{{1
  52. function! pandoc#keyboard#MovetoLine(line) abort
  53. if a:line > 0
  54. call cursor(a:line, 1)
  55. endif
  56. normal! ^
  57. endfunction
  58. " }}}1