From dfd4ef7f83918dc3eee674cda0914fa19af781fb Mon Sep 17 00:00:00 2001 From: Shivang Gangadia Date: Mon, 30 Sep 2024 20:17:37 +0100 Subject: [PATCH] Restored C++14, made C++ language server access through symbolic linnk. Updated documentation. --- CMakeLists.txt | 2 +- docs/language_servers.md | 13 +++++++++++++ src/config.cpp | 2 -- src/config.hpp | 1 - src/notebook.cpp | 4 ++-- src/source_clang.cpp | 4 ++-- 6 files changed, 18 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c75d410..d6dbee8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,7 +26,7 @@ endif(CCACHE_FOUND) include(CPack) -set(CMAKE_CXX_STANDARD 20) +set(CMAKE_CXX_STANDARD 14) add_compile_options(-pthread -Wall -Wextra -Wno-unused-parameter -Wno-deprecated-declarations) add_definitions(-DJUCI_VERSION="${JUCI_VERSION}") diff --git a/docs/language_servers.md b/docs/language_servers.md index 8a0c606..8bbfba4 100644 --- a/docs/language_servers.md +++ b/docs/language_servers.md @@ -6,6 +6,7 @@ - [Go](#go) - [Julia](#julia) - [GLSL](#glsl) +- [C++](#cpp) ## JavaScript/TypeScript @@ -175,3 +176,15 @@ echo '#!/bin/sh /usr/local/bin/glslls --stdin' > /usr/local/bin/glsl-language-server chmod 755 /usr/local/bin/glsl-language-server ``` + +## C++ + +- Prerequisites: + - A language server installed on your system (clangd or ccls) + +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 +``` diff --git a/src/config.cpp b/src/config.cpp index 18b9c1f..26e4044 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -156,7 +156,6 @@ void Config::read(const JSON &cfg) { 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(source_json.integer("clang_usages_threads", JSON::ParseOptions::accept_string)); source.clang_tidy_enable = source_json.boolean("clang_tidy_enable", JSON::ParseOptions::accept_string); @@ -304,7 +303,6 @@ std::string Config::default_config() { "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", diff --git a/src/config.hpp b/src/config.hpp index 43d050a..012a904 100644 --- a/src/config.hpp +++ b/src/config.hpp @@ -100,7 +100,6 @@ public: 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; diff --git a/src/notebook.cpp b/src/notebook.cpp index 8524a35..792bcde 100644 --- a/src/notebook.cpp +++ b/src/notebook.cpp @@ -208,8 +208,8 @@ 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 && 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))); + 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"))); else source_views.emplace_back(new Source::ClangView(file_path, language)); } diff --git a/src/source_clang.cpp b/src/source_clang.cpp index db484e1..398c414 100644 --- a/src/source_clang.cpp +++ b/src/source_clang.cpp @@ -19,8 +19,8 @@ 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 &languageId) { - return Source::ClangView::CTypeLanguages.contains(languageId); +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)