~martanne/vis

c3cfeacc22abae245047dbf429413e265f92bc3c — Marc André Tanner 8 months ago 0158a39 scintillua
lexers/typescript: add new upstream lexer revision 28e2b60
2 files changed, 27 insertions(+), 1 deletions(-)

A lua/lexers/typescript.lua
M lua/plugins/filetype.lua
A lua/lexers/typescript.lua => lua/lexers/typescript.lua +23 -0
@@ 0,0 1,23 @@
-- Copyright 2021 Mitchell. See LICENSE.
-- TypeScript LPeg lexer.

local lexer = require('lexer')
local token, word_match = lexer.token, lexer.word_match
local P, S = lpeg.P, lpeg.S

local lex = lexer.new('typescript', {inherit = lexer.load('javascript')})

-- Whitespace
lex:modify_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1))

-- Keywords.
lex:modify_rule('keyword', token(lexer.KEYWORD, word_match[[
  abstract as constructor declare is module namespace require type
]]) + lex:get_rule('keyword'))

-- Types.
lex:modify_rule('type', token(lexer.TYPE, word_match[[
  boolean number bigint string unknown any void never symbol object
]]) + lex:get_rule('type'))

return lex

M lua/plugins/filetype.lua => lua/plugins/filetype.lua +4 -1
@@ 204,7 204,7 @@ vis.ftdetect.filetypes = {
		ext = { "%.bsh$", "%.java$" },
	},
	javascript = {
		ext = { "%.cjs$", "%.js$", "%.jsfl$", "%.mjs$", "%.ts$" },
		ext = { "%.cjs$", "%.js$", "%.jsfl$", "%.mjs$" },
	},
	jq = {
		ext = { "%.jq$" },


@@ 424,6 424,9 @@ vis.ftdetect.filetypes = {
	toml = {
		ext = { "%.toml$" },
	},
	typescript = {
		ext = { "%.ts$" },
	},
	vala = {
		ext = { "%.vala$" }
	},