diff --git a/CMakeLists.txt b/CMakeLists.txt index 145d3bd..e9b7928 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required (VERSION 2.8.8) project(juci) -set(JUCI_VERSION "1.6.0.1") +set(JUCI_VERSION "1.6.0.2") set(CPACK_PACKAGE_NAME "jucipp") set(CPACK_PACKAGE_CONTACT "Ole Christian Eidheim ") diff --git a/README.md b/README.md index f1421c6..da536c6 100644 --- a/README.md +++ b/README.md @@ -13,12 +13,7 @@ towards libclang with speed, stability, and ease of use in mind. * Syntax highlighting for more than 100 different file types * C++ warnings and errors on the fly * C++ Fix-its -* Integrated Clang-Tidy checks possible through clang plugins, for instance (recreating existing build is needed): - -```sh - CXX=clang++ CXXFLAGS="-Xclang -add-plugin -Xclang clang-tidy -Xclang -plugin-arg-clang-tidy -Xclang -checks='-*, clang-analyzer-core.*'" juci [project-path] -``` - +* Integrated Clang-Tidy checks can be enabled in preferences * Debug integration, both local and remote, through lldb * Supports the following build systems: * CMake diff --git a/src/compile_commands.cc b/src/compile_commands.cc index 1422e75..9e3482d 100644 --- a/src/compile_commands.cc +++ b/src/compile_commands.cc @@ -1,5 +1,6 @@ #include "compile_commands.h" #include "clangmm.h" +#include "config.h" #include "terminal.h" #include #include @@ -238,6 +239,19 @@ std::vector CompileCommands::get_arguments(const boost::filesystem: arguments.emplace_back(build_path.string()); } + if(Config::get().source.enable_clang_tidy) { + arguments.emplace_back("-Xclang"); + arguments.emplace_back("-add-plugin"); + arguments.emplace_back("-Xclang"); + arguments.emplace_back("clang-tidy"); + if(!Config::get().source.clang_tidy_checks.empty()) { + arguments.emplace_back("-Xclang"); + arguments.emplace_back("-plugin-arg-clang-tidy"); + arguments.emplace_back("-Xclang"); + arguments.emplace_back("-checks=" + Config::get().source.clang_tidy_checks); + } + } + return arguments; } diff --git a/src/config.cc b/src/config.cc index a52dc9a..57a6c08 100644 --- a/src/config.cc +++ b/src/config.cc @@ -172,6 +172,8 @@ void Config::read(const boost::property_tree::ptree &cfg) { source.search_for_selection = source_json.get("search_for_selection"); source.clang_format_style = source_json.get("clang_format_style"); source.clang_usages_threads = static_cast(source_json.get("clang_usages_threads")); + source.enable_clang_tidy = source_json.get("enable_clang_tidy"); + source.clang_tidy_checks = source_json.get("clang_tidy_checks"); source.debug_place_cursor_at_stop = source_json.get("debug_place_cursor_at_stop"); auto pt_doc_search = cfg.get_child("documentation_searches"); for(auto &pt_doc_search_lang : pt_doc_search) { diff --git a/src/config.h b/src/config.h index 83b4395..5d9c596 100644 --- a/src/config.h +++ b/src/config.h @@ -95,6 +95,9 @@ public: std::string clang_format_style; unsigned clang_usages_threads; + bool enable_clang_tidy; + std::string clang_tidy_checks; + bool debug_place_cursor_at_stop; std::unordered_map documentation_searches; diff --git a/src/files.h b/src/files.h index ad092a3..cbb269c 100644 --- a/src/files.h +++ b/src/files.h @@ -67,6 +67,10 @@ const std::string default_config_file = R"RAW({ "clang_format_style": "ColumnLimit: 0, NamespaceIndentation: All", "clang_usages_threads_comment": "The number of threads used in finding usages in unparsed files. -1 corresponds to the number of cores available, and 0 disables the search", "clang_usages_threads": -1, + "enable_clang_tidy_comment": "Enable clang-tidy in new C/C++ buffers", + "enable_clang_tidy": false, + "clang_tidy_checks_comment": "In new C/C++ buffers, these checks are appended to the value of 'Checks' in the .clang-tidy file, if any", + "clang_tidy_checks": "", "debug_place_cursor_at_stop": false }, "terminal": {