支持全局函数补全

This commit is contained in:
csh
2025-09-27 22:23:04 +08:00
parent aac12137cb
commit dc713e6893
220 changed files with 195514 additions and 195869 deletions
+37 -16
View File
@@ -5,36 +5,44 @@
namespace lsp::utils
{
ServerConfig ArgsParser::Parse(int argc, char* argv[])
ArgsParser& ArgsParser::GetInstance()
{
ServerConfig config;
static ArgsParser instance;
return instance;
}
const ServerConfig& ArgsParser::Parse(int argc, char* argv[])
{
config_ = ServerConfig {};
bool use_stdio = false;
for (int i = 1; i < argc; ++i)
{
std::string arg = argv[i];
if (arg == "--help")
{
config.show_help = true;
return config;
config_.show_help = true;
return config_;
}
if (arg == "--log=trace")
config.log_level = spdlog::level::trace;
config_.log_level = spdlog::level::trace;
else if (arg == "--log=debug")
config.log_level = spdlog::level::debug;
config_.log_level = spdlog::level::debug;
else if (arg == "--log=info")
config.log_level = spdlog::level::info;
config_.log_level = spdlog::level::info;
else if (arg == "--log=warn")
config.log_level = spdlog::level::warn;
config_.log_level = spdlog::level::warn;
else if (arg == "--log=error")
config.log_level = spdlog::level::err;
config_.log_level = spdlog::level::err;
else if (arg == "--log=off")
config.log_level = spdlog::level::off;
config_.log_level = spdlog::level::off;
else if (arg.find("--log-file=") == 0)
config.log_file = arg.substr(11);
config_.log_file = arg.substr(11);
else if (arg == "--log-stderr")
config.use_stderr = true;
config_.use_stderr = true;
else if (arg.find("--interpreter=") == 0)
config_.interpreter_path = arg.substr(14);
else if (arg.find("--threads=") == 0)
{
std::string count_str = arg.substr(10);
@@ -46,7 +54,7 @@ namespace lsp::utils
std::cerr << "[TSL-LSP] Error: Thread count must be between 1 and 32" << std::endl;
std::exit(1);
}
config.thread_count = count;
config_.thread_count = count;
}
catch (const std::exception&)
{
@@ -56,7 +64,7 @@ namespace lsp::utils
}
else if (arg == "--stdio")
{
std::cerr << "[TSL-LSP] JosnRPc using stdio" << std::endl;
use_stdio = true;
}
else
{
@@ -64,8 +72,17 @@ namespace lsp::utils
std::cerr << "Use --help for usage information" << std::endl;
}
}
std::cerr << "TSL Language Server " << __DATE__ << std::endl;
if (use_stdio)
std::cerr << "[TSL-LSP] JosnRPc using stdio" << std::endl;
return config;
// config_.interpreter_path = "/mnt/c/Programs/Tinysoft/TSLGen2/";
return config_;
}
const ServerConfig& ArgsParser::GetConfig() const
{
return config_;
}
void ArgsParser::SetupLogger(const ServerConfig& config)
@@ -103,13 +120,17 @@ namespace lsp::utils
hardware_threads = 0; // 表示无法检测
std::cout << "TSL Language Server Protocol (LSP) Server\n"
<< "Version: 1.0.0 (" << __DATE__ << " build)\n"
<< "Version: " << __DATE__ << " build\n"
<< "\n"
<< "Usage: " << program_name << " [options]\n"
<< "\n"
<< "Options:\n"
<< " --help Show this help message and exit\n"
<< "\n"
<< "Interpreter options:\n"
<< " --interpreter=PATH Set path to TSL interpreter executable\n"
<< " Required for some language features\n"
<< "\n"
<< "Logging options:\n"
<< " --log=LEVEL Set log level (trace, debug, info, warn, error, off)\n"
<< " Default: info\n"