mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-22 07:35:08 +00:00
Rename some initialization options
* Delete index.enabled which can be achieved with index.blacklist: ['.'] * Move completion.include* to completion.include.* * move largeFileSize to highlight.largeFileSize
This commit is contained in:
parent
8d61b1aadb
commit
083a629f90
51
src/config.h
51
src/config.h
@ -118,25 +118,27 @@ struct Config {
|
||||
// that implement their own filtering and sorting logic.
|
||||
bool filterAndSort = true;
|
||||
|
||||
struct Include {
|
||||
// Regex patterns to match include completion candidates against. They
|
||||
// receive the absolute file path.
|
||||
//
|
||||
// For example, to hide all files in a /CACHE/ folder, use ".*/CACHE/.*"
|
||||
std::vector<std::string> includeBlacklist;
|
||||
std::vector<std::string> blacklist;
|
||||
|
||||
// Maximum path length to show in completion results. Paths longer than this
|
||||
// will be elided with ".." put at the front. Set to 0 or a negative number
|
||||
// to disable eliding.
|
||||
int includeMaxPathSize = 30;
|
||||
// Maximum path length to show in completion results. Paths longer than
|
||||
// this will be elided with ".." put at the front. Set to 0 or a negative
|
||||
// number to disable eliding.
|
||||
int maxPathSize = 30;
|
||||
|
||||
// Whitelist that file paths will be tested against. If a file path does not
|
||||
// end in one of these values, it will not be considered for
|
||||
// Whitelist that file paths will be tested against. If a file path does
|
||||
// not end in one of these values, it will not be considered for
|
||||
// auto-completion. An example value is { ".h", ".hpp" }
|
||||
//
|
||||
// This is significantly faster than using a regex.
|
||||
std::vector<std::string> includeSuffixWhitelist = {".h", ".hpp", ".hh", ".inc"};
|
||||
std::vector<std::string> suffixWhitelist = {".h", ".hpp", ".hh", ".inc"};
|
||||
|
||||
std::vector<std::string> includeWhitelist;
|
||||
std::vector<std::string> whitelist;
|
||||
} include;
|
||||
} completion;
|
||||
|
||||
struct Diagnostics {
|
||||
@ -164,6 +166,9 @@ struct Config {
|
||||
|
||||
// Semantic highlighting
|
||||
struct Highlight {
|
||||
// Disable semantic highlighting for files larger than the size.
|
||||
int64_t largeFileSize = 2 * 1024 * 1024;
|
||||
|
||||
// true: LSP line/character; false: position
|
||||
bool lsRanges = false;
|
||||
|
||||
@ -189,9 +194,6 @@ struct Config {
|
||||
// - https://github.com/autozimu/LanguageClient-neovim/issues/224
|
||||
int comments = 2;
|
||||
|
||||
// If false, the indexer will be disabled.
|
||||
bool enabled = true;
|
||||
|
||||
// By default, all project entries will be indexed on initialization. Use
|
||||
// these two options to exclude some. They can still be indexed after you
|
||||
// open them.
|
||||
@ -215,15 +217,12 @@ struct Config {
|
||||
|
||||
// Whether to reparse a file if write times of its dependencies have
|
||||
// changed. The file will always be reparsed if its own write time changes.
|
||||
// 0: no, 1: only after initial load of project, 2: yes
|
||||
// 0: no, 1: only during initial load of project, 2: yes
|
||||
int trackDependency = 2;
|
||||
|
||||
std::vector<std::string> whitelist;
|
||||
} index;
|
||||
|
||||
// Disable semantic highlighting for files larger than the size.
|
||||
int64_t largeFileSize = 2 * 1024 * 1024;
|
||||
|
||||
struct WorkspaceSymbol {
|
||||
int caseSensitivity = 1;
|
||||
// Maximum workspace search results.
|
||||
@ -246,24 +245,24 @@ MAKE_REFLECT_STRUCT(Config::Clang, excludeArgs, extraArgs, pathMappings,
|
||||
MAKE_REFLECT_STRUCT(Config::ClientCapability, hierarchicalDocumentSymbolSupport,
|
||||
snippetSupport);
|
||||
MAKE_REFLECT_STRUCT(Config::CodeLens, localVariables);
|
||||
MAKE_REFLECT_STRUCT(Config::Completion::Include, blacklist, maxPathSize,
|
||||
suffixWhitelist, whitelist);
|
||||
MAKE_REFLECT_STRUCT(Config::Completion, caseSensitivity, detailedLabel,
|
||||
dropOldRequests, duplicateOptional, filterAndSort,
|
||||
includeBlacklist, includeMaxPathSize,
|
||||
includeSuffixWhitelist, includeWhitelist);
|
||||
dropOldRequests, duplicateOptional, filterAndSort, include);
|
||||
MAKE_REFLECT_STRUCT(Config::Diagnostics, blacklist, onChange, onOpen, onSave,
|
||||
spellChecking, whitelist)
|
||||
MAKE_REFLECT_STRUCT(Config::Highlight, lsRanges, blacklist, whitelist)
|
||||
MAKE_REFLECT_STRUCT(Config::Index, blacklist, comments, enabled,
|
||||
initialBlacklist, initialWhitelist, multiVersion,
|
||||
multiVersionBlacklist, multiVersionWhitelist, onChange,
|
||||
threads, trackDependency, whitelist);
|
||||
MAKE_REFLECT_STRUCT(Config::Highlight, largeFileSize, lsRanges, blacklist,
|
||||
whitelist)
|
||||
MAKE_REFLECT_STRUCT(Config::Index, blacklist, comments, initialBlacklist,
|
||||
initialWhitelist, multiVersion, multiVersionBlacklist,
|
||||
multiVersionWhitelist, onChange, threads, trackDependency,
|
||||
whitelist);
|
||||
MAKE_REFLECT_STRUCT(Config::WorkspaceSymbol, caseSensitivity, maxNum, sort);
|
||||
MAKE_REFLECT_STRUCT(Config::Xref, container, maxNum);
|
||||
MAKE_REFLECT_STRUCT(Config, compilationDatabaseCommand,
|
||||
compilationDatabaseDirectory, cacheDirectory, cacheFormat,
|
||||
|
||||
clang, client, codeLens, completion, diagnostics, highlight,
|
||||
index, largeFileSize, workspaceSymbol, xref);
|
||||
index, workspaceSymbol, xref);
|
||||
|
||||
extern Config *g_config;
|
||||
|
||||
|
@ -23,13 +23,11 @@ struct CompletionCandidate {
|
||||
};
|
||||
|
||||
std::string ElideLongPath(const std::string &path) {
|
||||
if (g_config->completion.includeMaxPathSize <= 0)
|
||||
if (g_config->completion.include.maxPathSize <= 0 ||
|
||||
(int)path.size() <= g_config->completion.include.maxPathSize)
|
||||
return path;
|
||||
|
||||
if ((int)path.size() <= g_config->completion.includeMaxPathSize)
|
||||
return path;
|
||||
|
||||
size_t start = path.size() - g_config->completion.includeMaxPathSize;
|
||||
size_t start = path.size() - g_config->completion.include.maxPathSize;
|
||||
return ".." + path.substr(start + 2);
|
||||
}
|
||||
|
||||
@ -101,11 +99,11 @@ void IncludeComplete::Rescan() {
|
||||
absolute_path_to_completion_item.clear();
|
||||
inserted_paths.clear();
|
||||
|
||||
if (!match_ && (g_config->completion.includeWhitelist.size() ||
|
||||
g_config->completion.includeBlacklist.size()))
|
||||
if (!match_ && (g_config->completion.include.whitelist.size() ||
|
||||
g_config->completion.include.blacklist.size()))
|
||||
match_ =
|
||||
std::make_unique<GroupMatch>(g_config->completion.includeWhitelist,
|
||||
g_config->completion.includeBlacklist);
|
||||
std::make_unique<GroupMatch>(g_config->completion.include.whitelist,
|
||||
g_config->completion.include.blacklist);
|
||||
|
||||
is_scanning = true;
|
||||
std::thread([this]() {
|
||||
@ -144,7 +142,7 @@ void IncludeComplete::InsertCompletionItem(const std::string &absolute_path,
|
||||
}
|
||||
|
||||
void IncludeComplete::AddFile(const std::string &absolute_path) {
|
||||
if (!EndsWithAny(absolute_path, g_config->completion.includeSuffixWhitelist))
|
||||
if (!EndsWithAny(absolute_path, g_config->completion.include.suffixWhitelist))
|
||||
return;
|
||||
if (match_ && !match_->IsMatch(absolute_path))
|
||||
return;
|
||||
@ -174,7 +172,7 @@ void IncludeComplete::InsertIncludesFromDirectory(std::string directory,
|
||||
directory, true /*recursive*/, false /*add_folder_to_path*/,
|
||||
[&](const std::string &path) {
|
||||
if (!include_cpp &&
|
||||
!EndsWithAny(path, g_config->completion.includeSuffixWhitelist))
|
||||
!EndsWithAny(path, g_config->completion.include.suffixWhitelist))
|
||||
return;
|
||||
if (match_ && !match_->IsMatch(directory + path))
|
||||
return;
|
||||
|
@ -1230,9 +1230,6 @@ Index(CompletionManager *completion, WorkingFiles *wfiles, VFS *vfs,
|
||||
const std::vector<const char *> &args,
|
||||
const std::vector<std::pair<std::string, std::string>> &remapped, bool &ok) {
|
||||
ok = true;
|
||||
if (!g_config->index.enabled)
|
||||
return {};
|
||||
|
||||
auto PCH = std::make_shared<PCHContainerOperations>();
|
||||
llvm::IntrusiveRefCntPtr<vfs::FileSystem> FS = vfs::getRealFileSystem();
|
||||
std::shared_ptr<CompilerInvocation> CI = BuildCompilerInvocation(args, FS);
|
||||
|
@ -121,7 +121,7 @@ void EmitSemanticHighlighting(DB *db, WorkingFile *wfile, QueryFile *file) {
|
||||
static GroupMatch match(g_config->highlight.whitelist,
|
||||
g_config->highlight.blacklist);
|
||||
assert(file->def);
|
||||
if (wfile->buffer_content.size() > g_config->largeFileSize ||
|
||||
if (wfile->buffer_content.size() > g_config->highlight.largeFileSize ||
|
||||
!match.IsMatch(file->def->path))
|
||||
return;
|
||||
|
||||
|
@ -283,7 +283,7 @@ bool Indexer_Parse(CompletionManager *completion, WorkingFiles *wfiles,
|
||||
path_to_index, entry.args, remapped, ok);
|
||||
|
||||
if (!ok) {
|
||||
if (g_config->index.enabled && request.id.Valid()) {
|
||||
if (request.id.Valid()) {
|
||||
Out_Error out;
|
||||
out.id = request.id;
|
||||
out.error.code = lsErrorCodes::InternalError;
|
||||
|
Loading…
Reference in New Issue
Block a user