From 4eb404de6ef02c376f91a1a60552f2754bb30cd5 Mon Sep 17 00:00:00 2001 From: Alpha Chen Date: Tue, 3 Dec 2024 20:48:24 -0800 Subject: [PATCH] [nvim] fennel ftplugin --- .config/nvim/ftplugin/fennel.fnl | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .config/nvim/ftplugin/fennel.fnl diff --git a/.config/nvim/ftplugin/fennel.fnl b/.config/nvim/ftplugin/fennel.fnl new file mode 100644 index 0000000..04e1426 --- /dev/null +++ b/.config/nvim/ftplugin/fennel.fnl @@ -0,0 +1,15 @@ +;; https://github.com/rktjmp/hotpot.nvim/discussions/93#discussioncomment-4362209 +(vim.cmd "iabbrev lambda v:lua.iab_lambda()") + +;; fnlfmt: skip +(fn _G.iab_lambda [] + (let [line (vim.fn.getline :.) + col (vim.fn.col :.) + ;; a b c \lambda + ;; ^ check here (may not exist) + ;; but dont do anything if that under runs the first character + offset (- col (length :lambda) 1)] + (match [(< 0 offset) (string.sub line offset offset)] + ;; replace term codes so the expr actually runs backspace, not inserts the string + [true :\] (vim.api.nvim_replace_termcodes :λ true false true) + [false _] :lambda)))