PageRenderTime 45ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/plugin/acp.vim

https://github.com/Alan0521/vimfiles
Vim Script | 164 lines | 123 code | 6 blank | 35 comment | 7 complexity | cf913714ef4c3d1df3f2f841170c8a5f MD5 | raw file
  1. "=============================================================================
  2. " Copyright (c) 2007-2009 Takeshi NISHIDA
  3. "
  4. " GetLatestVimScripts: 1879 1 :AutoInstall: AutoComplPop
  5. "=============================================================================
  6. " LOAD GUARD {{{1
  7. try
  8. if !l9#guardScriptLoading(expand('<sfile>:p'), 702, 101, [])
  9. finish
  10. endif
  11. catch /E117/
  12. echoerr '***** L9 library must be installed! *****'
  13. finish
  14. endtry
  15. " }}}1
  16. "=============================================================================
  17. " FUNCTION: {{{1
  18. "
  19. function s:makeDefaultBehavior()
  20. let behavs = {
  21. \ '*' : [],
  22. \ 'ruby' : [],
  23. \ 'python' : [],
  24. \ 'perl' : [],
  25. \ 'xml' : [],
  26. \ 'html' : [],
  27. \ 'xhtml' : [],
  28. \ 'css' : [],
  29. \ }
  30. "---------------------------------------------------------------------------
  31. if !empty(g:acp_behaviorUserDefinedFunction) &&
  32. \ !empty(g:acp_behaviorUserDefinedMeets)
  33. for key in keys(behavs)
  34. call add(behavs[key], {
  35. \ 'command' : "\<C-x>\<C-u>",
  36. \ 'completefunc' : g:acp_behaviorUserDefinedFunction,
  37. \ 'meets' : g:acp_behaviorUserDefinedMeets,
  38. \ 'repeat' : 0,
  39. \ })
  40. endfor
  41. endif
  42. "---------------------------------------------------------------------------
  43. for key in keys(behavs)
  44. call add(behavs[key], {
  45. \ 'command' : "\<C-x>\<C-u>",
  46. \ 'completefunc' : 'acp#completeSnipmate',
  47. \ 'meets' : 'acp#meetsForSnipmate',
  48. \ 'onPopupClose' : 'acp#onPopupCloseSnipmate',
  49. \ 'repeat' : 0,
  50. \ })
  51. endfor
  52. "---------------------------------------------------------------------------
  53. for key in keys(behavs)
  54. call add(behavs[key], {
  55. \ 'command' : g:acp_behaviorKeywordCommand,
  56. \ 'meets' : 'acp#meetsForKeyword',
  57. \ 'repeat' : 0,
  58. \ })
  59. endfor
  60. "---------------------------------------------------------------------------
  61. for key in keys(behavs)
  62. call add(behavs[key], {
  63. \ 'command' : "\<C-x>\<C-f>",
  64. \ 'meets' : 'acp#meetsForFile',
  65. \ 'repeat' : 1,
  66. \ })
  67. endfor
  68. "---------------------------------------------------------------------------
  69. call add(behavs.ruby, {
  70. \ 'command' : "\<C-x>\<C-o>",
  71. \ 'meets' : 'acp#meetsForRubyOmni',
  72. \ 'repeat' : 0,
  73. \ })
  74. "---------------------------------------------------------------------------
  75. call add(behavs.python, {
  76. \ 'command' : "\<C-x>\<C-o>",
  77. \ 'meets' : 'acp#meetsForPythonOmni',
  78. \ 'repeat' : 0,
  79. \ })
  80. "---------------------------------------------------------------------------
  81. call add(behavs.perl, {
  82. \ 'command' : "\<C-x>\<C-o>",
  83. \ 'meets' : 'acp#meetsForPerlOmni',
  84. \ 'repeat' : 0,
  85. \ })
  86. "---------------------------------------------------------------------------
  87. call add(behavs.xml, {
  88. \ 'command' : "\<C-x>\<C-o>",
  89. \ 'meets' : 'acp#meetsForXmlOmni',
  90. \ 'repeat' : 1,
  91. \ })
  92. "---------------------------------------------------------------------------
  93. call add(behavs.html, {
  94. \ 'command' : "\<C-x>\<C-o>",
  95. \ 'meets' : 'acp#meetsForHtmlOmni',
  96. \ 'repeat' : 1,
  97. \ })
  98. "---------------------------------------------------------------------------
  99. call add(behavs.xhtml, {
  100. \ 'command' : "\<C-x>\<C-o>",
  101. \ 'meets' : 'acp#meetsForHtmlOmni',
  102. \ 'repeat' : 1,
  103. \ })
  104. "---------------------------------------------------------------------------
  105. call add(behavs.css, {
  106. \ 'command' : "\<C-x>\<C-o>",
  107. \ 'meets' : 'acp#meetsForCssOmni',
  108. \ 'repeat' : 0,
  109. \ })
  110. "---------------------------------------------------------------------------
  111. return behavs
  112. endfunction
  113. " }}}1
  114. "=============================================================================
  115. " INITIALIZATION {{{1
  116. "-----------------------------------------------------------------------------
  117. call l9#defineVariableDefault('g:acp_enableAtStartup', 1)
  118. call l9#defineVariableDefault('g:acp_mappingDriven', 0)
  119. call l9#defineVariableDefault('g:acp_ignorecaseOption', 1)
  120. call l9#defineVariableDefault('g:acp_completeOption', '.,w,b,k')
  121. call l9#defineVariableDefault('g:acp_completeoptPreview', 0)
  122. call l9#defineVariableDefault('g:acp_behaviorUserDefinedFunction', '')
  123. call l9#defineVariableDefault('g:acp_behaviorUserDefinedMeets', '')
  124. call l9#defineVariableDefault('g:acp_behaviorSnipmateLength', -1)
  125. call l9#defineVariableDefault('g:acp_behaviorKeywordCommand', "\<C-n>")
  126. call l9#defineVariableDefault('g:acp_behaviorKeywordLength', 2)
  127. call l9#defineVariableDefault('g:acp_behaviorKeywordIgnores', [])
  128. call l9#defineVariableDefault('g:acp_behaviorFileLength', 0)
  129. call l9#defineVariableDefault('g:acp_behaviorRubyOmniMethodLength', 0)
  130. call l9#defineVariableDefault('g:acp_behaviorRubyOmniSymbolLength', 1)
  131. call l9#defineVariableDefault('g:acp_behaviorPythonOmniLength', 0)
  132. call l9#defineVariableDefault('g:acp_behaviorPerlOmniLength', -1)
  133. call l9#defineVariableDefault('g:acp_behaviorXmlOmniLength', 0)
  134. call l9#defineVariableDefault('g:acp_behaviorHtmlOmniLength', 0)
  135. call l9#defineVariableDefault('g:acp_behaviorCssOmniPropertyLength', 1)
  136. call l9#defineVariableDefault('g:acp_behaviorCssOmniValueLength', 0)
  137. call l9#defineVariableDefault('g:acp_behavior', {})
  138. "-----------------------------------------------------------------------------
  139. call extend(g:acp_behavior, s:makeDefaultBehavior(), 'keep')
  140. "-----------------------------------------------------------------------------
  141. command! -bar -narg=0 AcpEnable call acp#enable()
  142. command! -bar -narg=0 AcpDisable call acp#disable()
  143. command! -bar -narg=0 AcpLock call acp#lock()
  144. command! -bar -narg=0 AcpUnlock call acp#unlock()
  145. "-----------------------------------------------------------------------------
  146. " legacy commands
  147. command! -bar -narg=0 AutoComplPopEnable AcpEnable
  148. command! -bar -narg=0 AutoComplPopDisable AcpDisable
  149. command! -bar -narg=0 AutoComplPopLock AcpLock
  150. command! -bar -narg=0 AutoComplPopUnlock AcpUnlock
  151. "-----------------------------------------------------------------------------
  152. if g:acp_enableAtStartup
  153. AcpEnable
  154. endif
  155. "-----------------------------------------------------------------------------
  156. " }}}1
  157. "=============================================================================
  158. " vim: set fdm=marker: