I recently tried Lite XL v2.1.0, a forked and updated version of the original rxi/lite, “A lightweight text editor written in Lua”, on MacOS ARM. Here are some findings.

  • Upsides: Open source. Fast. Plugins. Markdown.
  • Downsides: No menubar. No Emoji. Buggy text selection. Consumes CPU even when no document is open and in the background:

Lite XL on MacOS

Alas, the last downside is a deal-breaker for me, see screenshot, peaking at 50% while idle! But I’ll keep an eye on future updates, things may change. Lite XL on MacOS high CPU utilization

Installation

  • Download the latest .DMG for MacOS from Lite-XL Releases on GitHub.
  • Run the .DMG as usual and drag the Lite XL.app to your Applications folder.
  • Mark the application as “safe”, xattr -d com.apple.quarantine /Applications/Lite\ XL.app.
  • Run it (if you skip the previous step, you will get an error "Lite XL" is damaged and can't be opened. .
  • Next, visit lite-xl-plugins and download any desired plugins (.lua source code). I note:
    • minimap.lua - causes Lite XL to crash when line wrapping is enabled,
    • spellcheck.lua - uses the default /usr/share/dict/words, which on MacOS, is rather outdated. So, download a SCOWL (and friends) word list and configure the plugin to use it.
    • ghmarkdown.lua to preview markdown actually submits your file to https://api.github.com to convert to HTML. A replacement below.
  • Save the plugins in ~/.config/lite-xl/plugins
  • Finally, restart Lite XL - you can use Core: Find Command Cmd-Shift-P and Core: Restart

Markdown Preview

Even though I don’t use Lite XL, here is a simple markdown preview / editor using SimpleMDE - Markdown Editor with code highlighting, and based on the original ghmarkdown.lua script.

Save as ~/.config/lite-xl/plugins/markdownpreview.lua:

-- mod-version:3
local core = require "core"
local command = require "core.command"
local keymap = require "core.keymap"

local html = [[
<html>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.css">
  <script src="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.js"></script>
  <script src="https://cdn.jsdelivr.net/highlight.js/latest/highlight.min.js"></script>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/highlight.js/latest/styles/github.min.css">
<style>
  body { margin:auto; max-width:750px; line-height: 1.4; }
</style>
<head>
  <title>${title}</title>
<head>
<body>
  <textarea>${content}</textarea>
<pre>${content}</pre>
<script>
let simplemde = new SimpleMDE({ autofocus: true,
renderingConfig: { codeSyntaxHighlighting: true } })
</script>
</body>
</html>
]]

command.add("core.docview!", {
  ["markdown:preview"] = function(dv)
    local title = dv:get_name()
    local content = dv.doc:get_text(1, 1, math.huge, math.huge)
    local text = html:gsub("${(.-)}", { title = title, content = content })
    local htmlfile = core.temp_filename(".html")
    local fp = io.open(htmlfile, "w")
    fp:write(text)
    fp:close()
    core.log("Opening markdown preview for \"%s\"", content)
    if PLATFORM == "Windows" then
      system.exec("start " .. htmlfile)
    elseif PLATFORM == "Mac OS X" then
      system.exec(string.format("open %q", htmlfile))
    else
      system.exec(string.format("xdg-open %q", htmlfile))
    end
    core.add_thread(function()
      coroutine.yield(5)
      os.remove(htmlfile)
    end)
  end
})

keymap.add { ["ctrl+alt+m"] = "markdown:preview" }

Happy new year!