This commit is contained in:
Chiel92 2013-08-14 16:35:55 +02:00
commit 8f63ec9e09
14 changed files with 219 additions and 63 deletions

1
.gitignore vendored
View File

@ -4,6 +4,7 @@
*.o
# Compiled Dynamic libraries
*.dll
*.so
*.dylib

View File

@ -293,9 +293,10 @@ User Guide
- If the offered completions are too broad, keep typing characters; YCM will
continue refining the offered completions based on your input.
- Filtering is "smart-case" sensitive; if you are typing only lowercase letters,
then it's case-insensitive. If your input involves uppercase letters, then
it's case-sensitive. So "foo" matches "Foo" and "foo", but "Foo" matches "Foo"
but not "foo".
then it's case-insensitive. If your input contains uppercase letters, then the
uppercase letters in your query must match uppercase letters in the completion
strings (the lowercase letters still match both). So, "foo" matches "Foo" and
"foo", "Foo" matches "Foo" and "FOO" but not "foo".
- Use the TAB key to accept a completion and continue pressing TAB to cycle
through the completions. Use Shift-TAB to cycle backwards. Note that if you're
using console Vim (that is, not Gvim or MacVim) then it's likely that the
@ -595,6 +596,27 @@ This command clears that cache entirely. YCM will then re-query your
Supported in filetypes: `c, cpp, objc, objcpp`
### The `StartServer` subcommand
Starts the semantic-engine-as-localhost-server for those semantic engines that
work as separate servers that YCM talks to.
Supported in filetypes: `cs`
### The `StopServer` subcommand
Stops the semantic-engine-as-localhost-server for those semantic engines that
work as separate servers that YCM talks to.
Supported in filetypes: `cs`
### The `RestartServer` subcommand
Restarts the semantic-engine-as-localhost-server for those semantic engines that
work as separate servers that YCM talks to.
Supported in filetypes: `cs`
Options
-------
@ -682,6 +704,7 @@ Default: `{'notes': 1, 'markdown': 1, 'text': 1}`
\ 'notes' : 1,
\ 'markdown' : 1,
\ 'text' : 1,
\ 'unite' : 1,
\}
### The `g:ycm_filetype_specific_completion_to_disable` option
@ -809,6 +832,33 @@ Default: `0`
let g:ycm_seed_identifiers_with_syntax = 0
### The `g:ycm_csharp_server_port` option
The port number (on `localhost`) on which the OmniSharp server should be
started.
Default: `2000`
let g:ycm_csharp_server_port = 2000
### The `g:ycm_auto_start_csharp_server` option
When set to `1`, the OmniSharp server will be automatically started (once per
Vim session) when you open a C# file.
Default: `1`
let g:ycm_auto_start_csharp_server = 1
### The `g:ycm_auto_stop_csharp_server` option
When set to `1`, the OmniSharp server will be automatically stopped upon
closing Vim.
Default: `1`
let g:ycm_auto_stop_csharp_server = 1
### The `g:ycm_add_preview_to_completeopt` option
When this option is set to `1`, YCM will add the `preview` string to Vim's
@ -938,6 +988,9 @@ When this option is set to `1` YCM will ask once per `.ycm_extra_conf.py` file
if it is safe to be loaded. This is to prevent execution of malicious code
from a `.ycm_extra_conf.py` file you didn't write.
To selectively get YCM to ask/not ask about loading certain `.ycm_extra_conf.py`
files, see the `g:ycm_extra_conf_globlist` option.
Default: `1`
let g:ycm_confirm_extra_conf = 1

View File

