aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/autosave.lua20
-rw-r--r--plugins/autowrap.lua20
-rw-r--r--plugins/bigclock.lua30
-rw-r--r--plugins/centerdoc.lua75
-rw-r--r--plugins/datetimestamps.lua27
-rw-r--r--plugins/gitstatus.lua47
-rw-r--r--plugins/indent_convert.lua14
-rw-r--r--plugins/linenumbers.lua26
-rw-r--r--plugins/memoryusage.lua26
-rw-r--r--plugins/minimap.lua140
-rw-r--r--plugins/motiontrail.lua30
-rw-r--r--plugins/nonicons.lua90
-rw-r--r--plugins/openfilelocation.lua33
-rw-r--r--plugins/openselected.lua33
-rw-r--r--plugins/rainbowparen.lua42
-rw-r--r--plugins/scalestatus.lua28
-rw-r--r--plugins/smallclock.lua44
-rw-r--r--plugins/smoothcaret.lua34
-rw-r--r--plugins/spellcheck.lua82
-rw-r--r--plugins/statusclock.lua37
-rw-r--r--plugins/tabnumbers.lua56
-rw-r--r--plugins/titleize.lua1
-rw-r--r--plugins/typingspeed.lua135
23 files changed, 834 insertions, 236 deletions
diff --git a/plugins/autosave.lua b/plugins/autosave.lua
index 34d2ad6..7691e5a 100644
--- a/plugins/autosave.lua
+++ b/plugins/autosave.lua
@@ -9,8 +9,24 @@ local last_keypress = os.time()
-- this exists so that we don't end up with multiple copies of the loop running at once
local looping = false
local on_text_change = Doc.on_text_change
--- the approximate amount of time, in seconds, that it takes to trigger an autosave
-config.plugins.autosave = common.merge({ timeout = 1 }, config.plugins.autosave)
+
+config.plugins.autosave = common.merge({
+ -- the approximate amount of time, in seconds, that it takes to trigger an autosave
+ timeout = 1,
+ -- The config specification used by the settings gui
+ config_spec = {
+ name = "Auto Save",
+ {
+ label = "Timeout",
+ description = "Approximate amount of time in seconds it takes to trigger an autosave.",
+ path = "timeout",
+ type = "number",
+ default = 1,
+ min = 1,
+ max = 30
+ }
+ }
+}, config.plugins.autosave)
local function loop_for_save()
diff --git a/plugins/autowrap.lua b/plugins/autowrap.lua
index fee001b..238053d 100644
--- a/plugins/autowrap.lua
+++ b/plugins/autowrap.lua
@@ -7,7 +7,25 @@ local DocView = require "core.docview"
config.plugins.autowrap = common.merge({
enable = false,
- files = { "%.md$", "%.txt$" }
+ files = { "%.md$", "%.txt$" },
+ -- The config specification used by the settings gui
+ config_spec = {
+ name = "Auto Wrap",
+ {
+ label = "Enable",
+ description = "Activates text auto wrapping by default.",
+ path = "enable",
+ type = "toggle",
+ default = false
+ },
+ {
+ label = "Files",
+ description = "List of Lua patterns matching files to auto wrap.",
+ path = "files",
+ type = "list_strings",
+ default = { "%.md$", "%.txt$" },
+ }
+ }
}, config.plugins.autowrap)
diff --git a/plugins/bigclock.lua b/plugins/bigclock.lua
index 1f38b02..66b63f1 100644
--- a/plugins/bigclock.lua
+++ b/plugins/bigclock.lua
@@ -10,7 +10,35 @@ local View = require "core.view"
config.plugins.bigclock = common.merge({
time_format = "%H:%M:%S",
date_format = "%A, %d %B %Y",
- scale = 1
+ scale = 1,
+ -- The config specification used by the settings gui
+ config_spec = {
+ name = "Big Clock",
+ {
+ label = "Time Format",
+ description = "Time specification defined with Lua date/time place holders.",
+ path = "time_format",
+ type = "string",
+ default = "%H:%M:%S"
+ },
+ {
+ label = "Date Format",
+ description = "Date specification defined with Lua date/time place holders.",
+ path = "date_format",
+ type = "string",
+ default = "%A, %d %B %Y",
+ },
+ {
+ label = "Scale",
+ description = "Size of the clock relative to screen.",
+ path = "scale",
+ type = "number",
+ default = 1,
+ min = 0.5,
+ max = 3.0,
+ step = 0.1
+ }
+ }
}, config.plugins.bigclock)
diff --git a/plugins/centerdoc.lua b/plugins/centerdoc.lua
index a771925..fb5943c 100644
--- a/plugins/centerdoc.lua
+++ b/plugins/centerdoc.lua
@@ -8,7 +8,8 @@ local treeview = require "plugins.treeview"
local DocView = require "core.docview"
config.plugins.centerdoc = common.merge({
- enable = true
+ enable = true,
+ zen_mode = false
}, config.plugins.centerdoc)
local draw_line_gutter = DocView.draw_line_gutter
@@ -38,33 +39,69 @@ function DocView:get_gutter_width()
end
end
-local zen_mode = false
+
local previous_win_status = system.get_window_mode()
local previous_treeview_status = treeview.visible
local previous_statusbar_status = core.status_view.visible
+local function toggle_zen_mode(enabled)
+ config.plugins.centerdoc.zen_mode = enabled
+
+ if config.plugins.centerdoc.zen_mode then
+ previous_win_status = system.get_window_mode()
+ previous_treeview_status = treeview.visible
+ previous_statusbar_status = core.status_view.visible
+
+ config.plugins.centerdoc.enable = true
+ system.set_window_mode("fullscreen")
+ treeview.visible = false
+ command.perform "status-bar:hide"
+ else
+ config.plugins.centerdoc.enable = false
+ system.set_window_mode(previous_win_status)
+ treeview.visible = previous_treeview_status
+ core.status_view.visible = previous_statusbar_status
+ end
+end
+
+local on_startup = true
+
+-- The config specification used by the settings gui
+config.plugins.centerdoc.config_spec = {
+ name = "Center Document",
+ {
+ label = "Enable",
+ description = "Activates document centering by default.",
+ path = "enable",
+ type = "toggle",
+ default = true
+ },
+ {
+ label = "Zen Mode",
+ description = "Activates zen mode by default.",
+ path = "zen_mode",
+ type = "toggle",
+ default = false,
+ on_apply = function(enabled)
+ if on_startup then
+ core.add_thread(function()
+ toggle_zen_mode(enabled)
+ end)
+ on_startup = false
+ else
+ toggle_zen_mode(enabled)
+ end
+ end
+ }
+}
+
+
command.add(nil, {
["center-doc:toggle"] = function()
config.plugins.centerdoc.enable = not config.plugins.centerdoc.enable
end,
["center-doc:zen-mode-toggle"] = function()
- zen_mode = not zen_mode
-
- if zen_mode then
- previous_win_status = system.get_window_mode()
- previous_treeview_status = treeview.visible
- previous_statusbar_status = core.status_view.visible
-
- config.plugins.centerdoc.enable = true
- system.set_window_mode("fullscreen")
- treeview.visible = false
- command.perform "status-bar:hide"
- else
- config.plugins.centerdoc.enable = false
- system.set_window_mode(previous_win_status)
- treeview.visible = previous_treeview_status
- core.status_view.visible = previous_statusbar_status
- end
+ toggle_zen_mode(not config.plugins.centerdoc.zen_mode)
end,
})
diff --git a/plugins/datetimestamps.lua b/plugins/datetimestamps.lua
index 2880f99..2cbc410 100644
--- a/plugins/datetimestamps.lua
+++ b/plugins/datetimestamps.lua
@@ -29,7 +29,32 @@ from https://www.lua.org/pil/22.1.html
config.plugins.datetimestamps = common.merge({
format_datestamp = "%Y%m%d",
format_datetimestamp = "%Y%m%d_%H%M%S",
- format_timestamp = "%H%M%S"
+ format_timestamp = "%H%M%S",
+ -- The config specification used by the settings gui
+ config_spec = {
+ name = "Date and Time Stamps",
+ {
+ label = "Date",
+ description = "Date specification defined with Lua date/time place holders.",
+ path = "format_datestamp",
+ type = "string",
+ default = "%Y%m%d"
+ },
+ {
+ label = "Time",
+ description = "Time specification defined with Lua date/time place holders.",
+ path = "format_timestamp",
+ type = "string",
+ default = "%H%M%S"
+ },
+ {
+ label = "Date and Time",
+ description = "Date and time specification defined with Lua date/time place holders.",
+ path = "format_datetimestamp",
+ type = "string",
+ default = "%Y%m%d_%H%M%S"
+ }
+ }
}, config.plugins.datetimestamps)
local function datestamp()
diff --git a/plugins/gitstatus.lua b/plugins/gitstatus.lua
index 33dc5e5..9ba792c 100644
--- a/plugins/gitstatus.lua
+++ b/plugins/gitstatus.lua
@@ -6,15 +6,37 @@ local style = require "core.style"
local StatusView = require "core.statusview"
local TreeView = require "plugins.treeview"
+config.plugins.gitstatus = common.merge({
+ recurse_submodules = true,
+ -- The config specification used by the settings gui
+ config_spec = {
+ name = "Git Status",
+ {
+ label = "Recurse Submodules",
+ description = "Also retrieve git stats from submodules.",
+ path = "recurse_submodules",
+ type = "toggle",
+ default = true
+ }
+ }
+}, config.plugins.gitstatus)
+
+style.gitstatus_addition = {common.color "#587c0c"}
+style.gitstatus_modification = {common.color "#0c7d9d"}
+style.gitstatus_deletion = {common.color "#94151b"}
+
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)
+-- Override TreeView's get_item_text to add modification color
+local treeview_get_item_text = TreeView.get_item_text
+function TreeView:get_item_text(item, active, hovered)
+ local text, font, color = treeview_get_item_text(self, item, active, hovered)
+ if cached_color_for_item[item.abs_filename] then
+ color = cached_color_for_item[item.abs_filename]
+ end
+ return text, font, color
end
@@ -24,15 +46,6 @@ local git = {
deletes = 0,
}
-
-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)
-- Don't use proc:wait() here - that will freeze the app.
@@ -57,7 +70,11 @@ core.add_thread(function()
-- get diff
local diff = exec({"git", "diff", "--numstat"})
- if config.gitstatus.recurse_submodules and system.get_file_info(".gitmodules") then
+ if
+ config.plugins.gitstatus.recurse_submodules
+ and
+ system.get_file_info(".gitmodules")
+ then
local diff2 = exec({"git", "submodule", "foreach", "git diff --numstat"})
diff = diff .. diff2
end
diff --git a/plugins/indent_convert.lua b/plugins/indent_convert.lua
index 2442b39..af241a7 100644
--- a/plugins/indent_convert.lua
+++ b/plugins/indent_convert.lua
@@ -5,7 +5,19 @@ local config = require "core.config"
local command = require "core.command"
config.plugins.indent_convert = common.merge({
- update_indent_type = true -- set to false to avoid updating the document indent type
+ -- set to false to avoid updating the document indent type
+ update_indent_type = true,
+ -- The config specification used by the settings gui
+ config_spec = {
+ name = "Indent Convert",
+ {
+ label = "Update Indent Type",
+ description = "Disable to avoid updating the document indent type.",
+ path = "update_indent_type",
+ type = "toggle",
+ default = true
+ }
+ }
}, config.plugins.indent_convert)
local zero_pattern = _VERSION == "Lua 5.1" and "%z" or "\0"
diff --git a/plugins/linenumbers.lua b/plugins/linenumbers.lua
index 76c691d..5cf198a 100644
--- a/plugins/linenumbers.lua
+++ b/plugins/linenumbers.lua
@@ -7,7 +7,25 @@ local command = require "core.command"
config.plugins.linenumbers = common.merge({
show = true,
- relative = false
+ relative = false,
+ -- The config specification used by the settings gui
+ config_spec = {
+ name = "Line Numbers",
+ {
+ label = "Show Numbers",
+ description = "Display or hide the line numbers.",
+ path = "show",
+ type = "toggle",
+ default = true
+ },
+ {
+ label = "Relative Line Numbers",
+ description = "Display relative line numbers starting from active line.",
+ path = "relative",
+ type = "toggle",
+ default = false
+ }
+ }
}, config.plugins.linenumbers)
local draw_line_gutter = DocView.draw_line_gutter
@@ -15,11 +33,7 @@ local get_width = DocView.get_gutter_width
function DocView:draw_line_gutter(line, x, y, width)
local lh = self:get_line_height()
- if
- not config.plugins.linenumbers.show
- and
- not config.plugins.linenumbers.relative
- then
+ if not config.plugins.linenumbers.show then
return lh
end
diff --git a/plugins/memoryusage.lua b/plugins/memoryusage.lua
index e06b883..a8b8005 100644
--- a/plugins/memoryusage.lua
+++ b/plugins/memoryusage.lua
@@ -1,9 +1,35 @@
-- mod-version:3 --lite-xl 2.1
-- original implementation by AqilCont
local core = require "core"
+local config = require "core.config"
+local common = require "core.common"
local style = require "core.style"
local StatusView = require "core.statusview"
+config.plugins.memoryusage = common.merge({
+ enabled = true,
+ -- The config specification used by the settings gui
+ config_spec = {
+ name = "Memory Usage",
+ {
+ label = "Enabled",
+ description = "Show or hide the lua memory usage from the status bar.",
+ path = "enabled",
+ type = "toggle",
+ default = true,
+ on_apply = function(enabled)
+ core.add_thread(function()
+ if enabled then
+ core.status_view:get_item("status:memory-usage"):show()
+ else
+ core.status_view:get_item("status:memory-usage"):hide()
+ end
+ end)
+ end
+ }
+ }
+}, config.plugins.memoryusage)
+
core.status_view:add_item(
nil,
"status:memory-usage",
diff --git a/plugins/minimap.lua b/plugins/minimap.lua
index ac86b85..932f9dd 100644
--- a/plugins/minimap.lua
+++ b/plugins/minimap.lua
@@ -7,6 +7,19 @@ local style = require "core.style"
local DocView = require "core.docview"
local Object = require "core.object"
+-- Sample configurations:
+-- 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
+
-- General plugin settings
config.plugins.minimap = common.merge({
enabled = true,
@@ -17,28 +30,127 @@ config.plugins.minimap = common.merge({
-- how many spaces one tab is equivalent to
tab_width = 4,
draw_background = true,
-
-- you can override these colors
selection_color = nil,
caret_color = nil,
-
-- If other plugins provide per-line highlights,
-- this controls the placement. (e.g. gitdiff_highlight)
highlight_align = 'left',
highlight_width = 3,
gutter_width = 5,
- -- try these values:
- -- full width:
- -- config.plugins.minimap.highlight_width = 100
- -- config.plugins.minimap.gutter_width = 0
- -- left side:
- -- config.plugins.minimap.highlight_align = 'left'
- -- config.plugins.minimap.highlight_width = 3
- -- config.plugins.minimap.gutter_width = 4
- -- right side:
- -- config.plugins.minimap.highlight_align = 'right'
- -- config.plugins.minimap.highlight_width = 5
- -- config.plugins.minimap.gutter_width = 0
+ -- The config specification used by the settings gui
+ config_spec = {
+ name = "Mini Map",
+ {
+ label = "Enabled",
+ description = "Activate the minimap by default.",
+ path = "enabled",
+ type = "toggle",
+ default = true
+ },
+ {
+ label = "Width",
+ description = "Width of the minimap in pixels.",
+ path = "width",
+ type = "number",
+ default = 100,
+ min = 50,
+ max = 1000
+ },
+ {
+ label = "Instant Scroll",
+ description = "When enabled disables the scrolling animation.",
+ path = "instant_scroll",
+ type = "toggle",
+ default = false
+ },
+ {
+ label = "Syntax Highlighting",
+ description = "Disable to improve performance.",
+ path = "syntax_highlight",
+ type = "toggle",
+ default = true
+ },
+ {
+ label = "Scale",
+ description = "Size of the minimap using a scaling factor.",
+ path = "scale",
+ type = "number",
+ default = 1,
+ min = 0.5,
+ max = 10,
+ step = 0.1
+ },
+ {
+ label = "Tabs Width",
+ description = "The amount of spaces that represent a tab.",
+ path = "tab_width",
+ type = "number",
+ default = 4,
+ min = 1,
+ max = 8
+ },
+ {
+ label = "Draw Background",
+ description = "When disabled makes the minimap transparent.",
+ path = "draw_background",
+ type = "toggle",
+ default = true
+ },
+ {
+ label = "Selection Color",
+ description = "Background color of selected text in html notation eg: #FFFFFF. Leave empty to use default.",
+ path = "selection_color_html",
+ type = "string",
+ on_apply = function(value)
+ if value and value:match("#%x%x%x%x%x%x") then
+ config.plugins.minimap.selection_color = { common.color(value) }
+ else
+ config.plugins.minimap.selection_color = nil
+ end
+ end
+ },
+ {
+ label = "Caret Color",
+ description = "Background color of active line in html notation eg: #FFFFFF. Leave empty to use default.",
+ path = "caret_color_html",
+ type = "string",
+ on_apply = function(value)
+ if value and value:match("#%x%x%x%x%x%x") then
+ config.plugins.minimap.caret_color = { common.color(value) }
+ else
+ config.plugins.minimap.caret_color = nil
+ end
+ end
+ },
+ {
+ label = "Highlight Alignment",
+ path = "highlight_align",
+ type = "selection",
+ default = "left",
+ values = {
+ {"Left", "left"},
+ {"Right", "right"}
+ }
+ },
+ {
+ label = "Highlight Width",
+ path = "highlight_width",
+ type = "number",
+ default = 3,
+ min = 0,
+ max = 50
+ },
+ {
+ label = "Gutter Width",
+ description = "Left padding of the minimap.",
+ path = "gutter_width",
+ type = "number",
+ default = 5,
+ min = 0,
+ max = 50
+ },
+ }
}, config.plugins.minimap)
-- Configure size for rendering each char in the minimap
diff --git a/plugins/motiontrail.lua b/plugins/motiontrail.lua
index fd42b5f..cc94ca9 100644
--- a/plugins/motiontrail.lua
+++ b/plugins/motiontrail.lua
@@ -5,7 +5,30 @@ local common = require "core.common"
local style = require "core.style"
local DocView = require "core.docview"
-config.plugins.motiontrail = common.merge({ steps = 50 }, config.plugins.motiontrail)
+config.plugins.motiontrail = common.merge({
+ enabled = true,
+ steps = 50,
+ -- The config specification used by the settings gui
+ config_spec = {
+ name = "Motion Trail",
+ {
+ label = "Enabled",
+ description = "Disable or enable the caret motion trail effect.",
+ path = "enabled",
+ type = "toggle",
+ default = true
+ },
+ {
+ label = "Steps",
+ description = "Amount of trail steps to generate on caret movement.",
+ path = "steps",
+ type = "number",
+ default = 50,
+ min = 10,
+ max = 100
+ },
+ }
+}, config.plugins.motiontrail)
local function lerp(a, b, t)
@@ -16,7 +39,6 @@ end
local function get_caret_rect(dv)
local line, col = dv.doc:get_selection()
local x, y = dv:get_line_screen_position(line, col)
- x = x + dv:get_col_x_offset(line, col)
return x, y, style.caret_width, dv:get_line_height()
end
@@ -27,7 +49,9 @@ local draw = DocView.draw
function DocView:draw(...)
draw(self, ...)
- if self ~= core.active_view then return end
+ if not config.plugins.motiontrail.enabled or self ~= core.active_view then
+ return
+ end
local x, y, w, h = get_caret_rect(self)
diff --git a/plugins/nonicons.lua b/plugins/nonicons.lua
index baded52..e249508 100644
--- a/plugins/nonicons.lua
+++ b/plugins/nonicons.lua
@@ -13,7 +13,40 @@ local Node = require "core.node"
config.plugins.nonicons = common.merge({
use_default_dir_icons = false,
use_default_chevrons = false,
- draw_tab_icons = true
+ draw_treeview_icons = true,
+ draw_tab_icons = true,
+ -- The config specification used by the settings gui
+ config_spec = {
+ name = "Nonicons",
+ {
+ label = "Use Default Directory Icons",
+ description = "When enabled does not use nonicon directory icons.",
+ path = "use_default_dir_icons",
+ type = "toggle",
+ default = false
+ },
+ {
+ label = "Use Default Chevrons",
+ description = "When enabled does not use nonicon expand/collapse arrow icons.",
+ path = "use_default_chevrons",
+ type = "toggle",
+ default = false
+ },
+ {
+ label = "Draw Treeview Icons",
+ description = "Enables file related icons on the treeview.",
+ path = "draw_treeview_icons",
+ type = "toggle",
+ default = true
+ },
+ {
+ label = "Draw Tab Icons",
+ description = "Adds file related icons to tabs.",
+ path = "draw_tab_icons",
+ type = "toggle",
+ default = true
+ }
+ }
}, config.plugins.nonicons)
local icon_font = renderer.font.load(USERDIR.."/fonts/nonicons.ttf", 15 * SCALE)
@@ -79,39 +112,39 @@ for k, v in pairs(known_names_icons) do
v[1] = { common.color(v[1]) }
end
--- Override function to define dir and file custom icons if setting is disabled
-if not config.plugins.nonicons.use_default_dir_icons then
- function TreeView:get_item_icon(item, active, hovered)
- local icon = "" -- unicode 61766
- if item.type == "dir" then
- icon = item.expanded and "" or "" -- unicode 61771 and 61772
- end
- return icon, icon_font, style.text
- end
-end
-
--- Override function to change default icons for special extensions and names
+-- Override function to change default icons for dirs, special extensions and names
local TreeView_get_item_icon = TreeView.get_item_icon
function TreeView:get_item_icon(item, active, hovered)
local icon, font, color = TreeView_get_item_icon(self, item, active, hovered)
- local custom_icon = known_names_icons[item.name:lower()]
- if custom_icon == nil then
- custom_icon = extension_icons[item.name:match("^.+(%..+)$")]
- end
- if custom_icon ~= nil then
- color = custom_icon[1]
- icon = custom_icon[2]
+ if not config.plugins.nonicons.use_default_dir_icons then
+ icon = "" -- unicode 61766
font = icon_font
+ color = style.text
+ if item.type == "dir" then
+ icon = item.expanded and "" or "" -- unicode 61771 and 61772
+ end
end
- if active or hovered then
- color = style.accent
+ if config.plugins.nonicons.draw_treeview_icons then
+ local custom_icon = known_names_icons[item.name:lower()]
+ if custom_icon == nil then
+ custom_icon = extension_icons[item.name:match("^.+(%..+)$")]
+ end
+ if custom_icon ~= nil then
+ color = custom_icon[1]
+ icon = custom_icon[2]
+ font = icon_font
+ end
+ if active or hovered then
+ color = style.accent
+ end
end
return icon, font, color
end
-- Override function to draw chevrons if setting is disabled
-if not config.plugins.nonicons.use_default_chevrons then
- function TreeView:draw_item_chevron(item, active, hovered, x, y, w, h)
+local TreeView_draw_item_chevron = TreeView.draw_item_chevron
+function TreeView:draw_item_chevron(item, active, hovered, x, y, w, h)
+ if not config.plugins.nonicons.use_default_chevrons then
if item.type == "dir" then
local chevron_icon = item.expanded and "" or ""
local chevron_color = hovered and style.accent or style.text
@@ -119,12 +152,13 @@ if not config.plugins.nonicons.use_default_chevrons then
end
return chevron_width + style.padding.x/4
end
+ return TreeView_draw_item_chevron(self, item, active, hovered, x, y, w, h)
end
-- Override function to draw icons in tabs titles if setting is enabled
-if config.plugins.nonicons.draw_tab_icons then
- local Node_draw_tab_title = Node.draw_tab_title
- function Node:draw_tab_title(view, font, is_active, is_hovered, x, y, w, h)
+local Node_draw_tab_title = Node.draw_tab_title
+function Node:draw_tab_title(view, font, is_active, is_hovered, x, y, w, h)
+ if config.plugins.nonicons.draw_tab_icons then
local padx = chevron_width + style.padding.x/2
local tx = x + padx -- Space for icon
w = w - padx
@@ -132,5 +166,7 @@ if config.plugins.nonicons.draw_tab_icons then
if (view == nil) or (view.doc == nil) then return end
local item = { type = "file", name = view.doc:get_name() }
TreeView:draw_item_icon(item, false, is_hovered, x, y, w, h)
+ else
+ Node_draw_tab_title(self, view, font, is_active, is_hovered, x, y, w, h)
end
end
diff --git a/plugins/openfilelocation.lua b/plugins/openfilelocation.lua
index 0328142..8e225cd 100644
--- a/plugins/openfilelocation.lua
+++ b/plugins/openfilelocation.lua
@@ -1,20 +1,33 @@
-- mod-version:3 --lite-xl 2.1
local core = require "core"
+local common = require "core.common"
local command = require "core.command"
local config = require "core.config"
-
-config.plugins.openfilelocation = {}
-if not config.plugins.openfilelocation.filemanager then
- if PLATFORM == "Windows" then
- config.plugins.openfilelocation.filemanager = "explorer"
- elseif PLATFORM == "Mac OS X" then
- config.plugins.openfilelocation.filemanager = "open"
- else
- config.plugins.openfilelocation.filemanager = "xdg-open"
- end
+local platform_filemanager
+if PLATFORM == "Windows" then
+ platform_filemanager = "explorer"
+elseif PLATFORM == "Mac OS X" then
+ platform_filemanager = "open"
+else
+ platform_filemanager = "xdg-open"
end
+config.plugins.openfilelocation = common.merge({
+ filemanager = platform_filemanager,
+ -- The config specification used by the settings gui
+ config_spec = {
+ name = "Open File Location",
+ {
+ label = "File Manager",
+ description = "Command of the file browser.",
+ path = "filemanager",
+ type = "string",
+ default = platform_filemanager
+ }
+ }
+}, config.plugins.openfilelocation)
+
command.add("core.docview", {
["open-file-location:open-file-location"] = function()
local doc = core.active_view.doc
diff --git a/plugins/openselected.lua b/plugins/openselected.lua
index c2cb3a4..7df4dba 100644
--- a/plugins/openselected.lua
+++ b/plugins/openselected.lua
@@ -7,17 +7,30 @@ local config = require "core.config"
local contextmenu = require "plugins.contextmenu"
-config.plugins.openselected = {}
-if not config.plugins.openselected.filemanager then
- 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
+local platform_filelauncher
+if PLATFORM == "Windows" then
+ platform_filelauncher = "start"
+elseif PLATFORM == "Mac OS X" then
+ platform_filelauncher = "open"
+else
+ platform_filelauncher = "xdg-open"
end
+config.plugins.openselected = common.merge({
+ filelauncher = platform_filelauncher,
+ -- The config specification used by the settings gui
+ config_spec = {
+ name = "Open Selected Text",
+ {
+ label = "File Launcher",
+ description = "Command used to open the selected path or link externally.",
+ path = "filelauncher",
+ type = "string",
+ default = platform_filelauncher
+ }
+ }
+}, config.plugins.openselected)
+
command.add("core.docview", {
["open-selected:open-selected"] = function()
local doc = core.active_view.doc
@@ -38,7 +51,7 @@ command.add("core.docview", {
core.log("Opening %s...", text)
- system.exec(config.plugins.openselected.filemanager .. " " .. text)
+ system.exec(config.plugins.openselected.filelauncher .. " " .. text)
end,
})
diff --git a/plugins/rainbowparen.lua b/plugins/rainbowparen.lua
index 0f63473..1df56ed 100644
--- a/plugins/rainbowparen.lua
+++ b/plugins/rainbowparen.lua
@@ -11,15 +11,24 @@ config.plugins.rainbowparen = common.merge({
enable = true
}, config.plugins.rainbowparen)
+style.syntax.paren_unbalanced = style.syntax.paren_unbalanced or { common.color "#DC0408" }
+style.syntax.paren1 = style.syntax.paren1 or { common.color "#FC6F71"}
+style.syntax.paren2 = style.syntax.paren2 or { common.color "#fcb053"}
+style.syntax.paren3 = style.syntax.paren3 or { common.color "#fcd476"}
+style.syntax.paren4 = style.syntax.paren4 or { common.color "#52dab2"}
+style.syntax.paren5 = style.syntax.paren5 or { common.color "#5a98cf"}
+
local tokenize = tokenizer.tokenize
local closers = {
["("] = ")",
["["] = "]",
["{"] = "}"
}
+
local function parenstyle(parenstack)
return "paren" .. ((#parenstack % 5) + 1)
end
+
function tokenizer.tokenize(syntax, text, state)
if not config.plugins.rainbowparen.enable then
return tokenize(syntax, text, state)
@@ -62,20 +71,31 @@ function tokenizer.tokenize(syntax, text, state)
return newres, { parenstack = parenstack, istate = istate }
end
-style.syntax.paren_unbalanced = style.syntax.paren_unbalanced or { common.color "#DC0408" }
-style.syntax.paren1 = style.syntax.paren1 or { common.color "#FC6F71"}
-style.syntax.paren2 = style.syntax.paren2 or { common.color "#fcb053"}
-style.syntax.paren3 = style.syntax.paren3 or { common.color "#fcd476"}
-style.syntax.paren4 = style.syntax.paren4 or { common.color "#52dab2"}
-style.syntax.paren5 = style.syntax.paren5 or { common.color "#5a98cf"}
+local function toggle_rainbowparen(enabled)
+ config.plugins.rainbowparen.enable = enabled
+ for _, doc in ipairs(core.docs) do
+ doc.highlighter = Highlighter(doc)
+ doc:reset_syntax()
+ end
+end
+-- The config specification used by the settings gui
+config.plugins.rainbowparen.config_spec = {
+ name = "Rainbow Parentheses",
+ {
+ label = "Enable",
+ description = "Activates rainbow parenthesis coloring by default.",
+ path = "enable",
+ type = "toggle",
+ default = true,
+ on_apply = function(enabled)
+ toggle_rainbowparen(enabled)
+ end
+ }
+}
command.add(nil, {
["rainbow-parentheses:toggle"] = function()
- config.plugins.rainbowparen.enable = not config.plugins.rainbowparen.enable
- for _, doc in ipairs(core.docs) do
- doc.highlighter = Highlighter(doc)
- doc:reset_syntax()
- end
+ toggle_rainbowparen(not config.plugins.rainbowparen.enable)
end
})
diff --git a/plugins/scalestatus.lua b/plugins/scalestatus.lua
index 85774a8..2379ed4 100644
--- a/plugins/scalestatus.lua
+++ b/plugins/scalestatus.lua
@@ -11,10 +11,30 @@ local config = require "core.config"
local scale = require "plugins.scale"
local StatusView = require "core.statusview"
-config.plugins.scalestatus = common.merge(
- { format = '%.0f%%' },
- config.plugins.scalestatus
-)
+config.plugins.scalestatus = common.merge({
+ enabled = true,
+ format = '%.0f%%',
+ -- The config specification used by the settings gui
+ config_spec = {
+ name = "Scale Status",
+ {
+ label = "Enabled",
+ description = "Show or hide the scale status from the status bar.",
+ path = "enabled",
+ type = "toggle",
+ default = true,
+ on_apply = function(enabled)
+ core.add_thread(function()
+ if enabled then
+ core.status_view:get_item("status:scale"):show()
+ else
+ core.status_view:get_item("status:scale"):hide()
+ end
+ end)
+ end
+ }
+ }
+}, config.plugins.scalestatus)
core.status_view:add_item(
nil,
diff --git a/plugins/smallclock.lua b/plugins/smallclock.lua
index 201a65a..7bc756c 100644
--- a/plugins/smallclock.lua
+++ b/plugins/smallclock.lua
@@ -1,15 +1,55 @@
-- mod-version:3 --lite-xl 2.1
local core = require "core"
+local config = require "core.config"
+local common = require "core.common"
local style = require "core.style"
local StatusView = require "core.statusview"
+config.plugins.smallclock = common.merge({
+ enabled = true,
+ clock_type = "24",
+ -- The config specification used by the settings gui
+ config_spec = {
+ name = "Small Clock",
+ {
+ label = "Enabled",
+ description = "Show or hide the small clock from the status bar.",
+ path = "enabled",
+ type = "toggle",
+ default = true,
+ on_apply = function(enabled)
+ core.add_thread(function()
+ if enabled then
+ core.status_view:get_item("status:small-clock"):show()
+ else
+ core.status_view:get_item("status:small-clock"):hide()
+ end
+ end)
+ end
+ },
+ {
+ label = "Clock Type",
+ description = "Choose between 12 or 24 hours clock mode.",
+ path = "clock_type",
+ type = "selection",
+ default = "24",
+ values = {
+ {"24 Hours", "24"},
+ {"12 Hours", "12"}
+ }
+ }
+ }
+}, config.plugins.smallclock)
+
local time = ""
local last_time = os.time()
local function update_time()
if os.time() > last_time then
- local t = os.date("*t")
- time = string.format("%02d:%02d", t.hour, t.min)
+ local h = config.plugins.smallclock.clock_type == "24"
+ and os.date("%H") or os.date("%I")
+ local m = os.date("%M")
+ time = string.format("%02d:%02d", h, m)
last_time = os.time()
end
end
diff --git a/plugins/smoothcaret.lua b/plugins/smoothcaret.lua
index 75ee769..3a30d5b 100644
--- a/plugins/smoothcaret.lua
+++ b/plugins/smoothcaret.lua
@@ -5,12 +5,38 @@ local style = require "core.style"
local common = require "core.common"
local DocView = require "core.docview"
-config.plugins.smoothcaret = common.merge({ rate = 0.65 }, config.plugins.smoothcaret)
+config.plugins.smoothcaret = common.merge({
+ enabled = true,
+ rate = 0.65,
+ -- The config specification used by the settings gui
+ config_spec = {
+ name = "Smooth Caret",
+ {
+ label = "Enabled",
+ description = "Disable or enable the smooth caret animation.",
+ path = "enabled",
+ type = "toggle",
+ default = true
+ },
+ {
+ label = "Rate",
+ description = "Speed of the animation.",
+ path = "rate",
+ type = "number",
+ default = 0.65,
+ min = 0.2,
+ max = 1.0,
+ step = 0.05
+ },
+ }
+}, config.plugins.smoothcaret)
local docview_update = DocView.update
function DocView:update()
docview_update(self)
+ if not config.plugins.smoothcaret.enabled then return end
+
local minline, maxline = self:get_visible_line_range()
-- We need to keep track of all the carets
@@ -73,7 +99,13 @@ function DocView:update()
self.caret_idx = 1
end
+local docview_draw_caret = DocView.draw_caret
function DocView:draw_caret(x, y)
+ if not config.plugins.smoothcaret.enabled then
+ docview_draw_caret(self, x, y)
+ return
+ end
+
local c = self.visible_carets[self.caret_idx] or { current = { x = x, y = y } }
local lh = self:get_line_height()
diff --git a/plugins/spellcheck.lua b/plugins/spellcheck.lua
index 45f0e76..0f79cab 100644
--- a/plugins/spellcheck.lua
+++ b/plugins/spellcheck.lua
@@ -7,35 +7,42 @@ local common = require "core.common"
local DocView = require "core.docview"
local Doc = require "core.doc"
+local platform_dictionary_file
+if PLATFORM == "Windows" then
+ platform_dictionary_file = EXEDIR .. "/words.txt"
+else
+ platform_dictionary_file = "/usr/share/dict/words"
+end
+
config.plugins.spellcheck = common.merge({
- enable = true,
+ enabled = true,
files = { "%.txt$", "%.md$", "%.markdown$" },
- dictionary_file = PLATFORM == "Windows"
- and EXEDIR .. "/words.txt"
- or "/usr/share/dict/words"
+ dictionary_file = platform_dictionary_file
}, config.plugins.spellcheck)
local last_input_time = 0
local word_pattern = "%a+"
local words
-core.add_thread(function()
- local t = {}
- local i = 0
- for line in io.lines(config.plugins.spellcheck.dictionary_file) do
- for word in line:gmatch(word_pattern) do
- t[word:lower()] = true
+local function load_dictionary()
+ core.add_thread(function()
+ local t = {}
+ local i = 0
+ for line in io.lines(config.plugins.spellcheck.dictionary_file) do
+ for word in line:gmatch(word_pattern) do
+ t[word:lower()] = true
+ end
+ i = i + 1
+ if i % 1000 == 0 then coroutine.yield() end
end
- i = i + 1
- if i % 1000 == 0 then coroutine.yield() end
- end
- words = t
- core.redraw = true
- core.log_quiet(
- "Finished loading dictionary file: \"%s\"",
- config.plugins.spellcheck.dictionary_file
- )
-end)
+ words = t
+ core.redraw = true
+ core.log_quiet(
+ "Finished loading dictionary file: \"%s\"",
+ config.plugins.spellcheck.dictionary_file
+ )
+ end)
+end
local function matches_any(filename, ptns)
@@ -67,7 +74,7 @@ function DocView:draw_line_text(idx, x, y)
local lh = draw_line_text(self, idx, x, y)
if
- not config.plugins.spellcheck.enable
+ not config.plugins.spellcheck.enabled
or
not words
or
@@ -120,10 +127,41 @@ local function compare_words(word1, word2)
end
+-- The config specification used by the settings gui
+config.plugins.spellcheck.config_spec = {
+ name = "Spell Check",
+ {
+ label = "Enabled",
+ description = "Disable or enable spell checking.",
+ path = "enabled",
+ type = "toggle",
+ default = true
+ },
+ {
+ label = "Files",
+ description = "List of Lua patterns matching files to spell check.",
+ path = "files",
+ type = "list_strings",
+ default = { "%.txt$", "%.md$", "%.markdown$" }
+ },
+ {
+ label = "Dictionary File",
+ description = "Path to a text file that contains a list of dictionary words.",
+ path = "dictionary_file",
+ type = "string",
+ default = platform_dictionary_file,
+ on_apply = function()
+ load_dictionary()
+ end
+ }
+}
+
+load_dictionary()
+
command.add("core.docview", {
["spell-check:toggle"] = function()
- config.plugins.spellcheck.enable = not config.plugins.spellcheck.enable
+ config.plugins.spellcheck.enabled = not config.plugins.spellcheck.enabled
end,
["spell-check:add-to-dictionary"] = function()
diff --git a/plugins/statusclock.lua b/plugins/statusclock.lua
index d39ca63..6d37b37 100644
--- a/plugins/statusclock.lua
+++ b/plugins/statusclock.lua
@@ -6,8 +6,43 @@ local common = require "core.common"
local StatusView = require "core.statusview"
config.plugins.statusclock = common.merge({
+ enabled = true,
time_format = "%H:%M:%S",
- date_format = "%A, %d %B %Y"
+ date_format = "%A, %d %B %Y",
+ -- The config specification used by the settings gui
+ config_spec = {
+ name = "Status Clock",
+ {
+ label = "Enabled",
+ description = "Show or hide the clock from the status bar.",
+ path = "enabled",
+ type = "toggle",
+ default = true,
+ on_apply = function(enabled)
+ core.add_thread(function()
+ if enabled then
+ core.status_view:get_item("status:clock"):show()
+ else
+ core.status_view:get_item("status:clock"):hide()
+ end
+ end)
+ end
+ },
+ {
+ label = "Time Format",
+ description = "Time specification defined with Lua date/time place holders.",
+ path = "time_format",
+ type = "string",
+ default = "%H:%M:%S"
+ },
+ {
+ label = "Date Format",
+ description = "Date specification defined with Lua date/time place holders.",
+ path = "date_format",
+ type = "string",
+ default = "%A, %d %B %Y",
+ }
+ }
}, config.plugins.statusclock)
local time_data = {
diff --git a/plugins/tabnumbers.lua b/plugins/tabnumbers.lua
index 1656100..3a842b7 100644
--- a/plugins/tabnumbers.lua
+++ b/plugins/tabnumbers.lua
@@ -1,28 +1,44 @@
-- mod-version:3 --lite-xl 2.1
+local config = require "core.config"
local common = require "core.common"
-local core = require "core"
local style = require "core.style"
+local Node = require "core.node"
--- quite hackish, but Node isn't normally public
-local Node = getmetatable(core.root_view.root_node)
-local draw_tabs = Node.draw_tabs
+config.plugins.tabnumbers = common.merge({
+ enabled = true,
+ -- The config specification used by the settings gui
+ config_spec = {
+ name = "Tab Numbers",
+ {
+ label = "Draw Tab Numbers",
+ description = "Show or hide numbers on the interface tabs.",
+ path = "enabled",
+ type = "toggle",
+ default = true
+ }
+ }
+}, config.plugins.tabnumbers)
-function Node:draw_tabs(...)
- draw_tabs(self, ...)
-
- for i, view in ipairs(self.views) do
- if i > 9 then break end
-
- local x, y, w, h = self:get_tab_rect(i)
- local number = tostring(i)
- local color = style.dim
- local title_width = style.font:get_width(view:get_name())
- local free_real_estate =
- math.min(math.max((w - title_width) / 2, style.padding.x), h)
- if view == self.active_view then
- color = style.accent
+-- Overwrite draw_tab_title to prepend tab number
+local Node_draw_tab_title = Node.draw_tab_title
+function Node:draw_tab_title(view, font, is_active, is_hovered, x, y, w, h)
+ if config.plugins.tabnumbers.enabled then
+ local number = ""
+ for i, v in ipairs(self.views) do
+ if view == v then
+ number = tostring(i)
+ end
+ end
+ local padx = 0
+ if number ~= "" then
+ padx = style.font:get_width(number) + (style.padding.x / 2)
+ w = w - padx
+ local color = is_active and style.text or style.dim
+ common.draw_text(style.font, color, number, nil, x, y, w, h)
end
- -- renderer.draw_rect(x, y + h - 1, free_real_estate, 1, color)
- common.draw_text(style.font, color, number, "center", x, y, free_real_estate, h)
+ local tx = x + padx -- Space for number
+ Node_draw_tab_title(self, view, font, is_active, is_hovered, tx, y, w, h)
+ else
+ Node_draw_tab_title(self, view, font, is_active, is_hovered, x, y, w, h)
end
end
diff --git a/plugins/titleize.lua b/plugins/titleize.lua
index 179e52b..b329671 100644
--- a/plugins/titleize.lua
+++ b/plugins/titleize.lua
@@ -9,4 +9,3 @@ command.add("core.docview", {
end)
end,
})
-
diff --git a/plugins/typingspeed.lua b/plugins/typingspeed.lua
index 62e44ef..d639252 100644
--- a/plugins/typingspeed.lua
+++ b/plugins/typingspeed.lua
@@ -6,17 +6,38 @@ local common = require "core.common"
local config = require "core.config"
local DocView = require "core.docview"
-if common["merge"] then
- config.plugins.typingspeed = common.merge({
- -- characters that should be counted as word boundary
- word_boundaries = "[%p%s]",
- }, config.plugins.keystats)
-else
- config.plugins.typingspeed = {
- -- characters that should be counted as word boundary
- word_boundaries = "[%p%s]",
- }
-end
+config.plugins.typingspeed = common.merge({
+ enabled = true,
+ -- characters that should be counted as word boundary
+ word_boundaries = "[%p%s]",
+ -- The config specification used by the settings gui
+ config_spec = {
+ name = "Typing Speed",
+ {
+ label = "Enabled",
+ description = "Show or hide the typing speed from the status bar.",
+ path = "enabled",
+ type = "toggle",
+ default = true,
+ on_apply = function(enabled)
+ core.add_thread(function()
+ if enabled then
+ core.status_view:get_item("typing-speed:stats"):show()
+ else
+ core.status_view:get_item("typing-speed:stats"):hide()
+ end
+ end)
+ end
+ },
+ {
+ label = "Word Boundaries",
+ description = "Lua pattern that matches characters to separate words.",
+ path = "word_boundaries",
+ type = "string",
+ default = "[%p%s]"
+ }
+ }
+}, config.plugins.typingspeed)
local chars = 0
local chars_last = 0
@@ -29,65 +50,51 @@ local wpm = 0
core.add_thread(function()
while true do
- local t = os.date("*t")
- if t.sec <= time_last then
- words_last = words
- words = 0
- chars_last = chars
- chars = 0
- time_last = t.sec
- end
- wpm = words_last * (1-(t.sec)/60) + words
- cpm = chars_last * (1-(t.sec)/60) + chars
+ if config.plugins.typingspeed.enabled then
+ local t = os.date("*t")
+ if t.sec <= time_last then
+ words_last = words
+ words = 0
+ chars_last = chars
+ chars = 0
+ time_last = t.sec
+ end
+ wpm = words_last * (1-(t.sec)/60) + words
+ cpm = chars_last * (1-(t.sec)/60) + chars
+ end
coroutine.yield(1)
end
end)
local on_text_input = DocView.on_text_input
function DocView:on_text_input(text, idx)
- chars = chars + 1
- if string.find(text, config.plugins.typingspeed.word_boundaries) then
- if started_word then
- words = words + 1
- started_word = false
- end
- else
- started_word = true
- end
+ if config.plugins.typingspeed.enabled then
+ chars = chars + 1
+ if string.find(text, config.plugins.typingspeed.word_boundaries) then
+ if started_word then
+ words = words + 1
+ started_word = false
+ end
+ else
+ started_word = true
+ end
+ end
on_text_input(self, text, idx)
end
-if core.status_view["add_item"] then
- core.status_view:add_item(
- function()
- return core.active_view and getmetatable(core.active_view) == DocView
- end,
- "keystats:stats",
- core.status_view.Item.RIGHT,
- function()
- return {
- style.text,
- string.format("%.0f CPM / %.0f WPM", cpm, wpm)
- }
- end,
- nil,
- 1,
- "characters / words per minute"
- ).separator = core.status_view.separator2
-else
- local get_items = core.status_view.get_items
- function core.status_view:get_items()
- local left, right = get_items(self)
-
- local t = {
- style.text, string.format("%.0f CPM / %.0f WPM", cpm, wpm),
- style.dim, self.separator2
- }
-
- for i, item in ipairs(t) do
- table.insert(right, i, item)
- end
-
- return left, right
- end
-end
+core.status_view:add_item(
+ function()
+ return core.active_view and getmetatable(core.active_view) == DocView
+ end,
+ "typing-speed:stats",
+ core.status_view.Item.RIGHT,
+ function()
+ return {
+ style.text,
+ string.format("%.0f CPM / %.0f WPM", cpm, wpm)
+ }
+ end,
+ nil,
+ 1,
+ "characters / words per minute"
+).separator = core.status_view.separator2