I haven’t had any thoughts about suicide for a long time. But in general, are suicidal thoughts sinful? Would being close to hurting yourself but not actually doing it be a sin?
If you have a passing thought about harming yourself but you easily and quickly dismiss the idea, then you are being tempted and temptation is not a sin. In a sense, it is the devil’s invitation to sin that you can decline.
However, if thoughts of harming yourself are regularly popping up, it can be an indication that something is wrong. It may mean that you are not handling the pressures of life well. It could mean that a medication that you are taking is interfering with your mind. It can also be an indicator of some developing mental illness. When such things occur regularly, it is best to talk with a trusted counselor, parent, or doctor to help you sort the problem out.
If you are dwelling on the idea of harming yourself regularly and you are actually finding the idea attractive, then that is a form of lust. Lust is a strong desire to do something, especially something wrong, to the point that you are justifying the sin in your mind. Harming yourself is wrong, therefore having a lust to harm yourself is also wrong. This would be considered an urgent matter that needs to be looked into because it is far too easy to move from lust to active sin.