| 43 | | class AutoEnd::Handler::Ruby |
| 44 | | include AutoEnd::Helper |
| 45 | | |
| 46 | | def self.filetypes |
| 47 | | %w(ruby) |
| 48 | | end |
| 49 | | |
| 50 | | def initialize |
| 51 | | @exps = [ |
| 52 | | /^\s*#/, |
| 53 | | /^(=begin)\b/, |
| 54 | | /^\s*(class|module|def)\b(?!.*;)/, |
| 55 | | /([(\[]|\bbegin)\s*$/, |
| 56 | | /(\bdo|\{)(?:\s*\|.*\|)?\s*$/, |
| 57 | | /<<-?["'`]?(\w+)["'`]?/ |
| 58 | | ] |
| 59 | | |
| 60 | | @assoc = Hash.new {|h, k| k }.merge( |
| 61 | | 'class' => 'end', |
| 62 | | 'module' => 'end', |
| 63 | | 'def' => 'end', |
| 64 | | 'begin' => 'end', |
| 65 | | 'do' => 'end', |
| 66 | | '(' => ')', |
| 67 | | '{' => '}', |
| 68 | | '[' => ']', |
| 69 | | '=begin' => '=end' |
| 70 | | ) |
| 71 | | end |
| 72 | | |
| 73 | | def handle(line = $curbuf.line) |
| 74 | | return unless eol? && @exps.find {|e| e =~ line } |
| 75 | | append_line(indent + @assoc[$1]) if $1 |
| 76 | | end |
| | 43 | Dir.glob(File.join(AutoEnd::Helper::HERE, 'autoend_*.rb')) do |f| |
| | 44 | require f |