1
0

youcompleteme.vim 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. " Copyright (C) 2011, 2012 Google Inc.
  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. function! s:restore_cpo()
  21. let &cpo = s:save_cpo
  22. unlet s:save_cpo
  23. endfunction
  24. if exists( "g:loaded_youcompleteme" )
  25. call s:restore_cpo()
  26. finish
  27. elseif v:version < 704 || (v:version == 704 && !has( 'patch1578' ))
  28. echohl WarningMsg |
  29. \ echomsg "YouCompleteMe unavailable: requires Vim 7.4.1578+" |
  30. \ echohl None
  31. call s:restore_cpo()
  32. finish
  33. elseif !has( 'timers' )
  34. echohl WarningMsg |
  35. \ echomsg "YouCompleteMe unavailable: requires Vim compiled with " .
  36. \ "the timers feature" |
  37. \ echohl None
  38. call s:restore_cpo()
  39. finish
  40. elseif !has( 'python' ) && !has( 'python3' )
  41. echohl WarningMsg |
  42. \ echomsg "YouCompleteMe unavailable: requires Vim compiled with " .
  43. \ "Python (2.6+ or 3.3+) support" |
  44. \ echohl None
  45. call s:restore_cpo()
  46. finish
  47. endif
  48. let g:loaded_youcompleteme = 1
  49. " NOTE: Most defaults are in third_party/ycmd/ycmd/default_settings.json. They
  50. " are loaded into Vim globals with the 'ycm_' prefix if such a key does not
  51. " already exist; thus, the user can override the defaults.
  52. " The only defaults that are here are the ones that are only relevant to the YCM
  53. " Vim client and not the ycmd server.
  54. let g:ycm_allow_changing_updatetime =
  55. \ get( g:, 'ycm_allow_changing_updatetime', 1 )
  56. let g:ycm_open_loclist_on_ycm_diags =
  57. \ get( g:, 'ycm_open_loclist_on_ycm_diags', 1 )
  58. let g:ycm_add_preview_to_completeopt =
  59. \ get( g:, 'ycm_add_preview_to_completeopt', 0 )
  60. let g:ycm_autoclose_preview_window_after_completion =
  61. \ get( g:, 'ycm_autoclose_preview_window_after_completion', 0 )
  62. let g:ycm_autoclose_preview_window_after_insertion =
  63. \ get( g:, 'ycm_autoclose_preview_window_after_insertion', 0 )
  64. let g:ycm_key_list_select_completion =
  65. \ get( g:, 'ycm_key_list_select_completion', ['<TAB>', '<Down>'] )
  66. let g:ycm_key_list_previous_completion =
  67. \ get( g:, 'ycm_key_list_previous_completion', ['<S-TAB>', '<Up>'] )
  68. let g:ycm_key_invoke_completion =
  69. \ get( g:, 'ycm_key_invoke_completion', '<C-Space>' )
  70. let g:ycm_key_detailed_diagnostics =
  71. \ get( g:, 'ycm_key_detailed_diagnostics', '<leader>d' )
  72. let g:ycm_cache_omnifunc =
  73. \ get( g:, 'ycm_cache_omnifunc', 1 )
  74. let g:ycm_log_level =
  75. \ get( g:, 'ycm_log_level',
  76. \ get( g:, 'ycm_server_log_level', 'info' ) )
  77. let g:ycm_keep_logfiles =
  78. \ get( g:, 'ycm_keep_logfiles',
  79. \ get( g:, 'ycm_server_keep_logfiles', 0 ) )
  80. let g:ycm_extra_conf_vim_data =
  81. \ get( g:, 'ycm_extra_conf_vim_data', [] )
  82. let g:ycm_server_python_interpreter =
  83. \ get( g:, 'ycm_server_python_interpreter',
  84. \ get( g:, 'ycm_path_to_python_interpreter', '' ) )
  85. let g:ycm_show_diagnostics_ui =
  86. \ get( g:, 'ycm_show_diagnostics_ui', 1 )
  87. let g:ycm_enable_diagnostic_signs =
  88. \ get( g:, 'ycm_enable_diagnostic_signs',
  89. \ get( g:, 'syntastic_enable_signs', 1 ) )
  90. let g:ycm_enable_diagnostic_highlighting =
  91. \ get( g:, 'ycm_enable_diagnostic_highlighting',
  92. \ get( g:, 'syntastic_enable_highlighting', 1 ) )
  93. let g:ycm_echo_current_diagnostic =
  94. \ get( g:, 'ycm_echo_current_diagnostic',
  95. \ get( g:, 'syntastic_echo_current_error', 1 ) )
  96. let g:ycm_always_populate_location_list =
  97. \ get( g:, 'ycm_always_populate_location_list',
  98. \ get( g:, 'syntastic_always_populate_loc_list', 0 ) )
  99. let g:ycm_error_symbol =
  100. \ get( g:, 'ycm_error_symbol',
  101. \ get( g:, 'syntastic_error_symbol', '>>' ) )
  102. let g:ycm_warning_symbol =
  103. \ get( g:, 'ycm_warning_symbol',
  104. \ get( g:, 'syntastic_warning_symbol', '>>' ) )
  105. let g:ycm_goto_buffer_command =
  106. \ get( g:, 'ycm_goto_buffer_command', 'same-buffer' )
  107. let g:ycm_disable_for_files_larger_than_kb =
  108. \ get( g:, 'ycm_disable_for_files_larger_than_kb', 1000 )
  109. if has( 'vim_starting' ) " Loading at startup.
  110. " We defer loading until after VimEnter to allow the gui to fork (see
  111. " `:h gui-fork`) and avoid a deadlock situation, as explained here:
  112. " https://github.com/Valloric/YouCompleteMe/pull/2473#issuecomment-267716136
  113. augroup youcompletemeStart
  114. autocmd!
  115. autocmd VimEnter * call youcompleteme#Enable()
  116. augroup END
  117. else " Manual loading with :packadd.
  118. call youcompleteme#Enable()
  119. endif
  120. " This is basic vim plugin boilerplate
  121. call s:restore_cpo()