From 54400ccf838a3547c824fc390c1eab071a8855e2 Mon Sep 17 00:00:00 2001 From: eidheim Date: Tue, 8 Oct 2024 10:21:52 +0200 Subject: [PATCH] Cleanup of clang language server commits --- CMakeLists.txt | 2 +- docs/language_servers.md | 13 ++++++++----- src/config.cpp | 2 -- src/config.hpp | 2 -- src/notebook.cpp | 6 +++--- src/source_clang.cpp | 5 ----- src/source_clang.hpp | 3 --- 7 files changed, 12 insertions(+), 21 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d6dbee8..8618152 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.5) project(juci) -set(JUCI_VERSION "1.8.0.3") +set(JUCI_VERSION "1.8.0.2") set(CPACK_PACKAGE_NAME "jucipp") set(CPACK_PACKAGE_CONTACT "Ole Christian Eidheim ") diff --git a/docs/language_servers.md b/docs/language_servers.md index 8bbfba4..fbd00f2 100644 --- a/docs/language_servers.md +++ b/docs/language_servers.md @@ -6,7 +6,7 @@ - [Go](#go) - [Julia](#julia) - [GLSL](#glsl) -- [C++](#cpp) +- [C/C++](#cc) ## JavaScript/TypeScript @@ -177,14 +177,17 @@ echo '#!/bin/sh chmod 755 /usr/local/bin/glsl-language-server ``` -## C++ +## C/C++ + +**Note that we recommend using the builtin C/C++ support in juCi++ instead.** - Prerequisites: - - A language server installed on your system (clangd or ccls) + - A language server installed on your system, for example clangd or ccls -Create symbolic link to enable language server in juCi++. For example, if you have the clangd installed and available on path: +Create symbolic link to enable language server in juCi++. For example, if you have the clangd +installed and available on path: ```sh # Usually as root: -ln -s `which clangd` /usr/local/bin/cpp-language-server +ln -s `which clangd` /usr/local/bin/clang-language-server ``` diff --git a/src/config.cpp b/src/config.cpp index 26e4044..663864d 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -155,7 +155,6 @@ 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.clang_format_style = source_json.string("clang_format_style"); source.clang_usages_threads = static_cast(source_json.integer("clang_usages_threads", JSON::ParseOptions::accept_string)); source.clang_tidy_enable = source_json.boolean("clang_tidy_enable", JSON::ParseOptions::accept_string); @@ -302,7 +301,6 @@ std::string Config::default_config() { "auto_reload_changed_files": true, "search_for_selection": true, "tooltip_top_offset": 0, - "use_lsp_for_c_languages": false, "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", diff --git a/src/config.hpp b/src/config.hpp index 012a904..ebc0e15 100644 --- a/src/config.hpp +++ b/src/config.hpp @@ -99,8 +99,6 @@ public: bool search_for_selection; int tooltip_top_offset; - bool use_lsp_for_c_languages; - std::string clang_format_style; unsigned clang_usages_threads; diff --git a/src/notebook.cpp b/src/notebook.cpp index 792bcde..7172583 100644 --- a/src/notebook.cpp +++ b/src/notebook.cpp @@ -207,9 +207,9 @@ bool Notebook::open(const boost::filesystem::path &file_path_, Position position } size_t source_views_previous_size = source_views.size(); - if(Source::ClangView::IsCompatibleWithLanguage(language_id)) { - if(Config::get().source.use_lsp_for_c_languages && !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"))); + if(language_id == "chdr" || language_id == "cpphdr" || language_id == "c" || language_id == "cpp" || language_id == "objc") { + if(!filesystem::find_executable("clang-language-server").empty()) + source_views.emplace_back(new Source::LanguageProtocolView(file_path, language, language_protocol_language_id, "clang-language-server")); else source_views.emplace_back(new Source::ClangView(file_path, language)); } diff --git a/src/source_clang.cpp b/src/source_clang.cpp index 398c414..9550ae1 100644 --- a/src/source_clang.cpp +++ b/src/source_clang.cpp @@ -18,11 +18,6 @@ const std::regex include_regex(R"(^[ \t]*#[ \t]*include[ \t]*[<"]([^<>"]+)[>"].*$)", std::regex::optimize); -const std::set Source::ClangView::CTypeLanguages = {"c", "cpp", "chdr", "cpphdr", "objc"}; -bool Source::ClangView::IsCompatibleWithLanguage(const std::string &language_id) { - return (Source::ClangView::CTypeLanguages.find(language_id) != Source::ClangView::CTypeLanguages.end()); -} - Source::ClangViewParse::ClangViewParse(const boost::filesystem::path &file_path, const Glib::RefPtr &language) : BaseView(file_path, language), Source::View(file_path, language) { Usages::Clang::erase_cache(file_path); diff --git a/src/source_clang.hpp b/src/source_clang.hpp index a16d0d8..78fd573 100644 --- a/src/source_clang.hpp +++ b/src/source_clang.hpp @@ -118,13 +118,10 @@ 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 CTypeLanguages; }; } // namespace Source