aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/autoinsert.lua12
-rw-r--r--plugins/autosave.lua11
-rw-r--r--plugins/autosaveonfocuslost.lua2
-rw-r--r--plugins/autowrap.lua6
-rw-r--r--plugins/bigclock.lua16
-rw-r--r--plugins/bracketmatch.lua2
-rw-r--r--plugins/centerdoc.lua9
-rw-r--r--plugins/colorpreview.lua2
-rw-r--r--plugins/copyfilelocation.lua4
-rw-r--r--plugins/datetimestamps.lua25
-rw-r--r--plugins/dragdropselected.lua2
-rw-r--r--plugins/ephemeraldocviews.lua2
-rw-r--r--plugins/eval.lua2
-rw-r--r--plugins/exec.lua2
-rw-r--r--plugins/ghmarkdown.lua2
-rw-r--r--plugins/gitstatus.lua16
-rw-r--r--plugins/gofmt.lua2
-rw-r--r--plugins/hidelinenumbers.lua2
-rw-r--r--plugins/hidestatus.lua2
-rw-r--r--plugins/indentguide.lua2
-rw-r--r--plugins/language_angelscript.lua2
-rw-r--r--plugins/language_batch.lua2
-rw-r--r--plugins/language_bib.lua2
-rw-r--r--plugins/language_cmake.lua2
-rw-r--r--plugins/language_cpp.lua2
-rw-r--r--plugins/language_csharp.lua2
-rw-r--r--plugins/language_d.lua2
-rw-r--r--plugins/language_dart.lua2
-rw-r--r--plugins/language_elixir.lua2
-rw-r--r--plugins/language_elm.lua2
-rw-r--r--plugins/language_fe.lua2
-rw-r--r--plugins/language_fennel.lua2
-rw-r--r--plugins/language_gdscript.lua2
-rw-r--r--plugins/language_glsl.lua2
-rw-r--r--plugins/language_go.lua2
-rw-r--r--plugins/language_hlsl.lua2
-rw-r--r--plugins/language_hs.lua2
-rw-r--r--plugins/language_java.lua2
-rw-r--r--plugins/language_jiyu.lua2
-rw-r--r--plugins/language_jsx.lua2
-rw-r--r--plugins/language_liquid.lua2
-rw-r--r--plugins/language_lobster.lua66
-rw-r--r--plugins/language_make.lua2
-rw-r--r--plugins/language_meson.lua2
-rw-r--r--plugins/language_moon.lua2
-rw-r--r--plugins/language_nim.lua2
-rw-r--r--plugins/language_objc.lua2
-rw-r--r--plugins/language_odin.lua2
-rw-r--r--plugins/language_perl.lua2
-rw-r--r--plugins/language_php.lua2
-rw-r--r--plugins/language_phps.lua2
-rw-r--r--plugins/language_pico8.lua2
-rw-r--r--plugins/language_po.lua2
-rw-r--r--plugins/language_powershell.lua2
-rw-r--r--plugins/language_psql.lua2
-rw-r--r--plugins/language_ruby.lua2
-rw-r--r--plugins/language_rust.lua2
-rw-r--r--plugins/language_sass.lua4
-rw-r--r--plugins/language_sh.lua2
-rw-r--r--plugins/language_tcl.lua68
-rw-r--r--plugins/language_teal.lua2
-rw-r--r--plugins/language_tex.lua2
-rw-r--r--plugins/language_toml.lua32
-rw-r--r--plugins/language_ts.lua73
-rw-r--r--plugins/language_tsx.lua2
-rw-r--r--plugins/language_v.lua32
-rw-r--r--plugins/language_wren.lua2
-rw-r--r--plugins/language_yaml.lua57
-rw-r--r--plugins/language_zig.lua167
-rw-r--r--plugins/lfautoinsert.lua11
-rwxr-xr-xplugins/linecopypaste.lua2
-rw-r--r--plugins/lineguide.lua21
-rw-r--r--plugins/linenumbers.lua85
-rw-r--r--plugins/macmodkeys.lua2
-rw-r--r--plugins/markers.lua6
-rw-r--r--plugins/memoryusage.lua2
-rw-r--r--plugins/minimap.lua299
-rw-r--r--plugins/motiontrail.lua6
-rw-r--r--plugins/navigate.lua2
-rw-r--r--plugins/openfilelocation.lua13
-rw-r--r--plugins/openselected.lua2
-rw-r--r--plugins/pdfview.lua2
-rw-r--r--plugins/rainbowparen.lua2
-rw-r--r--plugins/regexreplacepreview.lua2
-rw-r--r--plugins/restoretabs.lua2
-rw-r--r--plugins/scale.lua142
-rw-r--r--plugins/scalestatus.lua14
-rw-r--r--plugins/selectionhighlight.lua3
-rw-r--r--plugins/smallclock.lua27
-rw-r--r--plugins/sort.lua2
-rw-r--r--plugins/spellcheck.lua17
-rw-r--r--plugins/tabnumbers.lua2
-rw-r--r--plugins/texcompile.lua2
-rw-r--r--plugins/themeselect.lua2
-rw-r--r--plugins/titleize.lua2
-rw-r--r--plugins/togglesnakecamel.lua2
-rw-r--r--plugins/unboundedscroll.lua2
97 files changed, 915 insertions, 465 deletions
diff --git a/plugins/autoinsert.lua b/plugins/autoinsert.lua
index 7af2209..638d6cc 100644
--- a/plugins/autoinsert.lua
+++ b/plugins/autoinsert.lua
@@ -1,4 +1,4 @@
--- mod-version:1 -- lite-xl 1.16
+-- mod-version:2 -- lite-xl 2.0
local core = require "core"
local translate = require "core.doc.translate"
local config = require "core.config"
@@ -7,18 +7,18 @@ local command = require "core.command"
local keymap = require "core.keymap"
-config.autoinsert_map = {
+config.plugins.autoinsert = { map = {
["["] = "]",
["{"] = "}",
["("] = ")",
['"'] = '"',
["'"] = "'",
["`"] = "`",
-}
+} }
local function is_closer(chr)
- for _, v in pairs(config.autoinsert_map) do
+ for _, v in pairs(config.plugins.autoinsert.map) do
if v == chr then
return true
end
@@ -37,7 +37,7 @@ end
local on_text_input = DocView.on_text_input
function DocView:on_text_input(text)
- local mapping = config.autoinsert_map[text]
+ local mapping = config.plugins.autoinsert.map[text]
-- prevents plugin from operating on `CommandView`
if getmetatable(self) ~= DocView then
@@ -89,7 +89,7 @@ command.add(predicate, {
local doc = core.active_view.doc
local l, c = doc:get_selection()
local chr = doc:get_char(l, c)
- if config.autoinsert_map[doc:get_char(l, c - 1)] and is_closer(chr) then
+ if config.plugins.autoinsert.map[doc:get_char(l, c - 1)] and is_closer(chr) then
doc:delete_to(1)
end
command.perform "doc:backspace"
diff --git a/plugins/autosave.lua b/plugins/autosave.lua
index 2759ba6..9518adf 100644
--- a/plugins/autosave.lua
+++ b/plugins/autosave.lua
@@ -1,8 +1,7 @@
--- mod-version:1 -- lite-xl 1.16
+-- mod-version:2 -- lite-xl 2.0
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()
@@ -10,18 +9,18 @@ local last_keypress = os.time()
local looping = false
local on_text_change = Doc.on_text_change
-- the approximate amount of time, in seconds, that it takes to trigger an autosave
-config.autosave_timeout = 1
+config.plugins.autosave = { timeout = 1 }
local function loop_for_save()
while looping do
- if os.difftime(os.time(), last_keypress) >= config.autosave_timeout then
+ if os.difftime(os.time(), last_keypress) >= config.plugins.autosave.timeout then
command.perform "doc:save"
-- stop loop
looping = false
end
-- wait the timeout. may cause timeout to be slightly imprescise
- coroutine.yield(config.autosave_timeout)
+ coroutine.yield(config.plugins.autosave.timeout)
end
end
@@ -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/autosaveonfocuslost.lua b/plugins/autosaveonfocuslost.lua
index bc193a8..dea1e7c 100644
--- a/plugins/autosaveonfocuslost.lua
+++ b/plugins/autosaveonfocuslost.lua
@@ -1,4 +1,4 @@
--- mod-version:1 -- lite-xl 1.16
+-- mod-version:2 -- lite-xl 2.0
local core = require "core"
local CommandView = require "core.commandview"
local DocView = require "core.docview"
diff --git a/plugins/autowrap.lua b/plugins/autowrap.lua
index 1d5d08d..38f8eb3 100644
--- a/plugins/autowrap.lua
+++ b/plugins/autowrap.lua
@@ -1,10 +1,10 @@
--- mod-version:1 -- lite-xl 1.16
+-- mod-version:2 -- lite-xl 2.0
require "plugins.reflow"
local config = require "core.config"
local command = require "core.command"
local DocView = require "core.docview"
-config.autowrap_files = { "%.md$", "%.txt$" }
+config.plugins.autowrap = { files = { "%.md$", "%.txt$" } }
local on_text_input = DocView.on_text_input
@@ -15,7 +15,7 @@ DocView.on_text_input = function(self, ...)
-- early-exit if the filename does not match a file type pattern
local filename = self.doc.filename or ""
local matched = false
- for _, ptn in ipairs(config.autowrap_files) do
+ for _, ptn in ipairs(config.plugins.autowrap.files) do
if filename:match(ptn) then
matched = true
break
diff --git a/plugins/bigclock.lua b/plugins/bigclock.lua
index ac44c9f..e77f336 100644
--- a/plugins/bigclock.lua
+++ b/plugins/bigclock.lua
@@ -1,4 +1,4 @@
--- mod-version:1 -- lite-xl 1.16
+-- mod-version:2 -- lite-xl 2.0
local core = require "core"
local style = require "core.style"
local command = require "core.command"
@@ -7,9 +7,11 @@ local config = require "core.config"
local View = require "core.view"
-config.bigclock_time_format = "%H:%M:%S"
-config.bigclock_date_format = "%A, %d %B %Y"
-config.bigclock_scale = 1
+config.plugins.bigclock = {
+ time_format = "%H:%M:%S",
+ date_format = "%A, %d %B %Y"
+ scale = 1
+}
local ClockView = View:extend()
@@ -28,7 +30,7 @@ end
function ClockView:update_fonts()
- local size = math.floor(self.size.x * 0.15 / 15) * 15 * config.bigclock_scale
+ local size = math.floor(self.size.x * 0.15 / 15) * 15 * config.plugins.bigclock.scale
if self.font_size ~= size then
self.time_font = renderer.font.load(DATADIR .. "/fonts/font.ttf", size)
self.date_font = renderer.font.load(DATADIR .. "/fonts/font.ttf", size * 0.3)
@@ -40,8 +42,8 @@ end
function ClockView:update()
- local time_text = os.date(config.bigclock_time_format)
- local date_text = os.date(config.bigclock_date_format)
+ local time_text = os.date(config.plugins.bigclock.time_format)
+ local date_text = os.date(config.plugins.bigclock.date_format)
if self.time_text ~= time_text or self.date_text ~= date_text then
core.redraw = true
self.time_text = time_text
diff --git a/plugins/bracketmatch.lua b/plugins/bracketmatch.lua
index e6a740d..4d1da37 100644
--- a/plugins/bracketmatch.lua
+++ b/plugins/bracketmatch.lua
@@ -1,4 +1,4 @@
--- mod-version:1 -- lite-xl 1.16
+-- mod-version:2 -- lite-xl 2.0
local core = require "core"
local style = require "core.style"
local command = require "core.command"
diff --git a/plugins/centerdoc.lua b/plugins/centerdoc.lua
index c60c2dd..8e4f8a4 100644
--- a/plugins/centerdoc.lua
+++ b/plugins/centerdoc.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 DocView = require "core.docview"
@@ -7,9 +7,10 @@ local draw_line_gutter = DocView.draw_line_gutter
local get_gutter_width = DocView.get_gutter_width
-function DocView:draw_line_gutter(idx, x, y)
- local offset = self:get_gutter_width() - get_gutter_width(self)
- draw_line_gutter(self, idx, x + offset, y)
+function DocView:draw_line_gutter(idx, x, y, width)
+ local real_gutter_width = get_gutter_width(self)
+ local offset = self:get_gutter_width() - real_gutter_width * 2
+ draw_line_gutter(self, idx, x + offset, y, real_gutter_width)
end
diff --git a/plugins/colorpreview.lua b/plugins/colorpreview.lua
index 370d1d8..5b16d28 100644
--- a/plugins/colorpreview.lua
+++ b/plugins/colorpreview.lua
@@ -1,4 +1,4 @@
--- mod-version:1 -- lite-xl 1.16
+-- mod-version:2 -- lite-xl 2.0
local common = require "core.common"
local DocView = require "core.docview"
diff --git a/plugins/copyfilelocation.lua b/plugins/copyfilelocation.lua
index 9f33ee1..dedc188 100644
--- a/plugins/copyfilelocation.lua
+++ b/plugins/copyfilelocation.lua
@@ -1,8 +1,6 @@
--- mod-version:1 -- lite-xl 1.16
+-- mod-version:2 -- lite-xl 2.0
local core = require "core"
local command = require "core.command"
-local config = require "core.config"
-
command.add("core.docview", {
["copy-file-location:copy-file-location"] = function()
diff --git a/plugins/datetimestamps.lua b/plugins/datetimestamps.lua
index 9ce425a..51d698e 100644
--- a/plugins/datetimestamps.lua
+++ b/plugins/datetimestamps.lua
@@ -1,4 +1,4 @@
--- mod-version:1 -- lite-xl 1.16
+-- mod-version:2 -- lite-xl 2.0
local core = require "core"
local config = require "core.config"
local command = require "core.command"
@@ -25,32 +25,25 @@ from https://www.lua.org/pil/22.1.html
%y two-digit year (98) [00-99]
%% the character `%´
--]]
-config.datetimestamps_format_datestamp = "%Y%m%d"
-config.datetimestamps_format_datetimestamp = "%Y%m%d_%H%M%S"
-config.datetimestamps_format_timestamp = "%H%M%S"
+config.plugins.datetimestamps = {
+ format_datestamp = "%Y%m%d"
+ format_datetimestamp = "%Y%m%d_%H%M%S"
+ format_timestamp = "%H%M%S"
+}
local function datestamp()
-
- local sOut = os.date(config.datetimestamps_format_datestamp)
-
+ local sOut = os.date(config.plugins.datetimestamps.format_datestamp)
core.active_view.doc:text_input(sOut)
-
end
local function datetimestamp()
-
- local sOut = os.date(config.datetimestamps_format_datetimestamp)
-
+ local sOut = os.date(config.plugins.datetimestamps.format_datetimestamp)
core.active_view.doc:text_input(sOut)
-
end
local function timestamp()
-
- local sOut = os.date(config.datetimestamps_format_timestamp)
-
+ local sOut = os.date(config.plugins.datetimestamps.format_timestamp)
core.active_view.doc:text_input(sOut)
-
end
command.add("core.docview", {
diff --git a/plugins/dragdropselected.lua b/plugins/dragdropselected.lua
index aeacbd3..4dbaa84 100644
--- a/plugins/dragdropselected.lua
+++ b/plugins/dragdropselected.lua
@@ -1,4 +1,4 @@
--- mod-version:1 -- lite-xl 1.16
+-- mod-version:2 -- lite-xl 2.0
--[[
dragdropselected.lua
provides basic drag and drop of selected text (in same document)
diff --git a/plugins/ephemeraldocviews.lua b/plugins/ephemeraldocviews.lua
index 37b3a3b..cb9f53d 100644
--- a/plugins/ephemeraldocviews.lua
+++ b/plugins/ephemeraldocviews.lua
@@ -1,4 +1,4 @@
--- mod-version:1 -- lite-xl 1.16
+-- mod-version:2 -- lite-xl 2.0
local core = require "core"
local command = require "core.command"
local RootView = require "core.rootview"
diff --git a/plugins/eval.lua b/plugins/eval.lua
index ae13a14..bd1ff56 100644
--- a/plugins/eval.lua
+++ b/plugins/eval.lua
@@ -1,4 +1,4 @@
--- mod-version:1 -- lite-xl 1.16
+-- mod-version:2 -- lite-xl 2.0
local core = require "core"
local command = require "core.command"
diff --git a/plugins/exec.lua b/plugins/exec.lua
index d1ed6a8..cf2d8f2 100644
--- a/plugins/exec.lua
+++ b/plugins/exec.lua
@@ -1,4 +1,4 @@
--- mod-version:1 -- lite-xl 1.16
+-- mod-version:2 -- lite-xl 2.0
local core = require "core"
local command = require "core.command"
diff --git a/plugins/ghmarkdown.lua b/plugins/ghmarkdown.lua
index 6e81daa..7dcf3cb 100644
--- a/plugins/ghmarkdown.lua
+++ b/plugins/ghmarkdown.lua
@@ -1,4 +1,4 @@
--- mod-version:1 -- lite-xl 1.16
+-- mod-version:2 -- lite-xl 2.0
local core = require "core"
local command = require "core.command"
local keymap = require "core.keymap"
diff --git a/plugins/gitstatus.lua b/plugins/gitstatus.lua
index 904cd38..fda1388 100644
--- a/plugins/gitstatus.lua
+++ b/plugins/gitstatus.lua
@@ -1,4 +1,4 @@
--- mod-version:1 -- lite-xl 1.16
+-- mod-version:2 -- lite-xl 2.0
local core = require "core"
local config = require "core.config"
local style = require "core.style"
@@ -13,13 +13,9 @@ local git = {
local function exec(cmd, wait)
- local tempfile = core.temp_filename()
- system.exec(string.format("%s > %q", cmd, tempfile))
- coroutine.yield(wait)
- local fp = io.open(tempfile)
- local res = fp:read("*a")
- fp:close()
- os.remove(tempfile)
+ local proc = process.start(cmd)
+ proc:wait(wait * 1000)
+ local res = proc:read_stdout()
return res
end
@@ -28,10 +24,10 @@ core.add_thread(function()
while true do
if system.get_file_info(".git") then
-- get branch name
- git.branch = exec("git rev-parse --abbrev-ref HEAD", 1):match("[^\n]*")
+ git.branch = exec({"git", "rev-parse", "--abbrev-ref", "HEAD"}, 1):match("[^\n]*")
-- get diff
- local line = exec("git diff --stat", 1):match("[^\n]*%s*$")
+ local line = exec({"git", "diff", "--stat"}, 1):match("[^\n]*%s*$")
git.inserts = tonumber(line:match("(%d+) ins")) or 0
git.deletes = tonumber(line:match("(%d+) del")) or 0
diff --git a/plugins/gofmt.lua b/plugins/gofmt.lua
index fd204a6..02c817b 100644
--- a/plugins/gofmt.lua
+++ b/plugins/gofmt.lua
@@ -1,4 +1,4 @@
--- mod-version:1 -- lite-xl 1.16
+-- mod-version:2 -- lite-xl 2.0
local core = require "core"
local command = require "core.command"
local keymap = require "core.keymap"
diff --git a/plugins/hidelinenumbers.lua b/plugins/hidelinenumbers.lua
index 5ed23b3..4494670 100644
--- a/plugins/hidelinenumbers.lua
+++ b/plugins/hidelinenumbers.lua
@@ -1,4 +1,4 @@
--- mod-version:1 -- lite-xl 1.16
+-- mod-version:2 -- lite-xl 2.0
local style = require "core.style"
local DocView = require "core.docview"
diff --git a/plugins/hidestatus.lua b/plugins/hidestatus.lua
index fc687cb..6e63a81 100644
--- a/plugins/hidestatus.lua
+++ b/plugins/hidestatus.lua
@@ -1,4 +1,4 @@
--- mod-version:1 -- lite-xl 1.16
+-- mod-version:2 -- lite-xl 2.0
local command = require "core.command"
local StatusView = require "core.statusview"
diff --git a/plugins/indentguide.lua b/plugins/indentguide.lua
index f1b7cf7..0513be4 100644
--- a/plugins/indentguide.lua
+++ b/plugins/indentguide.lua
@@ -1,4 +1,4 @@
--- mod-version:1 -- lite-xl 1.16
+-- mod-version:2 -- lite-xl 2.0
local style = require "core.style"
local config = require "core.config"
local DocView = require "core.docview"
diff --git a/plugins/language_angelscript.lua b/plugins/language_angelscript.lua
index d34a0eb..d214ea0 100644
--- a/plugins/language_angelscript.lua
+++ b/plugins/language_angelscript.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_batch.lua b/plugins/language_batch.lua
index 441a367..b01c65d 100644
--- a/plugins/language_batch.lua
+++ b/plugins/language_batch.lua
@@ -1,4 +1,4 @@
--- mod-version:1 -- lite-xl 1.16
+-- mod-version:2 -- lite-xl 2.0
local syntax = require "core.syntax"
-- batch syntax for lite <liqube>
diff --git a/plugins/language_bib.lua b/plugins/language_bib.lua
index 08a5662..96c80c7 100644
--- a/plugins/language_bib.lua
+++ b/plugins/language_bib.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_cmake.lua b/plugins/language_cmake.lua
index 9f4df2f..34b4d0c 100644
--- a/plugins/language_cmake.lua
+++ b/plugins/language_cmake.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_cpp.lua b/plugins/language_cpp.lua
index bb1f347..f229134 100644
--- a/plugins/language_cpp.lua
+++ b/plugins/language_cpp.lua
@@ -1,4 +1,4 @@
--- mod-version:1 -- lite-xl 1.16
+-- mod-version:2 -- lite-xl 2.0
pcall(require, "plugins.language_c")
local syntax = require "core.syntax"
diff --git a/plugins/language_csharp.lua b/plugins/language_csharp.lua
index b6ee8e0..6bc6fcd 100644
--- a/plugins/language_csharp.lua
+++ b/plugins/language_csharp.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_d.lua b/plugins/language_d.lua
index a054de6..641aefa 100644
--- a/plugins/language_d.lua
+++ b/plugins/language_d.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_dart.lua b/plugins/language_dart.lua
index 2e3cfc3..01bdc97 100644
--- a/plugins/language_dart.lua
+++ b/plugins/language_dart.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_elixir.lua b/plugins/language_elixir.lua
index 8dd7cc9..e4919da 100644
--- a/plugins/language_elixir.lua
+++ b/plugins/language_elixir.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_elm.lua b/plugins/language_elm.lua
index c5f2223..4038420 100644
--- a/plugins/language_elm.lua
+++ b/plugins/language_elm.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_fe.lua b/plugins/language_fe.lua
index f1aeef4..c852124 100644
--- a/plugins/language_fe.lua
+++ b/plugins/language_fe.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_fennel.lua b/plugins/language_fennel.lua
index fbf1ba6..de229f1 100644
--- a/plugins/language_fennel.lua
+++ b/plugins/language_fennel.lua
@@ -1,4 +1,4 @@
--- mod-version:1 -- lite-xl 1.16
+-- mod-version:2 -- lite-xl 2.0
-- Support for the Fennel programming language: https://fennel-lang.org
-- Covers all the keywords up to Fennel version 0.4.0
diff --git a/plugins/language_gdscript.lua b/plugins/language_gdscript.lua
index c638ab9..5a29b97 100644
--- a/plugins/language_gdscript.lua
+++ b/plugins/language_gdscript.lua
@@ -1,4 +1,4 @@
--- mod-version:1 -- lite-xl 1.16
+-- mod-version:2 -- lite-xl 2.0
-- Support for the GDScript programming language: https://godotengine.org/
-- Covers the most used keywords up to Godot version 3.2.x
diff --git a/plugins/language_glsl.lua b/plugins/language_glsl.lua
index 1f57a06..36ceb03 100644
--- a/plugins/language_glsl.lua
+++ b/plugins/language_glsl.lua
@@ -1,4 +1,4 @@
--- mod-version:1 -- lite-xl 1.16
+-- mod-version:2 -- lite-xl 2.0
local style = require "core.style"
local common = require "core.common"
diff --git a/plugins/language_go.lua b/plugins/language_go.lua
index 76289bd..8c8900e 100644
--- a/plugins/language_go.lua
+++ b/plugins/language_go.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_hlsl.lua b/plugins/language_hlsl.lua
index 45128d6..0aedab0 100644
--- a/plugins/language_hlsl.lua
+++ b/plugins/language_hlsl.lua
@@ -1,4 +1,4 @@
--- mod-version:1 -- lite-xl 1.16
+-- mod-version:2 -- lite-xl 2.0
local style = require "core.style"
local common = require "core.common"
diff --git a/plugins/language_hs.lua b/plugins/language_hs.lua
index 5f69a5a..5530f87 100644
--- a/plugins/language_hs.lua
+++ b/plugins/language_hs.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_java.lua b/plugins/language_java.lua
index 42ad147..8c6e98e 100644
--- a/plugins/language_java.lua
+++ b/plugins/language_java.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_jiyu.lua b/plugins/language_jiyu.lua
index a433170..c30cd00 100644
--- a/plugins/language_jiyu.lua
+++ b/plugins/language_jiyu.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_jsx.lua b/plugins/language_jsx.lua
index 2648c68..328e2db 100644
--- a/plugins/language_jsx.lua
+++ b/plugins/language_jsx.lua
@@ -1,4 +1,4 @@
--- mod-version:1 -- lite-xl 1.16
+-- mod-version:2 -- lite-xl 2.0
-- Almost identical to JS, with the exception that / shouldn't denote a regex. Current JS syntax highlighter will highlight half the document due to closing tags.
local syntax = require "core.syntax"
diff --git a/plugins/language_liquid.lua b/plugins/language_liquid.lua
index 5cc7573..ffb2c96 100644
--- a/plugins/language_liquid.lua
+++ b/plugins/language_liquid.lua
@@ -1,4 +1,4 @@
--- mod-version:1 -- lite-xl 1.16
+-- mod-version:2 -- lite-xl 2.0
local syntax = require "core.syntax"
local liquid_syntax = {
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_make.lua b/plugins/language_make.lua
index 21e9df0..4ce5d00 100644
--- a/plugins/language_make.lua
+++ b/plugins/language_make.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_meson.lua b/plugins/language_meson.lua
index c1aa4b1..02763a7 100644
--- a/plugins/language_meson.lua
+++ b/plugins/language_meson.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_moon.lua b/plugins/language_moon.lua
index ef8d3bd..6b5f9d2 100644
--- a/plugins/language_moon.lua
+++ b/plugins/language_moon.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_nim.lua b/plugins/language_nim.lua
index d42cb4a..c9f3355 100644
--- a/plugins/language_nim.lua
+++ b/plugins/language_nim.lua
@@ -1,4 +1,4 @@
--- mod-version:1 -- lite-xl 1.16
+-- mod-version:2 -- lite-xl 2.0
local syntax = require "core.syntax"
local patterns = {}
diff --git a/plugins/language_objc.lua b/plugins/language_objc.lua
index c2b2eee..c0ef95e 100644
--- a/plugins/language_objc.lua
+++ b/plugins/language_objc.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_odin.lua b/plugins/language_odin.lua
index 52a24e0..29d9868 100644
--- a/plugins/language_odin.lua
+++ b/plugins/language_odin.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_perl.lua b/plugins/language_perl.lua
index 1332464..cf60849 100644
--- a/plugins/language_perl.lua
+++ b/plugins/language_perl.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 0db81a3..4f107aa 100644
--- a/plugins/language_php.lua
+++ b/plugins/language_php.lua
@@ -1,4 +1,4 @@
--- mod-version:1 -- lite-xl 1.16
+-- mod-version:2 -- lite-xl 2.0
--[[
language_php.lua
provides php syntax support allowing mixed html, css and js
diff --git a/plugins/language_phps.lua b/plugins/language_phps.lua
index 7476a8f..082b962 100644
--- a/plugins/language_phps.lua
+++ b/plugins/language_phps.lua
@@ -1,4 +1,4 @@
--- mod-version:1 -- lite-xl 1.16
+-- mod-version:2 -- lite-xl 2.0
--[[
language_phps.lua
complement to language_php.lua providing the php syntax support
diff --git a/plugins/language_pico8.lua b/plugins/language_pico8.lua
index c8ba027..b8b790e 100644
--- a/plugins/language_pico8.lua
+++ b/plugins/language_pico8.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_po.lua b/plugins/language_po.lua
index 0f07d40..54783ea 100644
--- a/plugins/language_po.lua
+++ b/plugins/language_po.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_powershell.lua b/plugins/language_powershell.lua
index 6cd0968..022170d 100644
--- a/plugins/language_powershell.lua
+++ b/plugins/language_powershell.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_psql.lua b/plugins/language_psql.lua
index 389f32a..09db99b 100644
--- a/plugins/language_psql.lua
+++ b/plugins/language_psql.lua
@@ -1,4 +1,4 @@
--- mod-version:1 -- lite-xl 1.16
+-- mod-version:2 -- lite-xl 2.0
local syntax = require "core.syntax"
-- In sql symbols can be lower case and upper case
diff --git a/plugins/language_ruby.lua b/plugins/language_ruby.lua
index 9661b1b..8b9bf33 100644
--- a/plugins/language_ruby.lua
+++ b/plugins/language_ruby.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_rust.lua b/plugins/language_rust.lua
index 4d0fef1..ac25305 100644
--- a/plugins/language_rust.lua
+++ b/plugins/language_rust.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_sass.lua b/plugins/language_sass.lua
index ce4aa2b..aa11637 100644
--- a/plugins/language_sass.lua
+++ b/plugins/language_sass.lua
@@ -1,8 +1,8 @@
--- mod-version:1 -- lite-xl 1.16
+-- mod-version:2 -- lite-xl 2.0
local syntax = require "core.syntax"
syntax.add {
- files = { "%.sass$" },
+ files = { "%.sass$" ,"%.scss$"},
comment = "//",
patterns = {
{ pattern = "/[/%*].-\n", type = "comment" },
diff --git a/plugins/language_sh.lua b/plugins/language_sh.lua
index 684b070..f21557d 100644
--- a/plugins/language_sh.lua
+++ b/plugins/language_sh.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_tcl.lua b/plugins/language_tcl.lua
new file mode 100644
index 0000000..a934777
--- /dev/null
+++ b/plugins/language_tcl.lua
@@ -0,0 +1,68 @@
+-- mod-version:2 -- lite-xl 2.0
+local syntax = require "core.syntax"
+
+syntax.add {
+ files = { "%.tcl$" },
+ comment = "#",
+ patterns = {
+ { pattern = "#.-\n", type = "comment" },
+ { pattern = { '"', '"', '\\' }, type = "string" },
+ { pattern = "0x%x+", type = "number" },
+ { pattern = "%d+[%d%.eE]*f?", type = "number" },
+ { pattern = "%.?%d+f?", type = "number" },
+ { pattern = "%$[%a_][%w_]*", type = "literal" },
+ { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" },
+ { pattern = "::[%a_][%w_]*", type = "function" },
+ { pattern = "[%a_][%w_]*%f[:]", type = "function" },
+ { pattern = "[%a_][%w_]*", type = "symbol" },
+ },
+ symbols = {
+ ["set"] = "keyword",
+ ["unset"] = "keyword",
+ ["rename"] = "keyword",
+ ["upvar"] = "keyword",
+ ["incr"] = "keyword",
+ ["source"] = "keyword",
+ ["expr"] = "keyword",
+ ["gets"] = "keyword",
+ ["puts"] = "keyword",
+ ["package"] = "keyword",
+ ["list"] = "keyword",
+ ["dict"] = "keyword",
+ ["split"] = "join",
+ ["concat"] = "join",
+ ["lappend"] = "keyword",
+ ["lset"] = "keyword",
+ ["lassign"] = "keyword",
+ ["lindex"] = "keyword",
+ ["llength"] = "keyword",
+ ["lsearch"] = "keyword",
+ ["lrange"] = "keyword",
+ ["linsert"] = "keyword",
+ ["lreplace"] = "keyword",
+ ["lrepeat"] = "keyword",
+ ["lsort"] = "keyword",
+ ["lreverse"] = "keyword",
+ ["array"] = "keyword",
+ ["concat"] = "keyword",
+ ["regexp"] = "keyword",
+ ["for"] = "keyword",
+ ["foreach"] = "keyword",
+ ["while"] = "keyword",
+ ["case"] = "keyword",
+ ["proc"] = "keyword",
+ ["if"] = "keyword",
+ ["else"] = "keyword",
+ ["elseif"] = "keyword",
+ ["break"] = "keyword",
+ ["continue"] = "keyword",
+ ["return"] = "keyword",
+ ["eval"] = "keyword",
+ ["try"] = "keyword2",
+ ["on"] = "keyword2",
+ ["finally"] = "keyword2",
+ ["throw"] = "keyword2",
+ ["error"] = "keyword2",
+ },
+}
+
diff --git a/plugins/language_teal.lua b/plugins/language_teal.lua
index 5b46fd8..f64c419 100644
--- a/plugins/language_teal.lua
+++ b/plugins/language_teal.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_tex.lua b/plugins/language_tex.lua
index 3f9a5fa..1bc08f5 100644
--- a/plugins/language_tex.lua
+++ b/plugins/language_tex.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_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_ts.lua b/plugins/language_ts.lua
new file mode 100644
index 0000000..1b322ed
--- /dev/null
+++ b/plugins/language_ts.lua
@@ -0,0 +1,73 @@
+-- mod-version:2 -- lite-xl 2.0
+-- copied from language_js, but added regex highlighting back
+local syntax = require "core.syntax"
+
+syntax.add {
+ files = { "%.ts$" },
+ comment = "//",
+ patterns = {
+ { pattern = "//.-\n", type = "comment" },
+ { pattern = { "/%*", "%*/" }, type = "comment" },
+ { pattern = { '/%g', '/', '\\' }, type = "string" },
+ { pattern = { '"', '"', '\\' }, type = "string" },
+ { pattern = { "'", "'", '\\' }, type = "string" },
+ { pattern = { "`", "`", '\\' }, type = "string" },
+ { pattern = "0x[%da-fA-F]+", type = "number" },
+ { pattern = "-?%d+[%d%.eE]*", type = "number" },
+ { pattern = "-?%.?%d+", type = "number" },
+ { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" },
+ { pattern = "interface%s()[%a_][%w_]*", type = {"keyword", "keyword2"} },
+ { pattern = "type%s()[%a_][%w_]*", type = {"keyword", "keyword2"} },
+ { pattern = "[%a_][%w_]*%f[(]", type = "function" },
+ { pattern = "[%a_][%w_]*", type = "symbol" },
+ },
+ symbols = {
+ ["async"] = "keyword",
+ ["await"] = "keyword",
+ ["break"] = "keyword",
+ ["case"] = "keyword",
+ ["catch"] = "keyword",
+ ["class"] = "keyword",
+ ["const"] = "keyword",
+ ["continue"] = "keyword",
+ ["debugger"] = "keyword",
+ ["default"] = "keyword",
+ ["delete"] = "keyword",
+ ["do"] = "keyword",
+ ["else"] = "keyword",
+ ["export"] = "keyword",
+ ["extends"] = "keyword",
+ ["finally"] = "keyword",
+ ["for"] = "keyword",
+ ["function"] = "keyword",
+ ["get"] = "keyword",
+ ["if"] = "keyword",
+ ["import"] = "keyword",
+ ["implements"] = "keyword",
+ ["in"] = "keyword",
+ ["instanceof"] = "keyword",
+ ["let"] = "keyword",
+ ["new"] = "keyword",
+ ["return"] = "keyword",
+ ["set"] = "keyword",
+ ["static"] = "keyword",
+ ["super"] = "keyword",
+ ["switch"] = "keyword",
+ ["throw"] = "keyword",
+ ["try"] = "keyword",
+ ["typeof"] = "keyword",
+ ["var"] = "keyword",
+ ["void"] = "keyword",
+ ["while"] = "keyword",
+ ["with"] = "keyword",
+ ["yield"] = "keyword",
+ ["true"] = "literal",
+ ["false"] = "literal",
+ ["null"] = "literal",
+ ["undefined"] = "literal",
+ ["arguments"] = "keyword2",
+ ["Infinity"] = "keyword2",
+ ["NaN"] = "keyword2",
+ ["this"] = "keyword2",
+ },
+}
diff --git a/plugins/language_tsx.lua b/plugins/language_tsx.lua
index 9dd93ad..63eef55 100644
--- a/plugins/language_tsx.lua
+++ b/plugins/language_tsx.lua
@@ -1,4 +1,4 @@
--- mod-version:1 -- lite-xl 1.16
+-- mod-version:2 -- lite-xl 2.0
-- Almost identical to JS, with the exception that / shouldn't denote a regex. Current JS syntax highlighter will highlight half the document due to closing tags.
local syntax = require "core.syntax"
diff --git a/plugins/language_v.lua b/plugins/language_v.lua
index e4dc19b..0c1c64a 100644
--- a/plugins/language_v.lua
+++ b/plugins/language_v.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 {
@@ -44,9 +44,8 @@ syntax.add {
["lock"] = "keyword",
["match"] = "keyword",
["module"] = "keyword",
- ["mut"] = "keyword2",
- ["none"] = "keyword",
["or"] = "keyword",
+ ["pub"] = "keyword",
["return"] = "keyword",
["rlock"] = "keyword",
["select"] = "keyword",
@@ -59,11 +58,30 @@ syntax.add {
["union"] = "keyword",
["unsafe"] = "keyword",
["__offsetof"] = "keyword",
-
-
+
+ ["mut"] = "keyword2",
+ ["i8"] = "keyword2",
+ ["i16"] = "keyword2",
+ ["int"] = "keyword2",
+ ["i64"] = "keyword2",
+ ["i128"] = "keyword2",
+ ["u8"] = "keyword2",
+ ["u16"] = "keyword2",
+ ["u32"] = "keyword2",
+ ["u64"] = "keyword2",
+ ["u128"] = "keyword2",
+ ["f32"] = "keyword2",
+ ["f64"] = "keyword2",
+ ["map"] = "keyword2",
+ ["string"] = "keyword2",
+ ["voidptr"] = "keyword2",
+ ["byte"] = "keyword2",
+ ["rune"] = "keyword2",
+ ["chan"] = "keyword2",
+ ["char"] = "keyword2",
+
["true"] = "literal",
["false"] = "literal",
- ["pub"] = "literal",
+ ["none"] = "literal",
},
}
-
diff --git a/plugins/language_wren.lua b/plugins/language_wren.lua
index 62ee24f..c4a6905 100644
--- a/plugins/language_wren.lua
+++ b/plugins/language_wren.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_yaml.lua b/plugins/language_yaml.lua
new file mode 100644
index 0000000..c86f733
--- /dev/null
+++ b/plugins/language_yaml.lua
@@ -0,0 +1,57 @@
+-- mod-version:2 -- lite-xl 2.0
+local syntax = require "core.syntax"
+
+syntax.add {
+ files = { "%.yml$", "%.yaml$" },
+ comment = "#",
+ patterns = {
+ { pattern = { "#", "\n"}, type = "comment" },
+ { pattern = { '"', '"', '\\' }, type = "string" },
+ { pattern = { "'", "'", '\\' }, type = "string" },
+ { pattern = "%-?%.inf", type = "number" },
+ { pattern = "%.NaN", type = "number" },
+ {
+ pattern = "%&()%g+",
+ type = { "keyword", "literal" }
+ },
+ { pattern = "!%g+", type = "keyword" },
+ { pattern = "<<", type = "literal" },
+ {
+ pattern = "[%s]%*()[%w%d_]+",
+ type = { "keyword", "keyword2" }
+ },
+ {
+ pattern = "%*()[%w%d_]+",
+ type = { "keyword", "literal" }
+ },
+ {
+ pattern = "[%[%{]()%s*[%w%d]+%g+%s*():%s",
+ type = { "operator", "keyword2", "operator" }
+ },
+ {
+ pattern = "[%s][%w%d]+%g+%s*():%s",
+ type = { "keyword2", "operator" }
+ },
+ {
+ pattern = "[%w%d]+%g+%s*():%s",
+ type = { "literal", "operator" }
+ },
+ { pattern = "0%d+", type = "number" },
+ { pattern = "0x%x+", type = "number" },
+ { pattern = "[%+%-]?%d+[,%.eE:%+%d]*%d+", type = "number" },
+ { pattern = "[%*%|%!>%%]", type = "keyword" },
+ { pattern = "[%-:%?%*%{%}%[%]]", type = "operator" },
+ -- Everything else for keywords to work
+ {
+ pattern = "[%d%a_][%g_]*()[%]%},]",
+ type = { "string", "operator" }
+ },
+ { pattern = "[%d%a_][%g_]*", type = "string" },
+ },
+ symbols = {
+ ["true"] = "number",
+ ["false"] = "number",
+ ["y"] = "number",
+ ["n"] = "number"
+ }
+}
diff --git a/plugins/language_zig.lua b/plugins/language_zig.lua
index 2c098af..4629e89 100644
--- a/plugins/language_zig.lua
+++ b/plugins/language_zig.lua
@@ -1,37 +1,45 @@
--- mod-version:1 -- lite-xl 1.16
+-- mod-version:2 -- lite-xl 2.0
local syntax = require "core.syntax"
syntax.add {
files = { "%.zig$" },
comment = "//",
patterns = {
- { pattern = "//.-\n", type = "comment" },
- { pattern = "#!.-\n", type = "comment" },
- { pattern = { '"', '"', '\\' }, type = "string" },
- { pattern = { "'", "'", '\\' }, type = "string" },
- { pattern = "-?[iuf][%d_]+", type = "keyword2" },
- { pattern = "-?\\x[%x_]+", type = "number" },
- { pattern = "-?\\u{[%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" },
+ { pattern = "//.-\n", type = "comment" },
+ { pattern = "\\\\.-\n", type = "string" },
+ { pattern = { '"', '"', '\\' }, type = "string" },
+ { pattern = { "'", "'", '\\' }, type = "string" },
+ { pattern = "[iu][%d_]+", type = "keyword2" },
+ { pattern = "0b[01_]+", type = "number" },
+ { pattern = "0o[0-7_]+", type = "number" },
+ { pattern = "0x[%x_]+", type = "number" },
+ { pattern = "0x[%x_]+%.[%x_]*[pP][-+]?%d+", type = "number" },
+ { pattern = "0x[%x_]+%.[%x_]*", type = "number" },
+ { pattern = "0x%.[%x_]+[pP][-+]?%d+", type = "number" },
+ { pattern = "0x%.[%x_]+", type = "number" },
+ { pattern = "0x[%x_]+[pP][-+]?%d+", type = "number" },
+ { pattern = "0x[%x_]+", type = "number" },
+ { pattern = "%d[%d_]*%.[%d_]*[eE][-+]?%d+", type = "number" },
+ { pattern = "%d[%d_]*%.[%d_]*", type = "number" },
+ { pattern = "%d[%d_]*", type = "number" },
+ { pattern = "[%+%-=/%*%^%%<>!~|&%.%?]", type = "operator" },
+ { pattern = "[%a_][%w_]*()%s*%(", type = {"function", "normal"} },
+ { pattern = "[A-Z][%w_]*", type = "keyword2" },
+ { pattern = "[%a_][%w_]*", type = "symbol" },
+ { pattern = "@()[%a_][%w_]*", type = {"operator", "function"} },
},
symbols = {
["fn"] = "keyword",
-
["asm"] = "keyword",
["volatile"] = "keyword",
-
["continue"] = "keyword",
["break"] = "keyword",
["switch"] = "keyword",
["for"] = "keyword",
["while"] = "keyword",
-
["var"] = "keyword",
["anytype"] = "keyword",
+ ["anyframe"] = "keyword",
["const"] = "keyword",
["test"] = "keyword",
["packed"] = "keyword",
@@ -42,146 +50,43 @@ syntax.add {
["errdefer"] = "keyword",
["align"] = "keyword",
["usingnamespace"] = "keyword",
-
["noasync"] = "keyword",
["async"] = "keyword",
["await"] = "keyword",
["cancel"] = "keyword",
["suspend"] = "keyword",
["resume"] = "keyword",
-
["threadlocal"] = "keyword",
-
["linksection"] = "keyword",
-
["callconv"] = "keyword",
-
["try"] = "keyword",
["catch"] = "keyword",
["orelse"] = "keyword",
["unreachable"] = "keyword",
- ["noreturn"] = "keyword",
["error"] = "keyword",
["if"] = "keyword",
["else"] = "keyword",
["return"] = "keyword",
["comptime"] = "keyword",
-
["stdcallcc"] = "keyword",
["ccc"] = "keyword",
["nakedcc"] = "keyword",
-
["and"] = "keyword",
["or"] = "keyword",
-
- -- std
- ["@import"] = "keyword",
- ["@cImport"] = "keyword",
-
- [ "@addWithOverflow" ] = "function",
- [ "@alignCast" ] = "function",
- [ "@alignOf" ] = "function",
- [ "@as" ] = "function",
- [ "@asyncCall" ] = "function",
- [ "@atomicLoad" ] = "function",
- [ "@atomicRmw" ] = "function",
- [ "@atomicStore" ] = "function",
- [ "@bitCast" ] = "function",
- [ "@bitOffsetOf" ] = "function",
- [ "@boolToInt" ] = "function",
- [ "@bitSizeOf" ] = "function",
- [ "@breakpoint" ] = "function",
- [ "@mulAdd" ] = "function",
- [ "@byteSwap" ] = "function",
- [ "@bitReverse" ] = "function",
- [ "@byteOffsetOf" ] = "function",
- [ "@call" ] = "function",
- [ "@cDefine" ] = "function",
- [ "@cImport" ] = "function",
- [ "@cInclude" ] = "function",
- [ "@clz" ] = "function",
- [ "@cmpxchgStrong" ] = "function",
- [ "@cmpxchgWeak" ] = "function",
- [ "@compileError" ] = "function",
- [ "@compileLog" ] = "function",
- [ "@ctz" ] = "function",
- [ "@cUndef" ] = "function",
- [ "@divExact" ] = "function",
- [ "@divFloor" ] = "function",
- [ "@divTrunc" ] = "function",
- [ "@embedFile" ] = "function",
- [ "@enumToInt" ] = "function",
- [ "@errorName" ] = "function",
- [ "@errorReturnTrace" ] = "function",
- [ "@errorToInt" ] = "function",
- [ "@errSetCast" ] = "function",
- [ "@export" ] = "function",
- [ "@fence" ] = "function",
- [ "@field" ] = "function",
- [ "@fieldParentPtr" ] = "function",
- [ "@floatCast" ] = "function",
- [ "@floatToInt" ] = "function",
- [ "@Frame" ] = "function",
- [ "@frame" ] = "function",
- [ "@frameAddress" ] = "function",
- [ "@frameSize" ] = "function",
- [ "@hasDecl" ] = "function",
- [ "@hasField" ] = "function",
- [ "@import" ] = "function",
- [ "@intCast" ] = "function",
- [ "@intToEnum" ] = "function",
- [ "@intToError" ] = "function",
- [ "@intToFloat" ] = "function",
- [ "@intToPtr" ] = "function",
- [ "@memcpy" ] = "function",
- [ "@memset" ] = "function",
- [ "@wasmMemorySize" ] = "function",
- [ "@wasmMemoryGrow" ] = "function",
- [ "@mod" ] = "function",
- [ "@mulWithOverflow" ] = "function",
- [ "@panic" ] = "function",
- [ "@popCount" ] = "function",
- [ "@ptrCast" ] = "function",
- [ "@ptrToInt" ] = "function",
- [ "@rem" ] = "function",
- [ "@returnAddress" ] = "function",
- [ "@setAlignStack" ] = "function",
- [ "@setCold" ] = "function",
- [ "@setEvalBranchQuota" ] = "function",
- [ "@setFloatMode" ] = "function",
- [ "@setRuntimeSafety" ] = "function",
- [ "@shlExact" ] = "function",
- [ "@shlWithOverflow" ] = "function",
- [ "@shrExact" ] = "function",
- [ "@shuffle" ] = "function",
- [ "@sizeOf" ] = "function",
- [ "@splat" ] = "function",
- [ "@src" ] = "function",
- [ "@sqrt" ] = "function",
- [ "@sin" ] = "function",
- [ "@cos" ] = "function",
- [ "@exp" ] = "function",
- [ "@exp2" ] = "function",
- [ "@log" ] = "function",
- [ "@log2" ] = "function",
- [ "@log10" ] = "function",
- [ "@fabs" ] = "function",
- [ "@floor" ] = "function",
- [ "@ceil" ] = "function",
- [ "@trunc" ] = "function",
- [ "@round" ] = "function",
- [ "@subWithOverflow" ] = "function",
- [ "@tagName" ] = "function",
- [ "@TagType" ] = "function",
- [ "@This" ] = "function",
- [ "@truncate" ] = "function",
- [ "@Type" ] = "function",
- [ "@typeInfo" ] = "function",
- [ "@typeName" ] = "function",
- [ "@TypeOf" ] = "function",
- [ "@unionInit" ] = "function",
+ ["struct"] = "keyword",
+ ["enum"] = "keyword",
+ ["union"] = "keyword",
+ ["opaque"] = "keyword",
+ ["inline"] = "keyword",
+ ["allowzero"] = "keyword",
+ ["noalias"] = "keyword",
+ ["nosuspend"] = "keyword",
-- types
+ ["f16"] = "keyword2",
+ ["f32"] = "keyword2",
+ ["f64"] = "keyword2",
+ ["f128"] = "keyword2",
["void"] = "keyword2",
["c_void"] = "keyword2",
["isize"] = "keyword2",
diff --git a/plugins/lfautoinsert.lua b/plugins/lfautoinsert.lua
index 0534aa8..5f4148b 100644
--- a/plugins/lfautoinsert.lua
+++ b/plugins/lfautoinsert.lua
@@ -1,11 +1,11 @@
--- mod-version:1 -- lite-xl 1.16
+-- mod-version:2 -- lite-xl 2.0
local core = require "core"
local command = require "core.command"
local common = require "core.common"
local config = require "core.config"
local keymap = require "core.keymap"
-config.lfautoinsert_map = {
+config.plugins.lfautoinsert = { map = {
["{%s*\n"] = "}",
["%(%s*\n"] = ")",
["%f[[]%[%s*\n"] = "]",
@@ -13,6 +13,7 @@ config.lfautoinsert_map = {
[":%s*\n"] = false,
["->%s*\n"] = false,
["^%s*<([^/][^%s>]*)[^>]*>%s*\n"] = "</$TEXT>",
+ ["^%s*{{#([^/][^%s}]*)[^}]*}}%s*\n"] = "{{/$TEXT}}",
["/%*%s*\n"] = "*/",
["c/c++"] = {
file_patterns = {
@@ -36,11 +37,11 @@ config.lfautoinsert_map = {
["%[%[%s*\n"] = "]]"
}
},
-}
+} }
local function get_autoinsert_map(filename)
local map = {}
- for pattern, closing in pairs(config.lfautoinsert_map) do
+ for pattern, closing in pairs(config.plugins.lfautoinsert.map) do
if type(closing) == "table" then
if common.match_pattern(filename, closing.file_patterns) then
for p, e in pairs(closing.map) do
@@ -101,7 +102,7 @@ keymap.add {
return {
add = function(file_patterns, map)
table.insert(
- config.lfautoinsert_map,
+ config.plugins.lfautoinsert.map,
{ file_patterns = file_patterns, map=map }
)
end
diff --git a/plugins/linecopypaste.lua b/plugins/linecopypaste.lua
index a4a5e60..d332cc1 100755
--- a/plugins/linecopypaste.lua
+++ b/plugins/linecopypaste.lua
@@ -1,4 +1,4 @@
--- mod-version:1 -- lite-xl 1.16
+-- mod-version:2 -- lite-xl 2.0
local core = require "core"
local command = require "core.command"
diff --git a/plugins/lineguide.lua b/plugins/lineguide.lua
deleted file mode 100644
index 2cf0b42..0000000
--- a/plugins/lineguide.lua
+++ /dev/null
@@ -1,21 +0,0 @@
--- mod-version:1 -- lite-xl 1.16
-local config = require "core.config"
-local style = require "core.style"
-local DocView = require "core.docview"
-
-local draw = DocView.draw
-
-function DocView:draw(...)
- draw(self, ...)
-
- local ns = ("n"):rep(config.line_limit)
- local ss = self:get_font():subpixel_scale()
- local offset = self:get_font():get_width_subpixel(ns) / ss
- local x = self:get_line_screen_position(1) + offset
- local y = self.position.y
- local w = math.ceil(SCALE * 1)
- local h = self.size.y
-
- local color = style.guide or style.selection
- renderer.draw_rect(x, y, w, h, color)
-end
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/macmodkeys.lua b/plugins/macmodkeys.lua
index 14f8995..d8c0d05 100644
--- a/plugins/macmodkeys.lua
+++ b/plugins/macmodkeys.lua
@@ -1,4 +1,4 @@
--- mod-version:1 -- lite-xl 1.16
+-- mod-version:2 -- lite-xl 2.0
local keymap = require "core.keymap"
local on_key_pressed = keymap.on_key_pressed
diff --git a/plugins/markers.lua b/plugins/markers.lua
index f4a70d6..ad89fad 100644
--- a/plugins/markers.lua
+++ b/plugins/markers.lua
@@ -1,4 +1,4 @@
--- mod-version:1 -- lite-xl 1.16
+-- mod-version:2 -- lite-xl 2.0
-- Markers plugin for lite text editor
-- original implementation by Petri Häkkinen
@@ -52,12 +52,12 @@ end
local draw_line_gutter = DocView.draw_line_gutter
-function DocView:draw_line_gutter(idx, x, y)
+function DocView:draw_line_gutter(idx, x, y, width)
if cache[self.doc] and cache[self.doc][idx] then
local h = self:get_line_height()
renderer.draw_rect(x, y, style.padding.x * 0.4, h, style.selection)
end
- draw_line_gutter(self, idx, x, y)
+ draw_line_gutter(self, idx, x, y, width)
end
diff --git a/plugins/memoryusage.lua b/plugins/memoryusage.lua
index ee472dd..fcdcc29 100644
--- a/plugins/memoryusage.lua
+++ b/plugins/memoryusage.lua
@@ -1,4 +1,4 @@
--- mod-version:1 -- lite-xl 1.16
+-- mod-version:2 -- lite-xl 2.0
-- original implementation by AqilCont
local style = require "core.style"
local StatusView = require "core.statusview"
diff --git a/plugins/minimap.lua b/plugins/minimap.lua
new file mode 100644
index 0000000..01f93c5
--- /dev/null
+++ b/plugins/minimap.lua
@@ -0,0 +1,299 @@
+-- mod-version:1
+local command = require "core.command"
+local common = require "core.common"
+local config = require "core.config"
+local style = require "core.style"
+local DocView = require "core.docview"
+
+-- General plugin settings
+config.plugins.minimap = {
+ enabled = true,
+ width = 100,
+ instant_scroll = false,
+ syntax_highlight = true,
+ scale = 1,
+ -- how many spaces one tab is equivalent to
+ tab_width = 4,
+ draw_background = true
+}
+
+-- Configure size for rendering each char in the minimap
+local char_height = 1 * SCALE * config.plugins.minimap.scale
+local char_spacing = 0.8 * SCALE * config.plugins.minimap.scale
+local line_spacing = 2 * SCALE * config.plugins.minimap.scale
+
+-- Overloaded since the default implementation adds a extra x3 size of hotspot for the mouse to hit the scrollbar.
+local prev_scrollbar_overlaps_point = DocView.scrollbar_overlaps_point
+DocView.scrollbar_overlaps_point = function(self, x, y)
+ if not config.plugins.minimap.enabled then
+ return prev_scrollbar_overlaps_point(self, x, y)
+ end
+
+ local sx, sy, sw, sh = self:get_scrollbar_rect()
+ return x >= sx and x < sx + sw and y >= sy and y < sy + sh
+end
+
+-- Helper function to determine if current file is too large to be shown fully inside the minimap area.
+local function is_file_too_large(self)
+ local line_count = #self.doc.lines
+ local _, _, _, sh = self:get_scrollbar_rect()
+
+ -- check if line count is too large to fit inside the minimap area
+ local max_minmap_lines = math.floor(sh / line_spacing)
+ return line_count > 1 and line_count > max_minmap_lines
+end
+
+-- Overloaded with an extra check if the user clicked inside the minimap to automatically scroll to that line.
+local prev_on_mouse_pressed = DocView.on_mouse_pressed
+DocView.on_mouse_pressed = function(self, button, x, y, clicks)
+ if not config.plugins.minimap.enabled then
+ return prev_on_mouse_pressed(self, button, x, y, clicks)
+ end
+
+ -- check if user clicked in the minimap area and jump directly to that line
+ -- unless they are actually trying to perform a drag
+ local minimap_hit = self:scrollbar_overlaps_point(x, y)
+ if minimap_hit then
+ local line_count = #self.doc.lines
+ local minimap_height = line_count * line_spacing
+
+ -- check if line count is too large to fit inside the minimap area
+ local is_too_large = is_file_too_large(self)
+ if is_too_large then
+ local _, _, _, sh = self:get_scrollbar_rect()
+ minimap_height = sh
+ end
+
+ -- calc which line to jump to
+ local dy = y - self.position.y
+ local jump_to_line = math.floor((dy / minimap_height) * line_count) + 1
+
+ local _, cy, _, cy2 = self:get_content_bounds()
+ local lh = self:get_line_height()
+ local visible_lines_count = math.max(1, (cy2 - cy) / lh)
+ local visible_lines_start = math.max(1, math.floor(cy / lh))
+
+ -- calc if user hit the currently visible area
+ local hit_visible_area = true
+ if is_too_large then
+
+ local visible_height = visible_lines_count * line_spacing
+ local scroll_pos = (visible_lines_start - 1) /
+ (line_count - visible_lines_count - 1)
+ scroll_pos = math.min(1.0, scroll_pos) -- 0..1
+ local visible_y = self.position.y + scroll_pos *
+ (minimap_height - visible_height)
+
+ local t = (line_count - visible_lines_start) / visible_lines_count
+ if t <= 1 then visible_y = visible_y + visible_height * (1.0 - t) end
+
+ if y < visible_y or y > visible_y + visible_height then
+ hit_visible_area = false
+ end
+ else
+
+ -- If the click is on the currently visible line numbers,
+ -- ignore it since then they probably want to initiate a drag instead.
+ if jump_to_line < visible_lines_start or jump_to_line > visible_lines_start +
+ visible_lines_count then hit_visible_area = false end
+ end
+
+ -- if user didn't click on the visible area (ie not dragging), scroll accordingly
+ if not hit_visible_area then
+ self:scroll_to_line(jump_to_line, false, config.plugins.minimap.instant_scroll)
+ return
+ end
+
+ end
+
+ return prev_on_mouse_pressed(self, button, x, y, clicks)
+end
+
+-- Overloaded with pretty much the same logic as original DocView implementation,
+-- with the exception of the dragging scrollbar delta. We want it to behave a bit snappier
+-- since the "scrollbar" essentially represents the lines visible in the content view.
+local prev_on_mouse_moved = DocView.on_mouse_moved
+DocView.on_mouse_moved = function(self, x, y, dx, dy)
+ if not config.plugins.minimap.enabled then
+ return prev_on_mouse_moved(self, x, y, dx, dy)
+ end
+
+ if self.dragging_scrollbar then
+ local line_count = #self.doc.lines
+ local lh = self:get_line_height()
+ local delta = lh / line_spacing * dy
+
+ if is_file_too_large(self) then
+ local _, sy, _, sh = self:get_scrollbar_rect()
+ delta = (line_count * lh) / sh * dy
+ end
+
+ self.scroll.to.y = self.scroll.to.y + delta
+ end
+
+ -- we need to "hide" that the scrollbar is dragging so that View doesnt does its own scrolling logic
+ local t = self.dragging_scrollbar
+ self.dragging_scrollbar = false
+ local r = prev_on_mouse_moved(self, x, y, dx, dy)
+ self.dragging_scrollbar = t
+ return r
+end
+
+-- Overloaded since we want the mouse to interact with the full size of the minimap area,
+-- not juse the scrollbar.
+local prev_get_scrollbar_rect = DocView.get_scrollbar_rect
+DocView.get_scrollbar_rect = function(self)
+ if not config.plugins.minimap.enabled then return prev_get_scrollbar_rect(self) end
+
+ return self.position.x + self.size.x - config.plugins.minimap.width * SCALE,
+ self.position.y, config.plugins.minimap.width * SCALE, self.size.y
+end
+
+-- Overloaded so we can render the minimap in the "scrollbar area".
+local prev_draw_scrollbar = DocView.draw_scrollbar
+DocView.draw_scrollbar = function(self)
+ if not config.plugins.minimap.enabled then return prev_draw_scrollbar(self) end
+
+ local x, y, w, h = self:get_scrollbar_rect()
+
+ local highlight = self.hovered_scrollbar or self.dragging_scrollbar
+ local visual_color = highlight and style.scrollbar2 or style.scrollbar
+
+ local _, cy, _, cy2 = self:get_content_bounds()
+ local lh = self:get_line_height()
+ local visible_lines_count = math.max(1, (cy2 - cy) / lh)
+ local visible_lines_start = math.max(1, math.floor(cy / lh))
+ local scroller_height = visible_lines_count * line_spacing
+ local line_count = #self.doc.lines
+
+ local visible_y = self.position.y + (visible_lines_start - 1) * line_spacing
+
+ -- check if file is too large to fit inside the minimap area
+ local max_minmap_lines = math.floor(h / line_spacing)
+ local minimap_start_line = 1
+ if is_file_too_large(self) then
+
+ local scroll_pos = (visible_lines_start - 1) /
+ (line_count - visible_lines_count - 1)
+ scroll_pos = math.min(1.0, scroll_pos) -- 0..1, procent of visual area scrolled
+
+ local scroll_pos_pixels = scroll_pos * (h - scroller_height)
+ visible_y = self.position.y + scroll_pos_pixels
+
+ -- offset visible area if user is scrolling past end
+ local t = (line_count - visible_lines_start) / visible_lines_count
+ if t <= 1 then visible_y = visible_y + scroller_height * (1.0 - t) end
+
+ minimap_start_line = visible_lines_start -
+ math.floor(scroll_pos_pixels / line_spacing)
+ minimap_start_line = math.max(1, math.min(minimap_start_line,
+ line_count - max_minmap_lines))
+ end
+
+ if config.plugins.minimap.draw_background then
+ renderer.draw_rect(x, y, w, h, style.minimap_background or style.background)
+ end
+ -- draw visual rect
+ renderer.draw_rect(x, visible_y, w, scroller_height, visual_color)
+
+ -- time to draw the actual code, setup some local vars that are used in both highlighted and plain renderind.
+ local line_y = y
+
+ -- when not using syntax highlighted rendering, just use the normal color but dim it 50%.
+ local color = style.syntax["normal"]
+ color = {color[1], color[2], color[3], color[4] * 0.5}
+
+ -- we try to "batch" characters so that they can be rendered as just one rectangle instead of one for each.
+ local batch_width = 0
+ local batch_start = x
+ local minimap_cutoff_x = x + config.plugins.minimap.width * SCALE
+ local batch_syntax_type = nil
+ local function flush_batch(type)
+ local old_color = color
+ color = style.syntax[batch_syntax_type]
+ if config.plugins.minimap.syntax_highlight and color ~= nil then
+ -- fetch and dim colors
+ color = {color[1], color[2], color[3], color[4] * 0.5}
+ else
+ color = old_color
+ end
+ if batch_width > 0 then
+ renderer.draw_rect(batch_start, line_y, batch_width, char_height, color)
+ end
+ batch_syntax_type = type
+ batch_start = batch_start + batch_width
+ batch_width = 0
+ end
+
+ -- render lines with syntax highlighting
+ if config.plugins.minimap.syntax_highlight then
+
+ -- keep track of the highlight type, since this needs to break batches as well
+ batch_syntax_type = nil
+
+ -- per line
+ local endidx = minimap_start_line + max_minmap_lines
+ endidx = math.min(endidx, line_count)
+ for idx = minimap_start_line, endidx do
+ batch_syntax_type = nil
+ batch_start = x
+ batch_width = 0
+
+ -- per token
+ for _, type, text in self.doc.highlighter:each_token(idx) do
+ -- flush prev batch
+ if not batch_syntax_type then batch_syntax_type = type end
+ if batch_syntax_type ~= type then flush_batch(type) end
+
+ -- per character
+ for char in common.utf8_chars(text) do
+ if char == " " or char == "\n" then
+ flush_batch(type)
+ batch_start = batch_start + char_spacing
+ elseif char == " " then
+ flush_batch(type)
+ batch_start = batch_start + (char_spacing * config.plugins.minimap.tab_width)
+ elseif batch_start + batch_width > minimap_cutoff_x then
+ flush_batch(type)
+ break
+ else
+ batch_width = batch_width + char_spacing
+ end
+
+ end
+ end
+ flush_batch(nil)
+ line_y = line_y + line_spacing
+ end
+
+ else -- render lines without syntax highlighting
+ for idx = 1, line_count - 1 do
+ batch_start = x
+ batch_width = 0
+
+ for char in common.utf8_chars(self.doc.lines[idx]) do
+ if char == " " or char == "\n" then
+ flush_batch()
+ batch_start = batch_start + char_spacing
+ elseif batch_start + batch_width > minimap_cutoff_x then
+ flush_batch()
+ else
+ batch_width = batch_width + char_spacing
+ end
+ end
+ flush_batch()
+ line_y = line_y + line_spacing
+ end
+
+ end
+
+end
+
+command.add(nil, {
+ ["minimap:toggle-visibility"] = function()
+ config.plugins.minimap.enabled = not config.plugins.minimap.enabled
+ end,
+ ["minimap:toggle-syntax-highlighting"] = function()
+ config.plugins.minimap.syntax_highlight = not config.plugins.minimap.syntax_highlight
+ end
+})
diff --git a/plugins/motiontrail.lua b/plugins/motiontrail.lua
index 6f448bb..1359c90 100644
--- a/plugins/motiontrail.lua
+++ b/plugins/motiontrail.lua
@@ -1,10 +1,10 @@
--- mod-version:1 -- lite-xl 1.16
+-- mod-version:2 -- lite-xl 2.0
local core = require "core"
local config = require "core.config"
local style = require "core.style"
local DocView = require "core.docview"
-config.motiontrail_steps = 50
+config.plugins.motiontrail = { steps = 50 }
local function lerp(a, b, t)
@@ -32,7 +32,7 @@ function DocView:draw(...)
if last_view == self and (x ~= last_x or y ~= last_y) then
local lx = x
- for i = 0, 1, 1 / config.motiontrail_steps do
+ for i = 0, 1, 1 / config.plugins.motiontrail.steps do
local ix = lerp(x, last_x, i)
local iy = lerp(y, last_y, i)
local iw = math.max(w, math.ceil(math.abs(ix - lx)))
diff --git a/plugins/navigate.lua b/plugins/navigate.lua
index dd985b5..4e6092f 100644
--- a/plugins/navigate.lua
+++ b/plugins/navigate.lua
@@ -1,4 +1,4 @@
--- mod-version:1 -- lite-xl 1.16
+-- mod-version:2 -- lite-xl 2.0
local core = require "core"
local common = require "core.common"
diff --git a/plugins/openfilelocation.lua b/plugins/openfilelocation.lua
index 48877bd..4b89815 100644
--- a/plugins/openfilelocation.lua
+++ b/plugins/openfilelocation.lua
@@ -1,15 +1,16 @@
--- mod-version:1 -- lite-xl 1.16
+-- mod-version:2 -- lite-xl 2.0
local core = require "core"
local command = require "core.command"
local config = require "core.config"
+config.plugins.openfilelocation = {}
if PLATFORM == "Windows" then
- config.filemanager = "explorer"
+ config.plugins.openfilelocation.filemanager = "explorer"
elseif PLATFORM == "Mac OS X" then
- config.filemanager = "open"
+ config.plugins.openfilelocation.filemanager = "open"
else
- config.filemanager = "xdg-open"
+ config.plugins.openfilelocation.filemanager = "xdg-open"
end
@@ -23,9 +24,9 @@ command.add("core.docview", {
local folder = doc.filename:match("^(.*)[/\\].*$") or "."
core.log("Opening \"%s\"", folder)
if PLATFORM == "Windows" then
- system.exec(string.format("%s %s", config.filemanager, folder))
+ system.exec(string.format("%s %s", config.plugins.openfilelocation.filemanager, folder))
else
- system.exec(string.format("%s %q", config.filemanager, folder))
+ system.exec(string.format("%s %q", config.plugins.openfilelocation.filemanager, folder))
end
end
})
diff --git a/plugins/openselected.lua b/plugins/openselected.lua
index ccaa8e3..a1e21a2 100644
--- a/plugins/openselected.lua
+++ b/plugins/openselected.lua
@@ -1,4 +1,4 @@
--- mod-version:1 -- lite-xl 1.16
+-- mod-version:2 -- lite-xl 2.0
local core = require "core"
local command = require "core.command"
local keymap = require "core.keymap"
diff --git a/plugins/pdfview.lua b/plugins/pdfview.lua
index 743c6ec..d5d749a 100644
--- a/plugins/pdfview.lua
+++ b/plugins/pdfview.lua
@@ -1,4 +1,4 @@
--- mod-version:1 -- lite-xl 1.16
+-- mod-version:2 -- lite-xl 2.0
local core = require "core"
local command = require "core.command"
local keymap = require "core.keymap"
diff --git a/plugins/rainbowparen.lua b/plugins/rainbowparen.lua
index b6075ac..52e9d50 100644
--- a/plugins/rainbowparen.lua
+++ b/plugins/rainbowparen.lua
@@ -1,4 +1,4 @@
--- mod-version:1 -- lite-xl 1.16
+-- mod-version:2 -- lite-xl 2.0
local tokenizer = require "core.tokenizer"
local style = require "core.style"
local common = require "core.common"
diff --git a/plugins/regexreplacepreview.lua b/plugins/regexreplacepreview.lua
index 926530b..1c8b845 100644
--- a/plugins/regexreplacepreview.lua
+++ b/plugins/regexreplacepreview.lua
@@ -1,4 +1,4 @@
--- mod-version:1 -- lite-xl 1.16
+-- mod-version:2 -- lite-xl 2.0
local core = require "core"
local keymap = require "core.keymap"
local command = require "core.command"
diff --git a/plugins/restoretabs.lua b/plugins/restoretabs.lua
index 6776e2c..5bcd977 100644
--- a/plugins/restoretabs.lua
+++ b/plugins/restoretabs.lua
@@ -1,4 +1,4 @@
--- mod-version:1 -- lite-xl 1.16
+-- mod-version:2 -- lite-xl 2.0
-- Not perfect, because we can't actually figure out when something closes, but should be good enough, so long as we check the list of open views.
-- Maybe find a better way to get at "Node"?
local core = require "core"
diff --git a/plugins/scale.lua b/plugins/scale.lua
deleted file mode 100644
index 14648fd..0000000
--- a/plugins/scale.lua
+++ /dev/null
@@ -1,142 +0,0 @@
--- mod-version:1 -- lite-xl 1.16
-local core = require "core"
-local common = require "core.common"
-local command = require "core.command"
-local config = require "core.config"
-local keymap = require "core.keymap"
-local style = require "core.style"
-local RootView = require "core.rootview"
-local CommandView = require "core.commandview"
-
-config.scale_mode = "code"
-config.scale_use_mousewheel = true
-
-local scale_level = 0
-local scale_steps = 0.1
-local font_cache = setmetatable({}, { __mode = "k" })
-
--- default lite fonts
-local regular_font = "font.ttf"
-local monospace_font = "monospace.ttf"
-
--- Set font names properly to work with latest lite-xl changes
-if io.open(DATADIR .. "/fonts/FiraSans-Regular.ttf", "r") then
- regular_font = "FiraSans-Regular.ttf"
-end
-
-if io.open(DATADIR .. "/fonts/JetBrainsMono-Regular.ttf", "r") then
- monospace_font = "JetBrainsMono-Regular.ttf"
-end
-
--- the following should be kept in sync with core.style's default font settings
-font_cache[style.font] = { DATADIR .. "/fonts/" .. regular_font, 13 * SCALE }
-font_cache[style.big_font] = { DATADIR .. "/fonts/" .. regular_font, 40 * SCALE }
-font_cache[style.icon_font] = { DATADIR .. "/fonts/icons.ttf", 14 * SCALE }
-font_cache[style.icon_big_font] = { DATADIR .. "/fonts/icons.ttf", 20 * SCALE }
-font_cache[style.code_font] = { DATADIR .. "/fonts/" .. monospace_font, 13 * SCALE }
-
-
-local load_font = renderer.font.load
-function renderer.font.load(...)
- local res = load_font(...)
- font_cache[res] = { ... }
- return res
-end
-
-
-local function scale_font(font, s)
- local fc = font_cache[font]
- return renderer.font.load(fc[1], fc[2] * s)
-end
-
-
-local current_scale = SCALE
-local default = current_scale
-
-
-local function get_scale() return current_scale end
-
-
-local function set_scale(scale)
- scale = common.clamp(scale, 0.2, 6)
-
- -- save scroll positions
- local scrolls = {}
- for _, view in ipairs(core.root_view.root_node:get_children()) do
- local n = view:get_scrollable_size()
- if n ~= math.huge and not view:is(CommandView) and n > view.size.y then
- scrolls[view] = view.scroll.y / (n - view.size.y)
- end
- end
-
- local s = scale / current_scale
- current_scale = scale
-
- if config.scale_mode == "ui" then
- SCALE = current_scale
-
- style.padding.x = style.padding.x * s
- style.padding.y = style.padding.y * s
- style.divider_size = style.divider_size * s
- style.scrollbar_size = style.scrollbar_size * s
- style.caret_width = style.caret_width * s
- style.tab_width = style.tab_width * s
-
- style.big_font = scale_font(style.big_font, s)
- style.icon_font = scale_font(style.icon_font, s)
- style.font = scale_font(style.font, s)
- end
-
- style.code_font = scale_font(style.code_font, s)
-
- -- restore scroll positions
- for view, n in pairs(scrolls) do
- view.scroll.y = n * (view:get_scrollable_size() - view.size.y)
- view.scroll.to.y = view.scroll.y
- end
-
- core.redraw = true
-end
-
-
-local on_mouse_wheel = RootView.on_mouse_wheel
-
-function RootView:on_mouse_wheel(d, ...)
- if keymap.modkeys["ctrl"] and config.scale_use_mousewheel then
- if d < 0 then command.perform "scale:decrease" end
- if d > 0 then command.perform "scale:increase" end
- else
- return on_mouse_wheel(self, d, ...)
- end
-end
-
-local function res_scale()
- scale_level = 0
- set_scale(default)
-end
-
-local function inc_scale()
- scale_level = scale_level + 1
- set_scale(default + scale_level * scale_steps)
-end
-
-local function dec_scale()
- scale_level = scale_level - 1
- set_scale(default + scale_level * scale_steps)
-end
-
-
-command.add(nil, {
- ["scale:reset" ] = function() res_scale() end,
- ["scale:decrease"] = function() dec_scale() end,
- ["scale:increase"] = function() inc_scale() end,
-})
-
-keymap.add {
- ["ctrl+0"] = "scale:reset",
- ["ctrl+-"] = "scale:decrease",
- ["ctrl+="] = "scale:increase",
-}
-
-return { get_scale = get_scale, set_scale = set_scale }
-
diff --git a/plugins/scalestatus.lua b/plugins/scalestatus.lua
index 2981523..8f3ef68 100644
--- a/plugins/scalestatus.lua
+++ b/plugins/scalestatus.lua
@@ -1,24 +1,16 @@
--- mod-version:1 -- lite-xl 1.16
+-- mod-version:2 -- lite-xl 2.0
--[[
scalestatus.lua
displays current scale (zoom) in status view
version: 20200628_155804
originally by SwissalpS
-
- Depends on plugin scale.lua version >= 20200628_154010
--]]
local scale = require "plugins.scale"
--- make sure plugin is installed and has get_scale field
-if not scale.get_scale then
- local core = require "core"
- core.error("Plugin 'scale' needs to be updated, scalestatus inactive.")
- return false
-end
local config = require "core.config"
local StatusView = require "core.statusview"
-config.scalestatus_format = '%.0f%%'
+config.plugins.scalestatus = { format = '%.0f%%' }
local get_items = StatusView.get_items
function StatusView:get_items()
@@ -27,7 +19,7 @@ function StatusView:get_items()
local t = {
self.separator,
- string.format(config.scalestatus_format, scale.get_scale() * 100),
+ string.format(config.plugins.scalestatus.format, scale.get() * 100),
}
for _, item in ipairs(t) do
diff --git a/plugins/selectionhighlight.lua b/plugins/selectionhighlight.lua
index 93ac0fb..1cec783 100644
--- a/plugins/selectionhighlight.lua
+++ b/plugins/selectionhighlight.lua
@@ -1,7 +1,6 @@
--- mod-version:1 -- lite-xl 1.16
+-- mod-version:2 -- lite-xl 2.0
local style = require "core.style"
local DocView = require "core.docview"
-local config = require "core.config"
-- originally written by luveti
diff --git a/plugins/smallclock.lua b/plugins/smallclock.lua
new file mode 100644
index 0000000..b22bc71
--- /dev/null
+++ b/plugins/smallclock.lua
@@ -0,0 +1,27 @@
+-- lite-xl 2.00
+local core = require "core"
+local style = require "core.style"
+local status_view = require "core.statusview"
+
+local time = ""
+
+core.add_thread(function()
+ while true do
+ local t = os.date("*t")
+ time = string.format("%02d:%02d", t.hour, t.min)
+ coroutine.yield(1)
+ end
+end)
+
+local get_items = status_view.get_items
+
+function status_view:get_items()
+ local left, right = get_items(self)
+ local t = {style.dim, self.separator2, style.accent, time}
+
+ for _, item in ipairs(t) do
+ table.insert(right, item)
+ end
+
+ return left, right
+end
diff --git a/plugins/sort.lua b/plugins/sort.lua
index 34b2b93..fd9d044 100644
--- a/plugins/sort.lua
+++ b/plugins/sort.lua
@@ -1,4 +1,4 @@
--- mod-version:1 -- lite-xl 1.16
+-- mod-version:2 -- lite-xl 2.0
local core = require "core"
local command = require "core.command"
local translate = require "core.doc.translate"
diff --git a/plugins/spellcheck.lua b/plugins/spellcheck.lua
index 975ef91..db58606 100644
--- a/plugins/spellcheck.lua
+++ b/plugins/spellcheck.lua
@@ -1,4 +1,4 @@
--- mod-version:1 -- lite-xl 1.16
+-- mod-version:2 -- lite-xl 2.0
local core = require "core"
local style = require "core.style"
local config = require "core.config"
@@ -7,11 +7,12 @@ local common = require "core.common"
local DocView = require "core.docview"
local Doc = require "core.doc"
-config.spellcheck_files = { "%.txt$", "%.md$", "%.markdown$" }
+config.plugins.spellcheck = {}
+config.spellcheck.files = { "%.txt$", "%.md$", "%.markdown$" }
if PLATFORM == "Windows" then
- config.dictionary_file = EXEDIR .. "/words.txt"
+ config.plugins.spellcheck.dictionary_file = EXEDIR .. "/words.txt"
else
- config.dictionary_file = "/usr/share/dict/words"
+ config.plugins.spellcheck.dictionary_file = "/usr/share/dict/words"
end
@@ -22,7 +23,7 @@ local words
core.add_thread(function()
local t = {}
local i = 0
- for line in io.lines(config.dictionary_file) do
+ for line in io.lines(config.plugins.spellcheck.dictionary_file) do
for word in line:gmatch(word_pattern) do
t[word:lower()] = true
end
@@ -31,7 +32,7 @@ core.add_thread(function()
end
words = t
core.redraw = true
- core.log_quiet("Finished loading dictionary file: \"%s\"", config.dictionary_file)
+ core.log_quiet("Finished loading dictionary file: \"%s\"", config.plugins.spellcheck.dictionary_file)
end)
@@ -64,7 +65,7 @@ function DocView:draw_line_text(idx, x, y)
draw_line_text(self, idx, x, y)
if not words
- or not matches_any(self.doc.filename or "", config.spellcheck_files) then
+ or not matches_any(self.doc.filename or "", config.plugins.spellcheck.files) then
return
end
@@ -120,7 +121,7 @@ command.add("core.docview", {
return
end
if word then
- local fp = assert(io.open(config.dictionary_file, "a"))
+ local fp = assert(io.open(config.plugins.spellcheck.dictionary_file, "a"))
fp:write("\n" .. word .. "\n")
fp:close()
words[word] = true
diff --git a/plugins/tabnumbers.lua b/plugins/tabnumbers.lua
index 70da707..581a6b2 100644
--- a/plugins/tabnumbers.lua
+++ b/plugins/tabnumbers.lua
@@ -1,4 +1,4 @@
--- mod-version:1 -- lite-xl 1.16
+-- mod-version:2 -- lite-xl 2.0
local common = require "core.common"
local core = require "core"
local style = require "core.style"
diff --git a/plugins/texcompile.lua b/plugins/texcompile.lua
index 7a5fd6e..2f53513 100644
--- a/plugins/texcompile.lua
+++ b/plugins/texcompile.lua
@@ -1,4 +1,4 @@
--- mod-version:1 -- lite-xl 1.16
+-- mod-version:2 -- lite-xl 2.0
local core = require "core"
local command = require "core.command"
local keymap = require "core.keymap"
diff --git a/plugins/themeselect.lua b/plugins/themeselect.lua
index cafc1be..70bd627 100644
--- a/plugins/themeselect.lua
+++ b/plugins/themeselect.lua
@@ -1,4 +1,4 @@
--- mod-version:1 -- lite-xl 1.16
+-- mod-version:2 -- lite-xl 2.0
local core = require "core"
-- Load a specific theme when the filename of an active document does match
diff --git a/plugins/titleize.lua b/plugins/titleize.lua
index ac64f44..edb50d2 100644
--- a/plugins/titleize.lua
+++ b/plugins/titleize.lua
@@ -1,4 +1,4 @@
--- mod-version:1 -- lite-xl 1.16
+-- mod-version:2 -- lite-xl 2.0
local core = require "core"
local command = require "core.command"
diff --git a/plugins/togglesnakecamel.lua b/plugins/togglesnakecamel.lua
index 0ba3ce9..b5d20d9 100644
--- a/plugins/togglesnakecamel.lua
+++ b/plugins/togglesnakecamel.lua
@@ -1,4 +1,4 @@
--- mod-version:1 -- lite-xl 1.16
+-- mod-version:2 -- lite-xl 2.0
local core = require "core"
local command = require "core.command"
local keymap = require "core.keymap"
diff --git a/plugins/unboundedscroll.lua b/plugins/unboundedscroll.lua
index 18d26a2..a27ab25 100644
--- a/plugins/unboundedscroll.lua
+++ b/plugins/unboundedscroll.lua
@@ -1,4 +1,4 @@
--- mod-version:1 -- lite-xl 1.16
+-- mod-version:2 -- lite-xl 2.0
local DocView = require "core.docview"
function DocView.clamp_scroll_position()