From c90e0cd124daa4be01d480fa07764329e572d9e6 Mon Sep 17 00:00:00 2001 From: Smirnov Oleksandr Date: Wed, 9 Aug 2023 12:59:52 +0300 Subject: [PATCH] refactor(iferr): use vim.notify i have tried to use _utils.runner, but i cannt figure out how to make `< file.go` for the command --- lua/gopher/iferr.lua | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/lua/gopher/iferr.lua b/lua/gopher/iferr.lua index fbeddf7..6213d3b 100644 --- a/lua/gopher/iferr.lua +++ b/lua/gopher/iferr.lua @@ -1,22 +1,17 @@ local c = require("gopher.config").commands -local u = require "gopher._utils" local iferr = {} -- That's Lua of vimscript implementation of: github.com/koron/iferr -iferr.iferr = function() +function iferr.iferr() local boff = vim.fn.wordcount().cursor_bytes - local cmd = (c.iferr .. " -pos " .. boff) - local data = vim.fn.systemlist(cmd, vim.fn.bufnr "%") + local pos = vim.fn.getcurpos()[2] + local data = vim.fn.systemlist((c.iferr .. " -pos " .. boff), vim.fn.bufnr "%") if vim.v.shell_error ~= 0 then - u.deferred_notify( - "command " .. cmd .. " exited with code " .. vim.v.shell_error, - vim.log.levels.ERROR - ) + vim.notify("iferr failed: " .. data, vim.log.levels.ERROR) return end - local pos = vim.fn.getcurpos()[2] vim.fn.append(pos, data) vim.cmd [[silent normal! j=2j]] vim.fn.setpos(".", pos)