aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrxi <rxi@users.noreply.github.com>2020-04-26 08:41:39 +0100
committerGitHub <noreply@github.com>2020-04-26 08:41:39 +0100
commitffaf9d83ff02880a3eeecbd6d6f5253764484b1a (patch)
treec3f435a9ea9cf0ec6037d44330e583a1b863cd27
parent8ebb6baf41dfaa58a193e7daa856e77d016d0499 (diff)
parentc1d14ec0b01f1f86bc77aa6526997d92a77ac355 (diff)
downloadlite-xl-plugins-ffaf9d83ff02880a3eeecbd6d6f5253764484b1a.tar.gz
lite-xl-plugins-ffaf9d83ff02880a3eeecbd6d6f5253764484b1a.zip
Merge pull request #17 from lordadamson/patch-1
Plugin for C++ files syntax highlighting
-rw-r--r--README.md1
-rw-r--r--plugins/language_cpp.lua121
2 files changed, 122 insertions, 0 deletions
diff --git a/README.md b/README.md
index aa010b4..c7d0042 100644
--- a/README.md
+++ b/README.md
@@ -14,6 +14,7 @@ Plugin | Description
[`eval`](plugins/eval.lua?raw=1) | Replaces selected Lua code with its evaluated result
[`gofmt`](plugins/gofmt.lua?raw=1) | Auto-formats the current go file, adds the missing imports and the missing return cases
[`indentguide`](plugins/indentguide.lua?raw=1) | Adds [indent guides](https://user-images.githubusercontent.com/3920290/79640716-f9860000-818a-11ea-9c3b-26d10dd0e0c0.png)
+[`language_cpp`](plugins/language_cpp.lua?raw=1) | Syntax for the [C++](https://isocpp.org/) programming language
[`language_fe`](plugins/language_fe.lua?raw=1) | Syntax for the [fe](https://github.com/rxi/fe) programming language
[`language_go`](plugins/language_go.lua?raw=1) | Syntax for the [Go](https://golang.org/) programming language
[`language_jiyu`](plugins/language_jiyu.lua?raw=1) | Syntax for the [jiyu](https://github.com/machinamentum/jiyu) programming language
diff --git a/plugins/language_cpp.lua b/plugins/language_cpp.lua
new file mode 100644
index 0000000..2b2fce5
--- /dev/null
+++ b/plugins/language_cpp.lua
@@ -0,0 +1,121 @@
+pcall(require, "plugins.language_c")
+
+local syntax = require "core.syntax"
+
+syntax.add {
+ files = {
+ "%.h$", "%.inl$", "%.cpp$", "%.cc$", "%.C$", "%.cxx$",
+ "%.c++$", "%.hh$", "%.H$", "%.hxx$", "%.hpp$", "%.h++$"
+ },
+ comment = "//",
+ patterns = {
+ { pattern = "//.-\n", type = "comment" },
+ { pattern = { "/%*", "%*/" }, type = "comment" },
+ { pattern = { "#", "[^\\]\n" }, 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 = "[%a_][%w_]*%f[(]", type = "function" },
+ { pattern = "[%a_][%w_]*", type = "symbol" },
+ },
+ symbols = {
+ ["alignof"] = "keyword",
+ ["alignas"] = "keyword",
+ ["and"] = "keyword",
+ ["and_eq"] = "keyword",
+ ["not"] = "keyword",
+ ["not_eq"] = "keyword",
+ ["or"] = "keyword",
+ ["or_eq"] = "keyword",
+ ["xor"] = "keyword",
+ ["xor_eq"] = "keyword",
+ ["private"] = "keyword",
+ ["protected"] = "keyword",
+ ["public"] = "keyword",
+ ["register"] = "keyword",
+ ["nullptr"] = "keyword",
+ ["operator"] = "keyword",
+ ["asm"] = "keyword",
+ ["bitand"] = "keyword",
+ ["bitor"] = "keyword",
+ ["catch"] = "keyword",
+ ["throw"] = "keyword",
+ ["try"] = "keyword",
+ ["class"] = "keyword",
+ ["compl"] = "keyword",
+ ["explicit"] = "keyword",
+ ["export"] = "keyword",
+ ["concept"] = "keyword",
+ ["consteval"] = "keyword",
+ ["constexpr"] = "keyword",
+ ["constinit"] = "keyword",
+ ["const_cast"] = "keyword",
+ ["dynamic_cast"] = "keyword",
+ ["reinterpret_cast"] = "keyword",
+ ["static_cast"] = "keyword",
+ ["static_assert"] = "keyword",
+ ["template"] = "keyword",
+ ["this"] = "keyword",
+ ["thread_local"] = "keyword",
+ ["requires"] = "keyword",
+ ["co_wait"] = "keyword",
+ ["co_return"] = "keyword",
+ ["co_yield"] = "keyword",
+ ["decltype"] = "keyword",
+ ["delete"] = "keyword",
+ ["export"] = "keyword",
+ ["friend"] = "keyword",
+ ["typeid"] = "keyword",
+ ["typename"] = "keyword",
+ ["mutable"] = "keyword",
+ ["virtual"] = "keyword",
+ ["using"] = "keyword",
+ ["namespace"] = "keyword",
+ ["new"] = "keyword",
+ ["noexcept"] = "keyword",
+ ["if"] = "keyword",
+ ["then"] = "keyword",
+ ["else"] = "keyword",
+ ["elseif"] = "keyword",
+ ["do"] = "keyword",
+ ["while"] = "keyword",
+ ["for"] = "keyword",
+ ["break"] = "keyword",
+ ["continue"] = "keyword",
+ ["return"] = "keyword",
+ ["goto"] = "keyword",
+ ["struct"] = "keyword",
+ ["union"] = "keyword",
+ ["typedef"] = "keyword",
+ ["enum"] = "keyword",
+ ["extern"] = "keyword",
+ ["static"] = "keyword",
+ ["volatile"] = "keyword",
+ ["const"] = "keyword",
+ ["inline"] = "keyword",
+ ["switch"] = "keyword",
+ ["case"] = "keyword",
+ ["default"] = "keyword",
+ ["auto"] = "keyword",
+ ["const"] = "keyword",
+ ["void"] = "keyword",
+ ["int"] = "keyword2",
+ ["short"] = "keyword2",
+ ["long"] = "keyword2",
+ ["float"] = "keyword2",
+ ["double"] = "keyword2",
+ ["char"] = "keyword2",
+ ["unsigned"] = "keyword2",
+ ["bool"] = "keyword2",
+ ["true"] = "keyword2",
+ ["false"] = "keyword2",
+ ["wchar_t"] = "keyword2",
+ ["char8_t"] = "keyword2",
+ ["char16_t"] = "keyword2",
+ ["char32_t"] = "keyword2",
+ ["NULL"] = "literal",
+ },
+}