aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/extend_selection_line.lua19
-rw-r--r--plugins/force_syntax.lua132
-rw-r--r--plugins/gitstatus.lua74
-rw-r--r--plugins/indent_convert.lua128
-rw-r--r--plugins/language_R.lua1
-rw-r--r--plugins/language_angelscript.lua1
-rw-r--r--plugins/language_batch.lua1
-rw-r--r--plugins/language_bib.lua1
-rw-r--r--plugins/language_cmake.lua1
-rw-r--r--plugins/language_cpp.lua1
-rw-r--r--plugins/language_csharp.lua1
-rw-r--r--plugins/language_d.lua1
-rw-r--r--plugins/language_dart.lua1
-rw-r--r--plugins/language_elixir.lua1
-rw-r--r--plugins/language_elm.lua1
-rw-r--r--plugins/language_fe.lua1
-rw-r--r--plugins/language_fennel.lua1
-rw-r--r--plugins/language_fstab.lua1
-rw-r--r--plugins/language_gdscript.lua1
-rw-r--r--plugins/language_glsl.lua1
-rw-r--r--plugins/language_go.lua1
-rw-r--r--plugins/language_hlsl.lua1
-rw-r--r--plugins/language_hs.lua1
-rw-r--r--plugins/language_ini.lua1
-rw-r--r--plugins/language_java.lua1
-rw-r--r--plugins/language_jiyu.lua1
-rw-r--r--plugins/language_jsx.lua1
-rw-r--r--plugins/language_julia.lua112
-rw-r--r--plugins/language_liquid.lua1
-rw-r--r--plugins/language_lobster.lua1
-rw-r--r--plugins/language_make.lua1
-rw-r--r--plugins/language_meson.lua1
-rw-r--r--plugins/language_moon.lua1
-rw-r--r--plugins/language_nginx.lua1
-rw-r--r--plugins/language_nim.lua1
-rw-r--r--plugins/language_objc.lua1
-rw-r--r--plugins/language_odin.lua1
-rw-r--r--plugins/language_perl.lua1
-rw-r--r--plugins/language_php.lua1
-rw-r--r--plugins/language_pico8.lua1
-rw-r--r--plugins/language_po.lua1
-rw-r--r--plugins/language_powershell.lua145
-rw-r--r--plugins/language_psql.lua1
-rw-r--r--plugins/language_rescript.lua1
-rw-r--r--plugins/language_ruby.lua1
-rw-r--r--plugins/language_rust.lua2
-rw-r--r--plugins/language_sass.lua1
-rw-r--r--plugins/language_scala.lua80
-rw-r--r--plugins/language_sh.lua1
-rw-r--r--plugins/language_ssh_config.lua1
-rw-r--r--plugins/language_tcl.lua1
-rw-r--r--plugins/language_teal.lua1
-rw-r--r--plugins/language_tex.lua1
-rw-r--r--plugins/language_toml.lua1
-rw-r--r--plugins/language_ts.lua1
-rw-r--r--plugins/language_tsx.lua1
-rw-r--r--plugins/language_v.lua1
-rw-r--r--plugins/language_wren.lua3
-rw-r--r--plugins/language_yaml.lua1
-rw-r--r--plugins/language_zig.lua1
-rw-r--r--plugins/minimap.lua76
-rw-r--r--plugins/opacity.lua62
-rw-r--r--plugins/open_ext.lua2
-rw-r--r--plugins/openselected.lua27
-rw-r--r--plugins/smoothcaret.lua26
65 files changed, 848 insertions, 91 deletions
diff --git a/plugins/extend_selection_line.lua b/plugins/extend_selection_line.lua
new file mode 100644
index 0000000..e986597
--- /dev/null
+++ b/plugins/extend_selection_line.lua
@@ -0,0 +1,19 @@
+-- mod-version:2 -- lite-xl 2.0
+local DocView = require "core.docview"
+local style = require "core.style"
+
+local draw_line_body = DocView.draw_line_body
+function DocView:draw_line_body(idx, x, y, ...)
+ draw_line_body(self, idx, x, y, ...)
+ local lh = self:get_line_height()
+ for _, line1, _, line2, _ in self.doc:get_selections(true) do
+ if idx >= line1 and idx < line2 and line1 ~= line2 then
+ -- draw selection from the end of the line to the end of the available space
+ local x1 = x + self:get_col_x_offset(idx, #self.doc.lines[idx])
+ local x2 = x + self.scroll.x + self.size.x
+ if x2 > x1 then
+ renderer.draw_rect(x1, y, x2 - x1, lh, style.selection)
+ end
+ end
+ end
+end
diff --git a/plugins/force_syntax.lua b/plugins/force_syntax.lua
new file mode 100644
index 0000000..dce4abc
--- /dev/null
+++ b/plugins/force_syntax.lua
@@ -0,0 +1,132 @@
+-- mod-version:2 -- lite-xl 2.0
+local core = require "core"
+local Doc = require "core.doc"
+local syntax = require "core.syntax"
+local command = require "core.command"
+local common = require "core.common"
+local style = require "core.style"
+local StatusView = require "core.statusview"
+local DocView = require "core.docview"
+
+local function doc()
+ if core.active_view and getmetatable(core.active_view) == DocView then return core.active_view.doc end
+ if core.last_active_view and getmetatable(core.last_active_view) == DocView then return core.last_active_view.doc end
+end
+
+-- Force plaintext syntax to have a name
+local plain_text_syntax = syntax.get("", "")
+plain_text_syntax.name = plain_text_syntax.name or "Plain Text"
+
+local doc_reset_syntax = Doc.reset_syntax
+function Doc:reset_syntax()
+ local syntax_get = syntax.get
+ if self.force_syntax then
+ syntax.get = function() return self.force_syntax end
+ end
+ doc_reset_syntax(self)
+ syntax.get = syntax_get
+end
+
+local function get_syntax_name(s)
+ if not s then return "Undefined" end
+ local name = s.name
+ if not name then
+ local exts = type(s.files) == "string" and { s.files } or s.files
+ if exts then
+ name = table.concat(exts, ", ")
+ end
+ end
+ return name or "Undefined"
+end
+
+local statusview_get_items = StatusView.get_items
+function StatusView:get_items()
+ local left, right = statusview_get_items(self)
+
+ local is_dv = core.active_view and getmetatable(core.active_view) == DocView
+ if not is_dv then return left, right end
+
+ local syntax_name = get_syntax_name(doc().syntax)
+
+ local ins = {
+ style.dim,
+ self.separator2,
+ style.text,
+ syntax_name
+ }
+
+ if syntax_name then
+ for _,item in pairs(ins) do
+ table.insert(right, item)
+ end
+ end
+
+ return left, right
+end
+
+local function get_syntax_list()
+ local pt_name = plain_text_syntax.name
+ if doc().syntax == plain_text_syntax then
+ pt_name = "Current: "..pt_name
+ end
+ local list = { ["Auto detect"] = false,
+ [pt_name] = plain_text_syntax }
+ local keylist = { "Auto detect", pt_name }
+
+ for _,s in pairs(syntax.items) do
+ local name = get_syntax_name(s)
+ local fullname = name
+ local i = 1
+ while list[fullname] do
+ i = i + 1
+ fullname = name.." ("..i..")"
+ end
+ if doc().syntax == s then
+ fullname = "Current: "..fullname
+ end
+ list[fullname] = s
+ table.insert(keylist, fullname)
+ end
+
+ return list, keylist
+end
+
+local function sorter(a, b)
+ -- Compare only syntax name
+ a = a:gsub("Current: ", "")
+ b = b:gsub("Current: ", "")
+ return string.upper(a) < string.upper(b)
+end
+
+local function bias_sorter(a, b)
+ -- Bias towards Current and Auto detect syntax
+ if a:match("Current: ") then return true end
+ if b:match("Current: ") then return false end
+ if a:match("Auto detect") then return true end
+ if b:match("Auto detect") then return false end
+ return sorter(a, b)
+end
+
+command.add("core.docview", {
+ ["force-syntax:select-file-syntax"] =
+ function()
+ core.command_view:enter(
+ "Set syntax for this file",
+ function(text, item) -- submit
+ local list, _ = get_syntax_list()
+ doc().force_syntax = list[item.text]
+ doc():reset_syntax()
+ end,
+ function(text) -- suggest
+ local _, keylist = get_syntax_list()
+ local res = common.fuzzy_match(keylist, text)
+ -- Force Current and Auto detect syntax to the bottom
+ -- if the text is empty
+ table.sort(res, #text == 0 and bias_sorter or sorter)
+ return res
+ end,
+ nil, -- cancel
+ nil -- validate
+ )
+ end
+})
diff --git a/plugins/gitstatus.lua b/plugins/gitstatus.lua
index bb16025..de5c74b 100644
--- a/plugins/gitstatus.lua
+++ b/plugins/gitstatus.lua
@@ -1,9 +1,21 @@
-- mod-version:2 -- lite-xl 2.0
local core = require "core"
+local common = require "core.common"
local config = require "core.config"
local style = require "core.style"
local StatusView = require "core.statusview"
+local TreeView = require "plugins.treeview"
+
local scan_rate = config.project_scan_rate or 5
+local cached_color_for_item = {}
+
+
+-- Override TreeView's color_for_item, but first
+-- stash the old one (using [] in case it is not there at all)
+local old_color_for_item = TreeView["color_for_item"]
+function TreeView:color_for_item(abs_path)
+ return cached_color_for_item[abs_path] or old_color_for_item(abs_path)
+end
local git = {
@@ -13,11 +25,24 @@ local git = {
}
-local function exec(cmd, wait)
+config.gitstatus = {
+ recurse_submodules = true
+}
+style.gitstatus_addition = {common.color "#587c0c"}
+style.gitstatus_modification = {common.color "#0c7d9d"}
+style.gitstatus_deletion = {common.color "#94151b"}
+
+
+local function exec(cmd)
local proc = process.start(cmd)
- proc:wait(wait * 1000)
- local res = proc:read_stdout()
- return res
+ -- Don't use proc:wait() here - that will freeze the app.
+ -- Instead, rely on the fact that this is only called within
+ -- a coroutine, and yield for a fraction of a second, allowing
+ -- other stuff to happen while we wait for the process to complete.
+ while proc:running() do
+ coroutine.yield(0.1)
+ end
+ return proc:read_stdout() or ""
end
@@ -25,12 +50,45 @@ 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"}):match("[^\n]*")
+
+ local inserts = 0
+ local deletes = 0
-- get diff
- 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
+ local diff = exec({"git", "diff", "--numstat"})
+ if config.gitstatus.recurse_submodules and system.get_file_info(".gitmodules") then
+ local diff2 = exec({"git", "submodule", "foreach", "git diff --numstat"})
+ diff = diff .. diff2
+ end
+
+ -- forget the old state
+ cached_color_for_item = {}
+
+ local folder = core.project_dir
+ for line in string.gmatch(diff, "[^\n]+") do
+ local submodule = line:match("^Entering '(.+)'$")
+ if submodule then
+ folder = core.project_dir .. PATHSEP .. submodule
+ else
+ local ins, dels, path = line:match("(%d+)%s+(%d+)%s+(.+)")
+ if path then
+ inserts = inserts + (tonumber(ins) or 0)
+ deletes = deletes + (tonumber(dels) or 0)
+ local abs_path = folder .. PATHSEP .. path
+ -- Color this file, and each parent folder,
+ -- so you can see at a glance which folders
+ -- have modified files in them.
+ while abs_path do
+ cached_color_for_item[abs_path] = style.gitstatus_modification
+ abs_path = common.dirname(abs_path)
+ end
+ end
+ end
+ end
+
+ git.inserts = inserts
+ git.deletes = deletes
else
git.branch = nil
diff --git a/plugins/indent_convert.lua b/plugins/indent_convert.lua
new file mode 100644
index 0000000..c86686d
--- /dev/null
+++ b/plugins/indent_convert.lua
@@ -0,0 +1,128 @@
+-- mod-version:2 -- lite-xl 2.0
+local core = require "core"
+local config = require "core.config"
+local command = require "core.command"
+
+config.plugins.indent_convert = {
+ update_indent_type = true -- set to false to avoid updating the document indent type
+}
+
+local zero_pattern = _VERSION == "Lua 5.1" and "%z" or "\0"
+
+-- TODO: only set document indent type if there are no selections
+-- TODO: correctly restore selections accounting for the offset caused by the conversion
+
+-- To replace N spaces with tabs, we match the last N spaces before the start of
+-- the actual code and replace them with a tab.
+-- We repeat this until we can't find any more spaces before the code.
+-- The problem we encounter with this method is that if we have less than N
+-- remaining spaces, those will end up at the start of the line.
+-- Eg:
+-- int main() {
+-- __printf("Hello world\n");
+-- ___return 0;
+-- }
+--
+-- Becomes
+-- int main() {
+-- #printf("Hello world\n");
+-- _#return 0;
+-- }
+--
+-- Instead of
+-- int main() {
+-- #printf("Hello world\n");
+-- #_return 0;
+-- }
+-- With regex we could do something like
+-- `regex.gsub("(^(?: {2})*)(?: {2})", "\\1\t")`
+-- but the implementation of `regex.gsub` is very slow.
+--
+-- The workaround is to find the longest possible repetition of N*X spaces and
+-- use that information to replace the longest repetition of spaces starting
+-- from the beginning of the line, then the second longest...
+local function spaces_replacer(text, indent_size)
+ local spaces = string.rep(" ", indent_size)
+ local total = 0
+ local n
+ local reps = 0
+ -- find the longest repetition of indent_size*spaces
+ repeat
+ reps = reps + 1
+ local s, _ = string.find(text, "%f[^"..zero_pattern.."\n]"..string.rep(spaces, reps))
+ until not s
+ reps = reps - 1
+ while reps > 0 do
+ text, n = string.gsub(text,
+ "(%f[^"..zero_pattern.."\n])("..string.rep(spaces, reps)..")",
+ "%1"..string.rep("\t", reps))
+ total = total + n
+ reps = reps - 1
+ end
+ return text, total
+end
+
+local function tabs_replacer(text, indent_size)
+ local spaces = string.rep(" ", indent_size)
+ local total = 0
+ local n
+ -- replace the last tab before the text until there aren't anymore
+ repeat
+ text, n = string.gsub(text, "(%f[^"..zero_pattern.."\n]\t*)(\t)", "%1"..spaces)
+ total = total + n
+ until n == 0
+ return text, total
+end
+
+local function replacer(doc, fn, indent_size)
+ return function(text)
+ return fn(text, indent_size)
+ end
+end
+
+local function get_indent_size(doc)
+ local indent_size = config.indent_size
+ if type(doc.get_indent_info) == "function" then
+ -- use the new `Doc:get_indent_info` function
+ indent_size = select(2, doc:get_indent_info())
+ end
+ return indent_size
+end
+
+local function tabs_to_spaces()
+ local doc = core.active_view.doc
+ local indent_size = get_indent_size(doc)
+ local selections = doc.selections
+ doc:replace(replacer(doc, tabs_replacer, indent_size))
+ doc.selections = selections
+ doc:sanitize_selection()
+ if config.plugins.indent_convert.update_indent_type then
+ doc.indent_info = {
+ type = "soft",
+ size = indent_size,
+ confirmed = true
+ }
+ end
+end
+
+local function spaces_to_tabs()
+ local doc = core.active_view.doc
+ local indent_size = get_indent_size(doc)
+ local selections = doc.selections
+ doc:replace(replacer(doc, spaces_replacer, indent_size))
+ doc.selections = selections
+ doc:sanitize_selection()
+ if config.plugins.indent_convert.update_indent_type then
+ doc.indent_info = {
+ type = "hard",
+ size = indent_size,
+ confirmed = true
+ }
+ end
+end
+
+command.add("core.docview", {
+ ["indent-convert:tabs-to-spaces"] = tabs_to_spaces,
+ ["indent-convert:spaces-to-tabs"] = spaces_to_tabs
+ }
+)
diff --git a/plugins/language_R.lua b/plugins/language_R.lua
index 68c3a18..ad3b483 100644
--- a/plugins/language_R.lua
+++ b/plugins/language_R.lua
@@ -2,6 +2,7 @@
local syntax = require "core.syntax"
syntax.add{
+ name = "R",
files = {"%.r$", "%.rds$", "%.rda$", "%.rdata$", "%.R$"},
comment = "#",
patterns = {
diff --git a/plugins/language_angelscript.lua b/plugins/language_angelscript.lua
index d214ea0..e62c1da 100644
--- a/plugins/language_angelscript.lua
+++ b/plugins/language_angelscript.lua
@@ -2,6 +2,7 @@
local syntax = require "core.syntax"
syntax.add {
+ name = "AngelScript",
files = { "%.as$", "%.asc$" },
comment = "//",
patterns = {
diff --git a/plugins/language_batch.lua b/plugins/language_batch.lua
index b01c65d..f9b9c4f 100644
--- a/plugins/language_batch.lua
+++ b/plugins/language_batch.lua
@@ -41,6 +41,7 @@ local function prepare_symbols(symtable)
end
syntax.add {
+ name = "Batch",
files = { "%.bat$", "%.cmd$" },
comment = "rem",
patterns = {
diff --git a/plugins/language_bib.lua b/plugins/language_bib.lua
index 96c80c7..cfde8da 100644
--- a/plugins/language_bib.lua
+++ b/plugins/language_bib.lua
@@ -2,6 +2,7 @@
local syntax = require "core.syntax"
syntax.add {
+ name = "BibTeX",
files = { "%.bib$" },
comment = "%%",
patterns = {
diff --git a/plugins/language_cmake.lua b/plugins/language_cmake.lua
index 34b4d0c..8103632 100644
--- a/plugins/language_cmake.lua
+++ b/plugins/language_cmake.lua
@@ -2,6 +2,7 @@
local syntax = require "core.syntax"
syntax.add {
+ name = "CMake",
files = { "%.cmake$", "CMakeLists.txt$" },
comment = "//",
patterns = {
diff --git a/plugins/language_cpp.lua b/plugins/language_cpp.lua
index f229134..8cd36a4 100644
--- a/plugins/language_cpp.lua
+++ b/plugins/language_cpp.lua
@@ -4,6 +4,7 @@ pcall(require, "plugins.language_c")
local syntax = require "core.syntax"
syntax.add {
+ name = "C++",
files = {
"%.h$", "%.inl$", "%.cpp$", "%.cc$", "%.C$", "%.cxx$",
"%.c++$", "%.hh$", "%.H$", "%.hxx$", "%.hpp$", "%.h++$"
diff --git a/plugins/language_csharp.lua b/plugins/language_csharp.lua
index 6bc6fcd..5e1e81a 100644
--- a/plugins/language_csharp.lua
+++ b/plugins/language_csharp.lua
@@ -2,6 +2,7 @@
local syntax = require "core.syntax"
syntax.add {
+ name = "C#",
files = "%.cs$",
comment = "//",
patterns = {
diff --git a/plugins/language_d.lua b/plugins/language_d.lua
index 641aefa..e59916e 100644
--- a/plugins/language_d.lua
+++ b/plugins/language_d.lua
@@ -2,6 +2,7 @@
local syntax = require "core.syntax"
syntax.add {
+ name = "D",
files = { "%.d$", "%.di$" },
comment = "//",
patterns = {
diff --git a/plugins/language_dart.lua b/plugins/language_dart.lua
index 01bdc97..97aa375 100644
--- a/plugins/language_dart.lua
+++ b/plugins/language_dart.lua
@@ -2,6 +2,7 @@
local syntax = require "core.syntax"
syntax.add {
+ name = "Dart",
files = { "%.dart$" },
comment = "//",
patterns = {
diff --git a/plugins/language_elixir.lua b/plugins/language_elixir.lua
index e4919da..f414bd4 100644
--- a/plugins/language_elixir.lua
+++ b/plugins/language_elixir.lua
@@ -2,6 +2,7 @@
local syntax = require "core.syntax"
syntax.add {
+ name = "Elixir",
files = { "%.ex$", "%.exs$"},
comment = "#",
patterns = {
diff --git a/plugins/language_elm.lua b/plugins/language_elm.lua
index 4038420..65ddc1f 100644
--- a/plugins/language_elm.lua
+++ b/plugins/language_elm.lua
@@ -2,6 +2,7 @@
local syntax = require "core.syntax"
syntax.add {
+ name = "Elm",
files = { "%.elm$" },
comment = "%-%-",
patterns = {
diff --git a/plugins/language_fe.lua b/plugins/language_fe.lua
index c852124..18400ac 100644
--- a/plugins/language_fe.lua
+++ b/plugins/language_fe.lua
@@ -2,6 +2,7 @@
local syntax = require "core.syntax"
syntax.add {
+ name = "fe",
files = "%.fe$",
comment = ";",
patterns = {
diff --git a/plugins/language_fennel.lua b/plugins/language_fennel.lua
index de229f1..d2fa7f0 100644
--- a/plugins/language_fennel.lua
+++ b/plugins/language_fennel.lua
@@ -8,6 +8,7 @@
local syntax = require "core.syntax"
syntax.add {
+ name = "Fennel",
files = "%.fnl$",
comment = ";",
patterns = {
diff --git a/plugins/language_fstab.lua b/plugins/language_fstab.lua
index ad10881..4198516 100644
--- a/plugins/language_fstab.lua
+++ b/plugins/language_fstab.lua
@@ -3,6 +3,7 @@
local syntax = require "core.syntax"
syntax.add {
+ name = "fstab",
files = { "fstab" },
comment = '#',
patterns = {
diff --git a/plugins/language_gdscript.lua b/plugins/language_gdscript.lua
index 5a29b97..168fc44 100644
--- a/plugins/language_gdscript.lua
+++ b/plugins/language_gdscript.lua
@@ -5,6 +5,7 @@
local syntax = require "core.syntax"
syntax.add {
+ name = "GDScript",
files = { "%.gd$" },
comment = "#",
patterns = {
diff --git a/plugins/language_glsl.lua b/plugins/language_glsl.lua
index 36ceb03..f8b2782 100644
--- a/plugins/language_glsl.lua
+++ b/plugins/language_glsl.lua
@@ -6,6 +6,7 @@ local common = require "core.common"
local syntax = require "core.syntax"
syntax.add {
+ name = "GLSL",
files = { "%.glsl$", "%.frag$", "%.vert$", },
comment = "//",
patterns = {
diff --git a/plugins/language_go.lua b/plugins/language_go.lua
index 8c8900e..51dd1ef 100644
--- a/plugins/language_go.lua
+++ b/plugins/language_go.lua
@@ -2,6 +2,7 @@
local syntax = require "core.syntax"
syntax.add {
+ name = "Go",
files = { "%.go$" },
comment = "//",
patterns = {
diff --git a/plugins/language_hlsl.lua b/plugins/language_hlsl.lua
index 0aedab0..696e9b2 100644
--- a/plugins/language_hlsl.lua
+++ b/plugins/language_hlsl.lua
@@ -6,6 +6,7 @@ local common = require "core.common"
local syntax = require "core.syntax"
syntax.add {
+ name = "HLSL",
files = { "%.hlsl$", },
comment = "//",
patterns = {
diff --git a/plugins/language_hs.lua b/plugins/language_hs.lua
index 5530f87..a60ff75 100644
--- a/plugins/language_hs.lua
+++ b/plugins/language_hs.lua
@@ -2,6 +2,7 @@
local syntax = require "core.syntax"
syntax.add {
+ name = "Haskell",
files = { "%.hs$" },
comment = "%-%-",
patterns = {
diff --git a/plugins/language_ini.lua b/plugins/language_ini.lua
index f106a57..706cc80 100644
--- a/plugins/language_ini.lua
+++ b/plugins/language_ini.lua
@@ -3,6 +3,7 @@
local syntax = require "core.syntax"
syntax.add {
+ name = "INI",
files = { "%.ini$", "%.inf$", "%.cfg$", "%.editorconfig$" },
comment = ';',
patterns = {
diff --git a/plugins/language_java.lua b/plugins/language_java.lua
index e6d3735..810ffd2 100644
--- a/plugins/language_java.lua
+++ b/plugins/language_java.lua
@@ -2,6 +2,7 @@
local syntax = require "core.syntax"
syntax.add {
+ name = "Java",
files = { "%.java$" },
comment = "//",
patterns = {
diff --git a/plugins/language_jiyu.lua b/plugins/language_jiyu.lua
index c30cd00..78cc377 100644
--- a/plugins/language_jiyu.lua
+++ b/plugins/language_jiyu.lua
@@ -2,6 +2,7 @@
local syntax = require "core.syntax"
syntax.add {
+ name = "Jiyu",
files = { "%.jiyu$", "%.jyu$" },
comment = "//",
patterns = {
diff --git a/plugins/language_jsx.lua b/plugins/language_jsx.lua
index 328e2db..891f160 100644
--- a/plugins/language_jsx.lua
+++ b/plugins/language_jsx.lua
@@ -3,6 +3,7 @@
local syntax = require "core.syntax"
syntax.add {
+ name = "JSX",
files = { "%.jsx$" },
comment = "//",
patterns = {
diff --git a/plugins/language_julia.lua b/plugins/language_julia.lua
new file mode 100644
index 0000000..e62a9b2
--- /dev/null
+++ b/plugins/language_julia.lua
@@ -0,0 +1,112 @@
+-- mod-version:2 -- lite-xl 2.0
+-- Support for the Julia programming language:
+-- Covers the most used keywords up to Julia version 1.6.4
+
+local syntax = require "core.syntax"
+
+syntax.add {
+ name = "Julia",
+ files = { "%.jl$" },
+ comment = "#",
+ patterns = {
+ {pattern = {"#=", "=#"}, type="comment" },
+ {pattern = "#.*$", type="comment" },
+ { pattern = { 'icxx"""', '"""' }, type = "string", syntax = ".cpp" },
+ { pattern = { 'cxx"""', '"""' }, type = "string", syntax = ".cpp" },
+ { pattern = { 'py"""', '"""' }, type = "string", syntax = ".py" },
+ { pattern = { 'js"""', '"""' }, type = "string", syntax = ".js" },
+ { pattern = { 'md"""', '"""' }, type = "string", syntax = ".md" },
+ { pattern = "%d%w*[%.-+*//]", type = "number" },
+ { pattern = "0[oO_][0-7]+", type = "number" },
+ { pattern = "-?0x[%x_]+", type = "number" },
+ { pattern = "-?0b[%x_]+", type = "number" },
+ { pattern = "-?%d+_%d", type = "number" },
+ { pattern = "-?%d+[%d%.eE]*f?", type = "number" },
+ { pattern = "-?%.?%d+f?", type = "number" },
+ { pattern = "[^%d%g]%:%a*", type = "function" },
+ { pattern = "[%+%-=/%*%^%%<>!~|&%:]",type = "operator"},
+ { pattern = '""".*"""', type = "string" },
+ { pattern = '".*"', type = "string" },
+ { pattern = '[bv]".*"', type = "string" },
+ { pattern = 'r".*$', type = "string" },
+ { pattern = "'\\.*'", type = "string" },
+ { pattern = "'.'", type = "string" },
+ { pattern = "[%a_][%w_]*%f[(]", type = "function" },
+ { pattern = "%g*!", type="function"},
+ { pattern = "[%a_][%w_]*", type = "symbol" },
+ },
+ symbols = {
+ -- keywords
+ ["baremodule"] = "keyword",
+ ["begin"] = "keyword",
+ ["break"] = "keyword",
+ ["catch"] = "keyword",
+ ["const"] = "keyword",
+ ["continue"] = "keyword",
+ ["do"] = "keyword",
+ ["Dict"] = "keyword",
+ ["Set"] = "keyword",
+ ["Union"] = "keyword",
+ ["else"] = "keyword",
+ ["elseif"] = "keyword",
+ ["end"] = "keyword",
+ ["export"] = "keyword",
+ ["finally"] = "keyword",
+ ["for"] = "keyword",
+ ["function"] = "keyword",
+ ["global"] = "keyword",
+ ["if"] = "keyword",
+ ["in"] = "keyword",
+ ["import"] = "keyword",
+ ["let"] = "keyword",
+ ["local"] = "keyword",
+ ["macro"] = "keyword",
+ ["type"] = "keyword",
+ ["module"] = "keyword",
+ ["mutable"] = "keyword",
+ ["quote"] = "keyword",
+ ["return"] = "keyword",
+ ["try"] = "keyword",
+ ["typeof"] = "keyword",
+ ["using"] = "keyword",
+ ["while"] = "keyword",
+ ["where"] = "keyword",
+
+ -- types
+ ["struct"] = "keyword2",
+ ["abstract"] = "keyword2",
+ ["primitive"] = "keyword2",
+ ["mutable"] = "keyword2",
+ ["Char"] = "keyword2",
+ ["Bool"] = "keyword2",
+ ["Int"] = "keyword2",
+ ["Integer"] = "keyword2",
+ ["Int8"] = "keyword2",
+ ["UInt8"] = "keyword2",
+ ["Int16"] = "keyword2",
+ ["UInt16"] = "keyword2",
+ ["Int32"] = "keyword2",
+ ["UInt32"] = "keyword2",
+ ["Int64"] = "keyword2",
+ ["UInt64"] = "keyword2",
+ ["Int128"] = "keyword2",
+ ["UInt128"] = "keyword2",
+ ["Float16"] = "keyword2",
+ ["Float32"] = "keyword2",
+ ["Float64"] = "keyword2",
+ ["Vector"] = "keyword2",
+ ["Matrix"] = "keyword2",
+ ["Ref"] = "keyword2",
+ ["String"] = "keyword2",
+ ["Function"] = "keyword2",
+ ["Number"] = "keyword2",
+
+ -- literals
+ ["missing"] = "literal",
+ ["true"] = "literal",
+ ["false"] = "literal",
+ ["nothing"] = "literal",
+ ["Inf"] = "literal",
+ ["NaN"] = "literal",
+ }
+}
diff --git a/plugins/language_liquid.lua b/plugins/language_liquid.lua
index ffb2c96..58688c8 100644
--- a/plugins/language_liquid.lua
+++ b/plugins/language_liquid.lua
@@ -97,6 +97,7 @@ local liquid_syntax = {
}
syntax.add {
+ name = "Liquid",
files = { "%.liquid?$" },
patterns = {
{ pattern = { "{%%", "%%}" }, syntax = liquid_syntax, type = "function" },
diff --git a/plugins/language_lobster.lua b/plugins/language_lobster.lua
index 593c89d..b6ab143 100644
--- a/plugins/language_lobster.lua
+++ b/plugins/language_lobster.lua
@@ -2,6 +2,7 @@
local syntax = require "core.syntax"
syntax.add {
+ name = "Lobster",
files = "%.lobster$",
comment = "//",
patterns = {
diff --git a/plugins/language_make.lua b/plugins/language_make.lua
index cedf512..687b827 100644
--- a/plugins/language_make.lua
+++ b/plugins/language_make.lua
@@ -2,6 +2,7 @@
local syntax = require "core.syntax"
syntax.add {
+ name = "Makefile",
files = { "Makefile", "makefile", "%.mk$" },
comment = "#",
patterns = {
diff --git a/plugins/language_meson.lua b/plugins/language_meson.lua
index 02763a7..f5c55d7 100644
--- a/plugins/language_meson.lua
+++ b/plugins/language_meson.lua
@@ -2,6 +2,7 @@
local syntax = require "core.syntax"
syntax.add {
+ name = "Meson",
files = "meson.build$",
comment = "#",
patterns = {
diff --git a/plugins/language_moon.lua b/plugins/language_moon.lua
index 6b5f9d2..59eea37 100644
--- a/plugins/language_moon.lua
+++ b/plugins/language_moon.lua
@@ -2,6 +2,7 @@
local syntax = require "core.syntax"
syntax.add {
+ name = "MoonScript",
files = "%.moon$",
headers = "^#!.*[ /]moon",
comment = "--",
diff --git a/plugins/language_nginx.lua b/plugins/language_nginx.lua
index f455edf..73cf979 100644
--- a/plugins/language_nginx.lua
+++ b/plugins/language_nginx.lua
@@ -4,6 +4,7 @@ local syntax = require "core.syntax"
-- Copied from https://github.com/shanoor/vscode-nginx/blob/master/syntaxes/nginx.tmLanguage
syntax.add {
+ name = "Nginx",
files = { "%.conf$" },
comment = "#",
patterns = {
diff --git a/plugins/language_nim.lua b/plugins/language_nim.lua
index c9f3355..5f00365 100644
--- a/plugins/language_nim.lua
+++ b/plugins/language_nim.lua
@@ -112,6 +112,7 @@ for _, pattern in ipairs(user_patterns) do
end
local nim = {
+ name = "Nim",
files = { "%.nim$", "%.nims$", "%.nimble$" },
comment = "#",
patterns = patterns,
diff --git a/plugins/language_objc.lua b/plugins/language_objc.lua
index c0ef95e..e0945d2 100644
--- a/plugins/language_objc.lua
+++ b/plugins/language_objc.lua
@@ -2,6 +2,7 @@
local syntax = require "core.syntax"
syntax.add {
+ name = "Objective-C",
files = { "%.m$" },
comment = "//",
patterns = {
diff --git a/plugins/language_odin.lua b/plugins/language_odin.lua
index 29d9868..ff75700 100644
--- a/plugins/language_odin.lua
+++ b/plugins/language_odin.lua
@@ -2,6 +2,7 @@
local syntax = require "core.syntax"
syntax.add {
+ name = "Odin",
files = "%.odin$",
comment = "//",
patterns = {
diff --git a/plugins/language_perl.lua b/plugins/language_perl.lua
index cf60849..1938b1b 100644
--- a/plugins/language_perl.lua
+++ b/plugins/language_perl.lua
@@ -2,6 +2,7 @@
local syntax = require "core.syntax"
syntax.add {
+ name = "Perl",
files = { "%.pm$", "%.pl$" },
headers = "^#!.*[ /]perl",
comment = "#",
diff --git a/plugins/language_php.lua b/plugins/language_php.lua
index 5ee6a93..610d77d 100644
--- a/plugins/language_php.lua
+++ b/plugins/language_php.lua
@@ -12,6 +12,7 @@ require "plugins.language_js"
-- define the core php syntax coloring
syntax.add {
+ name = "PHP",
files = { "%.phps$" },
headers = "^<%?php",
comment = "//",
diff --git a/plugins/language_pico8.lua b/plugins/language_pico8.lua
index b8b790e..40c9772 100644
--- a/plugins/language_pico8.lua
+++ b/plugins/language_pico8.lua
@@ -2,6 +2,7 @@
local syntax = require "core.syntax"
syntax.add {
+ name = "PICO-8",
files = "%.p8$",
headers = "^pico-8 cartridge",
comment = "--",
diff --git a/plugins/language_po.lua b/plugins/language_po.lua
index 54783ea..db060b1 100644
--- a/plugins/language_po.lua
+++ b/plugins/language_po.lua
@@ -2,6 +2,7 @@
local syntax = require "core.syntax"
syntax.add {
+ name = "PO",
files = { "%.po$", "%.pot$" },
comment = "#",
patterns = {
diff --git a/plugins/language_powershell.lua b/plugins/language_powershell.lua
index 022170d..63de2f3 100644
--- a/plugins/language_powershell.lua
+++ b/plugins/language_powershell.lua
@@ -1,73 +1,74 @@
-- mod-version:2 -- lite-xl 2.0
-local syntax = require "core.syntax"
-
-syntax.add {
- files = {"%.ps1$", "%.psm1$", "%.psd1$", "%.ps1xml$", "%.pssc$", "%.psrc$", "%.cdxml$"},
- comment = "#",
- patterns = {
- {pattern = "#.*\n", type = "comment"},
- {pattern = [[\.]], type = "normal"},
- {pattern = {'"', '"'}, type = "string"},
- {pattern = {"'", "'"}, type = "string"},
- {pattern = "%f[%w_][%d%.]+%f[^%w_]", type = "number"},
- {pattern = "[%+=/%*%^%%<>!~|&,:]+", type = "operator"},
- {pattern = "%f[%S]%-[%w%-_]+", type = "function"},
- {pattern = "[%u][%a]+[%-][%u][%a]+", type = "function"},
- {pattern = "${.*}", type = "symbol"},
- {pattern = "$[%a_@*][%w_]*", type = "keyword2"},
- {pattern = "$[%$][%a]+", type = "keyword2"},
- {pattern = "[%a_][%w_]*", type = "symbol"}
- },
- symbols = {
- ["if"] = "keyword",
- ["else"] = "keyword",
- ["elseif"] = "keyword",
- ["switch"] = "keyword",
- ["default"] = "keyword",
- ["function"] = "keyword",
- ["filter"] = "keyword",
- ["workflow"] = "keyword",
- ["configuration"] = "keyword",
- ["class"] = "keyword",
- ["enum"] = "keyword",
- ["Parameter"] = "keyword",
- ["ValidateScript"] = "keyword",
- ["CmdletBinding"] = "keyword",
- ["try"] = "keyword",
- ["catch"] = "keyword",
- ["finally"] = "keyword",
- ["throw"] = "keyword",
- ["while"] = "keyword",
- ["for"] = "keyword",
- ["do"] = "keyword",
- ["until"] = "keyword",
- ["break"] = "keyword",
- ["continue"] = "keyword",
- ["foreach"] = "keyword",
- ["in"] = "keyword",
- ["return"] = "keyword",
- ["where"] = "function",
- ["select"] = "function",
- ["filter"] = "keyword",
- ["in"] = "keyword",
- ["trap"] = "keyword",
- ["param"] = "keyword",
- ["data"] = "keyword",
- ["dynamicparam"] = "keyword",
- ["begin"] = "function",
- ["process"] = "function",
- ["end"] = "function",
- ["exit"] = "function",
- ["inlinescript"] = "function",
- ["parallel"] = "function",
- ["sequence"] = "function",
- ["true"] = "literal",
- ["false"] = "literal",
- ["TODO"] = "comment",
- ["FIXME"] = "comment",
- ["XXX"] = "comment",
- ["TBD"] = "comment",
- ["HACK"] = "comment",
- ["NOTE"] = "comment"
- }
-}
+local syntax = require "core.syntax"
+
+syntax.add {
+ name = "PowerShell",
+ files = {"%.ps1$", "%.psm1$", "%.psd1$", "%.ps1xml$", "%.pssc$", "%.psrc$", "%.cdxml$"},
+ comment = "#",
+ patterns = {
+ {pattern = "#.*\n", type = "comment"},
+ {pattern = [[\.]], type = "normal"},
+ {pattern = {'"', '"'}, type = "string"},
+ {pattern = {"'", "'"}, type = "string"},
+ {pattern = "%f[%w_][%d%.]+%f[^%w_]", type = "number"},
+ {pattern = "[%+=/%*%^%%<>!~|&,:]+", type = "operator"},
+ {pattern = "%f[%S]%-[%w%-_]+", type = "function"},
+ {pattern = "[%u][%a]+[%-][%u][%a]+", type = "function"},
+ {pattern = "${.*}", type = "symbol"},
+ {pattern = "$[%a_@*][%w_]*", type = "keyword2"},
+ {pattern = "$[%$][%a]+", type = "keyword2"},
+ {pattern = "[%a_][%w_]*", type = "symbol"}
+ },
+ symbols = {
+ ["if"] = "keyword",
+ ["else"] = "keyword",
+ ["elseif"] = "keyword",
+ ["switch"] = "keyword",
+ ["default"] = "keyword",
+ ["function"] = "keyword",
+ ["filter"] = "keyword",
+ ["workflow"] = "keyword",
+ ["configuration"] = "keyword",
+ ["class"] = "keyword",
+ ["enum"] = "keyword",
+ ["Parameter"] = "keyword",
+ ["ValidateScript"] = "keyword",
+ ["CmdletBinding"] = "keyword",
+ ["try"] = "keyword",
+ ["catch"] = "keyword",
+ ["finally"] = "keyword",
+ ["throw"] = "keyword",
+ ["while"] = "keyword",
+ ["for"] = "keyword",
+ ["do"] = "keyword",
+ ["until"] = "keyword",
+ ["break"] = "keyword",
+ ["continue"] = "keyword",
+ ["foreach"] = "keyword",
+ ["in"] = "keyword",
+ ["return"] = "keyword",
+ ["where"] = "function",
+ ["select"] = "function",
+ ["filter"] = "keyword",
+ ["in"] = "keyword",
+ ["trap"] = "keyword",
+ ["param"] = "keyword",
+ ["data"] = "keyword",
+ ["dynamicparam"] = "keyword",
+ ["begin"] = "function",
+ ["process"] = "function",
+ ["end"] = "function",
+ ["exit"] = "function",
+ ["inlinescript"] = "function",
+ ["parallel"] = "function",
+ ["sequence"] = "function",
+ ["true"] = "literal",
+ ["false"] = "literal",
+ ["TODO"] = "comment",
+ ["FIXME"] = "comment",
+ ["XXX"] = "comment",
+ ["TBD"] = "comment",
+ ["HACK"] = "comment",
+ ["NOTE"] = "comment"
+ }
+}
diff --git a/plugins/language_psql.lua b/plugins/language_psql.lua
index 09db99b..80bc4cd 100644
--- a/plugins/language_psql.lua
+++ b/plugins/language_psql.lua
@@ -74,6 +74,7 @@ for _, literal in ipairs(literals) do
end
syntax.add {
+ name = "PostgreSQL",
files = { "%.sql$", "%.psql$" },
comment = "--",
patterns = {
diff --git a/plugins/language_rescript.lua b/plugins/language_rescript.lua
index 94dc964..9007dc1 100644
--- a/plugins/language_rescript.lua
+++ b/plugins/language_rescript.lua
@@ -2,6 +2,7 @@
local syntax = require "core.syntax"
syntax.add {
+ name = "ReScript",
files = { "%.res$" },
comment = "//",
patterns = {
diff --git a/plugins/language_ruby.lua b/plugins/language_ruby.lua
index 8b9bf33..3651fb5 100644
--- a/plugins/language_ruby.lua
+++ b/plugins/language_ruby.lua
@@ -2,6 +2,7 @@
local syntax = require "core.syntax"
syntax.add {
+ name = "Ruby",
files = { "%.rb", "%.gemspec" },
headers = "^#!.*[ /]ruby",
comment = "#",
diff --git a/plugins/language_rust.lua b/plugins/language_rust.lua
index ac25305..a8dc017 100644
--- a/plugins/language_rust.lua
+++ b/plugins/language_rust.lua
@@ -2,6 +2,7 @@
local syntax = require "core.syntax"
syntax.add {
+ name = "Rust",
files = { "%.rs$" },
comment = "//",
patterns = {
@@ -15,6 +16,7 @@ syntax.add {
{ pattern = "-?%d+[%d%.eE]*f?", type = "number" },
{ pattern = "-?%.?%d+f?", type = "number" },
{ pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" },
+ { pattern = "[%a_][%w_]*!%f[%[(]", type = "function" },
{ pattern = "[%a_][%w_]*%f[(]", type = "function" },
{ pattern = "[%a_][%w_]*", type = "symbol" },
},
diff --git a/plugins/language_sass.lua b/plugins/language_sass.lua
index aa11637..723d975 100644
--- a/plugins/language_sass.lua
+++ b/plugins/language_sass.lua
@@ -2,6 +2,7 @@
local syntax = require "core.syntax"
syntax.add {
+ name = "Sass",
files = { "%.sass$" ,"%.scss$"},
comment = "//",
patterns = {
diff --git a/plugins/language_scala.lua b/plugins/language_scala.lua
new file mode 100644
index 0000000..fddadc7
--- /dev/null
+++ b/plugins/language_scala.lua
@@ -0,0 +1,80 @@
+-- mod-version:2 -- lite-xl 2.0
+local syntax = require "core.syntax"
+
+syntax.add {
+ name = "Scala",
+ files = { "%.sc$", "%.scala$" },
+ comment = "//",
+ patterns = {
+ { pattern = "//.-\n", type = "comment" },
+ { pattern = { "/%*", "%*/" }, type = "comment" },
+ { pattern = { '[ruU]?"', '"', '\\' }, type = "string" },
+ { pattern = { "[ruU]?'", "'", '\\' }, type = "string" },
+ { pattern = "0x[%da-fA-F]+", type = "number" },
+ { pattern = "-?%d+[%d%.eE]*", type = "number" },
+ { pattern = "-?%.?%d+", type = "number" },
+ { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" },
+ { pattern = '[%a_][%w_]*"""*[%a_][%w_]*"""', type = "string" },
+ { pattern = "[%a_][%w_]*%f[(]", type = "function" },
+ { pattern = "[%a_][%w_]*", type = "symbol" },
+ },
+ symbols = {
+ ["abstract"] = "keyword",
+ ["case"] = "keyword",
+ ["catch"] = "keyword",
+ ["class"] = "keyword",
+ ["finally"] = "keyword",
+ ["final"] = "keyword",
+ ["do"] = "keyword",
+ ["extends"] = "keyword",
+ ["forSome"] = "keyword",
+ ["implicit"] = "keyword",
+ ["lazy"] = "keyword",
+ ["match"] = "keyword",
+ ["new"] = "keyword",
+ ["override"] = "keyword",
+ ["package"] = "keyword",
+ ["throw"] = "keyword",
+ ["trait"] = "keyword",
+ ["type"] = "keyword",
+ ["var"] = "keyword",
+ ["val"] = "keyword",
+ ["println"] = "keyword",
+ ["return"] = "keyword",
+ ["for"] = "keyword",
+ ["Try"] = "keyword",
+ ["def"] = "keyword",
+ ["while"] = "keyword",
+ ["with"] = "keyword",
+ ["if"] = "keyword",
+ ["else"] = "keyword",
+ ["import"] = "keyword",
+ ["object"] = "keyword",
+ ["yield"] = "keyword",
+
+ ["private"] = "keyword2",
+ ["protected"] = "keyword2",
+ ["sealed"] = "keyword2",
+ ["super"] = "keyword2",
+ ["this"] = "keyword2",
+ ["Byte"] = "keyword2",
+ ["Short"] = "keyword2",
+ ["Int"] = "keyword2",
+ ["Long"] = "keyword2",
+ ["Float"] = "keyword2",
+ ["Double"] = "keyword2",
+ ["Char"] = "keyword2",
+ ["String"] = "keyword2",
+ ["List"] = "keyword2",
+ ["Array"] = "keyword2",
+ ["Boolean"] = "keyword2",
+
+ ["Null"] = "literal",
+ ["Any"] = "literal",
+ ["AnyRef"] = "literal",
+ ["Nothing"] = "literal",
+ ["Unit"] = "literal",
+ ["true"] = "literal",
+ ["false"] = "literal",
+ }
+}
diff --git a/plugins/language_sh.lua b/plugins/language_sh.lua
index a44b212..f3e604f 100644
--- a/plugins/language_sh.lua
+++ b/plugins/language_sh.lua
@@ -2,6 +2,7 @@
local syntax = require "core.syntax"
syntax.add {
+ name = "Shell script",
files = { "%.sh$" },
headers = "^#!.*bin.*sh\n",
comment = "#",
diff --git a/plugins/language_ssh_config.lua b/plugins/language_ssh_config.lua
index 666f3f3..c105082 100644
--- a/plugins/language_ssh_config.lua
+++ b/plugins/language_ssh_config.lua
@@ -2,6 +2,7 @@
local syntax = require "core.syntax"
syntax.add {
+ name = "SSH config",
files = { "sshd?/?_?config$" },
comment = '#',
patterns = {
diff --git a/plugins/language_tcl.lua b/plugins/language_tcl.lua
index a934777..1fb672e 100644
--- a/plugins/language_tcl.lua
+++ b/plugins/language_tcl.lua
@@ -2,6 +2,7 @@
local syntax = require "core.syntax"
syntax.add {
+ name = "Tcl",
files = { "%.tcl$" },
comment = "#",
patterns = {
diff --git a/plugins/language_teal.lua b/plugins/language_teal.lua
index f64c419..a974fdd 100644
--- a/plugins/language_teal.lua
+++ b/plugins/language_teal.lua
@@ -2,6 +2,7 @@
local syntax = require "core.syntax"
syntax.add {
+ name = "Teal",
files = {"%.tl$","%.d.tl$"},
comment = "--",
patterns = {
diff --git a/plugins/language_tex.lua b/plugins/language_tex.lua
index 9878505..858c811 100644
--- a/plugins/language_tex.lua
+++ b/plugins/language_tex.lua
@@ -2,6 +2,7 @@
local syntax = require "core.syntax"
syntax.add {
+ name = "TeX",
files = { "%.tex$" },
comment = "%%",
patterns = {
diff --git a/plugins/language_toml.lua b/plugins/language_toml.lua
index 3774dfb..2b7fd01 100644
--- a/plugins/language_toml.lua
+++ b/plugins/language_toml.lua
@@ -3,6 +3,7 @@
local syntax = require "core.syntax"
syntax.add {
+ name = "TOML",
files = { "%.toml$" },
comment = '#',
patterns = {
diff --git a/plugins/language_ts.lua b/plugins/language_ts.lua
index 1b322ed..13c6ac2 100644
--- a/plugins/language_ts.lua
+++ b/plugins/language_ts.lua
@@ -3,6 +3,7 @@
local syntax = require "core.syntax"
syntax.add {
+ name = "TypeScript",
files = { "%.ts$" },
comment = "//",
patterns = {
diff --git a/plugins/language_tsx.lua b/plugins/language_tsx.lua
index 63eef55..473f808 100644
--- a/plugins/language_tsx.lua
+++ b/plugins/language_tsx.lua
@@ -3,6 +3,7 @@
local syntax = require "core.syntax"
syntax.add {
+ name = "TypeScript with JSX",
files = { "%.tsx$" },
comment = "//",
patterns = {
diff --git a/plugins/language_v.lua b/plugins/language_v.lua
index 0c1c64a..51d3a76 100644
--- a/plugins/language_v.lua
+++ b/plugins/language_v.lua
@@ -2,6 +2,7 @@
local syntax = require "core.syntax"
syntax.add {
+ name = "V",
files = "%.v$", "%.vsh$",
headers = "^#!.*[ /]v\n",
comment = "//",
diff --git a/plugins/language_wren.lua b/plugins/language_wren.lua
index c4a6905..9bd6c82 100644
--- a/plugins/language_wren.lua
+++ b/plugins/language_wren.lua
@@ -2,6 +2,7 @@
local syntax = require "core.syntax"
syntax.add {
+ name = "Wren",
files = { "%.wren$" },
comment = "//",
patterns = {
@@ -41,4 +42,4 @@ syntax.add {
["false"] = "literal",
["null"] = "literal",
},
-} \ No newline at end of file
+}
diff --git a/plugins/language_yaml.lua b/plugins/language_yaml.lua
index c86f733..a83e89f 100644
--- a/plugins/language_yaml.lua
+++ b/plugins/language_yaml.lua
@@ -2,6 +2,7 @@
local syntax = require "core.syntax"
syntax.add {
+ name = "YAML",
files = { "%.yml$", "%.yaml$" },
comment = "#",
patterns = {
diff --git a/plugins/language_zig.lua b/plugins/language_zig.lua
index 4629e89..192b114 100644
--- a/plugins/language_zig.lua
+++ b/plugins/language_zig.lua
@@ -2,6 +2,7 @@
local syntax = require "core.syntax"
syntax.add {
+ name = "Zig",
files = { "%.zig$" },
comment = "//",
patterns = {
diff --git a/plugins/minimap.lua b/plugins/minimap.lua
index 3f4a2a2..2c383b8 100644
--- a/plugins/minimap.lua
+++ b/plugins/minimap.lua
@@ -4,6 +4,7 @@ local common = require "core.common"
local config = require "core.config"
local style = require "core.style"
local DocView = require "core.docview"
+local Object = require "core.object"
-- General plugin settings
config.plugins.minimap = {
@@ -14,7 +15,29 @@ config.plugins.minimap = {
scale = 1,
-- how many spaces one tab is equivalent to
tab_width = 4,
- draw_background = true
+ draw_background = true,
+
+ -- you can override these colors
+ selection_color = nil,
+ caret_color = nil,
+
+ -- If other plugins provide per-line highlights,
+ -- this controls the placement. (e.g. gitdiff_highlight)
+ highlight_align = 'left',
+ highlight_width = 3,
+ gutter_width = 5,
+ -- try these values:
+ -- full width:
+ -- config.plugins.minimap.highlight_width = 100
+ -- config.plugins.minimap.gutter_width = 0
+ -- left side:
+ -- config.plugins.minimap.highlight_align = 'left'
+ -- config.plugins.minimap.highlight_width = 3
+ -- config.plugins.minimap.gutter_width = 4
+ -- right side:
+ -- config.plugins.minimap.highlight_align = 'right'
+ -- config.plugins.minimap.highlight_width = 5
+ -- config.plugins.minimap.gutter_width = 0
}
-- Configure size for rendering each char in the minimap
@@ -22,6 +45,17 @@ 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
+local MiniMap = Object:extend()
+
+function MiniMap:new()
+end
+
+function MiniMap:line_highlight_color(line_index)
+ -- other plugins can override this, and return a color
+end
+
+local minimap = MiniMap()
+
-- 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)
@@ -101,7 +135,6 @@ DocView.on_mouse_pressed = function(self, button, x, y, clicks)
-- 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
@@ -196,6 +229,21 @@ DocView.draw_scrollbar = function(self)
-- draw visual rect
renderer.draw_rect(x, visible_y, w, scroller_height, visual_color)
+ -- highlight the selected lines, and the line with the caret on it
+ local selection_color = config.plugins.minimap.selection_color or style.dim
+ local caret_color = config.plugins.minimap.caret_color or style.caret
+ local selection_line, selection_col, selection_line2, selection_col2 = self.doc:get_selection()
+ local selection_y = y + (selection_line - minimap_start_line) * line_spacing
+ local selection2_y = y + (selection_line2 - minimap_start_line) * line_spacing
+ local selection_min_y = math.min(selection_y, selection2_y)
+ local selection_h = math.abs(selection2_y - selection_y)+1
+ renderer.draw_rect(x, selection_min_y, w, selection_h, selection_color)
+ renderer.draw_rect(x, selection_y, w, line_spacing, caret_color)
+
+ local highlight_align = config.plugins.minimap.highlight_align
+ local highlight_width = config.plugins.minimap.highlight_width
+ local gutter_width = config.plugins.minimap.gutter_width
+
-- time to draw the actual code, setup some local vars that are used in both highlighted and plain renderind.
local line_y = y
@@ -225,6 +273,19 @@ DocView.draw_scrollbar = function(self)
batch_width = 0
end
+ local highlight_x
+ if highlight_align == 'left' then
+ highlight_x = x
+ else
+ highlight_x = x + w - highlight_width
+ end
+ local function render_highlight(idx, line_y)
+ local highlight_color = minimap:line_highlight_color(idx)
+ if highlight_color then
+ renderer.draw_rect(highlight_x, line_y, highlight_width, line_spacing, highlight_color)
+ end
+ end
+
-- render lines with syntax highlighting
if config.plugins.minimap.syntax_highlight then
@@ -236,9 +297,11 @@ DocView.draw_scrollbar = function(self)
endidx = math.min(endidx, line_count)
for idx = minimap_start_line, endidx do
batch_syntax_type = nil
- batch_start = x
+ batch_start = x + gutter_width
batch_width = 0
+ render_highlight(idx, line_y)
+
-- per token
for _, type, text in self.doc.highlighter:each_token(idx) do
-- flush prev batch
@@ -268,9 +331,11 @@ DocView.draw_scrollbar = function(self)
else -- render lines without syntax highlighting
for idx = 1, line_count - 1 do
- batch_start = x
+ batch_start = x + gutter_width
batch_width = 0
+ render_highlight(idx, line_y)
+
for char in common.utf8_chars(self.doc.lines[idx]) do
if char == " " or char == "\n" then
flush_batch()
@@ -304,3 +369,6 @@ command.add(nil, {
config.plugins.minimap.syntax_highlight = not config.plugins.minimap.syntax_highlight
end
})
+
+return minimap
+
diff --git a/plugins/opacity.lua b/plugins/opacity.lua
new file mode 100644
index 0000000..8dd0d9a
--- /dev/null
+++ b/plugins/opacity.lua
@@ -0,0 +1,62 @@
+-- mod-version:2 -- lite-xl 2.0
+local common = require "core.common"
+local command = require "core.command"
+local keymap = require "core.keymap"
+local RootView = require "core.rootview"
+
+local opacity_on = true
+local use_mousewheel = true
+local opacity_steps = 0.05
+local default_opacity = 1
+local current_opacity = default_opacity
+
+local function set_opacity(opacity)
+ if not opacity_on then opacity_on = true end
+ current_opacity = common.clamp(opacity, 0.2, 1)
+ system.set_window_opacity(current_opacity)
+end
+
+local on_mouse_wheel = RootView.on_mouse_wheel
+
+function RootView:on_mouse_wheel(d, ...)
+ if keymap.modkeys["shift"] and use_mousewheel then
+ if d < 0 then command.perform "opacity:decrease" end
+ if d > 0 then command.perform "opacity:increase" end
+ else
+ return on_mouse_wheel(self, d, ...)
+ end
+end
+
+local function tog_opacity()
+ opacity_on = not opacity_on
+ if opacity_on then
+ system.set_window_opacity(current_opacity)
+ else
+ system.set_window_opacity(default_opacity)
+ end
+end
+
+local function res_opacity()
+ set_opacity(default_opacity)
+end
+
+local function inc_opacity()
+ set_opacity(current_opacity + opacity_steps)
+end
+
+local function dec_opacity()
+ set_opacity(current_opacity - opacity_steps)
+end
+
+command.add(nil, {
+ ["opacity:toggle" ] = function() tog_opacity() end,
+ ["opacity:reset" ] = function() res_opacity() end,
+ ["opacity:decrease"] = function() dec_opacity() end,
+ ["opacity:increase"] = function() inc_opacity() end,
+ ["opacity:toggle mouse wheel use"] = function() use_mousewheel = not use_mousewheel end,
+})
+
+keymap.add {
+ ["shift+f11"] = "opacity:toggle",
+ ["ctrl+f11"] = "opacity:toggle mouse wheel use",
+}
diff --git a/plugins/open_ext.lua b/plugins/open_ext.lua
index 0c7eff1..8a98516 100644
--- a/plugins/open_ext.lua
+++ b/plugins/open_ext.lua
@@ -143,7 +143,7 @@ local function validate_doc(doc)
if not f then return true end
local str = f:read(128 * 4) -- max bytes for 128 codepoints
f:close()
- return validate_utf8(str, 128)
+ return validate_utf8(str or "", 128)
end
diff --git a/plugins/openselected.lua b/plugins/openselected.lua
index a1e21a2..af00194 100644
--- a/plugins/openselected.lua
+++ b/plugins/openselected.lua
@@ -2,6 +2,17 @@
local core = require "core"
local command = require "core.command"
local keymap = require "core.keymap"
+local config = require "core.config"
+
+
+config.plugins.openselected = {}
+if PLATFORM == "Windows" then
+ config.plugins.openselected.filemanager = "start"
+elseif PLATFORM == "Mac OS X" then
+ config.plugins.openselected.filemanager = "open"
+else
+ config.plugins.openselected.filemanager = "xdg-open"
+end
command.add("core.docview", {
@@ -13,15 +24,21 @@ command.add("core.docview", {
end
local text = doc:get_text(doc:get_selection())
- core.log("Opening \"%s\"...", text)
- if PLATFORM == "Windows" then
- system.exec("start " .. text)
- else
- system.exec(string.format("xdg-open %q", text))
+ -- trim whitespace from the ends
+ text = text:match( "^%s*(.-)%s*$" )
+
+ -- non-Windows platforms need the text quoted (%q)
+ if PLATFORM ~= "Windows" then
+ text = string.format("%q", text)
end
+
+ core.log("Opening %s...", text)
+
+ system.exec(config.plugins.openselected.filemanager .. " " .. text)
end,
})
keymap.add { ["ctrl+shift+o"] = "open-selected:open-selected" }
+
diff --git a/plugins/smoothcaret.lua b/plugins/smoothcaret.lua
new file mode 100644
index 0000000..26f7d98
--- /dev/null
+++ b/plugins/smoothcaret.lua
@@ -0,0 +1,26 @@
+-- mod-version:2 -- lite-xl 2.0
+local config = require "core.config"
+local style = require "core.style"
+local DocView = require "core.docview"
+
+config.plugins.smoothcaret = { rate = 0.65 }
+
+local docview_update = DocView.update
+function DocView:update()
+ docview_update(self)
+
+ if not self.caret then
+ self.caret = { current = { x = 0, y = 0 }, target = { x = 0, y = 0 } }
+ end
+ local c = self.caret
+ self:move_towards(c.current, "x", c.target.x, config.plugins.smoothcaret.rate)
+ self:move_towards(c.current, "y", c.target.y, config.plugins.smoothcaret.rate)
+end
+
+function DocView:draw_caret(x, y)
+ local c = self.caret
+ local lh = self:get_line_height()
+ c.target.x = x
+ c.target.y = y
+ renderer.draw_rect(c.current.x, c.current.y, style.caret_width, lh, style.caret)
+end