aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorcukmekerb <cukmekerb@gmail.com>2021-09-11 13:44:38 -0700
committercukmekerb <cukmekerb@gmail.com>2021-09-11 13:44:38 -0700
commit37607f12c9165627de0253fdb4db07d2ffac56d6 (patch)
tree67231236ade80f36dfb99f8f31dff57b8de2d478 /plugins
parent132e67f214d20840e207da5703789f2f57c4845f (diff)
parenteca7bfe9d7e20acfb49902c9fced85f0a5a978cc (diff)
downloadlite-xl-plugins-37607f12c9165627de0253fdb4db07d2ffac56d6.tar.gz
lite-xl-plugins-37607f12c9165627de0253fdb4db07d2ffac56d6.zip
Merge branch 'master' of https://github.com/lite-xl/lite-plugins
Diffstat (limited to 'plugins')
-rw-r--r--plugins/langauge_rescript.lua59
-rw-r--r--plugins/language_java.lua106
-rw-r--r--plugins/language_lobster.lua2
-rw-r--r--plugins/language_php.lua177
-rw-r--r--plugins/language_phps.lua140
-rw-r--r--[-rwxr-xr-x]plugins/linecopypaste.lua6
-rw-r--r--plugins/linenumbers.lua2
7 files changed, 295 insertions, 197 deletions
diff --git a/plugins/langauge_rescript.lua b/plugins/langauge_rescript.lua
new file mode 100644
index 0000000..94dc964
--- /dev/null
+++ b/plugins/langauge_rescript.lua
@@ -0,0 +1,59 @@
+-- mod-version:2 -- lite-xl 2.0
+local syntax = require "core.syntax"
+
+syntax.add {
+ files = { "%.res$" },
+ comment = "//",
+ patterns = {
+ { pattern = "//.-\n", type = "comment" },
+ { pattern = { "/%*", "%*/" }, type = "comment" },
+ { pattern = { '"', '"', '\\' }, type = "string" },
+ { pattern = { "'", "'", '\\' }, type = "string" },
+ { pattern = { "`", "`", '\\' }, type = "string" },
+ { pattern = "#[%a_][%w_]*", type = "literal" },
+ { pattern = "0x[%da-fA-F]+", type = "number" },
+ { pattern = "-?%d+[%d%.eE]*", type = "number" },
+ { pattern = "-?%.?%d+", type = "number" },
+ { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" },
+ { pattern = "%f[^%.>]%l[%w_]*", type = "function" },
+ { pattern = "%l[%w_]*%f[(]", type = "function" },
+ { pattern = "%u[%w_]*", type = "keyword2" },
+ { pattern = "[%l_][%w_%.]*", type = "symbol" },
+ { pattern = "@%l[%w_]*", type = "string" },
+ },
+ symbols = {
+ ["and"] = "keyword",
+ ["array"] = "keyword2",
+ ["as"] = "keyword",
+ ["assert"] = "keyword",
+ ["bool"] = "keyword2",
+ ["constraint"] = "keyword",
+ ["downto"] = "keyword",
+ ["else"] = "keyword",
+ ["exception"] = "keyword",
+ ["external"] = "keyword",
+ ["false"] = "literal",
+ ["for"] = "keyword",
+ ["if"] = "keyword",
+ ["in"] = "keyword",
+ ["int"] = "keyword2",
+ ["include"] = "keyword",
+ ["lazy"] = "keyword",
+ ["let"] = "keyword",
+ ["module"] = "keyword",
+ ["mutable"] = "keyword",
+ ["of"] = "keyword",
+ ["open"] = "keyword",
+ ["option"] = "keyword2",
+ ["rec"] = "keyword",
+ ["switch"] = "keyword",
+ ["string"] = "keyword2",
+ ["to"] = "keyword",
+ ["true"] = "literal",
+ ["try"] = "keyword",
+ ["type"] = "keyword",
+ ["when"] = "keyword",
+ ["while"] = "keyword",
+ ["with"] = "keyword",
+ }
+}
diff --git a/plugins/language_java.lua b/plugins/language_java.lua
index 8c6e98e..e6d3735 100644
--- a/plugins/language_java.lua
+++ b/plugins/language_java.lua
@@ -20,55 +20,63 @@ syntax.add {
{ pattern = "[%a_][%w_]*", type = "symbol" },
},
symbols = {
- ["if"] = "keyword",
- ["then"] = "keyword",
- ["else"] = "keyword",
- ["else if"] = "keyword",
- ["do"] = "keyword",
- ["while"] = "keyword",
- ["for"] = "keyword",
- ["new"] = "keyword",
- ["break"] = "keyword",
- ["continue"] = "keyword",
- ["return"] = "keyword",
- ["goto"] = "keyword",
- ["class"] = "keyword",
- ["implements"] = "keyword",
- ["extends"] = "keyword",
- ["private"] = "keyword",
- ["protected"] = "keyword",
- ["public"] = "keyword",
- ["abstract"] = "keyword",
- ["interface"] = "keyword",
- ["assert"] = "keyword",
- ["import"] = "keyword",
- ["native"] = "keyword",
- ["package"] = "keyword",
- ["super"] = "keyword",
- ["synchronized"] = "keyword",
- ["instanceof"] = "keyword",
- ["enum"] = "keyword",
- ["catch"] = "keyword",
- ["throw"] = "keyword",
- ["throws"] = "keyword",
- ["try"] = "keyword",
- ["transient"] = "keyword",
- ["finally"] = "keyword",
- ["static"] = "keyword",
- ["volatile"] = "keyword",
- ["final"] = "keyword",
- ["switch"] = "keyword",
- ["case"] = "keyword",
- ["default"] = "keyword",
- ["void"] = "keyword",
- ["int"] = "keyword2",
- ["short"] = "keyword2",
- ["byte"] = "keyword2",
- ["long"] = "keyword2",
- ["float"] = "keyword2",
- ["double"] = "keyword2",
- ["char"] = "keyword2",
- ["boolean"] = "keyword2",
+ ["abstract"] = "keyword",
+ ["assert"] = "keyword",
+ ["break"] = "keyword",
+ ["case"] = "keyword",
+ ["catch"] = "keyword",
+ ["class"] = "keyword",
+ ["const"] = "keyword",
+ ["continue"] = "keyword",
+ ["default"] = "keyword",
+ ["do"] = "keyword",
+ ["else"] = "keyword",
+ ["enum"] = "keyword",
+ ["extends"] = "keyword",
+ ["final"] = "keyword",
+ ["finally"] = "keyword",
+ ["for"] = "keyword",
+ ["if"] = "keyword",
+ ["goto"] = "keyword",
+ ["implements"] = "keyword",
+ ["import"] = "keyword",
+ ["instanceof"] = "keyword",
+ ["interface"] = "keyword",
+ ["native"] = "keyword",
+ ["new"] = "keyword",
+ ["package"] = "keyword",
+ ["permits"] = "keyword",
+ ["private"] = "keyword",
+ ["protected"] = "keyword",
+ ["public"] = "keyword",
+ ["record"] = "keyword",
+ ["return"] = "keyword",
+ ["sealed"] = "keyword",
+ ["static"] = "keyword",
+ ["strictfp"] = "keyword",
+ ["super"] = "keyword",
+ ["switch"] = "keyword",
+ ["synchronized"] = "keyword",
+ ["this"] = "keyword",
+ ["throw"] = "keyword",
+ ["throws"] = "keyword",
+ ["transient"] = "keyword",
+ ["try"] = "keyword",
+ ["var"] = "keyword",
+ ["void"] = "keyword",
+ ["volatile"] = "keyword",
+ ["while"] = "keyword",
+ ["yield"] = "keyword",
+
+ ["boolean"] = "keyword2",
+ ["byte"] = "keyword2",
+ ["char"] = "keyword2",
+ ["double"] = "keyword2",
+ ["float"] = "keyword2",
+ ["int"] = "keyword2",
+ ["long"] = "keyword2",
+ ["short"] = "keyword2",
+
["true"] = "literal",
["false"] = "literal",
["null"] = "literal",
diff --git a/plugins/language_lobster.lua b/plugins/language_lobster.lua
index 8b4d899..593c89d 100644
--- a/plugins/language_lobster.lua
+++ b/plugins/language_lobster.lua
@@ -1,4 +1,4 @@
--- mod-version:1 -- lite-xl 1.16
+-- mod-version:2 -- lite-xl 2.0
local syntax = require "core.syntax"
syntax.add {
diff --git a/plugins/language_php.lua b/plugins/language_php.lua
index 4f107aa..5ee6a93 100644
--- a/plugins/language_php.lua
+++ b/plugins/language_php.lua
@@ -1,13 +1,149 @@
-- mod-version:2 -- lite-xl 2.0
--[[
- language_php.lua
- provides php syntax support allowing mixed html, css and js
- version: 20210513_144200
-
- Depends on plugin language_phps.lua version >= 20210512_181200
+ language_php.lua
+ provides php syntax support allowing mixed html, css and js
+ version: 20210902_1
--]]
local syntax = require "core.syntax"
+-- load syntax dependencies to add additional rules
+require "plugins.language_css"
+require "plugins.language_js"
+
+-- define the core php syntax coloring
+syntax.add {
+ files = { "%.phps$" },
+ headers = "^<%?php",
+ comment = "//",
+ patterns = {
+ -- Attributes
+ { pattern = {"#%[", "%]"}, type = "normal" },
+ -- Comments
+ { pattern = "//.-\n", type = "comment" },
+ { pattern = "#.-\n", type = "comment" },
+ { pattern = { "/%*", "%*/" }, type = "comment" },
+ -- The '\\' is for escaping to work on " or '
+ { pattern = { '"', '"', '\\' }, type = "string" },
+ { pattern = { "'", "'", '\\' }, type = "string" },
+ { pattern = "0[bB][%d]+", type = "number" },
+ { pattern = "0[xX][%da-fA-F]+", type = "number" },
+ { pattern = "-?%d[%d_%.eE]*", type = "number" },
+ { pattern = "-?%.?%d+", type = "number" },
+ { pattern = "[%.%+%-=/%*%^%%<>!~|&%?:]", type = "operator" },
+ -- Variables
+ { pattern = "%$[%w_]+", type = "keyword2" },
+ -- Respect control structures, treat as keyword not function
+ { pattern = "if[%s]*%f[(]", type = "keyword" },
+ { pattern = "else[%s]*%f[(]", type = "keyword" },
+ { pattern = "elseif[%s]*%f[(]", type = "keyword" },
+ { pattern = "for[%s]*%f[(]", type = "keyword" },
+ { pattern = "foreach[%s]*%f[(]", type = "keyword" },
+ { pattern = "while[%s]*%f[(]", type = "keyword" },
+ { pattern = "catch[%s]*%f[(]", type = "keyword" },
+ { pattern = "switch[%s]*%f[(]", type = "keyword" },
+ { pattern = "match[%s]*%f[(]", type = "keyword" },
+ { pattern = "fn[%s]*%f[(]", type = "keyword" },
+ -- All functions that aren't control structures
+ { pattern = "[%a_][%w_]*[%s]*%f[(]", type = "function" },
+ -- Array type hint not added on symbols to also make it work
+ -- as a function call
+ { pattern = "array", type = "literal" },
+ -- Match static or namespace container on sub element access
+ { pattern = "[%a_][%w_]*[%s]*%f[:]", type = "literal" },
+ -- Uppercase constants of at least 3 characters in len
+ { pattern = "%u[%u_][%u%d_]+", type = "number" },
+ -- Magic constants
+ { pattern = "__[%u]+__", type = "number" },
+ -- Everything else
+ { pattern = "[%a_][%w_]*", type = "symbol" },
+ },
+ symbols = {
+ ["return"] = "keyword",
+ ["if"] = "keyword",
+ ["else"] = "keyword",
+ ["elseif"] = "keyword",
+ ["endif"] = "keyword",
+ ["declare"] = "keyword",
+ ["enddeclare"] = "keyword",
+ ["switch"] = "keyword",
+ ["endswitch"] = "keyword",
+ ["as"] = "keyword",
+ ["do"] = "keyword",
+ ["for"] = "keyword",
+ ["endfor"] = "keyword",
+ ["foreach"] = "keyword",
+ ["endforeach"] = "keyword",
+ ["while"] = "keyword",
+ ["endwhile"] = "keyword",
+ ["match"] = "keyword",
+ ["case"] = "keyword",
+ ["continue"] = "keyword",
+ ["default"] = "keyword",
+ ["break"] = "keyword",
+ ["goto"] = "keyword",
+
+ ["try"] = "keyword",
+ ["catch"] = "keyword",
+ ["throw"] = "keyword",
+ ["finally"] = "keyword",
+
+ ["class"] = "keyword",
+ ["trait"] = "keyword",
+ ["interface"] = "keyword",
+ ["public"] = "keyword",
+ ["static"] = "keyword",
+ ["protected"] = "keyword",
+ ["private"] = "keyword",
+ ["abstract"] = "keyword",
+ ["final"] = "keyword",
+ ["$this"] = "literal",
+
+ ["function"] = "keyword",
+ ["fn"] = "keyword",
+ ["global"] = "keyword",
+ ["var"] = "keyword",
+ ["const"] = "keyword",
+
+ ["bool"] = "literal",
+ ["boolean"] = "literal",
+ ["int"] = "literal",
+ ["integer"] = "literal",
+ ["real"] = "literal",
+ ["double"] = "literal",
+ ["float"] = "literal",
+ ["string"] = "literal",
+ ["object"] = "literal",
+ ["callable"] = "literal",
+ ["iterable"] = "literal",
+ ["void"] = "literal",
+ ["parent"] = "literal",
+ ["self"] = "literal",
+ ["mixed"] = "literal",
+
+ ["namespace"] = "keyword",
+ ["extends"] = "keyword",
+ ["implements"] = "keyword",
+ ["instanceof"] = "keyword",
+ ["require"] = "keyword",
+ ["require_once"] = "keyword",
+ ["include"] = "keyword",
+ ["include_once"] = "keyword",
+ ["use"] = "keyword",
+ ["new"] = "keyword",
+ ["clone"] = "keyword",
+
+ ["true"] = "number",
+ ["false"] = "number",
+ ["NULL"] = "number",
+ ["null"] = "number",
+
+ ["print"] = "function",
+ ["echo"] = "function",
+ ["exit"] = "function",
+ },
+}
+
+-- allows html, css and js coloring on php files
syntax.add {
files = { "%.php$", "%.phtml" },
patterns = {
@@ -68,3 +204,34 @@ syntax.add {
symbols = {},
}
+-- allow coloring of php code inside css and js code
+local syntaxes = { "css", "js" }
+for _, ext in pairs(syntaxes) do
+ local syntax_table = syntax.get("file."..ext, "")
+
+ table.insert(
+ syntax_table.patterns,
+ 1,
+ {
+ pattern = {
+ "<%?=?",
+ "%?>"
+ },
+ syntax = ".phps",
+ type = "keyword2"
+ }
+ )
+
+ table.insert(
+ syntax_table.patterns,
+ 1,
+ {
+ pattern = {
+ "<%?php%s+",
+ "%?>"
+ },
+ syntax = ".phps",
+ type = "keyword2"
+ }
+ )
+end
diff --git a/plugins/language_phps.lua b/plugins/language_phps.lua
deleted file mode 100644
index 082b962..0000000
--- a/plugins/language_phps.lua
+++ /dev/null
@@ -1,140 +0,0 @@
--- mod-version:2 -- lite-xl 2.0
---[[
- language_phps.lua
- complement to language_php.lua providing the php syntax support
- version: 20210512_181200
---]]
-local syntax = require "core.syntax"
-
-syntax.add {
- files = { "%.phps$" },
- headers = "^<%?php",
- comment = "//",
- patterns = {
- -- Attributes
- { pattern = {"#%[", "%]"}, type = "normal" },
- -- Comments
- { pattern = "//.-\n", type = "comment" },
- { pattern = "#.-\n", type = "comment" },
- { pattern = { "/%*", "%*/" }, type = "comment" },
- -- The '\\' is for escaping to work on " or '
- { pattern = { '"', '"', '\\' }, type = "string" },
- { pattern = { "'", "'", '\\' }, type = "string" },
- { pattern = "0[bB][%d]+", type = "number" },
- { pattern = "0[xX][%da-fA-F]+", type = "number" },
- { pattern = "-?%d[%d_%.eE]*", type = "number" },
- { pattern = "-?%.?%d+", type = "number" },
- { pattern = "[%.%+%-=/%*%^%%<>!~|&%?:]", type = "operator" },
- -- Variables
- { pattern = "%$[%w_]+", type = "keyword2" },
- -- Respect control structures, treat as keyword not function
- { pattern = "if[%s]*%f[(]", type = "keyword" },
- { pattern = "else[%s]*%f[(]", type = "keyword" },
- { pattern = "elseif[%s]*%f[(]", type = "keyword" },
- { pattern = "for[%s]*%f[(]", type = "keyword" },
- { pattern = "foreach[%s]*%f[(]", type = "keyword" },
- { pattern = "while[%s]*%f[(]", type = "keyword" },
- { pattern = "catch[%s]*%f[(]", type = "keyword" },
- { pattern = "switch[%s]*%f[(]", type = "keyword" },
- { pattern = "match[%s]*%f[(]", type = "keyword" },
- { pattern = "fn[%s]*%f[(]", type = "keyword" },
- -- All functions that aren't control structures
- { pattern = "[%a_][%w_]*[%s]*%f[(]", type = "function" },
- -- Array type hint not added on symbols to also make it work
- -- as a function call
- { pattern = "array", type = "literal" },
- -- Match static or namespace container on sub element access
- { pattern = "[%a_][%w_]*[%s]*%f[:]", type = "literal" },
- -- Uppercase constants of at least 3 characters in len
- { pattern = "%u[%u_][%u%d_]+", type = "number" },
- -- Magic constants
- { pattern = "__[%u]+__", type = "number" },
- -- Everything else
- { pattern = "[%a_][%w_]*", type = "symbol" },
- },
- symbols = {
- ["return"] = "keyword",
- ["if"] = "keyword",
- ["else"] = "keyword",
- ["elseif"] = "keyword",
- ["endif"] = "keyword",
- ["declare"] = "keyword",
- ["enddeclare"] = "keyword",
- ["switch"] = "keyword",
- ["endswitch"] = "keyword",
- ["as"] = "keyword",
- ["do"] = "keyword",
- ["for"] = "keyword",
- ["endfor"] = "keyword",
- ["foreach"] = "keyword",
- ["endforeach"] = "keyword",
- ["while"] = "keyword",
- ["endwhile"] = "keyword",
- ["switch"] = "keyword",
- ["match"] = "keyword",
- ["case"] = "keyword",
- ["continue"] = "keyword",
- ["default"] = "keyword",
- ["break"] = "keyword",
- ["goto"] = "keyword",
-
- ["try"] = "keyword",
- ["catch"] = "keyword",
- ["throw"] = "keyword",
- ["finally"] = "keyword",
-
- ["class"] = "keyword",
- ["trait"] = "keyword",
- ["interface"] = "keyword",
- ["public"] = "keyword",
- ["static"] = "keyword",
- ["protected"] = "keyword",
- ["private"] = "keyword",
- ["abstract"] = "keyword",
- ["final"] = "keyword",
- ["$this"] = "literal",
-
- ["function"] = "keyword",
- ["fn"] = "keyword",
- ["global"] = "keyword",
- ["var"] = "keyword",
- ["const"] = "keyword",
-
- ["bool"] = "literal",
- ["boolean"] = "literal",
- ["int"] = "literal",
- ["integer"] = "literal",
- ["real"] = "literal",
- ["double"] = "literal",
- ["float"] = "literal",
- ["string"] = "literal",
- ["object"] = "literal",
- ["callable"] = "literal",
- ["iterable"] = "literal",
- ["void"] = "literal",
- ["parent"] = "literal",
- ["self"] = "literal",
- ["mixed"] = "literal",
-
- ["namespace"] = "keyword",
- ["extends"] = "keyword",
- ["implements"] = "keyword",
- ["instanceof"] = "keyword",
- ["require"] = "keyword",
- ["require_once"] = "keyword",
- ["include"] = "keyword",
- ["include_once"] = "keyword",
- ["use"] = "keyword",
- ["new"] = "keyword",
- ["clone"] = "keyword",
-
- ["true"] = "number",
- ["false"] = "number",
- ["NULL"] = "number",
- ["null"] = "number",
-
- ["print"] = "function",
- ["echo"] = "function",
- ["exit"] = "function",
- },
-}
diff --git a/plugins/linecopypaste.lua b/plugins/linecopypaste.lua
index d332cc1..ea2a84c 100755..100644
--- a/plugins/linecopypaste.lua
+++ b/plugins/linecopypaste.lua
@@ -28,7 +28,11 @@ command.map["doc:cut"].perform = function()
else
local line = doc():get_selection()
system.set_clipboard(doc().lines[line])
- doc():remove(line, 1, line+1, 1)
+ if line < #(doc().lines) then
+ doc():remove(line, 1, line+1, 1)
+ else -- last line in file
+ doc():remove(line, 1, line, #(doc().lines[line]))
+ end
doc():set_selection(line, 1)
line_in_clipboard = true
end
diff --git a/plugins/linenumbers.lua b/plugins/linenumbers.lua
index fde0a08..1b0bdc6 100644
--- a/plugins/linenumbers.lua
+++ b/plugins/linenumbers.lua
@@ -1,4 +1,4 @@
--- mod-version:1 -- lite-xl 1.16
+-- mod-version:2 -- lite-xl 2.0
local config = require "core.config"
local style = require "core.style"
local DocView = require "core.docview"