Type-IV wind turbines can experience torsional vibrations in the drivetrain structure. This can lead to additional stress on turbine components and a quality reduction of the power delivered to the grid. The vibrations are mostly induced by fast variations of the electromagnetic torque, which depends on the control of a back-to-back converter. A number of studies have already presented methods to mitigate the drivetrain vibrations. However, the research was dedicated to cases when the converter, interfacing a wind turbine to the grid, operates based on a grid-following control. A wind turbine can be also interfaced to a grid-forming converter. In this case, a back-to-back converter control creates a strong link between the electromagnetic torque and grid dynamics, so the abovementioned problem remains relevant. Therefore, this paper presents a solution to damp torsional vibrations in the direct drive of a Type-IV wind turbine, interfaced to the electrical power grid with a voltage source converter based on a grid-forming control. The damping of the drivetrain vibrations relies on the input shaping method implemented using a zero-vibration filter. Simulation results prove the effectiveness of the method to damp drivetrain vibrations during grid frequency variations. In addition to that, damping impact on system behavior with respect to other parameters is analyzed and its mitigation is discussed.