parent
7833cc1cf1
commit
e743076e14
10
README.md
10
README.md
@ -532,6 +532,16 @@ Default: `0`
|
||||
|
||||
let g:ycm_complete_in_comments_and_strings = 0
|
||||
|
||||
### The `g:ycm_collect_identifiers_from_comments_and_strings` option
|
||||
|
||||
When this option is set to `1`, YCM's identifier completer will also collect
|
||||
identifiers from strings and comments. Otherwise, the text in comments and
|
||||
strings will be ignored.
|
||||
|
||||
Default: `0`
|
||||
|
||||
let g:ycm_collect_identifiers_from_comments_and_strings = 0
|
||||
|
||||
### The `g:ycm_add_preview_to_completeopt` option
|
||||
|
||||
When this option is set to `1`, YCM will add the `preview` string to Vim's
|
||||
|
@ -137,20 +137,26 @@ void IdentifierCompleter::AddCandidatesToDatabase(
|
||||
void IdentifierCompleter::AddCandidatesToDatabaseFromBuffer(
|
||||
const std::string &buffer_contents,
|
||||
const std::string &filetype,
|
||||
const std::string &filepath ) {
|
||||
const std::string &filepath,
|
||||
bool collect_from_comments_and_strings) {
|
||||
ClearCandidatesStoredForFile( filetype, filepath );
|
||||
|
||||
AddCandidatesToDatabase(
|
||||
ExtractIdentifiersFromText( RemoveIdentifierFreeText( buffer_contents ) ),
|
||||
filetype,
|
||||
filepath );
|
||||
std::string new_contents =
|
||||
collect_from_comments_and_strings ?
|
||||
buffer_contents :
|
||||
RemoveIdentifierFreeText( buffer_contents );
|
||||
|
||||
AddCandidatesToDatabase( ExtractIdentifiersFromText( new_contents ),
|
||||
filetype,
|
||||
filepath );
|
||||
}
|
||||
|
||||
|
||||
void IdentifierCompleter::AddCandidatesToDatabaseFromBufferAsync(
|
||||
std::string buffer_contents,
|
||||
std::string filetype,
|
||||
std::string filepath ) {
|
||||
std::string filepath,
|
||||
bool collect_from_comments_and_strings ) {
|
||||
// TODO: throw exception when threading is not enabled and this is called
|
||||
if ( !threading_enabled_ )
|
||||
return;
|
||||
@ -160,7 +166,8 @@ void IdentifierCompleter::AddCandidatesToDatabaseFromBufferAsync(
|
||||
boost::ref( *this ),
|
||||
boost::move( buffer_contents ),
|
||||
boost::move( filetype ),
|
||||
boost::move( filepath ) );
|
||||
boost::move( filepath ),
|
||||
collect_from_comments_and_strings );
|
||||
|
||||
buffer_identifiers_task_stack_.Push(
|
||||
make_shared< packaged_task< void > >( boost::move( functor ) ) );
|
||||
|
@ -56,9 +56,11 @@ public:
|
||||
const std::string &filetype,
|
||||
const std::string &filepath );
|
||||
|
||||
void AddCandidatesToDatabaseFromBuffer( const std::string &buffer_contents,
|
||||
const std::string &filetype,
|
||||
const std::string &filepath );
|
||||
void AddCandidatesToDatabaseFromBuffer(
|
||||
const std::string &buffer_contents,
|
||||
const std::string &filetype,
|
||||
const std::string &filepath,
|
||||
bool collect_from_comments_and_strings );
|
||||
|
||||
// NOTE: params are taken by value on purpose! With a C++11 compiler we can
|
||||
// avoid an expensive copy of buffer_contents if the param is taken by value
|
||||
@ -66,7 +68,8 @@ public:
|
||||
void AddCandidatesToDatabaseFromBufferAsync(
|
||||
std::string buffer_contents,
|
||||
std::string filetype,
|
||||
std::string filepath );
|
||||
std::string filepath,
|
||||
bool collect_from_comments_and_strings );
|
||||
|
||||
// Only provided for tests!
|
||||
std::vector< std::string > CandidatesForQuery(
|
||||
|
@ -45,7 +45,7 @@ int YcmCoreVersion()
|
||||
{
|
||||
// We increment this every time when we want to force users to recompile
|
||||
// ycm_core.
|
||||
return 1;
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
||||
|
@ -77,6 +77,9 @@ let g:ycm_add_preview_to_completeopt =
|
||||
let g:ycm_complete_in_comments_and_strings =
|
||||
\ get( g:, 'ycm_complete_in_comments_and_strings', 0 )
|
||||
|
||||
let g:ycm_collect_identifiers_from_comments_and_strings =
|
||||
\ get( g:, 'ycm_collect_identifiers_from_comments_and_strings', 0 )
|
||||
|
||||
let g:ycm_autoclose_preview_window_after_completion =
|
||||
\ get( g:, 'ycm_autoclose_preview_window_after_completion', 0 )
|
||||
|
||||
|
@ -87,14 +87,18 @@ class IdentifierCompleter( Completer ):
|
||||
def AddBufferIdentifiers( self ):
|
||||
filetype = vim.eval( "&filetype" )
|
||||
filepath = vim.eval( "expand('%:p')" )
|
||||
collect_from_comments_and_strings = bool( int( vimsupport.GetVariableValue(
|
||||
"g:ycm_collect_identifiers_from_comments_and_strings" ) ) )
|
||||
|
||||
if not filetype or not filepath:
|
||||
return
|
||||
|
||||
text = "\n".join( vim.current.buffer )
|
||||
self.completer.AddCandidatesToDatabaseFromBufferAsync( text,
|
||||
filetype,
|
||||
filepath )
|
||||
self.completer.AddCandidatesToDatabaseFromBufferAsync(
|
||||
text,
|
||||
filetype,
|
||||
filepath,
|
||||
collect_from_comments_and_strings )
|
||||
|
||||
|
||||
def OnFileReadyToParse( self ):
|
||||
|
@ -238,7 +238,7 @@ def CurrentIdentifierFinished():
|
||||
return line[ : current_column ].isspace()
|
||||
|
||||
|
||||
COMPATIBLE_WITH_CORE_VERSION = 1
|
||||
COMPATIBLE_WITH_CORE_VERSION = 2
|
||||
|
||||
def CompatibleWithYcmCore():
|
||||
try:
|
||||
|
Loading…
Reference in New Issue
Block a user