Browse files

Added javascript ctags patterns and a rake task to install them

  • Loading branch information...
1 parent cb52fbc commit cf76032a4f981490735a2c8d93d2ab9c7ce16db3 Darrick Wiebe committed Sep 1, 2009
Showing with 45 additions and 0 deletions.
  1. +37 −0 Rakefile
  2. +8 −0 extras/ctags
  3. 0 tmp/.keep
View
37 Rakefile
@@ -1,7 +1,10 @@
require 'rake'
+require 'rake/clean'
files = ['syntax/javascript.vim', 'indent/javascript.vim']
+CLEAN.include 'tmp/*_ctags'
+
desc "Make zip file"
file 'javascript.zip' => files do |t|
File.unlink t.name if File.exists?(t.name)
@@ -47,6 +50,40 @@ task :install do
end
end
+desc "Copy ~/.ctags to tmp/original_ctags"
+task :get_original_ctags do
+ if File.exists?(File.expand_path("~/.ctags"))
+ File.unlink('tmp/original_ctags') if File.exists?('tmp/original_ctags')
+ FileUtils.cp(File.expand_path("~/.ctags"), 'tmp/original_ctags')
+ elsif not File.exists?("tmp/original_ctags")
+ File.open("tmp/original_ctags", "w") { }
+ end
+end
+
+desc "Combine tmp/original_ctags and extras/ctags"
+file 'tmp/combined_ctags' => ['tmp/original_ctags', 'extras/ctags'] do |t|
+ begin_string = '# Begin vim-javascript generated section'
+ end_string = '# End vim-javascript generated section'
+ File.unlink t.name if File.exists?(t.name)
+ File.open(t.name,"w") do |out|
+ orig = File.read('tmp/original_ctags')
+ orig.each_line.inject(true) do |can_print, line|
+ can_print = false if line.chomp == begin_string
+ out.puts line if can_print
+ can_print or line.chomp == end_string
+ end
+ out.puts begin_string
+ out.puts "# generated at #{ Time.now }"
+ out.puts File.read('extras/ctags')
+ out.puts end_string
+ end
+end
+
+desc "Add better javascript support to ctags"
+task :ctags => [:get_original_ctags, 'tmp/combined_ctags'] do
+ FileUtils.cp('tmp/combined_ctags', File.expand_path('~/.ctags'))
+end
+
task 'zip' => 'javascript.zip'
task 'vimball' => 'javascript.vba'
task :default => [:zip, :vimball]
View
8 extras/ctags
@@ -0,0 +1,8 @@
+--langdef=js
+--langmap=js:.js
+--regex-js=/([A-Za-z0-9._$]+)[ \t]*[:=][ \t]*\{/\1/,object/
+--regex-js=/([A-Za-z0-9._$()]+)[ \t]*[:=][ \t]*function[ \t]*\(/\1/,function/
+--regex-js=/function[ \t]+([A-Za-z0-9._$]+)[ \t]*([^)])/\1/,function/
+--regex-js=/([A-Za-z0-9._$]+)[ \t]*[:=][ \t]*\[/\1/,array/
+--regex-js=/([^= ]+)[ \t]*=[ \t]*[^"]'[^']*/\1/,string/
+--regex-js=/([^= ]+)[ \t]*=[ \t]*[^']"[^"]*/\1/,string/
View
0 tmp/.keep
No changes.

0 comments on commit cf76032

Please sign in to comment.