Which Function mode is a global minor mode which displays the current function name in the mode line, updating it as you move around in a buffer.
which-function-mode
‘M-x which-function-mode’
Which Function mode is a global minor mode. By default, it takes effect in all major modes that know how to support it (i.e., all the major modes that support Imenu).