vis: implement :set cursorline
[vis.git] / lexers / rhtml.lua
blob00dee38d89d6fc48f70814ea59f663b2d0b999a9
1 -- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE.
2 -- RHTML 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 = 'rhtml'}
10 -- Embedded in HTML.
11 local html = l.load('html')
13 -- Embedded Ruby.
14 local ruby = l.load('rails')
15 local ruby_start_rule = token('rhtml_tag', '<%' * P('=')^-1)
16 local ruby_end_rule = token('rhtml_tag', '%>')
17 l.embed_lexer(html, ruby, ruby_start_rule, ruby_end_rule)
19 M._tokenstyles = {
20 rhtml_tag = l.STYLE_EMBEDDED
23 local _foldsymbols = html._foldsymbols
24 _foldsymbols._patterns[#_foldsymbols._patterns + 1] = '<%%'
25 _foldsymbols._patterns[#_foldsymbols._patterns + 1] = '%%>'
26 _foldsymbols.rhtml_tag = {['<%'] = 1, ['%>'] = -1}
27 M._foldsymbols = _foldsymbols
29 return M