Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions autoload/laravel/goto.vim
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ endfunction

""
" @private
" Capture language name at cursor
" Capture language name at cursor using trans(), trans_choice() and __() method
function! laravel#goto#language() abort
return s:find_name('\<trans\%(_choice\)\?([''"]\([^''".]\+\)[^''"]*[''"][,)].*$')
return s:find_name('\<\%\(__\|trans\%(_choice\)\?\)([''"]\([^''".]\+\)[^''"]*[''"][,)].*$')
endfunction

""
Expand Down
31 changes: 29 additions & 2 deletions test/navigation.vader
Original file line number Diff line number Diff line change
Expand Up @@ -405,9 +405,12 @@ Expect (class template):

namespace App\Models;

class Example
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Example extends Model
{
//
use HasFactory;
}

Execute (edit notification):
Expand Down Expand Up @@ -462,3 +465,27 @@ Execute (edit routes):

Expect (generic template):
<?php

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's move these new tests to their own test file, tests/goto.vader (matching the autoload script name), since we're testing a different type of functionality.

Before (blade file with __() function):
tabedit test/fixtures/laravel-8/resources/views/viewfile.blade.php

Do (Move to (a)uth.failed, jump to translation file):
i{{ __('auth.failed') }}\<Esc>0fagf

Execute:
AssertEqual expand('%'), 'resources/lang/auth.php'
Comment on lines +472 to +476
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's good to exercise the gf mapping at least once, as you have here, but it would also be valuable to test the output of laravel#goto#filetype_php() and laravel#goto#filetype_blade() directly. They output strings that are executed as navigation commands:

  AssertEqual laravel#goto#filetype_blade(), 'Elanguage en/auth'


After (clean up buffer):
bdelete

Before (blade file with trans() function):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is that Before and After blocks are executed again for every test in the test file, so there should only be one of each per file. You can do additional setup for a single test in an Execute block instead.

tabedit test/fixtures/laravel-8/resources/views/viewfile2.blade.php

Do (Move to (a)uth.failed, jump to translation file):
i{{ trans('auth.failed') }}\<Esc>0fafagf

Execute:
AssertEqual expand('%'), 'resources/lang/auth.php'

After (clean up buffer):
bdelete