Skip to content

Commit 2c5c72a

Browse files
committed
Support {lnum} and {define} in "related" projection
References tpope#441
1 parent 2156c58 commit 2c5c72a

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

autoload/rails.vim

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3269,9 +3269,12 @@ function! s:readable_alternate_candidates(...) dict abort
32693269
let f = self.name()
32703270
let placeholders = {}
32713271
if a:0 && a:1
3272+
let placeholders.lnum = a:1
3273+
let placeholders.line = a:1
32723274
let lastmethod = self.last_method(a:1)
32733275
if !empty(lastmethod)
32743276
let placeholders.d = lastmethod
3277+
let placeholders.define = lastmethod
32753278
endif
32763279
let projected = self.projected('related', placeholders)
32773280
if !empty(projected)

doc/rails.txt

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -759,19 +759,19 @@ The full list of available options is as follows:
759759
*rails-projection-related*
760760
"related" ~
761761
Determines the destination of the |rails-:R| and :.A commands. In
762-
addition to the standard placeholders, %d can be used for the current
763-
'define' match (typically a method).
762+
addition to the standard placeholders, {define} can be used for the
763+
current 'define' match (typically a method).
764764
*rails-projection-test*
765765
"test" ~
766766
Determines the default test file to run with |rails-:Rrunner| and
767767
|rails-:Rake|. Also serves as a default for "alternate".
768768
*rails-projection-task*
769769
"task" ~
770-
Determines the default rake task to run. Provide %l or %d to
771-
substitute the current line or 'define' match (typically a method), or
772-
just a bare % (like |:_%|) to substitute the current file name. If a
773-
list with two tasks is provided, the first will be used when a line
774-
number is given, and the second when it's omitted.
770+
Determines the default rake task to run. Provide {lnum} or {define}
771+
to substitute the current line number or 'define' match (typically a
772+
method), or just a bare % (like |:_%|) to substitute the current file
773+
name. If a list with two tasks is provided, the first will be used
774+
when a line number is given, and the second when it's omitted.
775775
*rails-projection-compiler*
776776
"compiler" ~
777777
Determines the |:compiler| plugin to use with |rails-:Rrunner|.
@@ -880,10 +880,10 @@ bundled (requires bundler.vim).
880880
\ "spec/fabricators/*_fabricator.rb": {
881881
\ "command": "fabricator",
882882
\ "affinity": "model",
883-
\ "alternate": "app/models/%s.rb",
884-
\ "related": "db/schema.rb#%p",
885-
\ "test": "spec/models/%s_spec.rb",
886-
\ "template": "Fabricator :%s do\nend"}}}
883+
\ "alternate": "app/models/{}.rb",
884+
\ "related": "db/schema.rb#{plural}",
885+
\ "test": "spec/models/{}_spec.rb",
886+
\ "template": "Fabricator :{} do\nend"}}}
887887
<
888888
See |rails-projections|. Generally, you should prefer these gem projections
889889
over global projections to avoid getting a bunch of useless commands in every

0 commit comments

Comments
 (0)