youcompleteme.vim 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. " Copyright (C) 2011, 2012 Strahinja Val Markovic <val@markovic.io>
  2. "
  3. " This file is part of YouCompleteMe.
  4. "
  5. " YouCompleteMe is free software: you can redistribute it and/or modify
  6. " it under the terms of the GNU General Public License as published by
  7. " the Free Software Foundation, either version 3 of the License, or
  8. " (at your option) any later version.
  9. "
  10. " YouCompleteMe is distributed in the hope that it will be useful,
  11. " but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. " MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. " GNU General Public License for more details.
  14. "
  15. " You should have received a copy of the GNU General Public License
  16. " along with YouCompleteMe. If not, see <http://www.gnu.org/licenses/>.
  17. " This is basic vim plugin boilerplate
  18. let s:save_cpo = &cpo
  19. set cpo&vim
  20. if exists( "g:loaded_youcompleteme" )
  21. finish
  22. elseif v:version < 703 || !has( 'patch584' )
  23. echohl WarningMsg |
  24. \ echomsg "YouCompleteMe unavailable: requires Vim 7.3.584+" |
  25. \ echohl None
  26. finish
  27. elseif !has( 'python' )
  28. echohl WarningMsg |
  29. \ echomsg "YouCompleteMe unavailable: requires python 2.x" |
  30. \ echohl None
  31. finish
  32. endif
  33. let s:script_folder_path = escape( expand( '<sfile>:p:h' ), '\' )
  34. function! s:HasYcmCore()
  35. let path_prefix = s:script_folder_path . '/../python/'
  36. if filereadable(path_prefix . 'ycm_core.so')
  37. return 1
  38. elseif filereadable(path_prefix . 'ycm_core.pyd')
  39. return 1
  40. endif
  41. return 0
  42. endfunction
  43. let g:ycm_check_if_ycm_core_present =
  44. \ get( g:, 'ycm_check_if_ycm_core_present', 1 )
  45. if g:ycm_check_if_ycm_core_present && !s:HasYcmCore()
  46. echohl WarningMsg |
  47. \ echomsg "ycm_core.[so|pyd] not detected; you need to compile YCM " .
  48. \ "before using it. Read the docs!" |
  49. \ echohl None
  50. finish
  51. endif
  52. let g:loaded_youcompleteme = 1
  53. let g:ycm_min_num_of_chars_for_completion =
  54. \ get( g:, 'ycm_min_num_of_chars_for_completion', 2 )
  55. let g:ycm_filetype_whitelist =
  56. \ get( g:, 'ycm_filetype_whitelist', {
  57. \ '*' : 1,
  58. \ } )
  59. " The fallback to g:ycm_filetypes_to_completely_ignore is here because of
  60. " backwards compatibility with previous versions of YCM.
  61. let g:ycm_filetype_blacklist =
  62. \ get( g:, 'ycm_filetype_blacklist',
  63. \ get( g:, 'ycm_filetypes_to_completely_ignore', {
  64. \ 'notes' : 1,
  65. \ 'markdown' : 1,
  66. \ 'text' : 1,
  67. \ } ) )
  68. let g:ycm_filetype_specific_completion_to_disable =
  69. \ get( g:, 'ycm_filetype_specific_completion_to_disable', {} )
  70. let g:ycm_register_as_syntastic_checker =
  71. \ get( g:, 'ycm_register_as_syntastic_checker', 1 )
  72. let g:ycm_allow_changing_updatetime =
  73. \ get( g:, 'ycm_allow_changing_updatetime', 1 )
  74. let g:ycm_add_preview_to_completeopt =
  75. \ get( g:, 'ycm_add_preview_to_completeopt', 0 )
  76. let g:ycm_complete_in_comments =
  77. \ get( g:, 'ycm_complete_in_comments', 0 )
  78. let g:ycm_complete_in_strings =
  79. \ get( g:, 'ycm_complete_in_strings', 1 )
  80. let g:ycm_collect_identifiers_from_comments_and_strings =
  81. \ get( g:, 'ycm_collect_identifiers_from_comments_and_strings', 0 )
  82. let g:ycm_collect_identifiers_from_tags_files =
  83. \ get( g:, 'ycm_collect_identifiers_from_tags_files', 0 )
  84. let g:ycm_seed_identifiers_with_syntax =
  85. \ get( g:, 'ycm_seed_identifiers_with_syntax', 0 )
  86. let g:ycm_autoclose_preview_window_after_completion =
  87. \ get( g:, 'ycm_autoclose_preview_window_after_completion', 0 )
  88. let g:ycm_autoclose_preview_window_after_insertion =
  89. \ get( g:, 'ycm_autoclose_preview_window_after_insertion', 0 )
  90. let g:ycm_max_diagnostics_to_display =
  91. \ get( g:, 'ycm_max_diagnostics_to_display', 30 )
  92. let g:ycm_key_list_select_completion =
  93. \ get( g:, 'ycm_key_list_select_completion', ['<TAB>', '<Down>'] )
  94. let g:ycm_key_list_previous_completion =
  95. \ get( g:, 'ycm_key_list_previous_completion', ['<S-TAB>', '<Up>'] )
  96. let g:ycm_key_invoke_completion =
  97. \ get( g:, 'ycm_key_invoke_completion', '<C-Space>' )
  98. let g:ycm_key_detailed_diagnostics =
  99. \ get( g:, 'ycm_key_detailed_diagnostics', '<leader>d' )
  100. let g:ycm_global_ycm_extra_conf =
  101. \ get( g:, 'ycm_global_ycm_extra_conf', '' )
  102. let g:ycm_confirm_extra_conf =
  103. \ get( g:, 'ycm_confirm_extra_conf', 1 )
  104. let g:ycm_extra_conf_globlist =
  105. \ get( g:, 'ycm_extra_conf_globlist', [] )
  106. let g:ycm_filepath_completion_use_working_dir =
  107. \ get( g:, 'ycm_filepath_completion_use_working_dir', 0 )
  108. let g:ycm_semantic_triggers =
  109. \ get( g:, 'ycm_semantic_triggers', {
  110. \ 'c' : ['->', '.'],
  111. \ 'objc' : ['->', '.'],
  112. \ 'ocaml' : ['.', '#'],
  113. \ 'cpp,objcpp' : ['->', '.', '::'],
  114. \ 'perl' : ['->'],
  115. \ 'php' : ['->', '::'],
  116. \ 'cs,java,javascript,d,vim,ruby,python,perl6,scala,vb,elixir,go' : ['.'],
  117. \ 'lua' : ['.', ':'],
  118. \ 'erlang' : [':'],
  119. \ } )
  120. let g:ycm_cache_omnifunc =
  121. \ get( g:, 'ycm_cache_omnifunc', 1 )
  122. " On-demand loading. Let's use the autoload folder and not slow down vim's
  123. " startup procedure.
  124. augroup youcompletemeStart
  125. autocmd!
  126. autocmd VimEnter * call youcompleteme#Enable()
  127. augroup END
  128. " This is basic vim plugin boilerplate
  129. let &cpo = s:save_cpo
  130. unlet s:save_cpo