aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md11
-rw-r--r--language_fe.lua33
-rw-r--r--macmodkeys.lua18
-rw-r--r--togglesnakecamel.lua32
4 files changed, 94 insertions, 0 deletions
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..c51502f
--- /dev/null
+++ b/README.md
@@ -0,0 +1,11 @@
+Plugins for the [lite text editor](https://github.com/rxi/lite)
+
+---
+
+Plugin | Description
+-------|-----------------------------------------
+[`language_fe`](language_fe.lua?raw=1) | Syntax for the `fe` programming language
+[`macmodkeys`](macmodkeys.lua?raw=1) | Remaps mac modkeys `command/option` to `ctrl/alt`
+[`togglesnakecamel`](togglesnakecamel.lua?raw=1) | Toggles highlighted text between snake-case and camel-case
+
+
diff --git a/language_fe.lua b/language_fe.lua
new file mode 100644
index 0000000..f97e73b
--- /dev/null
+++ b/language_fe.lua
@@ -0,0 +1,33 @@
+local syntax = require "core.syntax"
+
+syntax.add {
+ files = "%.fe$",
+ comment = ";",
+ patterns = {
+ { pattern = ";.-\n", type = "comment" },
+ { pattern = { '"', '"', '\\' }, type = "string" },
+ { pattern = "0x[%da-fA-F]+", type = "number" },
+ { pattern = "-?%d+[%d%.]*", type = "number" },
+ { pattern = "-?%.?%d+", type = "number" },
+ { pattern = "'", type = "symbol" },
+ { pattern = "%f[^(][^()'%s\"]+", type = "function" },
+ { pattern = "[^()'%s\"]+", type = "symbol" },
+ },
+ symbols = {
+ ["if"] = "keyword2",
+ ["let"] = "keyword2",
+ ["do"] = "keyword2",
+ ["fn"] = "keyword2",
+ ["mac"] = "keyword2",
+ ["'"] = "keyword2",
+ ["print"] = "keyword",
+ ["while"] = "keyword",
+ ["car"] = "keyword",
+ ["cdr"] = "keyword",
+ ["not"] = "keyword",
+ ["setcdr"] = "keyword",
+ ["setcar"] = "keyword",
+ ["nil"] = "literal",
+ ["t"] = "literal",
+ }
+}
diff --git a/macmodkeys.lua b/macmodkeys.lua
new file mode 100644
index 0000000..69028ab
--- /dev/null
+++ b/macmodkeys.lua
@@ -0,0 +1,18 @@
+local keymap = require "core.keymap"
+
+local on_key_pressed = keymap.on_key_pressed
+local on_key_released = keymap.on_key_released
+
+local function remap_key(k)
+ return k:gsub("command", "ctrl")
+ :gsub("option", "alt")
+end
+
+function keymap.on_key_pressed(k)
+ return on_key_pressed(remap_key(k))
+end
+
+function keymap.on_key_released(k)
+ return on_key_released(remap_key(k))
+end
+
diff --git a/togglesnakecamel.lua b/togglesnakecamel.lua
new file mode 100644
index 0000000..236c22e
--- /dev/null
+++ b/togglesnakecamel.lua
@@ -0,0 +1,32 @@
+local core = require "core"
+local command = require "core.command"
+local keymap = require "core.keymap"
+
+
+local function f(x, y)
+ return x .. "_" .. string.lower(y)
+end
+
+
+local function toggle(symbol)
+ if not symbol:match("[a-z]") then
+ return
+ elseif symbol:match("_") then
+ return symbol:gsub("_(.)", string.upper)
+ elseif symbol:match("^[a-z]") then
+ return symbol:gsub("(.)([A-Z])", f):lower()
+ end
+end
+
+
+command.add("core.docview", {
+ ["toggle-snake-camel:toggle"] = function()
+ core.active_view.doc:replace(function(text)
+ return text:gsub("[%w][%w%d_]*", toggle)
+ end)
+ end,
+})
+
+keymap.add {
+ ["f6"] = "toggle-snake-camel:toggle",
+}