\captionof messes with paragraph indent

One way is to use \captionof inside a group.

\documentclass{mwrep}
\usepackage[font=small,compatibility=false]{caption}
\usepackage{listings}
\usepackage{lipsum}
\begin{document}
\chapter{Test}
\lipsum[2-3]
\begingroup
\captionof{lstlisting}{Caption of listing}
\endgroup

\lipsum[2-3]
\end{document}

caption warns you:

Package caption Warning: \captionsetup{type*=...} or \captionof
(caption)                outside box or environment on input line 13.
See the caption package documentation for explanation.

Put a group or environment around the command.