diff --git a/src/ctags.cpp b/src/ctags.cpp index c9eb378..cd57f0a 100644 --- a/src/ctags.cpp +++ b/src/ctags.cpp @@ -6,7 +6,7 @@ #include #include -Ctags::Ctags(const boost::filesystem::path &path, bool enable_scope, bool enable_kind) : enable_scope(enable_scope), enable_kind(enable_kind) { +Ctags::Ctags(const boost::filesystem::path &path, bool enable_scope, bool enable_kind, const std::string &languages) : enable_scope(enable_scope), enable_kind(enable_kind) { std::string fields(" --fields=n"); if(enable_scope) fields += 's'; @@ -24,7 +24,8 @@ Ctags::Ctags(const boost::filesystem::path &path, bool enable_scope, bool enable } else project_path = path; - command = Config::get().project.ctags_command + exclude + fields + " --sort=foldcase -I \"override noexcept\" -f - -R *"; + auto extra = !languages.empty() ? " --languages=" + languages : std::string(); + command = Config::get().project.ctags_command + exclude + fields + extra + " --sort=foldcase -I \"override noexcept\" -f - -R *"; } else { project_path = path.parent_path(); @@ -203,8 +204,8 @@ std::vector Ctags::get_type_parts(const std::string &type) { return parts; } -std::vector Ctags::get_locations(const boost::filesystem::path &path, const std::string &name, const std::string &type) { - Ctags ctags(path, true); +std::vector Ctags::get_locations(const boost::filesystem::path &path, const std::string &name, const std::string &type, const std::string &languages) { + Ctags ctags(path, true, false, languages); if(!ctags) return {}; diff --git a/src/ctags.hpp b/src/ctags.hpp index df55b38..1efb1b1 100644 --- a/src/ctags.hpp +++ b/src/ctags.hpp @@ -18,7 +18,7 @@ public: operator bool() const { return !file_path.empty(); } }; - Ctags(const boost::filesystem::path &path, bool enable_scope = false, bool enable_kind = false); + Ctags(const boost::filesystem::path &path, bool enable_scope = false, bool enable_kind = false, const std::string &languages = {}); operator bool(); @@ -27,7 +27,7 @@ public: boost::filesystem::path project_path; std::stringstream output; - static std::vector get_locations(const boost::filesystem::path &path, const std::string &name, const std::string &type); + static std::vector get_locations(const boost::filesystem::path &path, const std::string &name, const std::string &type, const std::string &languages = {}); private: bool enable_scope, enable_kind; diff --git a/src/source_clang.cpp b/src/source_clang.cpp index a59dd3c..4ec8f4d 100644 --- a/src/source_clang.cpp +++ b/src/source_clang.cpp @@ -1391,7 +1391,7 @@ Source::ClangViewRefactor::ClangViewRefactor(const boost::filesystem::path &file name.insert(0, spelling); parent = parent.get_semantic_parent(); } - auto ctags_locations = Ctags::get_locations(this->file_path.parent_path(), name, identifier.cursor.get_type_description()); + auto ctags_locations = Ctags::get_locations(this->file_path.parent_path(), name, identifier.cursor.get_type_description(), is_cpp ? "C++,C" : "C"); if(!ctags_locations.empty()) { for(auto &ctags_location : ctags_locations) { Offset offset;