@ -206,6 +206,19 @@ function! s:SetUpCompleteopt()
endif
endfunction
" For various functions/use-cases, we want to keep track of whether the buffer
" has changed since the last time they were invoked. We keep the state of
" b:changedtick of the last time the specific function was called in
" b:ycm_changedtick.
function! s:SetUpYcmChangedTick()
let b:ycm_changedtick =
\ get( b:, 'ycm_changedtick', {
\ 'file_ready_to_parse' : -1,
\ } )
endfunction
function! s:OnVimLeave()
py ycm_state.OnVimLeave()
py extra_conf_store.CallExtraConfVimCloseIfExists()
@ -213,6 +226,11 @@ endfunction
function! s:OnBufferVisit()
" We need to do this even when we are not allowed to complete in the current
" file because we might be allowed to complete in the future! The canonical
" example is creating a new buffer with :enew and then setting a filetype.
call s:SetUpYcmChangedTick()
if !s:AllowedToCompleteInCurrentFile()
return
endif
@ -247,7 +265,15 @@ endfunction
function! s:OnFileReadyToParse()
py ycm_state.OnFileReadyToParse()
" We need to call this just in case there is no b:ycm_changetick; this can
" happen for special buffers.
call s:SetUpYcmChangedTick()
let buffer_changed = b:changedtick != b:ycm_changedtick.file_ready_to_parse
if buffer_changed
py ycm_state.OnFileReadyToParse()
endif
let b:ycm_changedtick.file_ready_to_parse = b:changedtick
endfunction
@ -311,6 +337,7 @@ function! s:OnInsertLeave()
let s:omnifunc_mode = 0
call s:UpdateDiagnosticNotifications()
call s:OnFileReadyToParse()
py ycm_state.OnInsertLeave()
if g:ycm_autoclose_preview_window_after_completion ||
\ g:ycm_autoclose_preview_window_after_insertion

View File

@ -103,7 +103,13 @@ endif()
# too. Sadly there's no way around the warning.
if ( CPP11_AVAILABLE )
message( "Your C++ compiler supports C++11, compiling in that mode." )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x" )
# Cygwin needs its hand held a bit; see issue #473
if ( CYGWIN AND CMAKE_COMPILER_IS_GNUCXX )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x" )
else()
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x" )
endif()
else()
message(
"Your C++ compiler does NOT support C++11, compiling in C++03 mode." )

View File

