diff --git a/docs/clice.toml b/docs/clice.toml index ec28b923..1b423096 100644 --- a/docs/clice.toml +++ b/docs/clice.toml @@ -21,8 +21,8 @@ cache_dir = "${workspace}/.clice/cache" # Directory for storing index files. index_dir = "${workspace}/.clice/index" logging_dir = "${workspace}/.clice/logging" -# Compile commands directories to search for compile_commands.json files. -compile_commands_dirs = ["${workspace}/build"] +# Compile commands files or directories to search for compile_commands.json files. +compile_commands_paths = ["${workspace}/build"] # Control the behavior for specific files. Note that Clice matches rules # in order. If you want to add your own rules, either delete this rule diff --git a/include/Server/Config.h b/include/Server/Config.h index 59beca6e..951437bc 100644 --- a/include/Server/Config.h +++ b/include/Server/Config.h @@ -21,7 +21,7 @@ struct ProjectOptions { std::string logging_dir = "${workspace}/.clice/logging"; - std::vector compile_commands_dirs = {"${workspace}/build"}; + std::vector compile_commands_paths = {"${workspace}/build"}; }; struct Rule { diff --git a/src/Server/Lifecycle.cpp b/src/Server/Lifecycle.cpp index ed841d07..02dd241d 100644 --- a/src/Server/Lifecycle.cpp +++ b/src/Server/Lifecycle.cpp @@ -1,5 +1,7 @@ #include "Server/Server.h" +#include + namespace clice { async::Task Server::on_initialize(proto::InitializeParams params) { @@ -36,8 +38,12 @@ async::Task Server::on_initialize(proto::InitializeParams params) { opening_files.set_capability(config.project.max_active_file); /// Load compile commands.json - for(auto& dir: config.project.compile_commands_dirs) { - database.load_compile_database(path::join(dir, "compile_commands.json")); + for(auto& dir_or_file: config.project.compile_commands_paths) { + if(fs::is_directory(dir_or_file)) { + database.load_compile_database(path::join(dir_or_file, "compile_commands.json")); + } else { + database.load_compile_database(dir_or_file); + } } /// Load cache info.