diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/language_assembly_x86.lua | 1 | ||||
-rw-r--r-- | plugins/language_miniscript.lua | 102 | ||||
-rw-r--r-- | plugins/linecopypaste.lua | 50 | ||||
-rw-r--r-- | plugins/nonicons.lua | 3 | ||||
-rw-r--r-- | plugins/settings.lua | 57 |
5 files changed, 152 insertions, 61 deletions
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_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/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/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/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 |