[PATCH] D140462: [clangd] Add schema for `.clangd` config

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 28 18:03:41 PST 2022


sammccall added inline comments.


================
Comment at: clang-tools-extra/clangd/schema/config.json:20
+  "properties": {
+    "If": {
+      "description": "Conditions in the If block restrict when a fragment applies.",
----------------
nridge wrote:
> sammccall wrote:
> > disabling `additionalProperties` probably yields useful diagnostics
> One question here is, do we want diagnostics from the schema validation to duplicate or replace clangd's own diagnostics for the config file?
I'm not totally sure.

It's tempting to call these a failed experiment. The UX for clangd-emitted diags is pretty sad (since they only generate/update when we happen to process the config file again).

However there are definitely going to be things you can get wrong that the schema won't catch, and we should make them visible *somehow*.


================
Comment at: clang-tools-extra/clangd/schema/config.json:25
+        "PathMatch": {
+          "description": "The file being processed must fully match a regular expression.",
+          "$ref": "#/$defs/stringOrArrayOf"
----------------
nridge wrote:
> sammccall wrote:
> > Unfortunately it's not valid to specify description together with $ref (implementations are required to ignore it)
> > 
> > https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-01#section-8.3
> Hmmm... the spec draft at https://json-schema.org/draft/2020-12/json-schema-core.html#section-8.2.3.1, which is newer (2022 rather than 2018) does not seem to have this wording, and the example at https://json-schema.org/learn/getting-started-step-by-step.html#references uses `$ref` together with `description`.
Yeah, one of the complexities here is the version skew :-(
Different versions are (partially) supported by different tools. Some of them pay attention to what the file is self-declared as, others don't.

draft-07 looks like the lowest-common-denominator (and is what this file claims to be), and in particular `yaml-language-server` [always validates against draft-07](https://github.com/redhat-developer/yaml-language-server/issues/780) regardless of what the file claims.


================
Comment at: clang-tools-extra/clangd/schema/config.json:172
+        },
+        "ParameterNames": {
+          "description": "A boolean that enables/disables inlay-hints for parameter names in function calls.",
----------------
nridge wrote:
> sammccall wrote:
> > hmm, there are two more categories here - were they missing somewhere?
> `Designators` is missing from https://clangd.llvm.org/config.html#inlayhints
> 
> What's the other one?
There isn't one, I was confused.
(I think I was thinking of type-param hints, but we never added it :-()


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D140462/new/

https://reviews.llvm.org/D140462



More information about the cfe-commits mailing list