From 30beb18ff3ace60e18d3485a3fe14181f37858ad Mon Sep 17 00:00:00 2001 From: eidheim Date: Mon, 19 Oct 2015 14:43:45 +0200 Subject: [PATCH] Added clang-format style options to config file. --- src/config.cc | 2 ++ src/files.h | 13 +++++++------ src/source.h | 1 + src/source_clang.cc | 2 ++ 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/config.cc b/src/config.cc index 6b98535..51fb2ac 100644 --- a/src/config.cc +++ b/src/config.cc @@ -135,6 +135,8 @@ void MainConfig::GenerateSource() { for (auto &i : source_json.get_child("clang_types")) source_cfg->clang_types[i.first] = i.second.get_value(); + source_cfg->clang_format_style = source_json.get("clang_format_style"); + auto pt_doc_search=cfg.get_child("documentation_searches"); for(auto &pt_doc_search_lang: pt_doc_search) { source_cfg->documentation_searches[pt_doc_search_lang.first].separator=pt_doc_search_lang.second.get("separator"); diff --git a/src/files.h b/src/files.h index 2c5d92f..d892167 100644 --- a/src/files.h +++ b/src/files.h @@ -29,6 +29,12 @@ const std::string configjson = " \"show_map\": true,\n" " \"map_font_size\": \"1\",\n" " \"spellcheck_language\": \"en_US\", //Use \"\" to set language from your locale settings\n" +" \"auto_tab_char_and_size\": true, //Use false to always use default tab char and size\n" +" \"default_tab_char\": \" \", //Use \"\\t\" for regular tab\n" +" \"default_tab_size\": 2,\n" +" \"wrap_lines\": false,\n" +" \"highlight_current_line\": true,\n" +" \"show_line_numbers\": true,\n" " \"clang_types\": {\n" " \"8\": \"def:function\",\n" " \"21\": \"def:function\",\n" @@ -43,12 +49,7 @@ const std::string configjson = " \"702\": \"def:statement\",\n" " \"705\": \"def:comment\"\n" " },\n" -" \"auto_tab_char_and_size\": true, //Use false to always use default tab char and size\n" -" \"default_tab_char\": \" \", //Use \"\\t\" for regular tab\n" -" \"default_tab_size\": 2,\n" -" \"wrap_lines\": false,\n" -" \"highlight_current_line\": true,\n" -" \"show_line_numbers\": true\n" +" \"clang_format_style\": \"UseTab: Never, ColumnLimit: 0\" //See http://clang.llvm.org/docs/ClangFormatStyleOptions.html\n" " },\n" " \"keybindings\": {\n" " \"new_file\": \"n\",\n" diff --git a/src/source.h b/src/source.h index 14f46c4..bb7a308 100644 --- a/src/source.h +++ b/src/source.h @@ -36,6 +36,7 @@ namespace Source { bool highlight_current_line; bool show_line_numbers; std::unordered_map clang_types; + std::string clang_format_style; std::unordered_map documentation_searches; }; diff --git a/src/source_clang.cc b/src/source_clang.cc index 4d990cd..d855131 100644 --- a/src/source_clang.cc +++ b/src/source_clang.cc @@ -936,6 +936,8 @@ Source::ClangViewAutocomplete(file_path, project_path, language) { juci::filesystem::write(temp_file_path, get_buffer()); std::string command="clang-format \""+temp_file_path.string()+"\""; command+=" -style=\"{IndentWidth: "+std::to_string(tab_size); + if(Singleton::Config::source()->clang_format_style!="") + command+=", "+Singleton::Config::source()->clang_format_style; command+="}\""; std::stringstream stdout_stream;