vis

a vi-like editor based on Plan 9's structural regular expressions

git clone https://9o.is/git/vis.git

commit a8fa7d3c4f96b9cfdcfa9edf55515727fe7c913f
parent b6bf780b34fbeb63877dcb31ce4b390a1b9bc22f
Author: Marc André Tanner <mat@brain-dump.org>
Date:   Thu, 16 Jan 2020 16:40:31 +0100

Merge branch 'text' of https://github.com/zsugabubus/vis

Diffstat:
Mlua/lexers/text.lua | 9+++++++++
Mlua/plugins/filetype.lua | 10++++++++++
2 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/lua/lexers/text.lua b/lua/lexers/text.lua @@ -1,6 +1,15 @@ -- Copyright 2006-2017 Mitchell mitchell.att.foicica.com. See LICENSE. -- Text LPeg lexer. +local l = require('lexer') + local M = {_NAME = 'text'} +-- Whitespace. +local ws = l.token(l.WHITESPACE, l.space^1) + +M._rules = { + {'whitespace', ws}, +} + return M diff --git a/lua/plugins/filetype.lua b/lua/plugins/filetype.lua @@ -388,6 +388,10 @@ vis.ftdetect.filetypes = { texinfo = { ext = { "%.texi$" }, }, + text = { + ext = { "%.txt$" }, + mime = { "text/plain" }, + }, toml = { ext = { "%.toml$" }, }, @@ -500,6 +504,12 @@ vis.events.subscribe(vis.events.WIN_OPEN, function(win) end end + -- try text lexer as a last resort + if (mime or 'text/plain'):match('^text/.+$') then + set_filetype('text', vis.ftdetect.filetypes.text) + return + end + win:set_syntax(nil) end)