diff options
author | Jefferson González <jgmdev@gmail.com> | 2022-03-04 15:06:26 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-04 15:06:26 -0400 |
commit | 65ebd563b97b782a25ca05a62363212406d00fa3 (patch) | |
tree | 1d87141967e0aeca8dcc31fbe275bb23e595f14c | |
parent | d3d9cf68f7d2c98e7be3696a55b13e0e83160e40 (diff) | |
parent | d8bbcd3fac574c06b2ec4d541d34081b41ef5439 (diff) | |
download | lite-xl-plugins-65ebd563b97b782a25ca05a62363212406d00fa3.tar.gz lite-xl-plugins-65ebd563b97b782a25ca05a62363212406d00fa3.zip |
Merge pull request #38 from jgmdev/language_diff
Language Diff
-rw-r--r-- | README.md | 1 | ||||
-rw-r--r-- | plugins/language_diff.lua | 70 |
2 files changed, 71 insertions, 0 deletions
@@ -52,6 +52,7 @@ to something other than a raw file it should be marked with an asterisk.* | [`language_crystal`](https://github.com/Tamnac/lite-xl-plugins) | Syntax for the [Crystal](https://crystal-lang.org) programming language | | [`language_csharp`](plugins/language_csharp.lua?raw=1) | Syntax for the [C#](http://csharp.net) programming language | | [`language_d`](plugins/language_d.lua?raw=1) | Syntax for the [D](https://dlang.org/) programming language | +| [`language_diff`](plugins/language_diff.lua?raw=1) | Syntax for diff and patch files | | [`language_dart`](plugins/language_dart.lua?raw=1) | Syntax for the [Dart](https://dart.dev/) programming languiage | | [`language_elixir`](plugins/language_elixir.lua?raw=1) | Syntax for the [Elixir](https://elixir-lang.org) programming language | | [`language_elm`](plugins/language_elm.lua?raw=1) | Syntax for the [Elm](https://elm-lang.org) programming language | diff --git a/plugins/language_diff.lua b/plugins/language_diff.lua new file mode 100644 index 0000000..4376b26 --- /dev/null +++ b/plugins/language_diff.lua @@ -0,0 +1,70 @@ +-- mod-version:2 -- lite-xl 2.0 +local syntax = require "core.syntax" +local style = require "core.style" +local common = require "core.common" + +-- we need these symbol types to have uniform colors +style.syntax["diff_add"] = { common.color "#72b886" } +style.syntax["diff_del"] = { common.color "#F36161" } + +syntax.add { + name = "Diff", + files = { "%.diff$", "%.patch$", "%.rej$" }, + headers = "^diff %-", + patterns = { + -- Method the patch was generated with and source/target files + { regex = "^diff .+", type = "function" }, + -- Seen for changing the file permissions + { regex = "^new .+", type = "comment" }, + -- Usually holds starting and ending commit + { regex = "^index .+", type = "comment" }, + -- Position to patch + { + pattern = "@@.-@@ ().+", --with heading + type = { "number", "string" } + }, + { + regex = "^@@ [\\d,\\-\\+ ]+ @@\n", --wihtout heading + type = "number" + }, + -- Other position to patch formats + { + regex = "^-{3} [\\d]+,[\\d]+ \\-{4}\n", + type = "number" + }, + { + regex = "^\\*{3} [\\d]+,[\\d]+ \\*{4}\n", + type = "number" + }, + -- Source and target file + { regex = "^-{3} .+", type = "keyword" }, + { regex = "^\\+{3} .+", type = "keyword" }, + -- Rarely used source file indicator + { regex = "^\\*{3} .+", type = "keyword" }, + -- git patches seem to add 3 dashes to separate message from changed files + { regex = "^-{3}\n", type = "normal" }, + -- Addition and deletion of lines + { regex = "^-.*", type = "diff_del" }, + { regex = "^\\+.*", type = "diff_add" }, + { regex = "^<.*", type = "diff_del" }, + { regex = "^>.*", type = "diff_add" }, + -- Change between two lines + { regex = "^!.*", type = "number" }, + -- Stuff usually found on a authored patch heading + { + pattern = "From ()[a-fA-F0-9]+ ().+", + type = { "keyword", "number", "string" } + }, + { regex = "^[a-zA-Z\\-]+: ", type = "keyword" }, + -- Diff stats + { regex = "^ [\\d]+ files? changed", type = "function" }, + { regex = "[\\d]+ insertions?\\(\\+\\)", type = "diff_add" }, + { regex = "[\\d]+ deletions?\\(\\-\\)", type = "diff_del" }, + -- Match e-mail + { + pattern = ".*()<[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+%.[a-zA-Z0-9-.]+>", + type = {"string", "keyword2"} + }, + }, + symbols = {} +} |