Skip to content

Commit cf76032

Browse files
author
Darrick Wiebe
committed
Added javascript ctags patterns and a rake task to install them
1 parent cb52fbc commit cf76032

3 files changed

Lines changed: 45 additions & 0 deletions

File tree

Rakefile

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
require 'rake'
2+
require 'rake/clean'
23

34
files = ['syntax/javascript.vim', 'indent/javascript.vim']
45

6+
CLEAN.include 'tmp/*_ctags'
7+
58
desc "Make zip file"
69
file 'javascript.zip' => files do |t|
710
File.unlink t.name if File.exists?(t.name)
@@ -47,6 +50,40 @@ task :install do
4750
end
4851
end
4952

53+
desc "Copy ~/.ctags to tmp/original_ctags"
54+
task :get_original_ctags do
55+
if File.exists?(File.expand_path("~/.ctags"))
56+
File.unlink('tmp/original_ctags') if File.exists?('tmp/original_ctags')
57+
FileUtils.cp(File.expand_path("~/.ctags"), 'tmp/original_ctags')
58+
elsif not File.exists?("tmp/original_ctags")
59+
File.open("tmp/original_ctags", "w") { }
60+
end
61+
end
62+
63+
desc "Combine tmp/original_ctags and extras/ctags"
64+
file 'tmp/combined_ctags' => ['tmp/original_ctags', 'extras/ctags'] do |t|
65+
begin_string = '# Begin vim-javascript generated section'
66+
end_string = '# End vim-javascript generated section'
67+
File.unlink t.name if File.exists?(t.name)
68+
File.open(t.name,"w") do |out|
69+
orig = File.read('tmp/original_ctags')
70+
orig.each_line.inject(true) do |can_print, line|
71+
can_print = false if line.chomp == begin_string
72+
out.puts line if can_print
73+
can_print or line.chomp == end_string
74+
end
75+
out.puts begin_string
76+
out.puts "# generated at #{ Time.now }"
77+
out.puts File.read('extras/ctags')
78+
out.puts end_string
79+
end
80+
end
81+
82+
desc "Add better javascript support to ctags"
83+
task :ctags => [:get_original_ctags, 'tmp/combined_ctags'] do
84+
FileUtils.cp('tmp/combined_ctags', File.expand_path('~/.ctags'))
85+
end
86+
5087
task 'zip' => 'javascript.zip'
5188
task 'vimball' => 'javascript.vba'
5289
task :default => [:zip, :vimball]

extras/ctags

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
--langdef=js
2+
--langmap=js:.js
3+
--regex-js=/([A-Za-z0-9._$]+)[ \t]*[:=][ \t]*\{/\1/,object/
4+
--regex-js=/([A-Za-z0-9._$()]+)[ \t]*[:=][ \t]*function[ \t]*\(/\1/,function/
5+
--regex-js=/function[ \t]+([A-Za-z0-9._$]+)[ \t]*([^)])/\1/,function/
6+
--regex-js=/([A-Za-z0-9._$]+)[ \t]*[:=][ \t]*\[/\1/,array/
7+
--regex-js=/([^= ]+)[ \t]*=[ \t]*[^"]'[^']*/\1/,string/
8+
--regex-js=/([^= ]+)[ \t]*=[ \t]*[^']"[^"]*/\1/,string/

tmp/.keep

Whitespace-only changes.

0 commit comments

Comments
 (0)