|
|
|
@ -1,6 +1,7 @@ |
|
|
|
#include "source_clang.h" |
|
|
|
#include "source_clang.h" |
|
|
|
#include "config.h" |
|
|
|
#include "config.h" |
|
|
|
#include "terminal.h" |
|
|
|
#include "terminal.h" |
|
|
|
|
|
|
|
#include "cmake.h" |
|
|
|
|
|
|
|
|
|
|
|
namespace sigc { |
|
|
|
namespace sigc { |
|
|
|
#ifndef SIGC_FUNCTORS_DEDUCE_RESULT_TYPE_WITH_DECLTYPE |
|
|
|
#ifndef SIGC_FUNCTORS_DEDUCE_RESULT_TYPE_WITH_DECLTYPE |
|
|
|
@ -178,7 +179,7 @@ void Source::ClangViewParse::soft_reparse() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
std::vector<std::string> Source::ClangViewParse::get_compilation_commands() { |
|
|
|
std::vector<std::string> Source::ClangViewParse::get_compilation_commands() { |
|
|
|
clang::CompilationDatabase db(project_path.string()); |
|
|
|
clang::CompilationDatabase db(CMake::get_default_build_path(project_path).string()); |
|
|
|
clang::CompileCommands commands(file_path.string(), db); |
|
|
|
clang::CompileCommands commands(file_path.string(), db); |
|
|
|
std::vector<clang::CompileCommand> cmds = commands.get_commands(); |
|
|
|
std::vector<clang::CompileCommand> cmds = commands.get_commands(); |
|
|
|
std::vector<std::string> arguments; |
|
|
|
std::vector<std::string> arguments; |
|
|
|
@ -964,26 +965,44 @@ Source::ClangViewAutocomplete(file_path, project_path, language) { |
|
|
|
|
|
|
|
|
|
|
|
auto_indent=[this]() { |
|
|
|
auto_indent=[this]() { |
|
|
|
auto command=Config::get().terminal.clang_format_command; |
|
|
|
auto command=Config::get().terminal.clang_format_command; |
|
|
|
unsigned indent_width; |
|
|
|
bool use_style_file=false; |
|
|
|
std::string tab_style; |
|
|
|
|
|
|
|
if(tab_char=='\t') { |
|
|
|
auto style_file_search_path=this->file_path.parent_path(); |
|
|
|
indent_width=tab_size*8; |
|
|
|
while(true) { |
|
|
|
tab_style="UseTab: Always"; |
|
|
|
auto style_file=style_file_search_path/"CMakeLists.txt"; |
|
|
|
|
|
|
|
if(boost::filesystem::exists(style_file_search_path/".clang-format") || boost::filesystem::exists(style_file_search_path/"_clang-format")) { |
|
|
|
|
|
|
|
use_style_file=true; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(style_file_search_path==style_file_search_path.root_directory()) |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
style_file_search_path=style_file_search_path.parent_path(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(use_style_file) |
|
|
|
|
|
|
|
command+=" -style=file"; |
|
|
|
else { |
|
|
|
else { |
|
|
|
indent_width=tab_size; |
|
|
|
unsigned indent_width; |
|
|
|
tab_style="UseTab: Never"; |
|
|
|
std::string tab_style; |
|
|
|
|
|
|
|
if(tab_char=='\t') { |
|
|
|
|
|
|
|
indent_width=tab_size*8; |
|
|
|
|
|
|
|
tab_style="UseTab: Always"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
indent_width=tab_size; |
|
|
|
|
|
|
|
tab_style="UseTab: Never"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
command+=" -style=\"{IndentWidth: "+std::to_string(indent_width); |
|
|
|
|
|
|
|
command+=", "+tab_style; |
|
|
|
|
|
|
|
command+=", "+std::string("AccessModifierOffset: -")+std::to_string(indent_width); |
|
|
|
|
|
|
|
if(Config::get().source.clang_format_style!="") |
|
|
|
|
|
|
|
command+=", "+Config::get().source.clang_format_style; |
|
|
|
|
|
|
|
command+="}\""; |
|
|
|
} |
|
|
|
} |
|
|
|
command+=" -style=\"{IndentWidth: "+std::to_string(indent_width); |
|
|
|
|
|
|
|
command+=", "+tab_style; |
|
|
|
|
|
|
|
command+=", "+std::string("AccessModifierOffset: -")+std::to_string(indent_width); |
|
|
|
|
|
|
|
if(Config::get().source.clang_format_style!="") |
|
|
|
|
|
|
|
command+=", "+Config::get().source.clang_format_style; |
|
|
|
|
|
|
|
command+="}\""; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::stringstream stdin_stream(get_buffer()->get_text()), stdout_stream; |
|
|
|
std::stringstream stdin_stream(get_buffer()->get_text()), stdout_stream; |
|
|
|
|
|
|
|
|
|
|
|
auto exit_status=Terminal::get().process(stdin_stream, stdout_stream, command); |
|
|
|
auto exit_status=Terminal::get().process(stdin_stream, stdout_stream, command, this->file_path.parent_path()); |
|
|
|
if(exit_status==0) { |
|
|
|
if(exit_status==0) { |
|
|
|
get_source_buffer()->begin_user_action(); |
|
|
|
get_source_buffer()->begin_user_action(); |
|
|
|
auto iter=get_buffer()->get_insert()->get_iter(); |
|
|
|
auto iter=get_buffer()->get_insert()->get_iter(); |
|
|
|
|