Before I say what I'm attempting to do, I want to preface it with me being open to any/all solutions.
Basically I'm editing a PHP file. We have a localization function in the class I'm editing that takes a key, similar to this:
What I'm looking to do (in VIM) is create a keybinding that will determine what the localization value of that function call is, when the cursor is over that key. I can get the key easily enough into a vimscript function. My plan was then to just find the class name via regex (this doesn't need to be perfect) and then instantiate that class via :exec php -r and call the function. So more or less, create a minimal script that would actually make the call.
Like I said, I can get the key isolated the way I want. But trying to figure out the proper vimscript way to find the current class. Basically I want the second word on the first line that matches /^class / in the current file, in a vimscript variable. I've browsed some of the documentation but can't seem to get it to work.
Open to any/all suggestions on how to perform this operation.
Edit: To clarify, I can isolate the key I'm highlighting by doing something like:
noremap <leader>z :call DoSomething(expand("<cword>"))<CR> function! DoSomething(l) let key = a:l echom key endfunction