youcompleteme.vim 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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 || (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. elseif filereadable(path_prefix . 'ycm_core.dll')
  41. return 1
  42. endif
  43. return 0
  44. endfunction
  45. let g:ycm_check_if_ycm_core_present =
  46. \ get( g:, 'ycm_check_if_ycm_core_present', 1 )
  47. if g:ycm_check_if_ycm_core_present && !s:HasYcmCore()
  48. echohl WarningMsg |
  49. \ echomsg "ycm_core.[so|pyd|dll] not detected; you need to compile " .
  50. \ "YCM before using it. Read the docs!" |
  51. \ echohl None
  52. finish
  53. endif
  54. let g:loaded_youcompleteme = 1
  55. let g:ycm_min_num_of_chars_for_completion =
  56. \ get( g:, 'ycm_min_num_of_chars_for_completion', 2 )
  57. let g:ycm_min_num_identifier_candidate_chars =
  58. \ get( g:, 'ycm_min_num_identifier_candidate_chars', 0 )
  59. let g:ycm_filetype_whitelist =
  60. \ get( g:, 'ycm_filetype_whitelist', {
  61. \ '*' : 1,
  62. \ } )
  63. " The fallback to g:ycm_filetypes_to_completely_ignore is here because of
  64. " backwards compatibility with previous versions of YCM.
  65. let g:ycm_filetype_blacklist =
  66. \ get( g:, 'ycm_filetype_blacklist',
  67. \ get( g:, 'ycm_filetypes_to_completely_ignore', {
  68. \ 'notes' : 1,
  69. \ 'markdown' : 1,
  70. \ 'text' : 1,
  71. \ 'unite' : 1,
  72. \ 'tagbar' : 1,
  73. \ } ) )
  74. let g:ycm_filetype_specific_completion_to_disable =
  75. \ get( g:, 'ycm_filetype_specific_completion_to_disable', {} )
  76. let g:ycm_register_as_syntastic_checker =
  77. \ get( g:, 'ycm_register_as_syntastic_checker', 1 )
  78. let g:ycm_allow_changing_updatetime =
  79. \ get( g:, 'ycm_allow_changing_updatetime', 1 )
  80. let g:ycm_add_preview_to_completeopt =
  81. \ get( g:, 'ycm_add_preview_to_completeopt', 0 )
  82. let g:ycm_complete_in_comments =
  83. \ get( g:, 'ycm_complete_in_comments', 0 )
  84. let g:ycm_complete_in_strings =
  85. \ get( g:, 'ycm_complete_in_strings', 1 )
  86. let g:ycm_collect_identifiers_from_comments_and_strings =
  87. \ get( g:, 'ycm_collect_identifiers_from_comments_and_strings', 0 )
  88. let g:ycm_collect_identifiers_from_tags_files =
  89. \ get( g:, 'ycm_collect_identifiers_from_tags_files', 0 )
  90. let g:ycm_seed_identifiers_with_syntax =
  91. \ get( g:, 'ycm_seed_identifiers_with_syntax', 0 )
  92. let g:ycm_autoclose_preview_window_after_completion =
  93. \ get( g:, 'ycm_autoclose_preview_window_after_completion', 0 )
  94. let g:ycm_autoclose_preview_window_after_insertion =
  95. \ get( g:, 'ycm_autoclose_preview_window_after_insertion', 0 )
  96. let g:ycm_max_diagnostics_to_display =
  97. \ get( g:, 'ycm_max_diagnostics_to_display', 30 )
  98. let g:ycm_key_list_select_completion =
  99. \ get( g:, 'ycm_key_list_select_completion', ['<TAB>', '<Down>'] )
  100. let g:ycm_key_list_previous_completion =
  101. \ get( g:, 'ycm_key_list_previous_completion', ['<S-TAB>', '<Up>'] )
  102. let g:ycm_key_invoke_completion =
  103. \ get( g:, 'ycm_key_invoke_completion', '<C-Space>' )
  104. let g:ycm_key_detailed_diagnostics =
  105. \ get( g:, 'ycm_key_detailed_diagnostics', '<leader>d' )
  106. let g:ycm_global_ycm_extra_conf =
  107. \ get( g:, 'ycm_global_ycm_extra_conf', '' )
  108. let g:ycm_confirm_extra_conf =
  109. \ get( g:, 'ycm_confirm_extra_conf', 1 )
  110. let g:ycm_extra_conf_globlist =
  111. \ get( g:, 'ycm_extra_conf_globlist', [] )
  112. let g:ycm_filepath_completion_use_working_dir =
  113. \ get( g:, 'ycm_filepath_completion_use_working_dir', 0 )
  114. " Default semantic triggers are in python/ycm/completers/completer_utils.py
  115. " these just append new triggers to the default dict.
  116. let g:ycm_semantic_triggers =
  117. \ get( g:, 'ycm_semantic_triggers', {} )
  118. let g:ycm_cache_omnifunc =
  119. \ get( g:, 'ycm_cache_omnifunc', 1 )
  120. let g:ycm_auto_start_csharp_server =
  121. \ get( g:, 'ycm_auto_start_csharp_server', 1 )
  122. let g:ycm_auto_stop_csharp_server =
  123. \ get( g:, 'ycm_auto_stop_csharp_server', 1 )
  124. let g:ycm_csharp_server_port =
  125. \ get( g:, 'ycm_csharp_server_port', 2000 )
  126. let g:ycm_server_use_vim_stdout =
  127. \ get( g:, 'ycm_server_use_vim_stdout', 0 )
  128. let g:ycm_server_log_level =
  129. \ get( g:, 'ycm_server_log_level', 'info' )
  130. " On-demand loading. Let's use the autoload folder and not slow down vim's
  131. " startup procedure.
  132. augroup youcompletemeStart
  133. autocmd!
  134. autocmd VimEnter * call youcompleteme#Enable()
  135. augroup END
  136. " This is basic vim plugin boilerplate
  137. let &cpo = s:save_cpo
  138. unlet s:save_cpo