| 54 | } |
| 55 | |
| 56 | std::shared_ptr<lsp::InitializeResult> LSPHandle::OnInitialize(std::shared_ptr<lsp::InitializeParams> params) { |
| 57 | _server->InitializeService(); |
| 58 | |
| 59 | auto result = std::make_shared<lsp::InitializeResult>(); |
| 60 | |
| 61 | result->capabilities.documentFormattingProvider = true; |
| 62 | result->capabilities.documentRangeFormattingProvider = true; |
| 63 | |
| 64 | lsp::DocumentOnTypeFormattingOptions typeOptions; |
| 65 | |
| 66 | typeOptions.firstTriggerCharacter = "\n"; |
| 67 | |
| 68 | result->capabilities.documentOnTypeFormattingProvider = typeOptions; |
| 69 | |
| 70 | result->capabilities.textDocumentSync.change = lsp::TextDocumentSyncKind::Incremental; |
| 71 | result->capabilities.textDocumentSync.openClose = true; |
| 72 | |
| 73 | result->capabilities.codeActionProvider = true; |
| 74 | result->capabilities.executeCommandProvider.commands = |
| 75 | _server->GetService<CommandService>()->GetCommands(); |
| 76 | |
| 77 | result->capabilities.diagnosticProvider.identifier = "EmmyLuaCodeStyle"; |
| 78 | result->capabilities.diagnosticProvider.workspaceDiagnostics = false; |
| 79 | result->capabilities.diagnosticProvider.interFileDependencies = false; |
| 80 | |
| 81 | auto &editorConfigFiles = params->initializationOptions.editorConfigFiles; |
| 82 | for (auto &configFile: editorConfigFiles) { |
| 83 | _server->GetService<ConfigService>()->LoadEditorconfig(configFile.workspace, configFile.path); |
| 84 | } |
| 85 | |
| 86 | std::filesystem::path localePath = params->initializationOptions.localeRoot; |
| 87 | localePath /= params->locale + ".json"; |
| 88 | |
| 89 | if (std::filesystem::exists(localePath) && std::filesystem::is_regular_file(localePath)) { |
| 90 | _server->GetService<ConfigService>()->LoadLanguageTranslator(localePath.string()); |
| 91 | } |
| 92 | |
| 93 | |
| 94 | // if (!param->initializationOptions.extensionChars.empty()) { |
| 95 | // for (auto &c: param->initializationOptions.extensionChars) { |
| 96 | // LuaIdentify::AddIdentifyChar(c); |
| 97 | // } |
| 98 | // } |
| 99 | |
| 100 | auto dictionaryPath = params->initializationOptions.dictionaryPath; |
| 101 | if (!dictionaryPath.empty()) { |
| 102 | for (auto &path: dictionaryPath) { |
| 103 | _server->GetService<DiagnosticService>()->GetSpellChecker()->LoadDictionary(path); |
| 104 | } |
| 105 | } |
| 106 | return result; |
| 107 | } |
| 108 | |
| 109 | std::shared_ptr<lsp::Serializable> LSPHandle::OnInitialized(std::shared_ptr<lsp::Serializable> param) { |
| 110 | return nullptr; |
nothing calls this directly
no test coverage detected