ctags is more compatible with OSX and homebrew.

This commit is contained in:
Kyle West 2012-01-24 13:42:00 -05:00
parent c0d8c402c3
commit ed5e906906
2 changed files with 13 additions and 10 deletions

View File

@ -3,8 +3,12 @@
# A script to run ctags on all .rb files in a project. Can be run on # A script to run ctags on all .rb files in a project. Can be run on
# the current dir, called from a git callback, or install itself as a # the current dir, called from a git callback, or install itself as a
# git post-merge and post-commit callback. # git post-merge and post-commit callback.
# More info here: http://vimeo.com/3989493
#
# This fork will work with homebrew installed ctags on OS X ("brew install ctags")
# Source: https://gist.github.com/1564787
CTAGS = '/opt/local/bin/ctags' CTAGS = '/usr/local/bin/ctags'
HOOKS = %w{ post-merge post-commit post-checkout } HOOKS = %w{ post-merge post-commit post-checkout }
HOOKS_DIR = '.git/hooks' HOOKS_DIR = '.git/hooks'
@ -13,13 +17,13 @@ def install
$stderr.print "The install option [-i] can only be used within a git repo; exiting.\n" $stderr.print "The install option [-i] can only be used within a git repo; exiting.\n"
exit 1 exit 1
end end
HOOKS.each { |hook| install_hook("#{HOOKS_DIR}/#{hook}") } HOOKS.each { |hook| install_hook("#{HOOKS_DIR}/#{hook}") }
end end
def run_tags(dir) def run_tags(dir)
if File.executable?(CTAGS) and File.writable?(dir) if File.executable?(CTAGS) and File.writable?(dir)
%x{find #{dir} -name \\*.rb | #{CTAGS} -e -f #{dir}/TAGS -L - 2>>/dev/null} %x{find #{dir} -name \\*.rb | #{CTAGS} -f #{dir}/TAGS -L - 2>>/dev/null}
else else
$stderr.print "FAILED to write TAGS file to #{dir}\n" $stderr.print "FAILED to write TAGS file to #{dir}\n"
end end
@ -30,7 +34,7 @@ def install_hook(hook)
$stderr.print "A file already exists at #{hook}, and will NOT be replaced.\n" $stderr.print "A file already exists at #{hook}, and will NOT be replaced.\n"
return return
end end
print "Linking #{__FILE__} to #{hook}\n" print "Linking #{__FILE__} to #{hook}\n"
%x{ln -s #{__FILE__} #{hook}} %x{ln -s #{__FILE__} #{hook}}
end end
@ -40,4 +44,4 @@ if ARGV.first == '-i'
else else
# if GIT_DIR is set, we are being called from git # if GIT_DIR is set, we are being called from git
run_tags( ENV['GIT_DIR'] ? "#{ENV['GIT_DIR']}/.." : Dir.pwd ) run_tags( ENV['GIT_DIR'] ? "#{ENV['GIT_DIR']}/.." : Dir.pwd )
end end

View File

@ -1,12 +1,12 @@
" set up automatic ctags " set up automatic ctags
let Tlist_Ctags_Cmd='/opt/local/bin/ctags' let Tlist_Ctags_Cmd='ctags'
" taglist defaults " taglist defaults
let Tlist_Auto_Highlight_Tag=0 let Tlist_Auto_Highlight_Tag=0
let Tlist_Auto_Open=0 let Tlist_Auto_Open=0
let Tlist_Compact_Format = 1 let Tlist_Compact_Format = 1
let Tlist_Exist_OnlyWindow = 1 let Tlist_Exist_OnlyWindow = 1
let Tlist_WinWidth = 40 let Tlist_WinWidth = 40
let Tlist_GainFocus_On_ToggleOpen = 1 let Tlist_GainFocus_On_ToggleOpen = 1
let Tlist_Show_Menu = 1 let Tlist_Show_Menu = 1
let Tlist_Use_Right_Window = 1 let Tlist_Use_Right_Window = 1
@ -16,4 +16,3 @@ let Tlist_Show_One_File = 1
let Tlist_Enable_Fold_Column = 0 let Tlist_Enable_Fold_Column = 0
let Tlist_Display_Prototype = 0 let Tlist_Display_Prototype = 0
let Tlist_Use_SingleClick = 1 let Tlist_Use_SingleClick = 1