From 5f95a2bfdebc4238c84808164a76e02a24c345e7 Mon Sep 17 00:00:00 2001 From: Strahinja Val Markovic Date: Sun, 5 Aug 2012 19:49:54 -0700 Subject: [PATCH] Showing preview window data for completions Also, const functions have " const" correctly appended in the completion window. --- cpp/ycm/ClangUtils.cpp | 11 +++++++---- cpp/ycm/ycm_core.cpp | 2 +- python/completers/cpp/clang_completer.py | 3 ++- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/cpp/ycm/ClangUtils.cpp b/cpp/ycm/ClangUtils.cpp index e4d9e872..16f384c6 100644 --- a/cpp/ycm/ClangUtils.cpp +++ b/cpp/ycm/ClangUtils.cpp @@ -96,6 +96,7 @@ bool IsMainCompletionTextInfo( CXCompletionChunkKind kind ) kind == CXCompletionChunk_Colon || kind == CXCompletionChunk_SemiColon || kind == CXCompletionChunk_Equal || + kind == CXCompletionChunk_Informative || kind == CXCompletionChunk_HorizontalSpace; } @@ -204,9 +205,6 @@ CompletionData CompletionResultToCompletionData( if ( kind == CXCompletionChunk_TypedText ) data.original_string_ = ChunkToString( completion_string, j ); - - if ( kind == CXCompletionChunk_Informative ) - data.detailed_info_ = ChunkToString( completion_string, j ); } data.kind_ = CursorKindToVimKind( completion_result.CursorKind ); @@ -243,11 +241,16 @@ std::vector< CompletionData > ToCompletionDataVector( else { + std::string possible_newline = + completions[ index ].detailed_info_.empty() ? + "" : + "\n"; + // If we have already seen this completion, then this is an overload of a // function we have seen. We add the signature of the overload to the // detailed information. completions[ index ].detailed_info_ - .append( "\n" ) + .append( possible_newline ) .append( data.return_type_ ) .append( " " ) .append( data.everything_except_return_type_ ); diff --git a/cpp/ycm/ycm_core.cpp b/cpp/ycm/ycm_core.cpp index a462ac3c..8dbc8d5c 100644 --- a/cpp/ycm/ycm_core.cpp +++ b/cpp/ycm/ycm_core.cpp @@ -40,7 +40,7 @@ BOOST_PYTHON_MODULE(ycm_core) .def( "TextToInsertInBuffer", &CompletionData::TextToInsertInBuffer ) .def( "MainCompletionText", &CompletionData::MainCompletionText ) .def( "ExtraMenuInfo", &CompletionData::ExtraMenuInfo ) - .def( "DetailedInfoForPreviewWindow ", + .def( "DetailedInfoForPreviewWindow", &CompletionData::DetailedInfoForPreviewWindow ) .def_readonly( "kind_", &CompletionData::kind_ ); diff --git a/python/completers/cpp/clang_completer.py b/python/completers/cpp/clang_completer.py index 4df2df01..2901b2cb 100644 --- a/python/completers/cpp/clang_completer.py +++ b/python/completers/cpp/clang_completer.py @@ -146,14 +146,15 @@ def CompletionDataToDict( completion_data ): 'abbr' : completion_data.MainCompletionText(), 'menu' : completion_data.ExtraMenuInfo(), 'kind' : completion_data.kind_, + 'info' : completion_data.DetailedInfoForPreviewWindow(), 'dup' : 1, - # TODO: add detailed_info_ as 'info' } def DiagnosticToDict( diagnostic ): # see :h getqflist for a description of the dictionary fields return { + # TODO: wrap the bufnr generation into a function 'bufnr' : int( vim.eval( "bufnr('{0}', 1)".format( diagnostic.filename_ ) ) ), 'lnum' : diagnostic.line_number_,