diff options
author | Justin Gassner <justin.gassner@mailbox.org> | 2023-11-29 13:31:15 +0100 |
---|---|---|
committer | Justin Gassner <justin.gassner@mailbox.org> | 2023-11-29 13:31:15 +0100 |
commit | 6007ece6a7d712e091fef5a62985b3291748953a (patch) | |
tree | fa4d8002f29700d17a45ae850c8b35881eeb81f2 | |
parent | 6201764b139e56f76f7aed6d047e64685640eb5c (diff) | |
download | my-quicktex-keywords-6007ece6a7d712e091fef5a62985b3291748953a.tar.zst |
Make special keys work
-rw-r--r-- | lua/my-quicktex-keywords/init.lua | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lua/my-quicktex-keywords/init.lua b/lua/my-quicktex-keywords/init.lua index 18c5c90..54484f4 100644 --- a/lua/my-quicktex-keywords/init.lua +++ b/lua/my-quicktex-keywords/init.lua @@ -5,6 +5,14 @@ local mode = { normal = 0, math = 1, both = 2 } local quicktex_tex = {} local quicktex_math = {} +local function insert_special_keys(str) + local ret = str + ret = string.gsub(ret, '<BS>', string.char(8)) + ret = string.gsub(ret, '<CR>', string.char(13)) + ret = string.gsub(ret, '<ESC>', string.char(27)) + return ret +end + local function read_item(line) if string.match(line, '^#') then return @@ -64,7 +72,7 @@ local function read_item(line) local cap1, cap2 = string.match(line, '^(%g+) (.+)') if cap1 then item_keyword = cap1 - item_expansion = cap2 + item_expansion = insert_special_keys(cap2) return item_mode, item_keyword, item_expansion end end @@ -95,6 +103,7 @@ local function generate_quicktex_dictionaries() quicktex_math[' '] = string.char(27) .. ':call quicktex#DoJump()\n' vim.g.quicktex_tex = quicktex_tex vim.g.quicktex_math = quicktex_math + quicktex_tex['M'] = '$$\n<+++>\n$$' vim.g.quicktex_markdown = quicktex_tex end |