vim-laravel
vim-laravel copied to clipboard
allow gf (go to file) command also for __() method
(which is an alias for trans())
Thanks! This addition is welcome, but the proposed code change has a couple problems:
- It overwrites the original function, so we've lost support for
trans()
andtrans_choice()
. - The new pattern covers a non-existent
___choice()
function in addition to__()
.
Please extend the existing pattern to match __()
instead of creating another function. This is also a good opportunity to include test coverage for this functionality. See existing tests for examples.
Let me know if you need further guidance.
@noahfrederick Yes, i need some guidance. I almost got the regular expression right to also 'listen' on __()
- but he is not able to resolve the file properly using my technique. Could you please take a look at https://github.com/noahfrederick/vim-laravel/pull/21/commits/b20a49b799b59002d8c7bca6edad1d66eef8c59e ? Once this works i want to try to write a test for that myself :)
Do you want to try adding test coverage? It would involve using vader.vim to make assertions about the output of laravel#goto#filetype_php()
and laravel#goto#filetype_blade()
when the cursor is on different snippets of PHP code. The tests would look something like:
Before (in a laravel PHP buffer):
tabedit test/fixtures/laravel-8/app/Example.php
...add buffer contents
After (clean up buffer):
bdelete
Execute (Go to translation file):
AssertEqual laravel#goto#filetype_php(), 'Elanguage some/path.php'
...
The test suite actually involves running the tests against a new Laravel project. The setup script is here, and you can see how a test like this works here, and you can run the test suite with:
vim -Nu test/fixtures/init.vim -c 'Vader! test/*'
Yes - i will try in this running week. Awesome that there is a testing suite for vim... :)
Hey @noahfrederick
i think i am far to the goal, but it seems like the vim instance that vader.vim starts with your instructions does not have the vim-laravel module loaded. Setting the cursor the first a of auth on {{ __('auth.failed'); }}
and hitting "gf" does not do what is expected. How can i ensure that the vim-laravel project has been loaded? Doing this steps "manually" without vader.vim does have the expected behavior.
Thanks a lot !