vis
a vi-like editor based on Plan 9's structural regular expressions
git clone https://9o.is/git/vis.git
commit be129f6564176e363a292db8e600e3b41cc36829 parent e18cb20b2e22a9f74499f0cd68194cea59ca86f6 Author: Marc André Tanner <mat@brain-dump.org> Date: Tue, 30 May 2017 15:06:01 +0200 lexer: add simple strace(1) output lexer Diffstat:
| A | lua/lexers/strace.lua | | | 31 | +++++++++++++++++++++++++++++++ |
| M | lua/plugins/filetype.lua | | | 5 | +++++ |
2 files changed, 36 insertions(+), 0 deletions(-)
diff --git a/lua/lexers/strace.lua b/lua/lexers/strace.lua @@ -0,0 +1,31 @@ +-- strace(1) output lexer + +local l = require('lexer') +local token, word_match = l.token, l.word_match +local S = lpeg.S + +local M = {_NAME = 'strace'} + +local ws = token(l.WHITESPACE, l.space^1) +local string = token(l.STRING, l.delimited_range('"', true) + l.delimited_range("'", true)) +local number = token(l.NUMBER, l.float + l.integer) +local constant = token(l.CONSTANT, (l.upper + '_') * (l.upper + l.digit + '_')^0) +local syscall = token(l.KEYWORD, l.starts_line(l.word)) +local operator = token(l.OPERATOR, S('+-/*%<>~!=^&|?~:;,.()[]{}')) +local comment = token(l.COMMENT, l.nested_pair('/*', '*/') + ('(' * (l.alpha + ' ')^1 * ')\n')) +local result = token(l.TYPE, '= ' * l.integer) + +M._rules = { + {'whitespace', ws}, + {'keyword', syscall}, + {'constant', constant}, + {'string', string}, + {'comment', comment}, + {'type', result}, + {'number', number}, + {'operator', operator}, +} + +M._LEXBYLINE = true + +return M diff --git a/lua/plugins/filetype.lua b/lua/plugins/filetype.lua @@ -349,6 +349,11 @@ vis.ftdetect.filetypes = { sql= { ext = { "%.ddl$", "%.sql$" }, }, + strace = { + detect = function(file, data) + return data:match("^execve%(") + end + }, systemd = { ext = { "%.automount$", "%.device$", "%.mount$", "%.path$",