HackStudio: Enable CMake syntax highlighting

This commit is contained in:
Sam Atkins 2023-02-28 16:29:49 +00:00 committed by Andrew Kaster
parent ac824677b8
commit 0d0ad22572
Notes: sideshowbarker 2024-07-17 09:49:33 +09:00
4 changed files with 10 additions and 2 deletions

View file

@ -55,5 +55,5 @@ set(GENERATED_SOURCES
)
serenity_app(HackStudio ICON app-hack-studio)
target_link_libraries(HackStudio PRIVATE LibWebView LibWeb LibMarkdown LibGUI LibCpp LibGfx LibCore LibVT LibDebug LibX86 LibDiff LibShell LibSymbolication LibSyntax LibRegex LibSQL LibConfig LibCore LibCoredump LibDesktop LibIPC LibJS LibMain LibThreading)
target_link_libraries(HackStudio PRIVATE LibWebView LibWeb LibMarkdown LibGUI LibCpp LibCMake LibGfx LibCore LibVT LibDebug LibX86 LibDiff LibShell LibSymbolication LibSyntax LibRegex LibSQL LibConfig LibCore LibCoredump LibDesktop LibIPC LibJS LibMain LibThreading)
add_dependencies(HackStudio CppLanguageServer)

View file

@ -14,6 +14,7 @@
#include <AK/Debug.h>
#include <AK/JsonParser.h>
#include <AK/LexicalPath.h>
#include <LibCMake/SyntaxHighlighter.h>
#include <LibConfig/Client.h>
#include <LibCore/DeprecatedFile.h>
#include <LibCore/DirIterator.h>
@ -636,6 +637,9 @@ void Editor::set_syntax_highlighter_for(CodeDocument const& document)
} else
set_syntax_highlighter(make<Cpp::SyntaxHighlighter>());
break;
case Language::CMake:
set_syntax_highlighter(make<CMake::SyntaxHighlighter>());
break;
case Language::CSS:
set_syntax_highlighter(make<Web::CSS::SyntaxHighlighter>());

View file

@ -5,7 +5,6 @@
*/
#include "Language.h"
#include <AK/LexicalPath.h>
namespace HackStudio {
@ -19,6 +18,8 @@ Language language_from_file(LexicalPath const& file)
if (extension == "c" || extension == "cc" || extension == "cxx" || extension == "cpp" || extension == "c++"
|| extension == "h" || extension == "hh" || extension == "hxx" || extension == "hpp" || extension == "h++")
return Language::Cpp;
if (extension == "cmake" || (extension == "txt" && file.title() == "CMakeLists"))
return Language::CMake;
if (extension == "js" || extension == "mjs" || extension == "json")
return Language::JavaScript;
if (extension == "html" || extension == "htm")
@ -61,6 +62,8 @@ DeprecatedString language_name_from_file(LexicalPath const& file)
if (extension == "c" || extension == "cc" || extension == "cxx" || extension == "cpp" || extension == "c++"
|| extension == "h" || extension == "hh" || extension == "hxx" || extension == "hpp" || extension == "h++")
return "C++";
if (extension == "cmake" || (extension == "txt" && file.title() == "CMakeLists"))
return "CMake";
if (extension == "js" || extension == "mjs" || extension == "json")
return "JavaScript";
if (extension == "gml")

View file

@ -12,6 +12,7 @@
namespace HackStudio {
enum class Language {
Unknown,
CMake,
Cpp,
CSS,
JavaScript,