Skip to content

Commit 48387c5

Browse files
committed
Prefer .ctags over g:rails_ctags_arguments
1 parent b6b2078 commit 48387c5

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

autoload/rails.vim

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,7 +1073,7 @@ function! rails#new_app_command(bang,...) abort
10731073
return ''
10741074
endfunction
10751075

1076-
function! s:app_tags_command() dict
1076+
function! s:app_tags_command() dict abort
10771077
if exists("g:Tlist_Ctags_Cmd")
10781078
let cmd = g:Tlist_Ctags_Cmd
10791079
elseif executable("exuberant-ctags")
@@ -1090,8 +1090,19 @@ function! s:app_tags_command() dict
10901090
call s:error("ctags not found")
10911091
return ''
10921092
endif
1093-
let args = s:split(get(g:, 'rails_ctags_arguments', '--languages=ruby'))
1094-
exe '!'.cmd.' -f '.s:escarg(self.path("tags")).' -R '.join(args,' ').' '.s:escarg(self.path())
1093+
let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd' : 'cd'
1094+
let cwd = getcwd()
1095+
try
1096+
execute cd fnameescape(self.path())
1097+
if self.has_path('.ctags')
1098+
let args = []
1099+
else
1100+
let args = s:split(get(g:, 'rails_ctags_arguments', '--languages=ruby'))
1101+
endif
1102+
exe '!'.cmd.' -f '.s:escarg(self.path("tags")).' -R '.join(args,' ')
1103+
finally
1104+
execute cd fnameescape(cwd)
1105+
endtry
10951106
return ''
10961107
endfunction
10971108

doc/rails.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,9 @@ Ruby files.
849849
>
850850
let g:rails_ctags_arguments = ['--languages=ruby']
851851
<
852+
This option is ignored if a ctags configuration file named .ctags is found in
853+
the root of the project.
854+
852855
*g:rails_projections* >
853856
Defines the set of globally available projections. See |rails-projections|.
854857
Where possible, it is generally advisable to use |g:rails_gem_projections| or

0 commit comments

Comments
 (0)