Browse Source

Added support for optionally using LSP for c-like languages. Also bumped c++ version to 20 for project

pipelines/1486128344
Shivang Gangadia 1 year ago
parent
commit
aedd819fbe
  1. 4
      CMakeLists.txt
  2. 4
      src/config.cpp
  3. 3
      src/config.hpp
  4. 8
      src/notebook.cpp
  5. 5
      src/source_clang.cpp
  6. 3
      src/source_clang.hpp

4
CMakeLists.txt

@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.5)
project(juci)
set(JUCI_VERSION "1.8.0.2")
set(JUCI_VERSION "1.8.0.3")
set(CPACK_PACKAGE_NAME "jucipp")
set(CPACK_PACKAGE_CONTACT "Ole Christian Eidheim <eidheim@gmail.com>")
@ -26,7 +26,7 @@ endif(CCACHE_FOUND)
include(CPack)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD 20)
add_compile_options(-pthread -Wall -Wextra -Wno-unused-parameter -Wno-deprecated-declarations)
add_definitions(-DJUCI_VERSION="${JUCI_VERSION}")

4
src/config.cpp

@ -155,6 +155,8 @@ void Config::read(const JSON &cfg) {
source.auto_reload_changed_files = source_json.boolean("auto_reload_changed_files", JSON::ParseOptions::accept_string);
source.search_for_selection = source_json.boolean("search_for_selection", JSON::ParseOptions::accept_string);
source.tooltip_top_offset = source_json.integer("tooltip_top_offset", JSON::ParseOptions::accept_string);
source.use_lsp_for_c_languages = source_json.boolean("use_lsp_for_c_languages", JSON::ParseOptions::accept_string);
source.c_lsp_binary_name = source_json.string("c_lsp_binary_name");
source.clang_format_style = source_json.string("clang_format_style");
source.clang_usages_threads = static_cast<unsigned>(source_json.integer("clang_usages_threads", JSON::ParseOptions::accept_string));
source.clang_tidy_enable = source_json.boolean("clang_tidy_enable", JSON::ParseOptions::accept_string);
@ -301,6 +303,8 @@ std::string Config::default_config() {
"auto_reload_changed_files": true,
"search_for_selection": true,
"tooltip_top_offset": 0,
"use_lsp_for_c_languages": false,
"c_lsp_binary_name": "",
"clang_format_style_comment": "IndentWidth, AccessModifierOffset and UseTab are set automatically. See http://clang.llvm.org/docs/ClangFormatStyleOptions.html",
"clang_format_style": "ColumnLimit: 0, NamespaceIndentation: All",
"clang_tidy_enable_comment": "Enable clang-tidy in new C/C++ buffers",

3
src/config.hpp

@ -99,6 +99,9 @@ public:
bool search_for_selection;
int tooltip_top_offset;
bool use_lsp_for_c_languages;
std::string c_lsp_binary_name;
std::string clang_format_style;
unsigned clang_usages_threads;

8
src/notebook.cpp

@ -207,8 +207,12 @@ bool Notebook::open(const boost::filesystem::path &file_path_, Position position
}
size_t source_views_previous_size = source_views.size();
if(language_id == "chdr" || language_id == "cpphdr" || language_id == "c" || language_id == "cpp" || language_id == "objc")
source_views.emplace_back(new Source::ClangView(file_path, language));
if(Source::ClangView::IsCompatibleWithLanguage(language_id)) {
if(Config::get().source.use_lsp_for_c_languages && Config::get().source.c_lsp_binary_name.length() > 0 && !filesystem::find_executable(Config::get().source.c_lsp_binary_name).empty())
source_views.emplace_back(new Source::LanguageProtocolView(file_path, language, language_protocol_language_id, filesystem::escape_argument(Config::get().source.c_lsp_binary_name)));
else
source_views.emplace_back(new Source::ClangView(file_path, language));
}
else if(language && !language_protocol_language_id.empty() && !filesystem::find_executable(language_protocol_language_id + "-language-server").empty())
source_views.emplace_back(new Source::LanguageProtocolView(file_path, language, language_protocol_language_id, filesystem::escape_argument(language_protocol_language_id + "-language-server")));
else if(language && language_protocol_language_id == "rust") {

5
src/source_clang.cpp

@ -18,6 +18,11 @@
const std::regex include_regex(R"(^[ \t]*#[ \t]*include[ \t]*[<"]([^<>"]+)[>"].*$)", std::regex::optimize);
const std::set<std::string> Source::ClangView::CTypeLanguages = {"c", "cpp", "chdr", "cpphdr", "objc"};
bool Source::ClangView::IsCompatibleWithLanguage(const std::string &languageId) {
return Source::ClangView::CTypeLanguages.contains(languageId);
}
Source::ClangViewParse::ClangViewParse(const boost::filesystem::path &file_path, const Glib::RefPtr<Gsv::Language> &language)
: BaseView(file_path, language), Source::View(file_path, language) {
Usages::Clang::erase_cache(file_path);

3
src/source_clang.hpp

@ -118,10 +118,13 @@ namespace Source {
void full_reparse() override;
void async_delete();
static bool IsCompatibleWithLanguage(const std::string &languageId);
private:
Glib::Dispatcher do_delete_object;
std::thread delete_thread;
std::thread full_reparse_thread;
bool full_reparse_running = false;
static const std::set<std::string> CTypeLanguages;
};
} // namespace Source

Loading…
Cancel
Save