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