gopher.nvim/lua/gopher/iferr.lua
Smirnov Oleksandr 2e89cea6f3 refactor: commands runner (#42)
* feat(utils): first impl of own commands runner

* refactor(gotests): uses own runner instead of vendored

* refactor(utils): back to plenary.job

* refactor(gotests): use new runner, clean code

* fix(runner): now it returns output correctly

* refactor(iferr): use vim.system

i have tried to use _utils.runner, but i can't figure out how to make `< file.go` for the command

* refactor(impl): use new runner

* refactor(installer): use new runner

* refactor(struct_tags): use new runner

* refactor: commands such as :GoGet runs with new runner

* refactor: throw errors in more lua way, i think

* refactor(utils): notify now has title

* refactor: use more correct way of notifying

* refactor(runner): write error message on error
2023-08-10 12:11:26 +03:00

19 lines
501 B
Lua

local c = require("gopher.config").commands
local iferr = {}
-- That's Lua of vimscript implementation of: github.com/koron/iferr
function iferr.iferr()
local boff = vim.fn.wordcount().cursor_bytes
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
error("iferr failed: " .. data)
end
vim.fn.append(pos, data)
vim.cmd [[silent normal! j=2j]]
vim.fn.setpos(".", pos)
end
return iferr