PageRenderTime 33ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/plugin/acp.vim

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