Example 2 Let the function $f: \mathbf{R} \rightarrow \mathbf{R}$, satisfy $f(0)=1$, and for any $x, y \in \mathbf{R}$, there is $f(x y+1)=f(x) f(y)-f(y)-x+2$, find $f(x)$
(2004 National High School League Question)
Given the condition $f(x y+1)=f(x) f(y)-f(y)-x+2$, if we swap $x$ and $y$, we get:
$$
f(x y+1)=f(x) f(y)-f(x)-y+2
$$

Thus, $f(x) f(y)-f(y)-x+2=f(x) f(y)-f(x)-y+2$
which simplifies to $f(x)+y=f(y)+x$. Setting $y=0$, we get: $f(x)=x+1$