We prove an analog of the holomorphic Lefschetz formula for endofunctors of smooth compact dg-categories. We deduce from it a generalization of the Lefschetz formula of Lunts (J Algebra 356:230–256, 2012) that takes the form of a reciprocity law for a pair of commuting endofunctors. As an application, we prove a version of Lefschetz formula proposed by Frenkel and Ngô (Bull Math Sci 1(1):129–199, 2011). Also, we compute explicitly the ingredients of the holomorphic Lefschetz formula for the dg-category of matrix factorizations of an isolated singularity $${\varvec{w}}$$ w . We apply this formula to get some restrictions on the Betti numbers of a $${\mathbb Z}/2$$ Z / 2 -equivariant module over $$k[[x_1,\ldots ,x_n]]/({\varvec{w}})$$ k [ [ x 1 , … , x n ] ] / ( w ) in the case when $${\varvec{w}}(-x)={\varvec{w}}(x)$$ w ( - x ) = w ( x ) .