From e51c07b4e3c775a9dc4cec24a0baf0f98104418d Mon Sep 17 00:00:00 2001 From: ykiko Date: Sat, 31 Aug 2024 20:56:36 +0800 Subject: [PATCH] add Option. --- docs/option.toml | 12 ++++++++++++ include/Server/Option.h | 15 +++++++++++++++ src/Server/Option.cpp | 16 ++++++++++++++++ 3 files changed, 43 insertions(+) create mode 100644 docs/option.toml create mode 100644 include/Server/Option.h create mode 100644 src/Server/Option.cpp diff --git a/docs/option.toml b/docs/option.toml new file mode 100644 index 00000000..3349f873 --- /dev/null +++ b/docs/option.toml @@ -0,0 +1,12 @@ +[clang] +# the path of builtin headers that clang uses +resource-dir = "${executable}/../lib/clang/${version}" +# the commands that will be appended to the command line +append = [] +# the commands that will be removed from the command line +remove = [] + +[completion] + + +[inlay-hint] diff --git a/include/Server/Option.h b/include/Server/Option.h new file mode 100644 index 00000000..85f795de --- /dev/null +++ b/include/Server/Option.h @@ -0,0 +1,15 @@ +#pragma once + +#include +#include + +namespace clice { + +struct Option { + std::string resource_dir; + static Option parse(std::string_view execpath, std::string_view filepath); +}; + +extern Option option; + +} // namespace clice diff --git a/src/Server/Option.cpp b/src/Server/Option.cpp new file mode 100644 index 00000000..ee545aa8 --- /dev/null +++ b/src/Server/Option.cpp @@ -0,0 +1,16 @@ +#include "toml++/toml.hpp" +#include "Server/Option.h" + +namespace clice { + +// TODO: replace builtin variable in Setting +// e.g `{execute}` -> `execpath` + +Option Option::parse(std::string_view execpath, std::string_view filepath) { + auto config = toml::parse_file(filepath); + auto clang = config["clang"]; + auto resource_dir = clang["resource_dir"].as_string()->get(); + return Option{resource_dir}; +} + +} // namespace clice