@ -28,6 +28,7 @@ if ( NOT PYTHONLIBS_VERSION_STRING VERSION_LESS "3.0.0" )
"python2.\n" )
endif()
option( USE_DEV_FLAGS "Use compilation flags meant for YCM developers" OFF )
option( USE_CLANG_COMPLETER "Use Clang semantic completer for C/C++/ObjC" OFF )
option( USE_SYSTEM_LIBCLANG "Set to ON to use the system libclang library" OFF )
set( PATH_TO_LLVM_ROOT "" CACHE PATH "Path to the root of a LLVM+Clang binary distribution" )
@ -47,8 +48,8 @@ if ( USE_CLANG_COMPLETER AND NOT USE_SYSTEM_LIBCLANG AND NOT PATH_TO_LLVM_ROOT )
set( CLANG_DIRNAME "clang+llvm-3.3-Ubuntu-13.04-x86_64-linux-gnu" )
set( CLANG_MD5 "c0cbbe86c5836e03fe6eb96e95d059fa" )
else()
set( CLANG_DIRNAME "clang+llvm-3.3-Ubuntu-13.04-x86-linux-gnu" )
set( CLANG_MD5 "1478157ffdf583461fe9c377398cccf3" )
set( CLANG_DIRNAME "clang+llvm-3.3-i386-debian6" )
set( CLANG_MD5 "415d033b60659433d4631df894673802" )
endif()
set( CLANG_FILENAME "${CLANG_DIRNAME}.tar.bz2" )
endif()
@ -295,7 +296,7 @@ set_target_properties( ${PROJECT_NAME} PROPERTIES
# For some reason, Xcode is too dumb to understand the -isystem flag and thus
# borks on warnings in Boost.
if ( ( CMAKE_COMPILER_IS_GNUCXX OR COMPILER_IS_CLANG ) AND
if ( USE_DEV_FLAGS AND ( CMAKE_COMPILER_IS_GNUCXX OR COMPILER_IS_CLANG ) AND
NOT CMAKE_GENERATOR_IS_XCODE )
# We want all warnings, and warnings should be treated as errors
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror" )
@ -306,8 +307,8 @@ endif()
# We want warnings if we accidentally use C++11 features
# We can't use this warning on FreeBSD because std headers on that OS are dumb.
# See here: https://github.com/Valloric/YouCompleteMe/issues/260
if ( COMPILER_IS_CLANG AND NOT CMAKE_GENERATOR_IS_XCODE AND NOT
SYSTEM_IS_FREEBSD )
if ( USE_DEV_FLAGS AND COMPILER_IS_CLANG AND NOT CMAKE_GENERATOR_IS_XCODE AND
NOT SYSTEM_IS_FREEBSD )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wc++98-compat" )
endif()

View File

@ -39,17 +39,6 @@ LetterNode *FirstUppercaseNode( const std::list< LetterNode *> &list ) {
return node;
}
LetterNode *FirstLowercaseNode( const std::list< LetterNode *> &list ) {
LetterNode *node = NULL;
foreach( LetterNode * current_node, list ) {
if ( !current_node->LetterIsUppercase() ) {
node = current_node;
break;
}
}
return node;
}
} // unnamed namespace
std::string GetWordBoundaryChars( const std::string &text ) {
@ -107,9 +96,13 @@ Result Candidate::QueryMatchResult( const std::string &query,
return Result( false );
if ( case_sensitive ) {
// When the query letter is uppercase, then we force an uppercase match
// but when the query letter is lowercase, then it can match both an
// uppercase and a lowercase letter. This is by design and it's much
// better than forcing lowercase letter matches.
node = IsUppercase( letter ) ?
FirstUppercaseNode( *list ) :
FirstLowercaseNode( *list );
list->front();
if ( !node )
return Result( false );

View File

@ -192,26 +192,26 @@ TEST( CandidateTest, QueryMatchResultCaseSensitiveIsSubsequence ) {
EXPECT_TRUE( candidate.QueryMatchResult( "AA" , true ).IsSubsequence() );
EXPECT_TRUE( candidate.QueryMatchResult( "A" , true ).IsSubsequence() );
EXPECT_TRUE( candidate.QueryMatchResult( "B" , true ).IsSubsequence() );
EXPECT_TRUE( candidate.QueryMatchResult( "foobaaar", true ).IsSubsequence() );
EXPECT_TRUE( candidate.QueryMatchResult( "foobaAAr", true ).IsSubsequence() );
EXPECT_TRUE( candidate.QueryMatchResult( "fbAA" , true ).IsSubsequence() );
EXPECT_TRUE( candidate.QueryMatchResult( "fbaa" , true ).IsSubsequence() );
EXPECT_TRUE( candidate.QueryMatchResult( "b" , true ).IsSubsequence() );
EXPECT_TRUE( candidate.QueryMatchResult( "f" , true ).IsSubsequence() );
EXPECT_TRUE( candidate.QueryMatchResult( "fbar" , true ).IsSubsequence() );
}
TEST( CandidateTest, QueryMatchResultCaseSensitiveIsntSubsequence ) {
Candidate candidate( "FooBaAAr" );
EXPECT_FALSE( candidate.QueryMatchResult( "foobaaar", true ).IsSubsequence() );
EXPECT_FALSE( candidate.QueryMatchResult( "foobaAAr", true ).IsSubsequence() );
EXPECT_FALSE( candidate.QueryMatchResult( "fbAA" , true ).IsSubsequence() );
EXPECT_FALSE( candidate.QueryMatchResult( "fbaa" , true ).IsSubsequence() );
EXPECT_FALSE( candidate.QueryMatchResult( "goo" , true ).IsSubsequence() );
EXPECT_FALSE( candidate.QueryMatchResult( "R" , true ).IsSubsequence() );
EXPECT_FALSE( candidate.QueryMatchResult( "b" , true ).IsSubsequence() );
EXPECT_FALSE( candidate.QueryMatchResult( "f" , true ).IsSubsequence() );
EXPECT_FALSE( candidate.QueryMatchResult( "O" , true ).IsSubsequence() );
EXPECT_FALSE( candidate.QueryMatchResult( "OO" , true ).IsSubsequence() );
EXPECT_FALSE( candidate.QueryMatchResult( "OBA" , true ).IsSubsequence() );
EXPECT_FALSE( candidate.QueryMatchResult( "FBAR" , true ).IsSubsequence() );
EXPECT_FALSE( candidate.QueryMatchResult( "fbar" , true ).IsSubsequence() );
EXPECT_FALSE( candidate.QueryMatchResult( "FBAAR" , true ).IsSubsequence() );
EXPECT_FALSE( candidate.QueryMatchResult( "Oar" , true ).IsSubsequence() );
EXPECT_FALSE( candidate.QueryMatchResult( "FooBaAAR", true ).IsSubsequence() );
EXPECT_FALSE( candidate.QueryMatchResult( "FooBAAAr", true ).IsSubsequence() );
EXPECT_FALSE( candidate.QueryMatchResult( "FOoBaAAr", true ).IsSubsequence() );
EXPECT_FALSE( candidate.QueryMatchResult( "FOobaaar", true ).IsSubsequence() );

View File

@ -69,7 +69,8 @@ TEST( IdentifierCompleterTest, SmartCaseFiltering ) {
StringVector(
"fooBar",
"fooBaR" ) ).CandidatesForQuery( "fBr" ),
ElementsAre( "fooBar" ) );
ElementsAre( "fooBaR",
"fooBar" ) );
}
TEST( IdentifierCompleterTest, FirstCharSameAsQueryWins ) {

View File

@ -29,6 +29,9 @@ Contents ~
2. The |GoToDefinition| subcommand
3. The |GoToDefinitionElseDeclaration| subcommand
4. The |ClearCompilationFlagCache| subcommand
5. The |StartServer| subcommand
6. The |StopServer| subcommand
7. The |RestartServer| subcommand
9. Options |youcompleteme-options|
1. The |g:ycm_min_num_of_chars_for_completion| option
2. The |g:ycm_min_num_identifier_candidate_chars| option
@ -42,20 +45,23 @@ Contents ~
10. The |g:ycm_collect_identifiers_from_comments_and_strings| option
11. The |g:ycm_collect_identifiers_from_tags_files| option
12. The |g:ycm_seed_identifiers_with_syntax| option
13. The |g:ycm_add_preview_to_completeopt| option
14. The |g:ycm_autoclose_preview_window_after_completion| option
15. The |g:ycm_autoclose_preview_window_after_insertion| option
16. The |g:ycm_max_diagnostics_to_display| option
17. The |g:ycm_key_list_select_completion| option
18. The |g:ycm_key_list_previous_completion| option
19. The |g:ycm_key_invoke_completion| option
20. The |g:ycm_key_detailed_diagnostics| option
21. The |g:ycm_global_ycm_extra_conf| option
22. The |g:ycm_confirm_extra_conf| option
23. The |g:ycm_extra_conf_globlist| option
24. The |g:ycm_filepath_completion_use_working_dir| option
25. The |g:ycm_semantic_triggers| option
26. The |g:ycm_cache_omnifunc| option
13. The |g:ycm_csharp_server_port| option
14. The |g:ycm_auto_start_csharp_server| option
15. The |g:ycm_auto_stop_csharp_server| option
16. The |g:ycm_add_preview_to_completeopt| option
17. The |g:ycm_autoclose_preview_window_after_completion| option
18. The |g:ycm_autoclose_preview_window_after_insertion| option
19. The |g:ycm_max_diagnostics_to_display| option
20. The |g:ycm_key_list_select_completion| option
21. The |g:ycm_key_list_previous_completion| option
22. The |g:ycm_key_invoke_completion| option
23. The |g:ycm_key_detailed_diagnostics| option
24. The |g:ycm_global_ycm_extra_conf| option
25. The |g:ycm_confirm_extra_conf| option
26. The |g:ycm_extra_conf_globlist| option
27. The |g:ycm_filepath_completion_use_working_dir| option
28. The |g:ycm_semantic_triggers| option
29. The |g:ycm_cache_omnifunc| option
10. FAQ |youcompleteme-faq|
1. I get a linker warning regarding |libpython| on Mac when compiling YCM
2. I get a weird window at the top of my file when I use the semantic engine |youcompleteme-i-get-weird-window-at-top-of-my-file-when-i-use-semantic-engine|
@ -389,9 +395,11 @@ General Usage ~
continue refining the offered completions based on your input.
- Filtering is "smart-case" sensitive; if you are typing only lowercase
letters, then it's case-insensitive. If your input involves uppercase
letters, then it's case-sensitive. So "foo" matches "Foo" and "foo", but
"Foo" matches "Foo" but not "foo".
letters, then it's case-insensitive. If your input contains uppercase
letters, then the uppercase letters in your query must match uppercase
letters in the completion strings (the lowercase letters still match both).
So, "foo" matches "Foo" and "foo", "Foo" matches "Foo" and "FOO" but not
"foo".
- Use the TAB key to accept a completion and continue pressing TAB to cycle
through the completions. Use Shift-TAB to cycle backwards. Note that if
@ -722,6 +730,30 @@ This command clears that cache entirely. YCM will then re-query your
Supported in filetypes: 'c, cpp, objc, objcpp'
-------------------------------------------------------------------------------
The *StartServer* subcommand
Starts the semantic-engine-as-localhost-server for those semantic engines that
work as separate servers that YCM talks to.
Supported in filetypes: 'cs'
-------------------------------------------------------------------------------
The *StopServer* subcommand
Stops the semantic-engine-as-localhost-server for those semantic engines that
work as separate servers that YCM talks to.
Supported in filetypes: 'cs'
-------------------------------------------------------------------------------
The *RestartServer* subcommand
Restarts the semantic-engine-as-localhost-server for those semantic engines
that work as separate servers that YCM talks to.
Supported in filetypes: 'cs'
===============================================================================
*youcompleteme-options*
Options ~
@ -814,6 +846,7 @@ Default: "{'notes': 1, 'markdown': 1, 'text': 1}"
\ 'notes' : 1,
\ 'markdown' : 1,
\ 'text' : 1,
\ 'unite' : 1,
\}
<
-------------------------------------------------------------------------------
@ -949,6 +982,36 @@ Default: '0'
let g:ycm_seed_identifiers_with_syntax = 0
<
-------------------------------------------------------------------------------
The *g:ycm_csharp_server_port* option
The port number (on 'localhost') on which the OmniSharp server should be
started.
Default: '2000'
>
let g:ycm_csharp_server_port = 2000
<
-------------------------------------------------------------------------------
The *g:ycm_auto_start_csharp_server* option
When set to '1', the OmniSharp server will be automatically started (once per
Vim session) when you open a C# file.
Default: '1'
>
let g:ycm_auto_start_csharp_server = 1
<
-------------------------------------------------------------------------------
The *g:ycm_auto_stop_csharp_server* option
When set to '1', the OmniSharp server will be automatically stopped upon
closing Vim.
Default: '1'
>
let g:ycm_auto_stop_csharp_server = 1
<
-------------------------------------------------------------------------------
The *g:ycm_add_preview_to_completeopt* option
When this option is set to '1', YCM will add the 'preview' string to Vim's
@ -1088,6 +1151,9 @@ When this option is set to '1' YCM will ask once per '.ycm_extra_conf.py' file
if it is safe to be loaded. This is to prevent execution of malicious code from
a '.ycm_extra_conf.py' file you didn't write.
To selectively get YCM to ask/not ask about loading certain
'.ycm_extra_conf.py' files, see the |g:ycm_extra_conf_globlist| option.
Default: '1'
>
let g:ycm_confirm_extra_conf = 1
@ -1175,11 +1241,11 @@ Default: '[see next line]'
-------------------------------------------------------------------------------
The *g:ycm_cache_omnifunc* option
Some omnicompletion engines do not work well with the YCM cache—in
particular, they might not produce all possible results for a given prefix. By
unsetting this option you can ensure that the omnicompletion engine is
requeried on every keypress. That will ensure all completions will be
presented, but might cause stuttering and lagginess if the omnifunc is slow.
Some omnicompletion engines do not work well with the YCM cache—in particular,
they might not produce all possible results for a given prefix. By unsetting
this option you can ensure that the omnicompletion engine is requeried on every
keypress. That will ensure all completions will be presented, but might cause
stuttering and lagginess if the omnifunc is slow.
Default: '1'
>
@ -1506,7 +1572,7 @@ The author's homepage is http://val.markovic.io.
*youcompleteme-license*
License ~
This software is licensed under the GPL v3 license [31]. Š 2012 Strahinja Val
This software is licensed under the GPL v3 license [31]. © 2012 Strahinja Val
Markovic <val@markovic.io>.
===============================================================================

View File

@ -138,7 +138,7 @@ fi
if [ -z "$YCM_TESTRUN" ]; then
install $cmake_args $EXTRA_CMAKE_ARGS
else
testrun $cmake_args $EXTRA_CMAKE_ARGS
testrun $cmake_args -DUSE_DEV_FLAGS=ON $EXTRA_CMAKE_ARGS
fi
if $omnisharp_completer; then
@ -153,7 +153,7 @@ if $omnisharp_completer; then
ycm_dir=`pwd`
build_dir=$ycm_dir"/python/ycm/completers/cs/OmniSharpServer"
cd $build_dir
$buildcommand
cd $ycm_dir

View File

@ -79,6 +79,8 @@ let g:ycm_filetype_blacklist =
\ 'notes' : 1,
\ 'markdown' : 1,
\ 'text' : 1,
\ 'unite' : 1,
\ 'tagbar' : 1,
\ } ) )
let g:ycm_filetype_specific_completion_to_disable =
@ -152,6 +154,9 @@ let g:ycm_cache_omnifunc =
let g:ycm_auto_start_csharp_server =
\ get( g:, 'ycm_auto_start_csharp_server', 1 )
let g:ycm_auto_stop_csharp_server =
\ get( g:, 'ycm_auto_stop_csharp_server', 1 )
let g:ycm_csharp_server_port =
\ get( g:, 'ycm_csharp_server_port', 2000 )

