aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorAdam <adamdharrison@gmail.com>2021-08-17 11:26:18 -0230
committerGitHub <noreply@github.com>2021-08-17 11:26:18 -0230
commit9689846686f77dc0aa1e6f4d31fbfc42998c2085 (patch)
treeb187286f2ed78fa9317f288dc0c5144840bcdad9 /plugins
parent44659ba00207cecd90412b714e53c2a1b7233fb9 (diff)
parenta42a0d57b08a9080ed9fd8fa84f1269e3847980f (diff)
downloadlite-xl-plugins-9689846686f77dc0aa1e6f4d31fbfc42998c2085.tar.gz
lite-xl-plugins-9689846686f77dc0aa1e6f4d31fbfc42998c2085.zip
Merge branch 'master' into 2.0
Diffstat (limited to 'plugins')
-rw-r--r--plugins/autosave.lua3
-rw-r--r--plugins/language_lobster.lua66
-rw-r--r--plugins/language_sass.lua2
-rw-r--r--plugins/language_toml.lua32
-rw-r--r--plugins/language_v.lua4
-rw-r--r--plugins/language_zig.lua5
-rw-r--r--plugins/lfautoinsert.lua1
-rw-r--r--plugins/linenumbers.lua85
-rw-r--r--plugins/smallclock.lua2
9 files changed, 194 insertions, 6 deletions
diff --git a/plugins/autosave.lua b/plugins/autosave.lua
index e6fa21c..9518adf 100644
--- a/plugins/autosave.lua
+++ b/plugins/autosave.lua
@@ -2,7 +2,6 @@
local core = require "core"
local config = require "core.config"
local Doc = require "core.doc"
-local DocView = require "core.docview"
local command = require "core.command"
-- this is used to detect the wait time
local last_keypress = os.time()
@@ -42,5 +41,5 @@ function Doc:on_text_change(type)
if self.filename then
updatepress()
end
- return on_text_change(type)
+ return on_text_change(self, type)
end
diff --git a/plugins/language_lobster.lua b/plugins/language_lobster.lua
new file mode 100644
index 0000000..8b4d899
--- /dev/null
+++ b/plugins/language_lobster.lua
@@ -0,0 +1,66 @@
+-- mod-version:1 -- lite-xl 1.16
+local syntax = require "core.syntax"
+
+syntax.add {
+ files = "%.lobster$",
+ comment = "//",
+ patterns = {
+ { pattern = "//.-\n", type = "comment" },
+ { pattern = { "/%*", "%*/" }, type = "comment" },
+
+ { pattern = "struct%s()[%a_][%w_]*", type = {"keyword", "keyword2"} },
+ { pattern = "class%s()[%a_][%w_]*", type = {"keyword", "keyword2"} },
+ { pattern = "import%s+from", type = "keyword" },
+
+ { pattern = { '"', '"', '\\' }, type = "string" },
+ { 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 = {
+ ["import"] = "keyword",
+ ["def"] = "keyword",
+ ["fn"] = "keyword",
+ ["return"] = "keyword",
+ ["program"] = "keyword",
+ ["private"] = "keyword",
+ ["resource"] = "keyword",
+
+ -- not really keywords but provides control-flow constructs
+ ["if"] = "keyword",
+ ["for"] = "keyword",
+ ["while"] = "keyword",
+ ["else"] = "keyword",
+
+ ["enum"] = "keyword",
+ ["enum_flags"] = "keyword",
+
+ ["int"] = "keyword2",
+ ["float"] = "keyword2",
+ ["string"] = "keyword2",
+ ["any"] = "keyword2",
+ ["void"] = "keyword2",
+
+ ["is"] = "keyword",
+ ["typeof"] = "keyword",
+ ["var"] = "keyword",
+ ["let"] = "keyword",
+ ["pakfile"] = "keyword",
+ ["switch"] = "keyword",
+ ["case"] = "keyword",
+ ["default"] = "keyword",
+ ["namespace"] = "keyword",
+
+ ["not"] = "operator",
+ ["and"] = "operator",
+ ["or"] = "operator",
+
+ ["nil"] = "literal",
+ },
+}
+
diff --git a/plugins/language_sass.lua b/plugins/language_sass.lua
index 752f5b0..aa11637 100644
--- a/plugins/language_sass.lua
+++ b/plugins/language_sass.lua
@@ -2,7 +2,7 @@
local syntax = require "core.syntax"
syntax.add {
- files = { "%.sass$" },
+ files = { "%.sass$" ,"%.scss$"},
comment = "//",
patterns = {
{ pattern = "/[/%*].-\n", type = "comment" },
diff --git a/plugins/language_toml.lua b/plugins/language_toml.lua
new file mode 100644
index 0000000..9de31f9
--- /dev/null
+++ b/plugins/language_toml.lua
@@ -0,0 +1,32 @@
+-- lite-xl 1.16
+
+local syntax = require "core.syntax"
+
+syntax.add {
+ files = { "%.toml$" },
+ comment = '#',
+ patterns = {
+ { pattern = "#.-\n", type = "comment" },
+ { pattern = { '"""', '"""', '\\' }, type = "string" },
+ { pattern = { '"', '"', '\\' }, type = "string" },
+ { pattern = { "'''", "'''" }, type = "string" },
+ { pattern = { "'", "'" }, type = "string" },
+ { pattern = "[A-Za-z0-9_%.%-]+%s*%f[=]", type = "function" },
+ { pattern = "%[[A-Za-z0-9_%.%- ]+%]", type = "keyword" },
+ { pattern = "%[%[[A-Za-z0-9_%.%- ]+%]%]", type = "keyword" },
+ { pattern = "[%-+]?[0-9_]+%.[0-9_]+[eE][%-+]?[0-9_]+", type = "number" },
+ { pattern = "[%-+]?[0-9_]+%.[0-9_]+", type = "number" },
+ { pattern = "[%-+]?[0-9_]+[eE][%-+]?[0-9_]+", type = "number" },
+ { pattern = "[%-+]?[0-9_]+", type = "number" },
+ { pattern = "[%-+]?0x[0-9a-fA-F_]+", type = "number" },
+ { pattern = "[%-+]?0o[0-7_]+", type = "number" },
+ { pattern = "[%-+]?0b[01_]+", type = "number" },
+ { pattern = "[%-+]?nan", type = "number" },
+ { pattern = "[%-+]?inf", type = "number" },
+ { pattern = "[a-z]+", type = "symbol" },
+ },
+ symbols = {
+ ["true"] = "literal",
+ ["false"] = "literal",
+ },
+}
diff --git a/plugins/language_v.lua b/plugins/language_v.lua
index 526002f..774617a 100644
--- a/plugins/language_v.lua
+++ b/plugins/language_v.lua
@@ -45,8 +45,8 @@ syntax.add {
["match"] = "keyword",
["module"] = "keyword",
["mut"] = "keyword2",
- ["none"] = "keyword",
["or"] = "keyword",
+ ["pub"] = "keyword",
["return"] = "keyword",
["rlock"] = "keyword",
["select"] = "keyword",
@@ -63,7 +63,7 @@ syntax.add {
["true"] = "literal",
["false"] = "literal",
- ["pub"] = "literal",
+ ["none"] = "literal",
},
}
diff --git a/plugins/language_zig.lua b/plugins/language_zig.lua
index 3c4f6fa..4629e89 100644
--- a/plugins/language_zig.lua
+++ b/plugins/language_zig.lua
@@ -39,6 +39,7 @@ syntax.add {
["while"] = "keyword",
["var"] = "keyword",
["anytype"] = "keyword",
+ ["anyframe"] = "keyword",
["const"] = "keyword",
["test"] = "keyword",
["packed"] = "keyword",
@@ -76,6 +77,10 @@ syntax.add {
["enum"] = "keyword",
["union"] = "keyword",
["opaque"] = "keyword",
+ ["inline"] = "keyword",
+ ["allowzero"] = "keyword",
+ ["noalias"] = "keyword",
+ ["nosuspend"] = "keyword",
-- types
["f16"] = "keyword2",
diff --git a/plugins/lfautoinsert.lua b/plugins/lfautoinsert.lua
index ddbec5e..5f4148b 100644
--- a/plugins/lfautoinsert.lua
+++ b/plugins/lfautoinsert.lua
@@ -13,6 +13,7 @@ config.plugins.lfautoinsert = { map = {
[":%s*\n"] = false,
["->%s*\n"] = false,
["^%s*<([^/][^%s>]*)[^>]*>%s*\n"] = "</$TEXT>",
+ ["^%s*{{#([^/][^%s}]*)[^}]*}}%s*\n"] = "{{/$TEXT}}",
["/%*%s*\n"] = "*/",
["c/c++"] = {
file_patterns = {
diff --git a/plugins/linenumbers.lua b/plugins/linenumbers.lua
new file mode 100644
index 0000000..fde0a08
--- /dev/null
+++ b/plugins/linenumbers.lua
@@ -0,0 +1,85 @@
+-- mod-version:1 -- lite-xl 1.16
+local config = require "core.config"
+local style = require "core.style"
+local DocView = require "core.docview"
+local common = require "core.common"
+local command = require "core.command"
+
+local draw = DocView.draw_line_gutter
+local get_width = DocView.get_gutter_width
+
+function DocView:draw_line_gutter(idx, x, y, width)
+ if not config.line_numbers and not config.relative_line_numbers then
+ return
+ end
+
+ if config.relative_line_numbers then
+
+ local color = style.line_number
+ local local_idx = idx
+ local align = "right"
+
+ local l1 = self.doc:get_selection(false)
+ if idx == l1 then
+ color = style.line_number2
+ if config.line_numbers then
+ align = "center"
+ else
+ local_idx = 0
+ end
+ else
+ local_idx = math.abs(idx - l1)
+ end
+
+ -- Fix for old version (<=1.16)
+ if width == nil then
+ local gpad = style.padding.x * 2
+ local gw = self:get_font():get_width(#self.doc.lines) + gpad
+ width = gpad and gw - gpad or gw
+ end
+
+ common.draw_text(
+ self:get_font(),
+ color, local_idx, align,
+ x + style.padding.x,
+ y + self:get_line_text_y_offset(),
+ width, self:get_line_height()
+ )
+ else
+ draw(self, idx, x, y, width)
+ end
+end
+
+function DocView:get_gutter_width(...)
+ if not config.line_numbers and not config.relative_line_numbers then
+ return style.padding.x
+ else
+ return get_width(self, ...)
+ end
+end
+
+command.add(nil, {
+ ["line-numbers:toggle"] = function()
+ config.line_numbers = not config.line_numbers
+ end,
+
+ ["line-numbers:disable"] = function()
+ config.line_numbers = false
+ end,
+
+ ["line-numbers:enable"] = function()
+ config.line_numbers = true
+ end,
+
+ ["relative-line-numbers:toggle"] = function()
+ config.relative_line_numbers = not config.relative_line_numbers
+ end,
+
+ ["relative-line-numbers:enable"] = function()
+ config.relative_line_numbers = true
+ end,
+
+ ["relative-line-numbers:disable"] = function()
+ config.relative_line_numbers = false
+ end
+})
diff --git a/plugins/smallclock.lua b/plugins/smallclock.lua
index 3ab9e4a..b22bc71 100644
--- a/plugins/smallclock.lua
+++ b/plugins/smallclock.lua
@@ -9,7 +9,7 @@ core.add_thread(function()
while true do
local t = os.date("*t")
time = string.format("%02d:%02d", t.hour, t.min)
- coroutine.yield()
+ coroutine.yield(1)
end
end)