Class: VimTokenizer
- Inherits:
-
Syntax::Tokenizer
- Object
- Syntax::Tokenizer
- VimTokenizer
- Defined in:
- lib/vim-syntax.rb
Overview
Syntax highlighting for vim script code.
Produces the following tokens:
-
comment
-
string
-
number
-
key
-
punct
-
whitespace
-
command
-
word
Instance Method Summary collapse
Instance Method Details
#step ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/vim-syntax.rb', line 19 def step @got_command ||= false if comment = scan(%r{\n".*?$}) # full line comment start_group(:comment, comment) elsif comment = scan(%r{"[^"]*?$}) # end of line comment start_group(:comment, comment) elsif string = scan(%r{"[^"]*?"|'[^']*?'}) start_group(:string, string) elsif number = scan(%r{\d+}) start_group(:number, number) elsif key = scan(%r{<[^<]+>}) start_group(:key, key) elsif punct = scan(%r{[^\w\süöäß]}) start_group(:punct, punct) elsif space = scan(%r{\s}) @got_command = false if space == "\n" start_group(:whitespace, space) elsif not @got_command and command = scan(%r{\w+}) @got_command = true start_group(:command, command) elsif @got_command and word = scan(%r{\w+}) start_group(:word, word) else start_group(:word, scan(%r{.})) end end |