What semantic notions underlie "to think; to contemplate", with "but; however; nevertheless" with "only"? I know that meaning 3 originates from  忄 used here as the semantic component (Yellowbridge exhibits this more clearly below). But how did 3 semantically shift to 1, 2? Their lexical categories all differ!
Please answer separately for 1 and 2, because even in English, 1 and 2 don't mean the same.
Their lexical categories all differ!


but; however; nevertheless
only
to think; to contemplate
† Alternative form of 唯 (wéi, “to be”).
Their lexical categories all differ!

That is common in Chinese, especially in Classical Chinese.

How did 3 semantically shift to 1, 2?

Sometimes the different meanings of a character are not evolved from the same origin. In ancient times, people often designated a character with a certain meaning merely for the reason that it shares the sound of the oral language of that meaning, and so is the case.
By the way, meaning 1 &amp; 2 were fixed over 2200 years ago (before Qin Dynasty), and there are some other characters that is interchageable with 惟 under certain meanings (listed in bold font).
Let me list a relatively comprehensive entry of 惟（meanings still common in modern Chinese will be intalicized）：
Original meaning:
v.
维：凡思（to think），即浮泛之思，寻常之思。
e.g. 惟念圣意，谛听民声。
为：是（be）
e.g. 不变惟何？《天演论》
唯：顺遂，听从（to obey, to submit）
e.g. 惟惟诺诺=唯唯诺诺
希望，愿请（hope sb. to do sth.）
e.g. 万惟留心！《英烈传》
在于（lie in）
刑惟善察，谋惟善断。
adv.
唯，维：只有，单（only）
e.g. 惟吾德馨《陋室铭》
唯，维：发语词，希望（wish）
e.g. 先王无流连之乐，荒亡之行，惟君所行也。《孟子》
conj.
即使，虽然（even if，though）
e.g. 惟信亦为大王不如也。《史记》