obse.vim 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. " Vim filetype plugin file
  2. " Language: Oblivion Language (obl)
  3. " Original Creator: Kat <katisntgood@gmail.com>
  4. " Maintainer: Kat <katisntgood@gmail.com>
  5. " Created: August 08, 2021
  6. " Last Change: 13 November 2022
  7. if exists("b:did_ftplugin")
  8. finish
  9. endif
  10. let s:cpo_save = &cpo
  11. set cpo&vim
  12. let b:undo_ftplugin = "setl com< cms<"
  13. noremap <script> <buffer> <silent> [[ <nop>
  14. noremap <script> <buffer> <silent> ]] <nop>
  15. noremap <script> <buffer> <silent> [] <nop>
  16. noremap <script> <buffer> <silent> ][ <nop>
  17. setlocal commentstring=;%s
  18. setlocal comments=:;
  19. function s:NextSection(type, backwards, visual)
  20. if a:visual
  21. normal! gv
  22. endif
  23. if a:type == 1
  24. let pattern = '\v(\n\n^\S|%^)'
  25. let flags = 'e'
  26. elseif a:type == 2
  27. let pattern = '\v^\S.*'
  28. let flags = ''
  29. endif
  30. if a:backwards
  31. let dir = '?'
  32. else
  33. let dir = '/'
  34. endif
  35. execute 'silent normal! ' . dir . pattern . dir . flags . "\r"
  36. endfunction
  37. noremap <script> <buffer> <silent> ]]
  38. \ :call <SID>NextSection(1, 0, 0)<cr>
  39. noremap <script> <buffer> <silent> [[
  40. \ :call <SID>NextSection(1, 1, 0)<cr>
  41. noremap <script> <buffer> <silent> ][
  42. \ :call <SID>NextSection(2, 0, 0)<cr>
  43. noremap <script> <buffer> <silent> []
  44. \ :call <SID>NextSection(2, 1, 0)<cr>
  45. vnoremap <script> <buffer> <silent> ]]
  46. \ :<c-u>call <SID>NextSection(1, 0, 1)<cr>
  47. vnoremap <script> <buffer> <silent> [[
  48. \ :<c-u>call <SID>NextSection(1, 1, 1)<cr>
  49. vnoremap <script> <buffer> <silent> ][
  50. \ :<c-u>call <SID>NextSection(2, 0, 1)<cr>
  51. vnoremap <script> <buffer> <silent> []
  52. \ :<c-u>call <SID>NextSection(2, 1, 1)<cr>
  53. let &cpo = s:cpo_save
  54. unlet s:cpo_save