youcompleteme.vim 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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 < 703 || (v:version == 703 && !has('patch598'))
  28. echohl WarningMsg |
  29. \ echomsg "YouCompleteMe unavailable: requires Vim 7.3.598+" |
  30. \ echohl None
  31. call s:restore_cpo()
  32. finish
  33. elseif !has( 'python' ) && !has( 'python3' )
  34. echohl WarningMsg |
  35. \ echomsg "YouCompleteMe unavailable: requires Vim compiled with " .
  36. \ "Python (2.6+ or 3.3+) support" |
  37. \ echohl None
  38. call s:restore_cpo()
  39. finish
  40. endif
  41. let g:loaded_youcompleteme = 1
  42. " NOTE: Most defaults are in third_party/ycmd/ycmd/default_settings.json. They
  43. " are loaded into Vim globals with the 'ycm_' prefix if such a key does not
  44. " already exist; thus, the user can override the defaults.
  45. " The only defaults that are here are the ones that are only relevant to the YCM
  46. " Vim client and not the ycmd server.
  47. let g:ycm_allow_changing_updatetime =
  48. \ get( g:, 'ycm_allow_changing_updatetime', 1 )
  49. let g:ycm_open_loclist_on_ycm_diags =
  50. \ get( g:, 'ycm_open_loclist_on_ycm_diags', 1 )
  51. let g:ycm_add_preview_to_completeopt =
  52. \ get( g:, 'ycm_add_preview_to_completeopt', 0 )
  53. let g:ycm_autoclose_preview_window_after_completion =
  54. \ get( g:, 'ycm_autoclose_preview_window_after_completion', 0 )
  55. let g:ycm_autoclose_preview_window_after_insertion =
  56. \ get( g:, 'ycm_autoclose_preview_window_after_insertion', 0 )
  57. let g:ycm_key_list_select_completion =
  58. \ get( g:, 'ycm_key_list_select_completion', ['<TAB>', '<Down>'] )
  59. let g:ycm_key_list_previous_completion =
  60. \ get( g:, 'ycm_key_list_previous_completion', ['<S-TAB>', '<Up>'] )
  61. let g:ycm_key_invoke_completion =
  62. \ get( g:, 'ycm_key_invoke_completion', '<C-Space>' )
  63. let g:ycm_key_detailed_diagnostics =
  64. \ get( g:, 'ycm_key_detailed_diagnostics', '<leader>d' )
  65. let g:ycm_cache_omnifunc =
  66. \ get( g:, 'ycm_cache_omnifunc', 1 )
  67. let g:ycm_server_log_level =
  68. \ get( g:, 'ycm_server_log_level', 'info' )
  69. let g:ycm_server_keep_logfiles =
  70. \ get( g:, 'ycm_server_keep_logfiles', 0 )
  71. let g:ycm_extra_conf_vim_data =
  72. \ get( g:, 'ycm_extra_conf_vim_data', [] )
  73. let g:ycm_server_python_interpreter =
  74. \ get( g:, 'ycm_server_python_interpreter',
  75. \ get( g:, 'ycm_path_to_python_interpreter', '' ) )
  76. let g:ycm_show_diagnostics_ui =
  77. \ get( g:, 'ycm_show_diagnostics_ui',
  78. \ get( g:, 'ycm_register_as_syntastic_checker', 1 ) )
  79. let g:ycm_enable_diagnostic_signs =
  80. \ get( g:, 'ycm_enable_diagnostic_signs',
  81. \ get( g:, 'syntastic_enable_signs', 1 ) )
  82. let g:ycm_enable_diagnostic_highlighting =
  83. \ get( g:, 'ycm_enable_diagnostic_highlighting',
  84. \ get( g:, 'syntastic_enable_highlighting', 1 ) )
  85. let g:ycm_echo_current_diagnostic =
  86. \ get( g:, 'ycm_echo_current_diagnostic',
  87. \ get( g:, 'syntastic_echo_current_error', 1 ) )
  88. let g:ycm_always_populate_location_list =
  89. \ get( g:, 'ycm_always_populate_location_list',
  90. \ get( g:, 'syntastic_always_populate_loc_list', 0 ) )
  91. let g:ycm_error_symbol =
  92. \ get( g:, 'ycm_error_symbol',
  93. \ get( g:, 'syntastic_error_symbol', '>>' ) )
  94. let g:ycm_warning_symbol =
  95. \ get( g:, 'ycm_warning_symbol',
  96. \ get( g:, 'syntastic_warning_symbol', '>>' ) )
  97. let g:ycm_goto_buffer_command =
  98. \ get( g:, 'ycm_goto_buffer_command', 'same-buffer' )
  99. let g:ycm_disable_for_files_larger_than_kb =
  100. \ get( g:, 'ycm_disable_for_files_larger_than_kb', 1000 )
  101. " On-demand loading. Let's use the autoload folder and not slow down vim's
  102. " startup procedure.
  103. augroup youcompletemeStart
  104. autocmd!
  105. autocmd VimEnter * call youcompleteme#Enable()
  106. augroup END
  107. " This is basic vim plugin boilerplate
  108. call s:restore_cpo()