We construct weight functions on the Berkovich analytification of a variety
over a trivially-valued field of characteristic zero, and this leads to the
definition of the Kontsevich-Soibelman skeletons and the essential skeletons of
pairs. We prove that the weight functions determine a metric on the
pluricanonical bundles which coincides with Temkin's canonical metric in the
smooth case. The weight functions are defined in terms of log discrepancies,
which makes the Kontsevich-Soibelman and essential skeletons computable: this
allows us to relate the essential skeleton to its discretely-valued
counterpart, and explicitly describe the closure of the Kontsevich-Soibelman
skeletons. As a result, we employ these techniques to compute the dual boundary
complexes of certain character varieties: this provides the first evidence for
the geometric P=W conjecture in the compact case, and the first application of
Berkovich geometry in non-abelian Hodge theory.Comment: Sections 1.6-1.7 rewritten and minor changes in Sections 6-