🐛 fix(server): load interpreter funcext symbols

- Wire `--interpreter=...` into server startup.
- Auto-load `<interpreter>/funcext` as a system library via Symbol::LoadSystemLibrary.
This commit is contained in:
csh 2025-12-14 13:08:50 +08:00
parent 7d1db3f3ac
commit 2c9c0b2d8f
2 changed files with 24 additions and 3 deletions

View File

@ -24,7 +24,7 @@ export int Run(int argc, char* argv[])
try
{
spdlog::info("TSL-LSP server starting...");
lsp::core::LspServer server(config.thread_count);
lsp::core::LspServer server(config.thread_count, config.interpreter_path);
server.Run();
}
catch (const std::exception& e)

View File

@ -15,6 +15,7 @@ import lsp.core.dispacther;
import lsp.protocol;
import lsp.codec.facade;
import lsp.manager.manager_hub;
import lsp.manager.bootstrap;
import lsp.scheduler.async_executor;
import lsp.provider.base.interface;
import lsp.provider.base.registry;
@ -37,7 +38,8 @@ export namespace lsp::core
class LspServer
{
public:
LspServer(std::size_t concurrency = std::thread::hardware_concurrency());
explicit LspServer(std::size_t concurrency = std::thread::hardware_concurrency(),
std::string interpreter_path = "");
~LspServer();
void Run();
@ -80,6 +82,7 @@ export namespace lsp::core
RequestDispatcher dispatcher_;
scheduler::AsyncExecutor async_executor_;
manager::ManagerHub manager_hub_;
std::string interpreter_path_;
std::atomic<bool> is_initialized_ = false;
std::atomic<bool> is_shutting_down_ = false;
@ -89,7 +92,8 @@ export namespace lsp::core
namespace lsp::core
{
LspServer::LspServer(std::size_t concurrency) : async_executor_(concurrency)
LspServer::LspServer(std::size_t concurrency, std::string interpreter_path) : async_executor_(concurrency),
interpreter_path_(std::move(interpreter_path))
{
spdlog::info("Initializing LSP server with {} worker threads", concurrency);
@ -378,6 +382,23 @@ namespace lsp::core
void LspServer::InitializeManagerHub()
{
manager_hub_.Initialize();
if (!interpreter_path_.empty())
{
std::filesystem::path base = interpreter_path_;
std::filesystem::path funcext_path = base / "funcext";
if (std::filesystem::exists(funcext_path))
{
manager::bootstrap::InitializeManagerHub(
manager_hub_,
async_executor_,
{ funcext_path.string() });
}
else
{
spdlog::warn("Interpreter funcext path does not exist: {}", funcext_path.string());
}
}
}
void LspServer::RegisterProviders()