My dotfiles. Period.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. "=============================================================================
  2. " $Id: common.vim 520 2012-03-19 18:09:15Z luc.hermitte $
  3. " File: autoload/lh/common.vim {{{1
  4. " Author: Luc Hermitte <EMAIL:hermitte {at} free {dot} fr>
  5. " <URL:http://code.google.com/p/lh-vim/>
  6. " License: GPLv3 with exceptions
  7. " <URL:http://code.google.com/p/lh-vim/wiki/License>
  8. " Version: 3.0.0
  9. " Created: 07th Oct 2006
  10. " Last Update: $Date: 2012-03-19 19:09:15 +0100 (Mon, 19 Mar 2012) $ (08th Feb 2008)
  11. "------------------------------------------------------------------------
  12. " Description:
  13. " Some common functions for:
  14. " - displaying error messages
  15. " - checking dependencies
  16. "
  17. "------------------------------------------------------------------------
  18. " Installation:
  19. " Drop it into {rtp}/autoload/lh/
  20. " Vim 7+ required.
  21. " History:
  22. " v3.0.0
  23. " - GPLv3
  24. " v2.1.1
  25. " - New function: lh#common#echomsg_multilines()
  26. " - lh#common#warning_msg() supports multilines messages
  27. "
  28. " v2.0.0:
  29. " - Code moved from other plugins
  30. " }}}1
  31. "=============================================================================
  32. "=============================================================================
  33. let s:cpo_save=&cpo
  34. set cpo&vim
  35. "------------------------------------------------------------------------
  36. " Functions {{{1
  37. " Function: lh#common#echomsg_multilines {{{2
  38. function! lh#common#echomsg_multilines(text)
  39. let lines = split(a:text, "[\n\r]")
  40. for line in lines
  41. echomsg line
  42. endfor
  43. endfunction
  44. function! lh#common#echomsgMultilines(text)
  45. return lh#common#echomsg_multilines(a:text)
  46. endfunction
  47. " Function: lh#common#error_msg {{{2
  48. function! lh#common#error_msg(text)
  49. if has('gui_running')
  50. call confirm(a:text, '&Ok', '1', 'Error')
  51. else
  52. " echohl ErrorMsg
  53. echoerr a:text
  54. " echohl None
  55. endif
  56. endfunction
  57. function! lh#common#ErrorMsg(text)
  58. return lh#common#error_msg(a:text)
  59. endfunction
  60. " Function: lh#common#warning_msg {{{2
  61. function! lh#common#warning_msg(text)
  62. echohl WarningMsg
  63. " echomsg a:text
  64. call lh#common#echomsg_multilines(a:text)
  65. echohl None
  66. endfunction
  67. function! lh#common#WarningMsg(text)
  68. return lh#common#warning_msg(a:text)
  69. endfunction
  70. " Dependencies {{{2
  71. function! lh#common#check_deps(Symbol, File, path, plugin) " {{{3
  72. if !exists(a:Symbol)
  73. exe "runtime ".a:path.a:File
  74. if !exists(a:Symbol)
  75. call lh#common#error_msg( a:plugin.': Requires <'.a:File.'>')
  76. return 0
  77. endif
  78. endif
  79. return 1
  80. endfunction
  81. function! lh#common#CheckDeps(Symbol, File, path, plugin) " {{{3
  82. echomsg "lh#common#CheckDeps() is deprecated, use lh#common#check_deps() instead."
  83. return lh#common#check_deps(a:Symbol, a:File, a:path, a:plugin)
  84. endfunction
  85. " Functions }}}1
  86. "------------------------------------------------------------------------
  87. let &cpo=s:cpo_save
  88. "=============================================================================
  89. " vim600: set fdm=marker: