Skip to content

Commit

Permalink
Merge pull request #134 from Genio-The-Haiku-IDE/feature/lsp-separte-…
Browse files Browse the repository at this point in the history
…log-config
  • Loading branch information
Freaxed authored Oct 31, 2023
2 parents 9986a73 + 16f3cf2 commit c2f4adb
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 10 deletions.
16 changes: 15 additions & 1 deletion src/GenioApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <StringList.h>

#include <getopt.h>

#include "LSPLogLevels.h"
#include "ConfigManager.h"
#include "GenioNamespace.h"

Expand Down Expand Up @@ -303,6 +303,20 @@ GenioApp::PrepareConfig(ConfigManager& cfg)
cfg.AddConfig("Editor/Find", "find_whole_word", B_TRANSLATE("Whole word"), false);
cfg.AddConfig("Editor/Find", "find_match_case", B_TRANSLATE("Match case"), false);


GMessage lsplevels = {{ {"mode", "options"},
{"note", B_TRANSLATE("This setting will be updated on restart")}
}};

lsplevels["option_1"]["value"] = (int32)lsp_log_level::LSP_LOG_LEVEL_ERROR;
lsplevels["option_1"]["label"] = "Error";
lsplevels["option_2"]["value"] = (int32)lsp_log_level::LSP_LOG_LEVEL_INFO;
lsplevels["option_2"]["label"] = "Info";
lsplevels["option_3"]["value"] = (int32)lsp_log_level::LSP_LOG_LEVEL_TRACE;
lsplevels["option_3"]["label"] = "Trace";

cfg.AddConfig("LSP", "lsp_log_level", B_TRANSLATE("Log level:"), (int32)lsp_log_level::LSP_LOG_LEVEL_ERROR, &lsplevels);

cfg.AddConfig("Hidden", "ui_bounds", "", BRect(40, 40, 839, 639));
}

Expand Down
12 changes: 11 additions & 1 deletion src/config/ConfigWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <ScrollView.h>
#include <TextControl.h>
#include <Window.h>
#include <StringView.h>

#include "ConfigManager.h"

Expand Down Expand Up @@ -278,6 +279,8 @@ ConfigWindow::MakeViewFor(const char* groupName, GMessage& list)
return nullptr;

settingLayout->AddView(parameterView);
if (msg.Has("note"))
settingLayout->AddView(MakeNoteView(msg));
}

settingLayout->AddItem(BSpaceLayoutItem::CreateHorizontalStrut(10));
Expand All @@ -286,7 +289,14 @@ ConfigWindow::MakeViewFor(const char* groupName, GMessage& list)
return view;
}


BView*
ConfigWindow::MakeNoteView(GMessage& config)
{
BString name((const char*)config["key"]);
name << "_note";
BStringView* view = new BStringView(name.String(), config["note"]);
return view;
}

BView*
ConfigWindow::MakeControlFor(GMessage& config)
Expand Down
1 change: 1 addition & 0 deletions src/config/ConfigWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class ConfigWindow : public BWindow {

BView* MakeViewFor(const char* groupName, GMessage& config);
BView* MakeControlFor(GMessage& config);
BView* MakeNoteView(GMessage& config);

private:

Expand Down
11 changes: 11 additions & 0 deletions src/lsp-client/LSPLogLevels.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* Copyright 2023, Andrea Anzani <andrea.anzani@gmail.com>
* All rights reserved. Distributed under the terms of the MIT license.
*/
#pragma once

enum lsp_log_level {
LSP_LOG_LEVEL_ERROR = 0,
LSP_LOG_LEVEL_INFO = 1,
LSP_LOG_LEVEL_TRACE = 2
};
14 changes: 6 additions & 8 deletions src/lsp-client/LSPProjectWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
#include "LSPReaderThread.h"
#include "LSPTextDocument.h"
#include "protocol.h"

#include "LSPLogLevels.h"
#include "ConfigManager.h"
#include <Url.h>


Expand Down Expand Up @@ -57,17 +58,14 @@ LSPProjectWrapper::_Create()
fLSPPipeClient = new LSPPipeClient(*((MessageHandler*) this));
/** configuration for clangd */
std::string logLevel("--log=");
switch (Logger::Level()) {
case LOG_LEVEL_UNSET:
case LOG_LEVEL_OFF:
case LOG_LEVEL_ERROR:
switch ((int32)gCFG["lsp_log_level"]) {
case LSP_LOG_LEVEL_ERROR:
logLevel += "error"; // Error messages only
break;
case LOG_LEVEL_INFO:
case LSP_LOG_LEVEL_INFO:
logLevel += "info"; // High level execution tracing
break;
case LOG_LEVEL_DEBUG:
case LOG_LEVEL_TRACE:
case LSP_LOG_LEVEL_TRACE:
logLevel += "verbose"; // Low level details
break;
};
Expand Down

0 comments on commit c2f4adb

Please sign in to comment.