undotree.vim 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. "=================================================
  2. " File: plugin/undotree.vim
  3. " Description: Manage your undo history in a graph.
  4. " Author: Ming Bai <mbbill@gmail.com>
  5. " License: BSD
  6. " Avoid installing twice.
  7. if exists('g:loaded_undotree')
  8. finish
  9. endif
  10. let g:loaded_undotree = 0
  11. " At least version 7.3 with 005 patch is needed for undo branches.
  12. " Refer to https://github.com/mbbill/undotree/issues/4 for details.
  13. " Thanks kien
  14. if v:version < 703
  15. command! -nargs=0 -bar UndotreeToggle :echoerr "undotree.vim needs Vim version >= 7.3"
  16. finish
  17. endif
  18. if (v:version == 703 && !has("patch005"))
  19. command! -nargs=0 -bar UndotreeToggle :echoerr "undotree.vim needs vim7.3 with patch005 applied."
  20. finish
  21. endif
  22. let g:loaded_undotree = 1 " Signal plugin availability with a value of 1.
  23. "=================================================
  24. "Options:
  25. " Window layout
  26. " style 1
  27. " +----------+------------------------+
  28. " | | |
  29. " | | |
  30. " | undotree | |
  31. " | | |
  32. " | | |
  33. " +----------+ |
  34. " | | |
  35. " | diff | |
  36. " | | |
  37. " +----------+------------------------+
  38. " Style 2
  39. " +----------+------------------------+
  40. " | | |
  41. " | | |
  42. " | undotree | |
  43. " | | |
  44. " | | |
  45. " +----------+------------------------+
  46. " | |
  47. " | diff |
  48. " | |
  49. " +-----------------------------------+
  50. " Style 3
  51. " +------------------------+----------+
  52. " | | |
  53. " | | |
  54. " | | undotree |
  55. " | | |
  56. " | | |
  57. " | +----------+
  58. " | | |
  59. " | | diff |
  60. " | | |
  61. " +------------------------+----------+
  62. " Style 4
  63. " +-----------------------++----------+
  64. " | | |
  65. " | | |
  66. " | | undotree |
  67. " | | |
  68. " | | |
  69. " +------------------------+----------+
  70. " | |
  71. " | diff |
  72. " | |
  73. " +-----------------------------------+
  74. if !exists('g:undotree_WindowLayout')
  75. let g:undotree_WindowLayout = 1
  76. endif
  77. " e.g. using 'd' instead of 'days' to save some space.
  78. if !exists('g:undotree_ShortIndicators')
  79. let g:undotree_ShortIndicators = 0
  80. endif
  81. " undotree window width
  82. if !exists('g:undotree_SplitWidth')
  83. if g:undotree_ShortIndicators == 1
  84. let g:undotree_SplitWidth = 24
  85. else
  86. let g:undotree_SplitWidth = 30
  87. endif
  88. endif
  89. " diff window height
  90. if !exists('g:undotree_DiffpanelHeight')
  91. let g:undotree_DiffpanelHeight = 10
  92. endif
  93. " auto open diff window
  94. if !exists('g:undotree_DiffAutoOpen')
  95. let g:undotree_DiffAutoOpen = 1
  96. endif
  97. " if set, let undotree window get focus after being opened, otherwise
  98. " focus will stay in current window.
  99. if !exists('g:undotree_SetFocusWhenToggle')
  100. let g:undotree_SetFocusWhenToggle = 0
  101. endif
  102. " tree node shape.
  103. if !exists('g:undotree_TreeNodeShape')
  104. let g:undotree_TreeNodeShape = '*'
  105. endif
  106. " tree vertical shape.
  107. if !exists('g:undotree_TreeVertShape')
  108. let g:undotree_TreeVertShape = '|'
  109. endif
  110. " tree split shape.
  111. if !exists('g:undotree_TreeSplitShape')
  112. let g:undotree_TreeSplitShape = '/'
  113. endif
  114. " tree return shape.
  115. if !exists('g:undotree_TreeReturnShape')
  116. let g:undotree_TreeReturnShape = '\'
  117. endif
  118. if !exists('g:undotree_DiffCommand')
  119. let g:undotree_DiffCommand = "diff"
  120. endif
  121. " relative timestamp
  122. if !exists('g:undotree_RelativeTimestamp')
  123. let g:undotree_RelativeTimestamp = 1
  124. endif
  125. " Highlight changed text
  126. if !exists('g:undotree_HighlightChangedText')
  127. let g:undotree_HighlightChangedText = 1
  128. endif
  129. " Highlight changed text using signs in the gutter
  130. if !exists('g:undotree_HighlightChangedWithSign')
  131. let g:undotree_HighlightChangedWithSign = 1
  132. endif
  133. " Highlight linked syntax type.
  134. " You may chose your favorite through ":hi" command
  135. if !exists('g:undotree_HighlightSyntaxAdd')
  136. let g:undotree_HighlightSyntaxAdd = "DiffAdd"
  137. endif
  138. if !exists('g:undotree_HighlightSyntaxChange')
  139. let g:undotree_HighlightSyntaxChange = "DiffChange"
  140. endif
  141. if !exists('g:undotree_HighlightSyntaxDel')
  142. let g:undotree_HighlightSyntaxDel = "DiffDelete"
  143. endif
  144. " Deprecates the old style configuration.
  145. if exists('g:undotree_SplitLocation')
  146. echo "g:undotree_SplitLocation is deprecated,
  147. \ please use g:undotree_WindowLayout instead."
  148. endif
  149. " Show help line
  150. if !exists('g:undotree_HelpLine')
  151. let g:undotree_HelpLine = 1
  152. endif
  153. " Show cursorline
  154. if !exists('g:undotree_CursorLine')
  155. let g:undotree_CursorLine = 1
  156. endif
  157. " Define the default persistence undo directory if not defined in vim/nvim
  158. " startup script.
  159. if !exists('g:undotree_UndoDir')
  160. let s:undoDir = &undodir
  161. let s:subdir = has('nvim') ? 'nvim' : 'vim'
  162. if s:undoDir == "."
  163. let s:undoDir = $HOME . '/.local/state/' . s:subdir . '/undo/'
  164. endif
  165. let g:undotree_UndoDir = s:undoDir
  166. endif
  167. augroup undotreeDetectPersistenceUndo
  168. au!
  169. au BufReadPost * call undotree#UndotreePersistUndo(0)
  170. augroup END
  171. "=================================================
  172. " User commands.
  173. command! -nargs=0 -bar UndotreeToggle :call undotree#UndotreeToggle()
  174. command! -nargs=0 -bar UndotreeHide :call undotree#UndotreeHide()
  175. command! -nargs=0 -bar UndotreeShow :call undotree#UndotreeShow()
  176. command! -nargs=0 -bar UndotreeFocus :call undotree#UndotreeFocus()
  177. command! -nargs=0 -bar UndotreePersistUndo :call undotree#UndotreePersistUndo(1)
  178. " vim: set et fdm=marker sts=4 sw=4: