X Tutup
Skip to content

Commit ca6580f

Browse files
committed
quick test nginx lexer
1 parent f27345f commit ca6580f

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

lua-syntaxhighlight-dev-1.rockspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ build = {
9191
["syntaxhighlight.textadept.moonscript"] = "syntaxhighlight/textadept/moonscript.lua",
9292
["syntaxhighlight.textadept.myrddin"] = "syntaxhighlight/textadept/myrddin.lua",
9393
["syntaxhighlight.textadept.nemerle"] = "syntaxhighlight/textadept/nemerle.lua",
94+
["syntaxhighlight.textadept.nginx"] = "syntaxhighlight/textadept/nginx.lua",
9495
["syntaxhighlight.textadept.nim"] = "syntaxhighlight/textadept/nim.lua",
9596
["syntaxhighlight.textadept.nsis"] = "syntaxhighlight/textadept/nsis.lua",
9697
["syntaxhighlight.textadept.null"] = "syntaxhighlight/textadept/null.lua",
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
local lpeg = require('lpeg')
2+
3+
local lexer = require('syntaxhighlight.textadept.lexer')
4+
local token, word_match = lexer.token, lexer.word_match
5+
local P, S, R = lpeg.P, lpeg.S, lpeg.R
6+
7+
local lex = lexer.new('nginx')
8+
9+
-- Keywords.
10+
lex:add_rule('keyword', token(lexer.KEYWORD, word_match[[
11+
location server events
12+
on off
13+
]]))
14+
15+
16+
-- Libraries and deprecated libraries.
17+
local library = token('library', word_match[[
18+
worker_connections
19+
include
20+
listen
21+
lua_code_cache
22+
alias
23+
content_by_lua
24+
worker_processes
25+
error_log
26+
daemon
27+
pid
28+
]])
29+
30+
lex:add_rule('library', library)
31+
lex:add_style('library', lexer.STYLE_TYPE)
32+
33+
lex:add_rule('variable', token(lexer.VARIABLE, '$' * (1 - lexer.space)^1))
34+
35+
return lex

0 commit comments

Comments
 (0)
X Tutup