mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-22 15:45:08 +00:00
Add initialization option capabilities.*
and index.maxInitializerLines
indexer.cc: use index.maxInitializerLines instead of kInitializerMaxLines messages/initialize.cc: some ServerCapabilities are toggable: documentOnTypeFormattingProvider.firstTriggerCharacter foldingRangeProvider workspace.workspaceFolders.supported
This commit is contained in:
parent
aaa97fe8df
commit
3bf921b3bd
@ -42,6 +42,25 @@ struct Config {
|
|||||||
// member has changed.
|
// member has changed.
|
||||||
SerializeFormat cacheFormat = SerializeFormat::Binary;
|
SerializeFormat cacheFormat = SerializeFormat::Binary;
|
||||||
|
|
||||||
|
struct ServerCap {
|
||||||
|
struct DocumentOnTypeFormattingOptions {
|
||||||
|
std::string firstTriggerCharacter = "}";
|
||||||
|
std::vector<const char *> moreTriggerCharacter;
|
||||||
|
} documentOnTypeFormattingProvider;
|
||||||
|
|
||||||
|
// Set to false if you don't want folding ranges.
|
||||||
|
bool foldingRangeProvider = true;
|
||||||
|
|
||||||
|
struct Workspace {
|
||||||
|
struct WorkspaceFolders {
|
||||||
|
// Set to false if you don't want workspace folders.
|
||||||
|
bool supported = true;
|
||||||
|
|
||||||
|
bool changeNotifications = true;
|
||||||
|
} workspaceFolders;
|
||||||
|
} workspace;
|
||||||
|
} capabilities;
|
||||||
|
|
||||||
struct Clang {
|
struct Clang {
|
||||||
// Arguments that should be excluded, e.g. ["-fopenmp", "-Wall"]
|
// Arguments that should be excluded, e.g. ["-fopenmp", "-Wall"]
|
||||||
//
|
//
|
||||||
@ -207,6 +226,10 @@ struct Config {
|
|||||||
std::vector<std::string> initialBlacklist;
|
std::vector<std::string> initialBlacklist;
|
||||||
std::vector<std::string> initialWhitelist;
|
std::vector<std::string> initialWhitelist;
|
||||||
|
|
||||||
|
// If a variable initializer/macro replacement-list has fewer than this many
|
||||||
|
// lines, include the initializer in detailed_name.
|
||||||
|
int maxInitializerLines = 5;
|
||||||
|
|
||||||
// If not 0, a file will be indexed in each tranlation unit that includes it.
|
// If not 0, a file will be indexed in each tranlation unit that includes it.
|
||||||
int multiVersion = 0;
|
int multiVersion = 0;
|
||||||
|
|
||||||
@ -255,6 +278,13 @@ struct Config {
|
|||||||
int maxNum = 2000;
|
int maxNum = 2000;
|
||||||
} xref;
|
} xref;
|
||||||
};
|
};
|
||||||
|
REFLECT_STRUCT(Config::ServerCap::DocumentOnTypeFormattingOptions,
|
||||||
|
firstTriggerCharacter, moreTriggerCharacter);
|
||||||
|
REFLECT_STRUCT(Config::ServerCap::Workspace::WorkspaceFolders, supported,
|
||||||
|
changeNotifications);
|
||||||
|
REFLECT_STRUCT(Config::ServerCap::Workspace, workspaceFolders);
|
||||||
|
REFLECT_STRUCT(Config::ServerCap, documentOnTypeFormattingProvider,
|
||||||
|
foldingRangeProvider, workspace);
|
||||||
REFLECT_STRUCT(Config::Clang, excludeArgs, extraArgs, pathMappings,
|
REFLECT_STRUCT(Config::Clang, excludeArgs, extraArgs, pathMappings,
|
||||||
resourceDir);
|
resourceDir);
|
||||||
REFLECT_STRUCT(Config::ClientCapability, hierarchicalDocumentSymbolSupport,
|
REFLECT_STRUCT(Config::ClientCapability, hierarchicalDocumentSymbolSupport,
|
||||||
@ -269,17 +299,17 @@ REFLECT_STRUCT(Config::Diagnostics, blacklist, onChange, onOpen, onSave,
|
|||||||
spellChecking, whitelist)
|
spellChecking, whitelist)
|
||||||
REFLECT_STRUCT(Config::Highlight, largeFileSize, lsRanges, blacklist, whitelist)
|
REFLECT_STRUCT(Config::Highlight, largeFileSize, lsRanges, blacklist, whitelist)
|
||||||
REFLECT_STRUCT(Config::Index, blacklist, comments, initialBlacklist,
|
REFLECT_STRUCT(Config::Index, blacklist, comments, initialBlacklist,
|
||||||
initialWhitelist, multiVersion, multiVersionBlacklist,
|
initialWhitelist, maxInitializerLines, multiVersion,
|
||||||
multiVersionWhitelist, onChange, threads, trackDependency,
|
multiVersionBlacklist, multiVersionWhitelist, onChange, threads,
|
||||||
whitelist);
|
trackDependency, whitelist);
|
||||||
REFLECT_STRUCT(Config::Request, timeout);
|
REFLECT_STRUCT(Config::Request, timeout);
|
||||||
REFLECT_STRUCT(Config::Session, maxNum);
|
REFLECT_STRUCT(Config::Session, maxNum);
|
||||||
REFLECT_STRUCT(Config::WorkspaceSymbol, caseSensitivity, maxNum, sort);
|
REFLECT_STRUCT(Config::WorkspaceSymbol, caseSensitivity, maxNum, sort);
|
||||||
REFLECT_STRUCT(Config::Xref, maxNum);
|
REFLECT_STRUCT(Config::Xref, maxNum);
|
||||||
REFLECT_STRUCT(Config, compilationDatabaseCommand, compilationDatabaseDirectory,
|
REFLECT_STRUCT(Config, compilationDatabaseCommand, compilationDatabaseDirectory,
|
||||||
cacheDirectory, cacheFormat, clang, client, codeLens, completion,
|
cacheDirectory, cacheFormat, capabilities, clang, client,
|
||||||
diagnostics, highlight, index, request, session, workspaceSymbol,
|
codeLens, completion, diagnostics, highlight, index, request,
|
||||||
xref);
|
session, workspaceSymbol, xref);
|
||||||
|
|
||||||
extern Config *g_config;
|
extern Config *g_config;
|
||||||
|
|
||||||
|
@ -29,8 +29,6 @@ using namespace clang;
|
|||||||
namespace ccls {
|
namespace ccls {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
constexpr int kInitializerMaxLines = 3;
|
|
||||||
|
|
||||||
GroupMatch *multiVersionMatcher;
|
GroupMatch *multiVersionMatcher;
|
||||||
|
|
||||||
struct File {
|
struct File {
|
||||||
@ -586,7 +584,7 @@ public:
|
|||||||
if (L.isMacroID() || !SM.isBeforeInTranslationUnit(L, R.getBegin()))
|
if (L.isMacroID() || !SM.isBeforeInTranslationUnit(L, R.getBegin()))
|
||||||
return;
|
return;
|
||||||
StringRef Buf = GetSourceInRange(SM, Lang, R);
|
StringRef Buf = GetSourceInRange(SM, Lang, R);
|
||||||
Twine Init = Buf.count('\n') <= kInitializerMaxLines - 1
|
Twine Init = Buf.count('\n') <= g_config->index.maxInitializerLines - 1
|
||||||
? Buf.size() && Buf[0] == ':' ? Twine(" ", Buf)
|
? Buf.size() && Buf[0] == ':' ? Twine(" ", Buf)
|
||||||
: Twine(" = ", Buf)
|
: Twine(" = ", Buf)
|
||||||
: Twine();
|
: Twine();
|
||||||
@ -1085,7 +1083,7 @@ public:
|
|||||||
var.def.short_name_size = Name.size();
|
var.def.short_name_size = Name.size();
|
||||||
StringRef Buf = GetSourceInRange(SM, Lang, R);
|
StringRef Buf = GetSourceInRange(SM, Lang, R);
|
||||||
var.def.hover =
|
var.def.hover =
|
||||||
Intern(Buf.count('\n') <= kInitializerMaxLines - 1
|
Intern(Buf.count('\n') <= g_config->index.maxInitializerLines - 1
|
||||||
? Twine("#define ", GetSourceInRange(SM, Lang, R)).str()
|
? Twine("#define ", GetSourceInRange(SM, Lang, R)).str()
|
||||||
: Twine("#define ", Name).str());
|
: Twine("#define ", Name).str());
|
||||||
}
|
}
|
||||||
|
@ -76,10 +76,8 @@ struct ServerCap {
|
|||||||
} codeLensProvider;
|
} codeLensProvider;
|
||||||
bool documentFormattingProvider = true;
|
bool documentFormattingProvider = true;
|
||||||
bool documentRangeFormattingProvider = true;
|
bool documentRangeFormattingProvider = true;
|
||||||
struct DocumentOnTypeFormattingOptions {
|
Config::ServerCap::DocumentOnTypeFormattingOptions
|
||||||
std::string firstTriggerCharacter = "}";
|
documentOnTypeFormattingProvider;
|
||||||
std::vector<const char *> moreTriggerCharacter;
|
|
||||||
} documentOnTypeFormattingProvider;
|
|
||||||
bool renameProvider = true;
|
bool renameProvider = true;
|
||||||
struct DocumentLinkOptions {
|
struct DocumentLinkOptions {
|
||||||
bool resolveProvider = true;
|
bool resolveProvider = true;
|
||||||
@ -89,28 +87,18 @@ struct ServerCap {
|
|||||||
struct ExecuteCommandOptions {
|
struct ExecuteCommandOptions {
|
||||||
std::vector<const char *> commands = {ccls_xref};
|
std::vector<const char *> commands = {ccls_xref};
|
||||||
} executeCommandProvider;
|
} executeCommandProvider;
|
||||||
struct Workspace {
|
Config::ServerCap::Workspace workspace;
|
||||||
struct WorkspaceFolders {
|
|
||||||
bool supported = true;
|
|
||||||
bool changeNotifications = true;
|
|
||||||
} workspaceFolders;
|
|
||||||
} workspace;
|
|
||||||
};
|
};
|
||||||
REFLECT_STRUCT(ServerCap::CodeActionOptions, codeActionKinds);
|
REFLECT_STRUCT(ServerCap::CodeActionOptions, codeActionKinds);
|
||||||
REFLECT_STRUCT(ServerCap::CodeLensOptions, resolveProvider);
|
REFLECT_STRUCT(ServerCap::CodeLensOptions, resolveProvider);
|
||||||
REFLECT_STRUCT(ServerCap::CompletionOptions, resolveProvider,
|
REFLECT_STRUCT(ServerCap::CompletionOptions, resolveProvider,
|
||||||
triggerCharacters);
|
triggerCharacters);
|
||||||
REFLECT_STRUCT(ServerCap::DocumentLinkOptions, resolveProvider);
|
REFLECT_STRUCT(ServerCap::DocumentLinkOptions, resolveProvider);
|
||||||
REFLECT_STRUCT(ServerCap::DocumentOnTypeFormattingOptions,
|
|
||||||
firstTriggerCharacter, moreTriggerCharacter);
|
|
||||||
REFLECT_STRUCT(ServerCap::ExecuteCommandOptions, commands);
|
REFLECT_STRUCT(ServerCap::ExecuteCommandOptions, commands);
|
||||||
REFLECT_STRUCT(ServerCap::SaveOptions, includeText);
|
REFLECT_STRUCT(ServerCap::SaveOptions, includeText);
|
||||||
REFLECT_STRUCT(ServerCap::SignatureHelpOptions, triggerCharacters);
|
REFLECT_STRUCT(ServerCap::SignatureHelpOptions, triggerCharacters);
|
||||||
REFLECT_STRUCT(ServerCap::TextDocumentSyncOptions, openClose, change, willSave,
|
REFLECT_STRUCT(ServerCap::TextDocumentSyncOptions, openClose, change, willSave,
|
||||||
willSaveWaitUntil, save);
|
willSaveWaitUntil, save);
|
||||||
REFLECT_STRUCT(ServerCap::Workspace::WorkspaceFolders, supported,
|
|
||||||
changeNotifications);
|
|
||||||
REFLECT_STRUCT(ServerCap::Workspace, workspaceFolders);
|
|
||||||
REFLECT_STRUCT(ServerCap, textDocumentSync, hoverProvider, completionProvider,
|
REFLECT_STRUCT(ServerCap, textDocumentSync, hoverProvider, completionProvider,
|
||||||
signatureHelpProvider, declarationProvider, definitionProvider,
|
signatureHelpProvider, declarationProvider, definitionProvider,
|
||||||
implementationProvider, typeDefinitionProvider,
|
implementationProvider, typeDefinitionProvider,
|
||||||
@ -318,7 +306,15 @@ void Initialize(MessageHandler *m, InitializeParam ¶m, ReplyOnce &reply) {
|
|||||||
|
|
||||||
// Send initialization before starting indexers, so we don't send a
|
// Send initialization before starting indexers, so we don't send a
|
||||||
// status update too early.
|
// status update too early.
|
||||||
reply(InitializeResult{});
|
{
|
||||||
|
InitializeResult result;
|
||||||
|
auto &c = result.capabilities;
|
||||||
|
c.documentOnTypeFormattingProvider =
|
||||||
|
g_config->capabilities.documentOnTypeFormattingProvider;
|
||||||
|
c.foldingRangeProvider = g_config->capabilities.foldingRangeProvider;
|
||||||
|
c.workspace = g_config->capabilities.workspace;
|
||||||
|
reply(result);
|
||||||
|
}
|
||||||
|
|
||||||
// Set project root.
|
// Set project root.
|
||||||
EnsureEndsInSlash(project_path);
|
EnsureEndsInSlash(project_path);
|
||||||
|
Loading…
Reference in New Issue
Block a user