diff options
-rw-r--r-- | README.md | 25 | ||||
-rw-r--r-- | plugins/drawwhitespace.lua | 7 | ||||
-rw-r--r-- | plugins/inanimate.lua | 12 | ||||
-rw-r--r-- | plugins/indentguide.lua | 10 | ||||
-rw-r--r-- | plugins/language_sass.lua | 45 | ||||
-rw-r--r-- | plugins/lineguide.lua | 4 | ||||
-rw-r--r-- | plugins/projectmanager.lua | 128 | ||||
-rw-r--r-- | plugins/scale.lua | 8 | ||||
-rw-r--r-- | plugins/workspace.lua | 164 |
9 files changed, 77 insertions, 326 deletions
@@ -1,10 +1,12 @@ -Plugins for the [lite text editor](https://github.com/rxi/lite) +Plugins for [Lite XL](https://github.com/franko/lite-xl) *Note: if you make a pull request, the table should be updated and kept in alphabetical order. If your plugin is large (or you'd otherwise prefer it to have its own repo), the table can simply be updated to add a link to the repo; otherwise the plugin file itself can be submitted. If a plugin's link resolves -to something other than a raw file it should be marked with an asterisk.* +to something other than a raw file it should be marked with an asterisk. +If a plugin has modifications specific to Lite XL or is otherwise incompatible +with the official version of lite, format the name in italic.* --- @@ -18,12 +20,12 @@ Plugin | Description [`centerdoc`](plugins/centerdoc.lua?raw=1) | Centers document's content on the screen *([screenshot](https://user-images.githubusercontent.com/3920290/82127896-bf6e4500-97ae-11ea-97fc-ba9a552bc9a4.png))* [`closeconfirmx`](plugins/closeconfirmx.lua?raw=1) | Replaces a system close confirmation dialog with a command view, like for individual files *([screenshot](https://user-images.githubusercontent.com/1689801/107596774-afa76280-6c53-11eb-80ab-22e73058c097.png))* [`colorpreview`](plugins/colorpreview.lua?raw=1) | Underlays color values (eg. `#ff00ff` or `rgb(255, 0, 255)`) with their resultant color. *([screenshot](https://user-images.githubusercontent.com/3920290/80743752-731bd780-8b15-11ea-97d3-847db927c5dc.png))* -[`console`](https://github.com/rxi/console)* | A console for running external commands and capturing their output *([gif](https://user-images.githubusercontent.com/3920290/81343656-49325a00-90ad-11ea-8647-ff39d8f1d730.gif))* +*[`console`](https://github.com/franko/console)* | A console for running external commands and capturing their output *([gif](https://user-images.githubusercontent.com/3920290/81343656-49325a00-90ad-11ea-8647-ff39d8f1d730.gif))* [`copyfilelocation`](plugins/copyfilelocation.lua?raw=1) | Copy file location to clipboard [`datetimestamps`](plugins/datetimestamps.lua?raw=1) | Insert date-, time- and date-time-stamps -[`detectindent`](plugins/detectindent.lua?raw=1) | Automatically detects and uses the indentation size and tab type of a loaded file +~~[`detectindent`](plugins/detectindent.lua?raw=1)~~ | Included with lite-xl ~~Automatically detects and uses the indentation size and tab type of a loaded file~~ [`dragdropselected`](plugins/dragdropselected.lua?raw=1) | Provides basic drag and drop of selected text (in same document) -[`drawwhitespace`](plugins/drawwhitespace.lua?raw=1) | Draws tabs and spaces *([screenshot](https://user-images.githubusercontent.com/3920290/80573013-22ae5800-89f7-11ea-9895-6362a1c0abc7.png))* +*[`drawwhitespace`](plugins/drawwhitespace.lua?raw=1)* | Draws tabs and spaces *([screenshot](https://user-images.githubusercontent.com/3920290/80573013-22ae5800-89f7-11ea-9895-6362a1c0abc7.png))* [`eofnewline`](https://github.com/bokunodev/lite_modules/blob/master/plugins/eofnewline.lua?raw=1) | Make sure the file ends with one blank line. [`eval`](plugins/eval.lua?raw=1) | Replaces selected Lua code with its evaluated result [`exec`](plugins/exec.lua?raw=1) | Runs selected text through shell command and replaces with result @@ -33,8 +35,8 @@ Plugin | Description [`gofmt`](plugins/gofmt.lua?raw=1) | Auto-formats the current go file, adds the missing imports and the missing return cases [`hidelinenumbers`](plugins/hidelinenumbers.lua?raw=1) | Hides the line numbers on the left of documents *([screenshot](https://user-images.githubusercontent.com/3920290/81692043-b8b19c00-9455-11ea-8d74-ad99be4b9c5f.png))* [`hidestatus`](plugins/hidestatus.lua?raw=1) | Hides the status bar at the bottom of the window -[`inanimate`](plugins/inanimate.lua?raw=1) | Disables all transition animations -[`indentguide`](plugins/indentguide.lua?raw=1) | Adds indent guides *([screenshot](https://user-images.githubusercontent.com/3920290/79640716-f9860000-818a-11ea-9c3b-26d10dd0e0c0.png))* +~~[`inanimate`](plugins/inanimate.lua?raw=1)~~ | Integrated in lite-xl using `config.transitions = false` ~~Disables all transition animations~~ +*[`indentguide`](plugins/indentguide.lua?raw=1)* | Adds indent guides *([screenshot](https://user-images.githubusercontent.com/3920290/79640716-f9860000-818a-11ea-9c3b-26d10dd0e0c0.png))* [`language_angelscript`](plugins/language_angelscript.lua?raw=1) | Syntax for the [Angelscript](https://www.angelcode.com/angelscript/) programming language [`language_batch`](plugins/language_batch.lua?raw=1) | Syntax for Windows [Batch Files](https://en.wikipedia.org/wiki/Batch_file) [`language_cmake`](plugins/language_cmake.lua?raw=1) | Syntax for the CMake build system language @@ -65,6 +67,7 @@ Plugin | Description [`language_powershell`](plugins/language_powershell.lua?raw=1) | Syntax for [PowerShell](https://docs.microsoft.com/en-us/powershell) scripting language [`language_psql`](plugins/language_psql.lua?raw=1) | Syntax for the postgresql database access language [`language_rust`](plugins/language_rust.lua?raw=1) | Syntax for the [Rust](https://rust-lang.org/) programming language +[`language sass`](plugins/language_sass.lua?raw=1) | Syntax for the [Sass](https://sass-lang.com/) CSS preprocessor [`language_sh`](plugins/language_sh.lua?raw=1) | Syntax for shell scripting language [`language_teal`](plugins/language_teal.lua?raw=1) | Syntax for the [Teal](https://github.com/teal-language/tl) programming language, a typed dialect of Lua. [`language_tex`](plugins/language_tex.lua?raw=1) | Syntax for the [LaTeX](https://www.latex-project.org/) typesetting language @@ -72,7 +75,7 @@ Plugin | Description [`lastproject`](plugins/lastproject.lua?raw=1) | Loads the last loaded project if lite is launched without any arguments [`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 -[`lineguide`](plugins/lineguide.lua?raw=1) | Displays a line-guide at the line limit offset *([screenshot](https://user-images.githubusercontent.com/3920290/81476159-2cf70000-9208-11ea-928b-9dae3884c477.png))* +[*`lineguide`*](plugins/lineguide.lua?raw=1) | Displays a line-guide at the line limit offset *([screenshot](https://user-images.githubusercontent.com/3920290/81476159-2cf70000-9208-11ea-928b-9dae3884c477.png))* [`linter`](https://github.com/drmargarido/linters)* | Linters for multiple languages [`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))* [`macmodkeys`](plugins/macmodkeys.lua?raw=1) | Remaps mac modkeys `command/option` to `ctrl/alt` @@ -81,9 +84,9 @@ Plugin | Description [`nagbar`](https://github.com/takase1121/lite-nagbar)* | consistent and _beautiful_ confirmation dialogs for lite and lite-xl *([gif](https://raw.githubusercontent.com/takase1121/lite-nagbar/master/assets/preview.gif))* [`openfilelocation`](plugins/openfilelocation.lua?raw=1) | Opens the parent directory of the current file in the file manager [`openselected`](plugins/openselected.lua?raw=1) | Opens the selected filename or url -[`projectmanager`](plugins/projectmanager.lua?raw=1) | Save projects and load/reload them quickly +~~[`projectmanager`](plugins/projectmanager.lua?raw=1)~~ | Integrated in lite-xl with improvements ~~Save projects and load/reload them quickly~~ [`rainbowparen`](plugins/rainbowparen.lua?raw=1) | Show nesting of parentheses with rainbow colours -[`scale`](plugins/scale.lua?raw=1) | Provides support for dynamically adjusting the scale of the code font / UI (`ctrl+-`, `ctrl+=`) +*[`scale`](plugins/scale.lua?raw=1)* | Provides support for dynamically adjusting the scale of the code font / UI (`ctrl+-`, `ctrl+=`) [`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))* [`sort`](plugins/sort.lua?raw=1) | Sorts selected lines alphabetically @@ -95,4 +98,4 @@ Plugin | Description [`todotreeview`](https://github.com/drmargarido/TodoTreeView)* | Todo tree viewer for annotations in code like `TODO`, `BUG`, `FIX`, `IMPROVEMENT` [`togglesnakecamel`](plugins/togglesnakecamel.lua?raw=1) | Toggles symbols between `snake_case` and `camelCase` [`unboundedscroll`](plugins/unboundedscroll.lua?raw=1) | Allows scrolling outside the bounds of a document -[`workspace`](plugins/workspace.lua?raw=1) | Retains project's layout and open documents between sessions +~~[`workspace`](plugins/workspace.lua?raw=1)~~ | Integrated in lite-xl ~~Retains project's layout and open documents between sessions~~ diff --git a/plugins/drawwhitespace.lua b/plugins/drawwhitespace.lua index c6ed07d..4e2e109 100644 --- a/plugins/drawwhitespace.lua +++ b/plugins/drawwhitespace.lua @@ -16,17 +16,18 @@ function DocView:draw_line_text(idx, x, y) if not config.draw_whitespace then return end local text = self.doc.lines[idx] - local tx, ty = x, y + self:get_line_text_y_offset() local font = self:get_font() + local ss = font:subpixel_scale() + local tx, ty = ss * x, y + self:get_line_text_y_offset() local color = style.whitespace or style.syntax.comment local map = config.whitespace_map for chr in common.utf8_chars(text) do local rep = map[chr] if rep then - renderer.draw_text(font, rep, tx, ty, color) + renderer.draw_text_subpixel(font, rep, tx, ty, color) end - tx = tx + font:get_width(chr) + tx = tx + font:get_width_subpixel(chr) end end diff --git a/plugins/inanimate.lua b/plugins/inanimate.lua deleted file mode 100644 index a01aa40..0000000 --- a/plugins/inanimate.lua +++ /dev/null @@ -1,12 +0,0 @@ -local core = require "core" -local View = require "core.view" - -function View:move_towards(t, k, dest) - if type(t) ~= "table" then - return self:move_towards(self, t, k, dest) - end - if t[k] ~= dest then - core.redraw = true - end - t[k] = dest -end diff --git a/plugins/indentguide.lua b/plugins/indentguide.lua index daf7d8b..db57f9e 100644 --- a/plugins/indentguide.lua +++ b/plugins/indentguide.lua @@ -34,12 +34,16 @@ local draw_line_text = DocView.draw_line_text function DocView:draw_line_text(idx, x, y) local spaces = get_line_indent_guide_spaces(self.doc, idx) - local sw = self:get_font():get_width(" ") local w = math.ceil(1 * SCALE) local h = self:get_line_height() - for i = 0, spaces - 1, config.indent_size do + local sspaces = "" + local font = self:get_font() + local ss = font:subpixel_scale() + for _ = 0, spaces - 1, config.indent_size do local color = style.guide or style.selection - renderer.draw_rect(x + sw * i, y, w, h, color) + local sw = font:get_width_subpixel(sspaces) / ss + renderer.draw_rect(x + sw, y, w, h, color) + sspaces = sspaces .. (' '):rep(config.indent_size) end draw_line_text(self, idx, x, y) end diff --git a/plugins/language_sass.lua b/plugins/language_sass.lua new file mode 100644 index 0000000..5b043c1 --- /dev/null +++ b/plugins/language_sass.lua @@ -0,0 +1,45 @@ +local syntax = require "core.syntax" + +syntax.add { + files = { "%.sass$" }, + comment = "//", + patterns = { + { pattern = "/[/%*].-\n", type = "comment" }, + { pattern = { '"', '"', '\\' }, type = "string" }, + { pattern = { "'", "'", '\\' }, type = "string" }, + { pattern = "$%w+", type = "keyword" }, + { pattern = "@%w+", type = "literal" }, + { pattern = "[#,]%w+", type = "function" }, + { pattern = "&", type = "keyword2" }, + { pattern = "[:%/%*%-]", type = "operator" }, + { pattern = "[%a][%w-]*%s*%f[:]", type = "keyword2" }, + { pattern = "-?%d+[%d%.]*p[xt]", type = "number" }, + { pattern = "-?%d+[%d%.]*deg", type = "number" }, + { pattern = "-?%d+[%d%.]*[s%%]", type = "number" }, + { pattern = "-?%d+[%d%.]*", type = "number" }, + { pattern = "[%a_][%w_]*", type = "symbol" }, + }, + symbols = { + ["transparent"] = "literal", + ["none"] = "literal", + ["absolute"] = "literal", + ["relative"] = "literal", + ["solid"] = "literal", + ["flex"] = "literal", + ["flex-start"] = "literal", + ["flex-end"] = "literal", + ["row"] = "literal", + ["center"] = "literal", + ["column"] = "literal", + ["pointer"] = "literal", + ["ease"] = "literal", + ["white"] = "function", + ["black"] = "function", + ["gray"] = "function", + ["blue"] = "function", + ["red"] = "function", + ["purple"] = "function", + ["green"] = "function", + ["yellow"] = "function" + } +} diff --git a/plugins/lineguide.lua b/plugins/lineguide.lua index fc24567..7669c52 100644 --- a/plugins/lineguide.lua +++ b/plugins/lineguide.lua @@ -7,7 +7,9 @@ local draw = DocView.draw function DocView:draw(...) draw(self, ...) - local offset = self:get_font():get_width("n") * config.line_limit + local ns = ("n"):rep(config.line_limit) + local ss = self:get_font():subpixel_scale() + local offset = self:get_font():get_width_subpixel(ns) / ss local x = self:get_line_screen_position(1) + offset local y = self.position.y local w = math.ceil(SCALE * 1) diff --git a/plugins/projectmanager.lua b/plugins/projectmanager.lua deleted file mode 100644 index b5a66e3..0000000 --- a/plugins/projectmanager.lua +++ /dev/null @@ -1,128 +0,0 @@ -local project_manager = {} - -local core = require "core" -local command = require "core.command" -local common = require "core.common" -local keymap = require "core.keymap" - -local projects_file = ".lite_projects.lua" - -project_manager.projects = {} - -local function load_projects() - local ok, t = pcall(dofile, EXEDIR .. "/" .. projects_file) - if ok then project_manager.projects = t end -end - -load_projects() - -local function serialize(val) - if type(val) == "string" then - return string.format("%q", val) - elseif type(val) == "table" then - local t = {} - for k, v in pairs(val) do - table.insert(t, "[" .. serialize(k) .. "]=" .. serialize(v)) - end - return "{" .. table.concat(t, ",") .. "}" - end - return tostring(val) -end - -local function save_projects() - local fp = io.open(EXEDIR .. "/" .. projects_file, "w") - if fp then - fp:write("return ", serialize(project_manager.projects), "\n") - fp:close() - end -end - -local function path_base_name(str) - local pattern = "[\\/]?([^\\/]+)[\\/]?$" - return str:match(pattern) -end - -function project_manager.add_project() - local proj_dir = system.absolute_path(".") - local proj_name = path_base_name(proj_dir) - core.command_view:set_text(proj_name) - core.command_view:enter("Project Name", - function(text) - if text then - project_manager.projects[text] = proj_dir - save_projects() - end - end) -end - -local function get_project_names() - local t = {} - for k, v in pairs(project_manager.projects) do table.insert(t, k) end - return t -end - -local function project_lister(func) - local projects = get_project_names(); - core.command_view:enter("Open Project", func, function(text) - local res = common.fuzzy_match(projects, text) - for i, name in ipairs(res) do - res[i] = { - text = name, - info = project_manager.projects[name], - } - end - return res - end) -end - -function project_manager.rename_project(func) - project_lister(function(text, item) - if item then - core.command_view:set_text(item.text) - core.command_view:enter("Rename ".. item.text, - function(_text) - if _text then - project_manager.projects[_text] = project_manager.projects[item.text] - project_manager.projects[item.text] = nil - save_projects() - end - end) - end - end) -end - -function project_manager.open_project() - project_lister(function(text, item) - if item then - system.exec(string.format("%q %q", EXEFILE, item.info)) - end - end) -end - -function project_manager.switch_project() - project_lister(function(text, item) - if item then - system.exec(string.format("%q %q", EXEFILE, item.info)) - os.exit() - end - end) -end - -function project_manager.remove_project() - project_lister(function(text, item) - if item then - project_manager.projects[item.text] = nil - save_projects() - end - end) -end - -command.add(nil, { - ["project-manager:open-project"] = project_manager.open_project, - ["project-manager:switch-project"] = project_manager.switch_project, - ["project-manager:add-project"] = project_manager.add_project, - ["project-manager:remove-project"] = project_manager.remove_project, - ["project-manager:rename-project"] = project_manager.rename_project, - }) - -return project_manager diff --git a/plugins/scale.lua b/plugins/scale.lua index 5dfa699..9d9ea73 100644 --- a/plugins/scale.lua +++ b/plugins/scale.lua @@ -13,10 +13,10 @@ config.scale_use_mousewheel = true local font_cache = setmetatable({}, { __mode = "k" }) -- the following should be kept in sync with core.style's default font settings -font_cache[style.font] = { EXEDIR .. "/data/fonts/font.ttf", 14 * SCALE } -font_cache[style.big_font] = { EXEDIR .. "/data/fonts/font.ttf", 34 * SCALE } -font_cache[style.icon_font] = { EXEDIR .. "/data/fonts/icons.ttf", 14 * SCALE } -font_cache[style.code_font] = { EXEDIR .. "/data/fonts/monospace.ttf", 13.5 * SCALE } +font_cache[style.font] = { DATADIR .. "/fonts/font.ttf", 14 * SCALE } +font_cache[style.big_font] = { DATADIR .. "/fonts/font.ttf", 34 * SCALE } +font_cache[style.icon_font] = { DATADIR .. "/fonts/icons.ttf", 14 * SCALE } +font_cache[style.code_font] = { DATADIR .. "/fonts/monospace.ttf", 13.5 * SCALE } local load_font = renderer.font.load diff --git a/plugins/workspace.lua b/plugins/workspace.lua deleted file mode 100644 index 028e0a2..0000000 --- a/plugins/workspace.lua +++ /dev/null @@ -1,164 +0,0 @@ -local core = require "core" -local DocView = require "core.docview" - -local workspace_filename = ".lite_workspace.lua" - - -local function serialize(val) - if type(val) == "string" then - return string.format("%q", val) - elseif type(val) == "table" then - local t = {} - for k, v in pairs(val) do - table.insert(t, "[" .. serialize(k) .. "]=" .. serialize(v)) - end - return "{" .. table.concat(t, ",") .. "}" - end - return tostring(val) -end - - -local function has_no_locked_children(node) - if node.locked then return false end - if node.type == "leaf" then return true end - return has_no_locked_children(node.a) and has_no_locked_children(node.b) -end - - -local function get_unlocked_root(node) - if node.type == "leaf" then - return not node.locked and node - end - if has_no_locked_children(node) then - return node - end - return get_unlocked_root(node.a) or get_unlocked_root(node.b) -end - - -local function save_view(view) - local mt = getmetatable(view) - if mt == DocView then - return { - type = "doc", - active = (core.active_view == view), - filename = view.doc.filename, - selection = { view.doc:get_selection() }, - scroll = { x = view.scroll.to.x, y = view.scroll.to.y }, - text = not view.doc.filename and view.doc:get_text(1, 1, math.huge, math.huge) - } - end - for name, mod in pairs(package.loaded) do - if mod == mt then - return { - type = "view", - active = (core.active_view == view), - module = name - } - end - end -end - - -local function load_view(t) - if t.type == "doc" then - local ok, doc = pcall(core.open_doc, t.filename) - if not ok then - return DocView(core.open_doc()) - end - local dv = DocView(doc) - if t.text then doc:insert(1, 1, t.text) end - doc:set_selection(table.unpack(t.selection)) - dv.last_line, dv.last_col = doc:get_selection() - dv.scroll.x, dv.scroll.to.x = t.scroll.x, t.scroll.x - dv.scroll.y, dv.scroll.to.y = t.scroll.y, t.scroll.y - return dv - end - return require(t.module)() -end - - -local function save_node(node) - local res = {} - res.type = node.type - if node.type == "leaf" then - res.views = {} - for _, view in ipairs(node.views) do - local t = save_view(view) - if t then - table.insert(res.views, t) - if node.active_view == view then - res.active_view = #res.views - end - end - end - else - res.divider = node.divider - res.a = save_node(node.a) - res.b = save_node(node.b) - end - return res -end - - -local function load_node(node, t) - if t.type == "leaf" then - local res - for _, v in ipairs(t.views) do - local view = load_view(v) - if v.active then res = view end - node:add_view(view) - end - if t.active_view then - node:set_active_view(node.views[t.active_view]) - end - return res - else - node:split(t.type == "hsplit" and "right" or "down") - node.divider = t.divider - local res1 = load_node(node.a, t.a) - local res2 = load_node(node.b, t.b) - return res1 or res2 - end -end - - -local function save_workspace() - local root = get_unlocked_root(core.root_view.root_node) - local fp = io.open(workspace_filename, "w") - if fp then - fp:write("return ", serialize(save_node(root)), "\n") - fp:close() - end -end - - -local function load_workspace() - local ok, t = pcall(dofile, workspace_filename) - os.remove(workspace_filename) - if ok then - local root = get_unlocked_root(core.root_view.root_node) - local active_view = load_node(root, t) - if active_view then - core.set_active_view(active_view) - end - end -end - - -local run = core.run - -function core.run(...) - if #core.docs == 0 then - core.try(load_workspace) - - local exit = os.exit - function os.exit(...) - save_workspace() - exit(...) - end - end - - core.run = run - return core.run(...) -end |