diff options
57 files changed, 220 insertions, 81 deletions
@@ -129,6 +129,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_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 dc06335..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 = { 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_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/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 |