vis: implement :set cursorline
[vis.git] / lexers / props.lua
blobef5edad7450d62527b92e970dd7240c59227473c
1 -- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE.
2 -- Props LPeg lexer.
4 local l = require('lexer')
5 local token, word_match = l.token, l.word_match
6 local P, R, S = lpeg.P, lpeg.R, lpeg.S
8 local M = {_NAME = 'props'}
10 -- Whitespace.
11 local ws = token(l.WHITESPACE, l.space^1)
13 -- Comments.
14 local comment = token(l.COMMENT, '#' * l.nonnewline^0)
16 -- Equals.
17 local equals = token(l.OPERATOR, '=')
19 -- Strings.
20 local sq_str = l.delimited_range("'")
21 local dq_str = l.delimited_range('"')
22 local string = token(l.STRING, sq_str + dq_str)
24 -- Variables.
25 local variable = token(l.VARIABLE, '$(' * (l.any - ')')^1 * ')')
27 -- Colors.
28 local xdigit = l.xdigit
29 local color = token('color', '#' * xdigit * xdigit * xdigit * xdigit * xdigit *
30 xdigit)
32 M._rules = {
33 {'whitespace', ws},
34 {'color', color},
35 {'comment', comment},
36 {'equals', equals},
37 {'string', string},
38 {'variable', variable},
41 M._tokenstyles = {
42 color = l.STYLE_NUMBER
45 M._LEXBYLINE = true
47 return M