支持全局函数补全

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
@@ -2,7 +2,7 @@
#include "./initialize.hpp"
#include "../../protocol/transform/facade.hpp"
namespace lsp::providers
namespace lsp::provider
{
std::string Initialize::GetMethod() const
{
@@ -35,53 +35,69 @@ namespace lsp::providers
{
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;
result.serverInfo.version = __DATE__;
result.capabilities.textDocumentSync = BuildTextDocumentSyncOptions();
result.capabilities.completionProvider = BuildCompletionOptions();
// result.capabilities.semanticTokensProvider = BuildSemanticTokenOptions();
return result;
}
protocol::TextDocumentSyncOptions Initialize::BuildTextDocumentSyncOptions()
{
protocol::TextDocumentSyncOptions options;
options.openClose = true;
options.change = protocol::TextDocumentSyncKind::kIncremental;
return options;
}
protocol::CompletionOptions Initialize::BuildCompletionOptions()
{
protocol::CompletionOptions options;
options.triggerCharacters = { std::vector<std::string>{ "." } };
options.resolveProvider = true;
options.completionItem = {.labelDetailsSupport = true};
return options;
}
protocol::SemanticTokensOptions Initialize::BuildSemanticTokenOptions()
{
protocol::SemanticTokensOptions options;
options.legend.tokenTypes.emplace_back(protocol::SemanticTokenTypesLiterals::Namespace);
options.legend.tokenTypes.emplace_back(protocol::SemanticTokenTypesLiterals::Type);
options.legend.tokenTypes.emplace_back(protocol::SemanticTokenTypesLiterals::Class);
options.legend.tokenTypes.emplace_back(protocol::SemanticTokenTypesLiterals::Enum);
options.legend.tokenTypes.emplace_back(protocol::SemanticTokenTypesLiterals::Interface);
options.legend.tokenTypes.emplace_back(protocol::SemanticTokenTypesLiterals::Struct);
options.legend.tokenTypes.emplace_back(protocol::SemanticTokenTypesLiterals::TypeParameter);
options.legend.tokenTypes.emplace_back(protocol::SemanticTokenTypesLiterals::Parameter);
options.legend.tokenTypes.emplace_back(protocol::SemanticTokenTypesLiterals::Variable);
options.legend.tokenTypes.emplace_back(protocol::SemanticTokenTypesLiterals::Property);
options.legend.tokenTypes.emplace_back(protocol::SemanticTokenTypesLiterals::EnumMember);
options.legend.tokenTypes.emplace_back(protocol::SemanticTokenTypesLiterals::Event);
options.legend.tokenTypes.emplace_back(protocol::SemanticTokenTypesLiterals::Function);
options.legend.tokenTypes.emplace_back(protocol::SemanticTokenTypesLiterals::Method);
options.legend.tokenTypes.emplace_back(protocol::SemanticTokenTypesLiterals::Macro);
options.legend.tokenTypes.emplace_back(protocol::SemanticTokenTypesLiterals::Keyword);
options.legend.tokenTypes.emplace_back(protocol::SemanticTokenTypesLiterals::Modifier);
options.legend.tokenTypes.emplace_back(protocol::SemanticTokenTypesLiterals::Comment);
options.legend.tokenTypes.emplace_back(protocol::SemanticTokenTypesLiterals::String);
options.legend.tokenTypes.emplace_back(protocol::SemanticTokenTypesLiterals::Number);
options.legend.tokenTypes.emplace_back(protocol::SemanticTokenTypesLiterals::Regexp);
options.legend.tokenTypes.emplace_back(protocol::SemanticTokenTypesLiterals::Operator);
options.legend.tokenTypes.emplace_back(protocol::SemanticTokenTypesLiterals::Decorator);
options.legend.tokenModifiers.emplace_back(protocol::SemanticTokenModifiersLiterals::Declaration);
options.legend.tokenModifiers.emplace_back(protocol::SemanticTokenModifiersLiterals::Definition);
options.legend.tokenModifiers.emplace_back(protocol::SemanticTokenModifiersLiterals::Readonly);
options.legend.tokenModifiers.emplace_back(protocol::SemanticTokenModifiersLiterals::Static);
options.legend.tokenModifiers.emplace_back(protocol::SemanticTokenModifiersLiterals::Deprecated);
options.legend.tokenModifiers.emplace_back(protocol::SemanticTokenModifiersLiterals::Abstract);
options.legend.tokenModifiers.emplace_back(protocol::SemanticTokenModifiersLiterals::Async);
options.legend.tokenModifiers.emplace_back(protocol::SemanticTokenModifiersLiterals::Modification);
options.legend.tokenModifiers.emplace_back(protocol::SemanticTokenModifiersLiterals::Documentation);
options.legend.tokenModifiers.emplace_back(protocol::SemanticTokenModifiersLiterals::DefaultLibrary);
options.range = true;
options.full = protocol::SemanticTokensOptions::Full{ .delta = true };
return options;
}
}
@@ -1,7 +1,7 @@
#pragma once
#include "../base/provider_interface.hpp"
#include "../base/interface.hpp"
namespace lsp::providers
namespace lsp::provider
{
class Initialize : public IRequestProvider
{
@@ -14,5 +14,8 @@ namespace lsp::providers
private:
protocol::InitializeResult BuildInitializeResult();
protocol::TextDocumentSyncOptions BuildTextDocumentSyncOptions();
protocol::CompletionOptions BuildCompletionOptions();
protocol::SemanticTokensOptions BuildSemanticTokenOptions();
};
}