tree-sitter and lsp-methods
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
#include <spdlog/spdlog.h>
|
||||
#include "./initialize.hpp"
|
||||
#include "../../protocol/transform/facade.hpp"
|
||||
|
||||
namespace lsp::providers
|
||||
{
|
||||
std::string Initialize::GetMethod() const
|
||||
{
|
||||
return "initialize";
|
||||
}
|
||||
|
||||
std::string Initialize::GetProviderName() const
|
||||
{
|
||||
return "Initialize";
|
||||
}
|
||||
|
||||
std::string Initialize::ProvideResponse(const protocol::RequestMessage& request, ExecutionContext& context)
|
||||
{
|
||||
spdlog::debug("InitializeProvider: Providing response for method {}", request.method);
|
||||
|
||||
protocol::ResponseMessage response;
|
||||
response.id = request.id;
|
||||
response.result = transform::LSPAny(BuildInitializeResult());
|
||||
std::optional<std::string> json = transform::Serialize(response);
|
||||
if (!json.has_value())
|
||||
{
|
||||
context.TriggerLifecycleEvent(ServerLifecycleEvent::kInitializeFailed);
|
||||
return BuildErrorResponseMessage(request, protocol::ErrorCodes::kInternalError, "Internal error");
|
||||
}
|
||||
context.TriggerLifecycleEvent(ServerLifecycleEvent::kInitialized);
|
||||
return json.value();
|
||||
}
|
||||
|
||||
protocol::InitializeResult Initialize::BuildInitializeResult()
|
||||
{
|
||||
protocol::InitializeResult result;
|
||||
result.serverInfo.name = "TSL Language Server";
|
||||
result.serverInfo.version = "1.0.0";
|
||||
protocol::TextDocumentSyncOptions text_document_sync_options;
|
||||
text_document_sync_options.openClose = true;
|
||||
text_document_sync_options.change = protocol::TextDocumentSyncKind::kIncremental;
|
||||
protocol::CompletionOptions completion_provider;
|
||||
completion_provider.resolveProvider = false;
|
||||
protocol::SemanticTokensOptions semantic_tokens_options;
|
||||
semantic_tokens_options.legend.tokenTypes.emplace_back(protocol::SemanticTokenTypesLiterals::Namespace);
|
||||
semantic_tokens_options.legend.tokenTypes.emplace_back(protocol::SemanticTokenTypesLiterals::Type);
|
||||
semantic_tokens_options.legend.tokenTypes.emplace_back(protocol::SemanticTokenTypesLiterals::Class);
|
||||
semantic_tokens_options.legend.tokenTypes.emplace_back(protocol::SemanticTokenTypesLiterals::Enum);
|
||||
semantic_tokens_options.legend.tokenTypes.emplace_back(protocol::SemanticTokenTypesLiterals::Interface);
|
||||
semantic_tokens_options.legend.tokenTypes.emplace_back(protocol::SemanticTokenTypesLiterals::Struct);
|
||||
semantic_tokens_options.legend.tokenTypes.emplace_back(protocol::SemanticTokenTypesLiterals::TypeParameter);
|
||||
semantic_tokens_options.legend.tokenTypes.emplace_back(protocol::SemanticTokenTypesLiterals::Parameter);
|
||||
semantic_tokens_options.legend.tokenTypes.emplace_back(protocol::SemanticTokenTypesLiterals::Variable);
|
||||
semantic_tokens_options.legend.tokenTypes.emplace_back(protocol::SemanticTokenTypesLiterals::Property);
|
||||
semantic_tokens_options.legend.tokenTypes.emplace_back(protocol::SemanticTokenTypesLiterals::EnumMember);
|
||||
semantic_tokens_options.legend.tokenTypes.emplace_back(protocol::SemanticTokenTypesLiterals::Event);
|
||||
semantic_tokens_options.legend.tokenTypes.emplace_back(protocol::SemanticTokenTypesLiterals::Function);
|
||||
semantic_tokens_options.legend.tokenTypes.emplace_back(protocol::SemanticTokenTypesLiterals::Method);
|
||||
semantic_tokens_options.legend.tokenTypes.emplace_back(protocol::SemanticTokenTypesLiterals::Macro);
|
||||
semantic_tokens_options.legend.tokenTypes.emplace_back(protocol::SemanticTokenTypesLiterals::Keyword);
|
||||
semantic_tokens_options.legend.tokenTypes.emplace_back(protocol::SemanticTokenTypesLiterals::Modifier);
|
||||
semantic_tokens_options.legend.tokenTypes.emplace_back(protocol::SemanticTokenTypesLiterals::Comment);
|
||||
semantic_tokens_options.legend.tokenTypes.emplace_back(protocol::SemanticTokenTypesLiterals::String);
|
||||
semantic_tokens_options.legend.tokenTypes.emplace_back(protocol::SemanticTokenTypesLiterals::Number);
|
||||
semantic_tokens_options.legend.tokenTypes.emplace_back(protocol::SemanticTokenTypesLiterals::Regexp);
|
||||
semantic_tokens_options.legend.tokenTypes.emplace_back(protocol::SemanticTokenTypesLiterals::Operator);
|
||||
semantic_tokens_options.legend.tokenTypes.emplace_back(protocol::SemanticTokenTypesLiterals::Decorator);
|
||||
semantic_tokens_options.legend.tokenModifiers.emplace_back(protocol::SemanticTokenModifiersLiterals::Declaration);
|
||||
semantic_tokens_options.legend.tokenModifiers.emplace_back(protocol::SemanticTokenModifiersLiterals::Definition);
|
||||
semantic_tokens_options.legend.tokenModifiers.emplace_back(protocol::SemanticTokenModifiersLiterals::Readonly);
|
||||
semantic_tokens_options.legend.tokenModifiers.emplace_back(protocol::SemanticTokenModifiersLiterals::Static);
|
||||
semantic_tokens_options.legend.tokenModifiers.emplace_back(protocol::SemanticTokenModifiersLiterals::Deprecated);
|
||||
semantic_tokens_options.legend.tokenModifiers.emplace_back(protocol::SemanticTokenModifiersLiterals::Abstract);
|
||||
semantic_tokens_options.legend.tokenModifiers.emplace_back(protocol::SemanticTokenModifiersLiterals::Async);
|
||||
semantic_tokens_options.legend.tokenModifiers.emplace_back(protocol::SemanticTokenModifiersLiterals::Modification);
|
||||
semantic_tokens_options.legend.tokenModifiers.emplace_back(protocol::SemanticTokenModifiersLiterals::Documentation);
|
||||
semantic_tokens_options.legend.tokenModifiers.emplace_back(protocol::SemanticTokenModifiersLiterals::DefaultLibrary);
|
||||
semantic_tokens_options.range = true;
|
||||
semantic_tokens_options.full = protocol::SemanticTokensOptions::Full{.delta = true};
|
||||
|
||||
result.capabilities.textDocumentSync = text_document_sync_options;
|
||||
result.capabilities.completionProvider = completion_provider;
|
||||
result.capabilities.semanticTokensProvider = semantic_tokens_options;
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user