Indefinite integral $\int \frac{1}{2-\cos(x)}\,dx$ has discontinuities. How to fix?
Your problem is the $+C$ term. Take for example $\frac{1}{x}$. Its most general antiderivative is usually given as
$$\int \frac{1}{x}dx = \ln|x| + C$$
But this is not correct. Notice that the piecewise function
$$f(x)=\begin{cases} \ln(-x) +2 & x < 0\\ \ln(x) -1 & x> 0\\ \end{cases}$$
is also an antiderivative of $\frac{1}{x}$, even thought the $+C$'s on both sides were different. So any time your integrand has a singularity, the integration constant is allowed to change when you cross it.
On the domain when you integrated, the $+C$ are only uniform between the discontinuities. Otherwise, each discontinuous piece must have its own $+C$. And one can choose a series of $+C$'s such that the resultant antiderivative is continuous.
$\mathbf{EDIT}$: In this case, the continuous antiderivative should be of the form:
$$\frac{2}{\sqrt{3}}\tan^{-1}\left(\sqrt{3}\tan\left(\frac{x}{2}\right)\right) + \frac{2\pi}{\sqrt{3}}\Bigr\lfloor \frac{1}{2\pi}x+\frac{1}{2}\Bigr\rfloor + C$$
This function is both continuous and differentiable at its former discontinuities, even though it may not look like it at first glance.
And a graph of the fixed function, courtesy of Desmos: