You can just use the ARM GCC with STLink and whatever editor/IDE you like. You don't need CubeIDE or CubeMX. You can add whatever dependency you are comfortable with from there e.g CMSIS headers, libopencm3 or iirc the STM32 HAL. You probably need to be familar with setting up your build system with make, cmake or anything else.
There is a bare metal programming guide that really starts from 0 that is quite interesting. You can find it here: https://github.com/cpq/bare-metal-programming-guide