From 8fad9a5ecddc88d57a531e4b0084544984f23d25 Mon Sep 17 00:00:00 2001 From: Jacob McDonnell Date: Sat, 16 Jul 2022 18:13:16 -0400 Subject: Added profile and other missing configs --- .config/micro/plug/fzf/main.lua | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .config/micro/plug/fzf/main.lua (limited to '.config/micro/plug/fzf/main.lua') diff --git a/.config/micro/plug/fzf/main.lua b/.config/micro/plug/fzf/main.lua new file mode 100644 index 0000000..fbdcd97 --- /dev/null +++ b/.config/micro/plug/fzf/main.lua @@ -0,0 +1,38 @@ +VERSION = "1.1.1" + +local micro = import("micro") +local shell = import("micro/shell") +local config = import("micro/config") +local buffer = import("micro/buffer") + +function fzf(bp) + if shell.TermEmuSupported then + local err = shell.RunTermEmulator(bp, "fzf", false, true, fzfOutput, {bp}) + if err ~= nil then + micro.InfoBar():Error(err) + end + else + local output, err = shell.RunInteractiveShell("fzf", false, true) + if err ~= nil then + micro.InfoBar():Error(err) + else + fzfOutput(output, {bp}) + end + end +end + +function fzfOutput(output, args) + local bp = args[1] + local strings = import("strings") + output = strings.TrimSpace(output) + if output ~= "" then + local buf, err = buffer.NewBufferFromFile(output) + if err == nil then + bp:OpenBuffer(buf) + end + end +end + +function init() + config.MakeCommand("fzf", fzf, config.NoComplete) +end -- cgit v1.2.3