karottenreibe-vim-syntax 0.0.3 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/HISTORY.markdown +8 -0
- data/README.markdown +12 -0
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/lib/vim-syntax.rb +17 -8
- data/vim-syntax.gemspec +1 -1
- metadata +1 -1
data/HISTORY.markdown
CHANGED
data/README.markdown
CHANGED
@@ -19,3 +19,15 @@ Then:
|
|
19
19
|
convertor = Syntax::Convertors::HTML.for_syntax "vim"
|
20
20
|
puts convertor.convert( "let mapleader=','" )
|
21
21
|
|
22
|
+
What are the classes of the html elements it produces?
|
23
|
+
======================================================
|
24
|
+
|
25
|
+
* comment
|
26
|
+
* string
|
27
|
+
* key
|
28
|
+
* number
|
29
|
+
* punct
|
30
|
+
* command
|
31
|
+
* word
|
32
|
+
* whitespace
|
33
|
+
|
data/Rakefile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0
|
1
|
+
0.1.0
|
data/lib/vim-syntax.rb
CHANGED
@@ -1,29 +1,36 @@
|
|
1
1
|
|
2
2
|
require 'syntax'
|
3
3
|
|
4
|
+
#
|
5
|
+
# Syntax highlighting for vim script code.
|
6
|
+
#
|
7
|
+
# Produces the following tokens:
|
8
|
+
# - comment
|
9
|
+
# - string
|
10
|
+
# - number
|
11
|
+
# - key
|
12
|
+
# - punct
|
13
|
+
# - whitespace
|
14
|
+
# - command
|
15
|
+
# - word
|
16
|
+
#
|
4
17
|
class VimTokenizer < Syntax::Tokenizer
|
5
18
|
|
6
19
|
def step
|
7
20
|
@got_command ||= false
|
8
21
|
|
9
22
|
if comment = scan(%r{\n".*?$}) # full line comment
|
10
|
-
start_group(:whitespace, "\n")
|
11
23
|
start_group(:comment, comment)
|
12
24
|
elsif comment = scan(%r{"[^"]*?$}) # end of line comment
|
13
25
|
start_group(:comment, comment)
|
14
26
|
elsif string = scan(%r{"[^"]*?"|'[^']*?'})
|
15
27
|
start_group(:string, string)
|
16
|
-
elsif scan(%r{(function!?) (\w+)\(\)(.*?)endfunction}m)
|
17
|
-
start_group(:command, subgroup(1))
|
18
|
-
start_group(:functionname, subgroup(2))
|
19
|
-
start_group(:functionbody, subgroup(3))
|
20
|
-
start_group(:command, 'endfunction')
|
21
28
|
elsif number = scan(%r{\d+})
|
22
29
|
start_group(:number, number)
|
23
30
|
elsif key = scan(%r{<[^<]+>})
|
24
31
|
start_group(:key, key)
|
25
32
|
|
26
|
-
elsif punct = scan(%r{[^\w\
|
33
|
+
elsif punct = scan(%r{[^\w\süöäß]})
|
27
34
|
start_group(:punct, punct)
|
28
35
|
elsif space = scan(%r{\s})
|
29
36
|
@got_command = false if space == "\n"
|
@@ -32,8 +39,10 @@ class VimTokenizer < Syntax::Tokenizer
|
|
32
39
|
elsif not @got_command and command = scan(%r{\w+})
|
33
40
|
@got_command = true
|
34
41
|
start_group(:command, command)
|
42
|
+
elsif @got_command and word = scan(%r{\w+})
|
43
|
+
start_group(:word, word)
|
35
44
|
else
|
36
|
-
start_group(:
|
45
|
+
start_group(:word, scan(%r{.}))
|
37
46
|
end
|
38
47
|
end
|
39
48
|
|
data/vim-syntax.gemspec
CHANGED