Bottom line on top: you should violate Shabbos for all cases of suicide on Shabbos. (R Moshe Feinstein, Tzitz Eliezer); with one (very rare, practically non-existent) exception according to R Shlomo Zalman Auerbach.
Rabbi Moshe Halevi Spero explores this issue in his article in The Journal of Halacha and Contemporary Society, vol. 3 (Spring 1982). I strongly encourage you to read the article yourself, as it's very interesting and well-written, but I will summarize the main points of the article here to the best of my ability.
- The ציץ אליעזר (Rabbi EY Waldenburg) [8:15:4, 9:17:2:14, 10:25:17:13], אגרות משה (Rabbi Moshe Feinstein) [YD 3:90] and many others say that one is allowed to violate שבת both for one threatening suicide, as well as for a "מאבד עצמו לדעת" (one who knowingly destroys himself).
However, others (Rabbi SZ Auerbach, חכמת שלמה at 329:1) say that one may not violate Shabbos for the מאבד עצמו לדעת.
- However, even according to these opinions, there is a lot of room to be lenient on Shabbos.
- While one is not allowed to violate Shabbos to save a person from doing a single עבירה, (Rema to Orach Chayim 328:10, and to Orach Chayim 306:14), one is allowed to save someone from being forced into "perpetual apostacy," which could be one result of suicide. If so, then even Biblical prohibitions may be violated for the suicide, if we can compare the state of "having committed suicide" to the state of "perpetual apostacy."
1. However, it should be noted that there are issues with this comparison; notably, that (per MB 328, this cannot be done with a meizid or posheya. (However, Rabbis Feinstein and Wallenberg make use of this comparison, even for the meizid)
There is a responsum from the Rashba (cited in בית יוסף OC 306), that in the event of a "מצוה רבה," "great mitzvah," such as pikuach nefesh or pikuach dat (=conversion), one may violate Shabbos even for the meizid or the posheya.
- Additionally, R Feinstein notes that although one is forbidden from traveling by boat (or undergoing elective surgery) three days prior to Shabbos, if one did so, there would be no problem with saving the person's life, post facto.
R Spero cites a paper by R Shlomo Y. Zevin, who opined that although refuah is required for one of two reasons (either השבת אבידה, returning a lost object; or לא תעמוד על דם רעיך, the injunction to help a friend in need), even though those reasons may not apply (either due to being an אבידה מדעת, a "willingly lost object," which one is not required to return; or because the suicide is not considered to be "רעיך," due to breaking the rules of Judaism), one still must save this person's life, out of an obligation to prevent prohibitions from being done.
- Alternatively, R Zevin suggests that Judais does not consider one to be the owner of his own body, and as such one has no right to destroy it.
- R Spero offers several other lines of reasoning to circumvent the issue of אבידה מדעת.
To my mind, the most sweeping היתר of the entire paper is found in section C of the paper. There, R Spero writes that one may only be considered to be a "מאבד עצמו לדעת," "one who destroys himself knowingly," when we can verify that he is actually acting with דעת (possibly through עדים והתראה, which are decidedly rare in the event of suicide). The suicide also may be missing the critical element of דעת due to intense pain, depression, or other factors.
- An additional argument presented, in answer to the reasoning of labeling the suicide as a "חוטא," is the possibility that he may have done תשובה already. R Spero doesn't draw this comparison, but I think this might be analogous to Kiddushin 49b, where even a "complete רשע" who gave money to a woman and married her "on condition that I am righteous," is considered to be married, because "שמא הרהר תשובה בדעתו," "maybe he had a thought of תשובה."
From all the above (esp. point 5), it would appear that even according to those that would say that one is forbidden from participating in the saving of the life of the suicide (specifically, the מאבד עצמו לדעת) on Shabbos when doing so would violate Shabbos principles, would allow one to do so, even for the apparent מאבד עצמו לדעת.
* It should be noted that according to R Waldenberg, one is not allowed to violate Shabbos for the suicide where there is definitively no danger to life; however, he would certainly agree that when there is any room to have a concern for danger to life, that violating Shabbos would be allowed and obligatory.