diff options
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | plugins/autoinsert.lua | 9 | ||||
-rw-r--r-- | plugins/force_syntax.lua | 19 | ||||
-rw-r--r-- | plugins/gitstatus.lua | 17 | ||||
-rw-r--r-- | plugins/language_assembly_x86.lua | 1 | ||||
-rw-r--r-- | plugins/language_jsx.lua | 4 | ||||
-rw-r--r-- | plugins/language_miniscript.lua | 102 | ||||
-rw-r--r-- | plugins/language_rivet.lua | 15 | ||||
-rw-r--r-- | plugins/linecopypaste.lua | 50 | ||||
-rw-r--r-- | plugins/memoryusage.lua | 17 | ||||
-rw-r--r-- | plugins/nonicons.lua | 3 | ||||
-rw-r--r-- | plugins/rainbowparen.lua | 5 | ||||
-rw-r--r-- | plugins/scalestatus.lua | 17 | ||||
-rw-r--r-- | plugins/settings.lua | 57 | ||||
-rw-r--r-- | plugins/smallclock.lua | 15 | ||||
-rw-r--r-- | plugins/statusclock.lua | 15 | ||||
-rw-r--r-- | plugins/typingspeed.lua | 18 | ||||
-rw-r--r-- | plugins/wordcount.lua | 12 |
18 files changed, 237 insertions, 141 deletions
@@ -93,6 +93,7 @@ _Note: if you make a pull request, the table should be updated and kept in alpha | [`language_lobster`](plugins/language_lobster.lua?raw=1) | Syntax for [Lobster](https://strlen.com/lobster/) programming language | | [`language_make`](plugins/language_make.lua?raw=1) | Syntax for the Make build system language | | [`language_meson`](plugins/language_meson.lua?raw=1) | Syntax for the [Meson](https://mesonbuild.com) build system language | +| [`language_miniscript`](plugins/language_miniscript.lua?raw=1) | Syntax for the [MiniScript](https://miniscript.org) programming language | | [`language_moon`](plugins/language_moon.lua?raw=1) | Syntax for the [MoonScript](https://moonscript.org) scripting language | | [`language_nelua`](https://github.com/AKDev21/nelua-lite-xl)\* | Syntax for [Nelua](http://nelua.io/) programming | | [`language_nginx`](plugins/language_nginx.lua?raw=1) | Syntax for [Nginx](https://www.nginx.com/) config files | @@ -127,7 +128,6 @@ _Note: if you make a pull request, the table should be updated and kept in alpha | [`language_yaml`](plugins/language_yaml.lua?raw=1) | Syntax for [YAML](https://yaml.org/) serialization language | | [`language_zig`](plugins/language_zig.lua?raw=1) | Syntax for the [Zig](https://ziglang.org/) programming language | | [`lfautoinsert`](plugins/lfautoinsert.lua?raw=1) | Automatically inserts indentation and closing bracket/text after newline | -| [`linecopypaste`](plugins/linecopypaste.lua?raw=1) | Copy, cut and paste the current line when nothing is selected | | [`linenumbers`](plugins/linenumbers.lua?raw=1) | The ability to change the display of the line number _([screenshot](https://user-images.githubusercontent.com/5556081/129493788-6a4cbd7a-9074-4133-bab7-110ed55f18f7.png))_ | | [`lint+`](https://github.com/liquid600pgm/lintplus)\* | Advanced linter with ErrorLens-like error reporting. Compatible with linters made for `linter` _([screenshot](https://raw.githubusercontent.com/liquid600pgm/lintplus/master/screenshots/1.png))_ | | [`linter`](https://github.com/drmargarido/linters)\* | Linters for multiple languages | diff --git a/plugins/autoinsert.lua b/plugins/autoinsert.lua index 179a5ef..c49887a 100644 --- a/plugins/autoinsert.lua +++ b/plugins/autoinsert.lua @@ -89,9 +89,12 @@ command.add(predicate, { ["autoinsert:backspace"] = function() local doc = core.active_view.doc local l, c = doc:get_selection() - local chr = doc:get_char(l, c) - if config.plugins.autoinsert.map[doc:get_char(l, c - 1)] and is_closer(chr) then - doc:delete_to(1) + if c > 1 then + local chr = doc:get_char(l, c) + local mapped = config.plugins.autoinsert.map[doc:get_char(l, c - 1)] + if mapped and mapped == chr then + doc:delete_to(1) + end end command.perform "doc:backspace" end, diff --git a/plugins/force_syntax.lua b/plugins/force_syntax.lua index 5c1d2eb..ae5a138 100644 --- a/plugins/force_syntax.lua +++ b/plugins/force_syntax.lua @@ -39,23 +39,24 @@ local function get_syntax_name(s) return name or "Undefined" end -core.status_view:add_item( - function() +core.status_view:add_item({ + predicate = function() return core.active_view and getmetatable(core.active_view) == DocView end, - "doc:syntax", - StatusView.Item.RIGHT, - function() + name = "doc:syntax", + alignment = StatusView.Item.RIGHT, + get_item = function() local syntax_name = get_syntax_name(doc().syntax) return { style.text, syntax_name } end, - "force-syntax:select-file-syntax", - -1, - "file syntax" -).separator = core.status_view.separator2 + command = "force-syntax:select-file-syntax", + position = -1, + tooltip = "file syntax", + separator = core.status_view.separator2 +}) local function get_syntax_list() local pt_name = plain_text_syntax.name diff --git a/plugins/gitstatus.lua b/plugins/gitstatus.lua index fc7a2ea..9a36142 100644 --- a/plugins/gitstatus.lua +++ b/plugins/gitstatus.lua @@ -116,11 +116,10 @@ core.add_thread(function() end) -core.status_view:add_item( - nil, - "status:git", - StatusView.Item.RIGHT, - function() +core.status_view:add_item({ + name = "status:git", + alignment = StatusView.Item.RIGHT, + get_item = function() if not git.branch then return {} end @@ -133,7 +132,7 @@ core.status_view:add_item( git.deletes ~= 0 and style.accent or style.text, "-", git.deletes, } end, - nil, - -1, - "branch and changes" -).separator = core.status_view.separator2 + position = -1, + tooltip = "branch and changes", + separator = core.status_view.separator2 +}) diff --git a/plugins/language_assembly_x86.lua b/plugins/language_assembly_x86.lua index 5b3d727..e6d218b 100644 --- a/plugins/language_assembly_x86.lua +++ b/plugins/language_assembly_x86.lua @@ -6,6 +6,7 @@ local syntax = require "core.syntax" syntax.add { + name = "x86 Assembly", files = { "%.asm$", "%.[sS]$" }, comment = ";", patterns = { diff --git a/plugins/language_jsx.lua b/plugins/language_jsx.lua index 90d9979..04e846b 100644 --- a/plugins/language_jsx.lua +++ b/plugins/language_jsx.lua @@ -15,8 +15,9 @@ syntax.add { { pattern = "0x[%da-fA-F]+", type = "number" }, { pattern = "-?%d+[%d%.eE]*", type = "number" }, { pattern = "-?%.?%d+", type = "number" }, - { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" }, + { pattern = "%f[^<]/?[%a_][%w_]*", type = "function" }, { pattern = "[%a_][%w_]*%f[(]", type = "function" }, + { pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" }, { pattern = "[%a_][%w_]*", type = "symbol" }, }, symbols = { @@ -37,6 +38,7 @@ syntax.add { ["extends"] = "keyword", ["finally"] = "keyword", ["for"] = "keyword", + ["from"] = "keyword", ["function"] = "keyword", ["get"] = "keyword", ["if"] = "keyword", diff --git a/plugins/language_miniscript.lua b/plugins/language_miniscript.lua new file mode 100644 index 0000000..afe0a2b --- /dev/null +++ b/plugins/language_miniscript.lua @@ -0,0 +1,102 @@ +-- mod-version:3 +local syntax = require 'core.syntax' + +syntax.add { + name = "MiniScript", + files = { "%.ms$" }, + comment = "//", + patterns = { + { pattern = "//.*", type = "comment" }, + { pattern = { '"', '"' }, type = "string" }, + { pattern = "[<>!=]=", type = "operator" }, + { pattern = "[%+%-%*%/%^@<>:]", type = "operator" }, + { pattern = "%d%.%d*[eE][-+]?%d+", type = "number" }, + { pattern = "%d%.%d*", type = "number" }, + { pattern = "%.?%d*[eE][-+]?%d+", type = "number" }, + { pattern = "%.?%d+", type = "number" }, + { pattern = "[%a_][%w_]*", type = "symbol" }, + }, + symbols = { + ["if"] = "keyword", + ["not"] = "keyword", + ["and"] = "keyword", + ["or"] = "keyword", + ["else"] = "keyword", + ["then"] = "keyword", + ["for"] = "keyword", + ["in"] = "keyword", + ["while"] = "keyword", + ["break"] = "keyword", + ["continue"] = "keyword", + ["function"] = "keyword", + ["end"] = "keyword", + ["return"] = "keyword", + ["new"] = "keyword", + ["isa"] = "keyword", + ["self"] = "keyword2", + + ["true"] = "literal", + ["false"] = "literal", + ["null"] = "literal", + ["globals"] = "literal", + ["locals"] = "literal", + ["outer"] = "literal", + + -- Built-in types's classes + ["number"] = "literal", + ["string"] = "literal", + ["list"] = "literal", + ["map"] = "literal", + ["funcRef"] = "literal", + + -- Intrinsic functions + ["abs"] = "function", + ["acos"] = "function", + ["asin"] = "function", + ["atan"] = "function", + ["bitAnd"] = "function", + ["bitOr"] = "function", + ["bitXor"] = "function", + ["ceil"] = "function", + ["char"] = "function", + ["code"] = "function", + ["cos"] = "function", + ["floor"] = "function", + ["hash"] = "function", + ["hasIndex"] = "function", + ["indexes"] = "function", + ["indexOf"] = "function", + ["insert"] = "function", + ["join"] = "function", + ["len"] = "function", + ["log"] = "function", + ["lower"] = "function", + ["pi"] = "function", + ["pop"] = "function", + ["print"] = "function", + ["pull"] = "function", + ["push"] = "function", + ["range"] = "function", + ["remove"] = "function", + ["replace"] = "function", + ["rnd"] = "function", + ["round"] = "function", + ["shuffle"] = "function", + ["sign"] = "function", + ["sin"] = "function", + ["slice"] = "function", + ["sort"] = "function", + ["split"] = "function", + ["sqrt"] = "function", + ["str"] = "function", + ["sum"] = "function", + ["tan"] = "function", + ["time"] = "function", + ["upper"] = "function", + ["val"] = "function", + ["values"] = "function", + ["version"] = "function", + ["wait"] = "function", + ["yield"] = "function", + }, +} diff --git a/plugins/language_rivet.lua b/plugins/language_rivet.lua index 574b368..3437af5 100644 --- a/plugins/language_rivet.lua +++ b/plugins/language_rivet.lua @@ -13,7 +13,7 @@ syntax.add { patterns = { {pattern = "//.-\n", type = "comment"}, {pattern = {"/%*", "%*/"}, type = "comment"}, - {pattern = {'[rb]?"', '"', "\\"}, type = "string"}, + {pattern = {'[cbr]?"', '"', "\\"}, type = "string"}, {pattern = {"[b]?'", "'", '\\' }, type = "string"}, {pattern = "0b[01_]+", type = "number"}, {pattern = "0o[0-7_]+", type = "number"}, @@ -24,7 +24,11 @@ syntax.add { {pattern = "-?%.?%d+", type = "number"}, {pattern = "[%+%-=/%*%^%%<>!~|&%.%?]", type = "operator"}, {pattern = "[%a_][%w_]*::", type = "keyword2"}, - {pattern = "[A-Z][%w_]*", type = "keyword2"}, -- types and constants + { -- Uppercase constants of at least 2 chars in len + pattern = "_?%u[%u_][%u%d_]*%f[%s%+%*%-%.%)%]}%?%^%%=/<>~|&;:,!]", + type = "number" + }, + {pattern = "[A-Z][%w_]*", type = "keyword2"}, -- types {pattern = "[%a_][%w_]*%f[(]", type = "function"}, {pattern = "[%a_][%w_]*!%f[(]", type = "keyword2"}, {pattern = "[%a_][%w_]*", type = "symbol"}, @@ -34,7 +38,7 @@ syntax.add { }, symbols = { ["extern"] = "keyword", - ["use"] = "keyword", + ["using"] = "keyword", ["pub"] = "keyword", ["as"] = "keyword", @@ -77,15 +81,14 @@ syntax.add { ["goto"] = "keyword", ["orelse"] = "keyword", ["catch"] = "keyword", - ["cast"] = "keyword", ["or"] = "keyword", ["and"] = "keyword", ["is"] = "keyword", ["in"] = "keyword", -- types - ["c_void"] = "keyword2", ["void"] = "keyword2", + ["no_return"] = "keyword2", ["bool"] = "keyword2", ["i8"] = "keyword2", ["i16"] = "keyword2", @@ -104,7 +107,7 @@ syntax.add { ["Self"] = "keyword2", -- literals - ["base"] = "literal", + ["super"] = "literal", ["self"] = "literal", ["true"] = "literal", ["false"] = "literal", diff --git a/plugins/linecopypaste.lua b/plugins/linecopypaste.lua deleted file mode 100644 index 7be8492..0000000 --- a/plugins/linecopypaste.lua +++ /dev/null @@ -1,50 +0,0 @@ --- mod-version:3
-local core = require "core"
-local command = require "core.command"
-
-local function doc()
- return core.active_view.doc
-end
-
-local line_in_clipboard = false
-
-local doc_copy = command.map["doc:copy"].perform
-command.map["doc:copy"].perform = function()
- if doc():has_selection() then
- doc_copy()
- line_in_clipboard = false
- else
- local line = doc():get_selection()
- system.set_clipboard(doc().lines[line])
- line_in_clipboard = true
- end
-end
-
-local doc_cut = command.map["doc:cut"].perform
-command.map["doc:cut"].perform = function()
- if doc():has_selection() then
- doc_cut()
- line_in_clipboard = false
- else
- local line = doc():get_selection()
- system.set_clipboard(doc().lines[line])
- if line < #(doc().lines) then
- doc():remove(line, 1, line+1, 1)
- else -- last line in file
- doc():remove(line, 1, line, #(doc().lines[line]))
- end
- doc():set_selection(line, 1)
- line_in_clipboard = true
- end
-end
-
-local doc_paste = command.map["doc:paste"].perform
-command.map["doc:paste"].perform = function()
- if line_in_clipboard == false then
- doc_paste()
- else
- local line, col = doc():get_selection()
- doc():insert(line, 1, system.get_clipboard():gsub("\r", ""))
- doc():set_selection(line+1, col)
- end
-end
diff --git a/plugins/memoryusage.lua b/plugins/memoryusage.lua index d84a8c2..290b4e1 100644 --- a/plugins/memoryusage.lua +++ b/plugins/memoryusage.lua @@ -30,11 +30,10 @@ config.plugins.memoryusage = common.merge({ } }, config.plugins.memoryusage) -core.status_view:add_item( - nil, - "status:memory-usage", - StatusView.Item.RIGHT, - function() +core.status_view:add_item({ + name = "status:memory-usage", + alignment = StatusView.Item.RIGHT, + get_item = function() return { style.text, string.format( @@ -43,8 +42,8 @@ core.status_view:add_item( ) } end, - nil, - 1, - "lua memory usage" -).separator = core.status_view.separator2 + position = 1, + tooltip = "lua memory usage", + separator = core.status_view.separator2 +}) diff --git a/plugins/nonicons.lua b/plugins/nonicons.lua index 143da13..efbe3b4 100644 --- a/plugins/nonicons.lua +++ b/plugins/nonicons.lua @@ -89,7 +89,7 @@ local extension_icons = { -- Following without special icon: [".awk"] = { "#4d5a5e", "" }, [".nim"] = { "#F88A02", "" }, - + [".zig"] = { "#cbcb41", "" }, } local known_names_icons = { ["changelog"] = { "#657175", "" }, ["changelog.txt"] = { "#4d5a5e", "" }, @@ -102,6 +102,7 @@ local known_names_icons = { ["readme.md"] = { "#72b886", "" }, ["readme"] = { "#72b886", "" }, ["init.lua"] = { "#2d6496", "" }, ["setup.py"] = { "#559dd9", "" }, + ["build.zig"] = { "#6d8086", "" }, } -- Preparing colors diff --git a/plugins/rainbowparen.lua b/plugins/rainbowparen.lua index 0f4c5c8..6ca4cb4 100644 --- a/plugins/rainbowparen.lua +++ b/plugins/rainbowparen.lua @@ -8,7 +8,8 @@ local tokenizer = require "core.tokenizer" local Highlighter = require "core.doc.highlighter" config.plugins.rainbowparen = common.merge({ - enabled = true + enabled = true, + parens = 5 }, config.plugins.rainbowparen) style.syntax.paren_unbalanced = style.syntax.paren_unbalanced or { common.color "#DC0408" } @@ -26,7 +27,7 @@ local closers = { } local function parenstyle(parenstack) - return "paren" .. ((#parenstack % 5) + 1) + return "paren" .. ((#parenstack % config.plugins.rainbowparen.parens) + 1) end function tokenizer.tokenize(syntax, text, state) diff --git a/plugins/scalestatus.lua b/plugins/scalestatus.lua index aa08cdc..a7623b1 100644 --- a/plugins/scalestatus.lua +++ b/plugins/scalestatus.lua @@ -36,20 +36,19 @@ config.plugins.scalestatus = common.merge({ } }, config.plugins.scalestatus) -core.status_view:add_item( - nil, - "status:scale", - StatusView.Item.RIGHT, - function() +core.status_view:add_item({ + name = "status:scale", + alignment = StatusView.Item.RIGHT, + get_item = function() return {string.format( config.plugins.scalestatus.format, scale.get() * 100 )} end, - nil, - 1, - "scale" -).separator = core.status_view.separator2 + position = 1, + tooltip = "scale", + separator = core.status_view.separator2 +}) return true diff --git a/plugins/settings.lua b/plugins/settings.lua index a489430..a9fd1b9 100644 --- a/plugins/settings.lua +++ b/plugins/settings.lua @@ -26,6 +26,7 @@ local FoldingBook = require "widget.foldingbook" local FontsList = require "widget.fontslist" local ItemsList = require "widget.itemslist" local KeybindingDialog = require "widget.keybinddialog" +local Fonts = require "widget.fonts" local settings = {} @@ -69,6 +70,7 @@ settings.type = { ---@field public step number ---@field public values table ---@field public fonts_list table<string, renderer.font> +---@field public font_error boolean ---@field public get_value nil | fun(value:any):any ---@field public set_value nil | fun(value:any):any ---@field public icon string @@ -95,6 +97,8 @@ settings.option = { values = {}, ---Optionally used for FONT to store the generated font group. fonts_list = {}, + ---Flag set to true when loading user defined fonts fail + font_error = false, ---Optional function that is used to manipulate the current value on retrieval. get_value = nil, ---Optional function that is used to manipulate the saved value on save. @@ -161,6 +165,15 @@ settings.add("General", on_click = "core:open-user-module" }, { + label = "Clear Fonts Cache", + description = "Delete current font cache and regenerate a fresh one.", + type = settings.type.BUTTON, + icon = "C", + on_click = function() + Fonts.clean_cache() + end + }, + { label = "Maximum Project Files", description = "The maximum amount of project files to register.", path = "max_project_files", @@ -168,8 +181,10 @@ settings.add("General", default = 2000, min = 1, max = 100000, - on_apply = function() - core.rescan_project_directories() + on_apply = function(button, x, y) + if button == "left" then + core.rescan_project_directories() + end end }, { @@ -841,16 +856,29 @@ local function merge_font_settings(option, path, saved_value) font_options.hinting = font_options.hinting or "slight" local fonts = {} + local font_loaded = true for _, font in ipairs(saved_value.fonts) do - table.insert(fonts, renderer.font.load( - font.path, font_options.size * SCALE, font_options - )) + local font_data = nil + font_loaded = core.try(function() + font_data = renderer.font.load( + font.path, font_options.size * SCALE, font_options + ) + end) + if font_loaded then + table.insert(fonts, font_data) + else + option.font_error = true + core.error("Settings: could not load %s\n'%s - %s'", path, font.name, font.path) + break + end end - if option.fonts_list then - set_config_value(option.fonts_list, option.path, renderer.font.group(fonts)) - else - set_config_value(config, path, renderer.font.group(fonts)) + if font_loaded then + if option.fonts_list then + set_config_value(option.fonts_list, option.path, renderer.font.group(fonts)) + else + set_config_value(config, path, renderer.font.group(fonts)) + end end end @@ -1086,7 +1114,12 @@ local function add_control(pane, option, plugin_name) elseif option.type == settings.type.FONT then --get fonts without conversion to renderer.font if type(path) ~= "nil" then - option_value = get_config_value(settings.config, path, option.default) + if not option.font_error then + option_value = get_config_value(settings.config, path, option.default) + else + --fallback to default fonts if error loading user defined ones + option_value = option.default + end end ---@type widget.label Label(pane, option.label .. ":") @@ -1706,6 +1739,10 @@ function core.run() end) end + -- re-apply user settings + core.load_user_directory() + core.load_project_module() + core_run() end diff --git a/plugins/smallclock.lua b/plugins/smallclock.lua index 7c845d7..e975152 100644 --- a/plugins/smallclock.lua +++ b/plugins/smallclock.lua @@ -54,14 +54,13 @@ local function update_time() end end -core.status_view:add_item( - nil, - "status:small-clock", - StatusView.Item.RIGHT, - function() +core.status_view:add_item({ + name = "status:small-clock", + alignment = StatusView.Item.RIGHT, + get_item = function() update_time() return {style.accent, time} end, - nil, - -1 -).separator = core.status_view.separator2 + position = -1, + separator = core.status_view.separator2 +}) diff --git a/plugins/statusclock.lua b/plugins/statusclock.lua index 0fe95dd..aec58e3 100644 --- a/plugins/statusclock.lua +++ b/plugins/statusclock.lua @@ -68,11 +68,10 @@ local function update_time() end end -core.status_view:add_item( - nil, - "status:clock", - StatusView.Item.RIGHT, - function(self) +core.status_view:add_item({ + name = "status:clock", + alignment = StatusView.Item.RIGHT, + get_item = function(self) update_time() return { style.text, @@ -83,7 +82,7 @@ core.status_view:add_item( time_data.time_text, } end, - nil, - -1 -).separator = core.status_view.separator2 + position = -1, + separator = core.status_view.separator2 +}) diff --git a/plugins/typingspeed.lua b/plugins/typingspeed.lua index 14bd91c..0e28ec9 100644 --- a/plugins/typingspeed.lua +++ b/plugins/typingspeed.lua @@ -82,19 +82,19 @@ function DocView:on_text_input(text, idx) on_text_input(self, text, idx) end -core.status_view:add_item( - function() +core.status_view:add_item({ + predicate = function() return core.active_view and getmetatable(core.active_view) == DocView end, - "typing-speed:stats", - core.status_view.Item.RIGHT, - function() + name = "typing-speed:stats", + alignment = core.status_view.Item.RIGHT, + get_item = function() return { style.text, string.format("%.0f CPM / %.0f WPM", cpm, wpm) } end, - nil, - 1, - "characters / words per minute" -).separator = core.status_view.separator2 + position = 1, + tooltip = "characters / words per minute", + separator = core.status_view.separator2 +}) diff --git a/plugins/wordcount.lua b/plugins/wordcount.lua index 224ad5e..42224ac 100644 --- a/plugins/wordcount.lua +++ b/plugins/wordcount.lua @@ -71,11 +71,11 @@ end local cached_word_length, cached_word_count -core.status_view:add_item( - function() return core.active_view:is(DocView) and not core.active_view:is(CommandView) and words[core.active_view.doc] end, - "status:word-count", - StatusView.Item.RIGHT, - function() +core.status_view:add_item({ + predicate = function() return core.active_view:is(DocView) and not core.active_view:is(CommandView) and words[core.active_view.doc] end, + name = "status:word-count", + alignment = StatusView.Item.RIGHT, + get_item = function() local selection_text = core.active_view.doc:get_selection_text() if #selection_text ~= cached_word_length then cached_word_count = compute_line_words(selection_text) @@ -87,4 +87,4 @@ core.status_view:add_item( return { style.text, words[core.active_view.doc] .. " words" } end end -) +}) |