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