View File

@ -51,7 +51,7 @@ class CsharpCompleter( ThreadedCompleter ):
def OnVimLeave( self ):
if self._ServerIsRunning():
if vimsupport.GetBoolValue( 'g:ycm_auto_stop_csharp_server' ) and self._ServerIsRunning():
self._StopServer()
@ -194,10 +194,9 @@ class CsharpCompleter( ThreadedCompleter ):
try:
response = urllib2.urlopen( target, parameters )
return json.loads( response.read() )
except Exception as e:
if not silent:
vimsupport.PostVimMessage(
'OmniSharp : Could not connect to ' + target + ': ' + str( e ) )
except Exception:
# TODO: Add logging for this case. We can't post a Vim message because Vim
# crashes when that's done from a no-GUI thread.
return None

View File

@ -50,7 +50,7 @@ def ModuleFileForSourceFile( filename ):
order and return the filename of the first module that was allowed to load.
If no module was found or allowed to load, None is returned."""
if not _module_file_for_source_file.has_key( filename ):
if not filename in _module_file_for_source_file:
for module_file in _ExtraConfModuleSourceFilesForFile( filename ):
if _Load( module_file ):
_module_file_for_source_file[ filename ] = module_file
@ -109,7 +109,7 @@ def _Load( module_file, force = False ):
return None
if not force:
if _module_for_module_file.has_key( module_file ):
if module_file in _module_for_module_file:
return _module_for_module_file[ module_file ]
if not _ShouldLoad( module_file ):

View File

@ -79,6 +79,10 @@ def NumLinesInBuffer( buffer ):
def PostVimMessage( message ):
# TODO: Check are we on the main thread or not, and if not, force a crash
# here. This should make it impossible to accidentally call this from a
# non-GUI thread which *sometimes* crashes Vim because Vim is not thread-safe.
# A consistent crash should force us to notice the error.
vim.command( "echohl WarningMsg | echomsg '{0}' | echohl None"
.format( EscapeForVim( message ) ) )