vim-laravel icon indicating copy to clipboard operation
vim-laravel copied to clipboard

allow gf (go to file) command also for __() method

Open thyseus opened this issue 4 years ago • 5 comments

(which is an alias for trans())

thyseus avatar Feb 10 '21 09:02 thyseus

Thanks! This addition is welcome, but the proposed code change has a couple problems:

  1. It overwrites the original function, so we've lost support for trans() and trans_choice().
  2. 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 avatar Feb 13 '21 23:02 noahfrederick

@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 :)

thyseus avatar Feb 16 '21 11:02 thyseus

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/*'

noahfrederick avatar Feb 27 '21 13:02 noahfrederick

Yes - i will try in this running week. Awesome that there is a testing suite for vim... :)

thyseus avatar Mar 01 '21 08:03 thyseus

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 !

thyseus avatar Mar 04 '21 08:03 thyseus