Last active
December 30, 2015 02:49
-
-
Save tkfm-yamaguchi/7765358 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/autoload/unite/sources/outline/defaults/ruby.vim b/autoload/unite/sources/outline/defaults/ruby.vim | |
index eb53c82..116bf81 100644 | |
--- a/autoload/unite/sources/outline/defaults/ruby.vim | |
+++ b/autoload/unite/sources/outline/defaults/ruby.vim | |
@@ -19,6 +19,9 @@ function! unite#sources#outline#defaults#ruby#outline_info(...) | |
if path =~ '_spec\.rb$' | |
" RSpec | |
return 'ruby/rspec' | |
+ elseif path =~ 'Rakefile$' || path =~ '\.rake$' | |
+ " Rake | |
+ return 'ruby/rake' | |
endif | |
endif | |
return s:outline_info |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function! unite#sources#outline#rake#outline_info() | |
return s:outline_info | |
endfunction | |
let s:Util = unite#sources#outline#import('Util') | |
"----------------------------------------------------------------------------- | |
" Outline Info | |
" Inherit Ruby's outline info. | |
let s:super = unite#sources#outline#get_outline_info('ruby', 1, 1) | |
let s:outline_info = deepcopy(s:super) | |
call extend(s:outline_info, { | |
\ 'super': s:super, | |
\ 'rake_heading_keywords': [ | |
\ 'namespace', 'task' | |
\ ] | |
\}) | |
function! s:outline_info.initialize() | |
let self.rake_heading = '^\s*\(' . join(self.rake_heading_keywords, '\|') . '\)\>' | |
let self.heading_keywords += self.rake_heading_keywords | |
call call(self.super.initialize, [], self) | |
endfunction | |
function! s:outline_info.create_heading(which, heading_line, matched_line, context) | |
if a:which == 'heading' && a:heading_line =~ self.rake_heading | |
let word = a:heading_line | |
let type = 'generic' | |
let level = s:Util.get_indent_level(a:context, a:context.heading_lnum) | |
let heading = { | |
\ 'word': word, | |
\ 'type': type, | |
\ 'level': level | |
\ } | |
return heading | |
else | |
let heading = call(self.super.create_heading, | |
\ [a:which, a:heading_line, a:matched_line, a:context], self.super) | |
return heading | |
endif | |
endfunction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment