Created
September 2, 2021 16:37
-
-
Save SmileYzn/2046ea34473b70021beddae812b888fd to your computer and use it in GitHub Desktop.
Amx Mod X syntax for Lite Code Editor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- mod-version:2 -- lite-xl 2.0 | |
local syntax = require "core.syntax" | |
local symtable = { | |
["keyword"] = { | |
"if", | |
"then", | |
"else", | |
"elseif", | |
"do", | |
"while", | |
"for", | |
"break", | |
"continue", | |
"return", | |
"goto", | |
"typedef", | |
"enum", | |
"extern", | |
"static", | |
"stock", | |
"const", | |
"public", | |
"private", | |
"inline", | |
"switch", | |
"case", | |
"default", | |
"auto", | |
"new", | |
"void", | |
"int", | |
"short", | |
"long", | |
"Float", | |
"double", | |
"char", | |
"unsigned", | |
"bool", | |
"true", | |
"false", | |
"NULL", | |
"#include", | |
"#if", | |
"#ifdef", | |
"#ifndef", | |
"#else", | |
"#elseif", | |
"#endif", | |
"#define", | |
"#warning", | |
"#error", | |
"#pragma", | |
}, | |
["function"] = { | |
"register_plugin", "plugin_init", "client_putinserver" | |
}, | |
} | |
-- prepare a mixed symbol list | |
local function prepare_symbols(symtable) | |
local symbols = { } | |
for symtype, symlist in pairs(symtable) do | |
for _, symname in ipairs(symlist) do | |
symbols[symname:lower()] = symtype | |
symbols[symname:upper()] = symtype | |
end | |
end | |
return symbols | |
end | |
syntax.add { | |
files = { | |
"%.inc$", "%.inl$", "%.sma$" | |
}, | |
comment = "//", | |
patterns = { | |
{ pattern = "//.-\n", type = "comment" }, | |
{ pattern = { "/%*", "%*/" }, type = "comment" }, | |
{ pattern = { '"', '"', '\\' }, type = "string" }, | |
{ pattern = { "'", "'", '\\' }, type = "string" }, | |
{ pattern = "0x%x+", type = "number" }, | |
{ pattern = "%d+[%d%.eE]*f?", type = "number" }, | |
{ pattern = "%.?%d+f?", type = "number" }, | |
{ pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" }, | |
{ pattern = "struct%s()[%a_][%w_]*", type = {"keyword", "keyword2"} }, | |
{ pattern = "class%s()[%a_][%w_]*", type = {"keyword", "keyword2"} }, | |
{ pattern = "union%s()[%a_][%w_]*", type = {"keyword", "keyword2"} }, | |
{ pattern = "namespace%s()[%a_][%w_]*", type = {"keyword", "keyword2"} }, | |
{ pattern = "[%a_][%w_]*::", type = "symbol" }, | |
{ pattern = "::", type = "symbol" }, | |
{ pattern = "[%a_][%w_]*", type = "symbol" }, | |
{ pattern = "#include%s()<.->", type = {"keyword", "string"} }, | |
{ pattern = "#[%a_][%w_]*", type = "keyword" }, | |
}, | |
symbols = prepare_symbols(symtable), | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment