aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md3
-rw-r--r--plugins/gitstatus.lua74
-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.lua86
-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.lua58
-rw-r--r--plugins/open_ext.lua2
-rw-r--r--plugins/openselected.lua27
-rw-r--r--plugins/smoothcaret.lua26
62 files changed, 466 insertions, 91 deletions
diff --git a/README.md b/README.md
index dbb71f2..971f8e6 100644
--- a/README.md
+++ b/README.md
@@ -69,6 +69,7 @@ Plugin | Description
[`language_java`](plugins/language_java.lua?raw=1) | Syntax for the [Java](https://en.wikipedia.org/wiki/Java_(programming_language)) programming language
[`language_jiyu`](plugins/language_jiyu.lua?raw=1) | Syntax for the [jiyu](https://github.com/machinamentum/jiyu) programming language
[`language_jsx`](plugins/language_jsx.lua?raw=1) | Syntax for the [JSX](https://reactjs.org/docs/introducing-jsx.html) language for the React framework in JavaScript
+[`language_julia`](plugins/language_julia.lua?raw=1) | Syntax for the [Julia](https://julialang.org/) programming language
[`language_ksy`](https://raw.githubusercontent.com/whiteh0le/lite-plugins/main/plugins/language_ksy.lua?raw=1) | Syntax for [Kaitai](http://kaitai.io/) struct files
[`language_liquid`](plugins/language_liquid.lua?raw=1) | Syntax for [Liquid](https://shopify.github.io/liquid/) templating language
[`language_lobster`](plugins/language_lobster.lua?raw=1) | Syntax for [Lobster](https://strlen.com/lobster/) programming language
@@ -91,6 +92,7 @@ Plugin | Description
[`language_rust`](plugins/language_rust.lua?raw=1) | Syntax for the [Rust](https://rust-lang.org/) programming language
[`language_ruby`](plugins/language_ruby.lua?raw=1) | Syntax for the [Ruby](https://www.ruby-lang.org/) programming language
[`language sass`](plugins/language_sass.lua?raw=1) | Syntax for the [Sass](https://sass-lang.com/) CSS preprocessor
+[`language scala`](plugins/language_scala.lua?raw=1) | Syntax for the [Scala](https://scala-lang.org/) programming language
[`language_sh`](plugins/language_sh.lua?raw=1) | Syntax for shell scripting language
[`language_ssh_config`](plugins/language_ssh_config.lua?raw=1) | Syntax for ssh & sshd config files
[`language_tcl`](plugins/language_tcl.lua?raw=1) | Syntax for the [Tcl](https://www.tcl.tk/) programming language
@@ -129,6 +131,7 @@ Plugin | Description
[`scalestatus`](plugins/scalestatus.lua?raw=1) | Displays current scale (zoom) in status view (depends on scale plugin)
[`selectionhighlight`](plugins/selectionhighlight.lua?raw=1) | Highlights regions of code that match the current selection *([screenshot](https://user-images.githubusercontent.com/3920290/80710883-5f597c80-8ae7-11ea-97f0-76dfacc08439.png))*
[`smallclock`](plugins/smallclock.lua?raw=1) | Displays the current time in the corner of the status view
+*[`smoothcaret`](plugins/smoothcaret.lua?raw=1)* | Smooth caret animation *([gif](https://user-images.githubusercontent.com/20792268/139006049-a0ba6559-88cb-49a7-8077-4822445b4a1f.gif))*
[`sort`](plugins/sort.lua?raw=1) | Sorts selected lines alphabetically
[`spellcheck`](plugins/spellcheck.lua?raw=1) | Underlines misspelt words *([screenshot](https://user-images.githubusercontent.com/3920290/79923973-9caa7400-842e-11ea-85d4-7a196a91ca50.png))* *— note: on Windows a [`words.txt`](https://github.com/dwyl/english-words/blob/master/words.txt) dictionary file must be placed beside the exe*
[`statusclock`](plugins/statusclock.lua?raw=1) | Displays the current date and time in the corner of the status view
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/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..65bc1ce
--- /dev/null
+++ b/plugins/language_julia.lua
@@ -0,0 +1,86 @@
+-- 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 = "#.-\n", type = "comment" },
+ { pattern = { '"', '"', '\\' }, type = "string" },
+ { pattern = { "`", "`", '\\' }, type = "string" },
+ { pattern = "0[oO_][0-7]+", type = "number" },
+ { pattern = "-?0x[%x_]+", type = "number" },
+ { pattern = "-?%d+_%d", 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 = {
+ -- keywords
+ ["abstract type"] = "keyword",
+ ["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",
+ ["import"] = "keyword",
+ ["let"] = "keyword",
+ ["local"] = "keyword",
+ ["macro"] = "keyword",
+ ["module"] = "keyword",
+ ["quote"] = "keyword",
+ ["return"] = "keyword",
+ ["try"] = "keyword",
+ ["typeof"] = "keyword",
+ ["using"] = "keyword",
+ ["while"] = "keyword",
+
+ -- types
+ ["struct"] = "keyword2",
+ ["mutable struct"] = "keyword2",
+ ["Char"] = "keyword2",
+ ["Bool"] = "keyword2",
+ ["Int"] = "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",
+
+ -- literals
+ ["missing"] = "literal",
+ ["true"] = "literal",
+ ["false"] = "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..b129f40 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,22 @@ config.plugins.minimap = {
scale = 1,
-- how many spaces one tab is equivalent to
tab_width = 4,
- draw_background = true
+ draw_background = true,
+ 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 +38,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 +128,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 +222,10 @@ DocView.draw_scrollbar = function(self)
-- draw visual rect
renderer.draw_rect(x, visible_y, w, scroller_height, visual_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 +255,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 +279,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 +313,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 +351,6 @@ command.add(nil, {
config.plugins.minimap.syntax_highlight = not config.plugins.minimap.syntax_highlight
end
})
+
+return minimap
+
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