refactor: throw errors in more lua way, i think
This commit is contained in:
parent
640a36a7f2
commit
e49ee67ecc
3 changed files with 4 additions and 8 deletions
|
|
@ -12,8 +12,7 @@ local function add_test(args)
|
||||||
args = args,
|
args = args,
|
||||||
on_exit = function(data, status)
|
on_exit = function(data, status)
|
||||||
if not status == 0 then
|
if not status == 0 then
|
||||||
vim.notify("gotests failed: " .. data, vim.log.levels.ERROR)
|
error("gotests failed: " .. data, vim.log.levels.ERROR)
|
||||||
return
|
|
||||||
end
|
end
|
||||||
|
|
||||||
vim.notify("unit test(s) generated", vim.log.levels.INFO)
|
vim.notify("unit test(s) generated", vim.log.levels.INFO)
|
||||||
|
|
@ -25,7 +24,7 @@ end
|
||||||
function gotests.func_test()
|
function gotests.func_test()
|
||||||
local ns = ts_utils.get_func_method_node_at_pos(unpack(vim.api.nvim_win_get_cursor(0)))
|
local ns = ts_utils.get_func_method_node_at_pos(unpack(vim.api.nvim_win_get_cursor(0)))
|
||||||
if ns == nil or ns.name == nil then
|
if ns == nil or ns.name == nil then
|
||||||
vim.notify("cursor on func/method and execute the command again", vim.log.levels.INFO)
|
vim.notify("cursor on func/method and execute the command again", vim.log.levels.WARN)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,7 @@ function iferr.iferr()
|
||||||
|
|
||||||
local data = vim.fn.systemlist((c.iferr .. " -pos " .. boff), vim.fn.bufnr "%")
|
local data = vim.fn.systemlist((c.iferr .. " -pos " .. boff), vim.fn.bufnr "%")
|
||||||
if vim.v.shell_error ~= 0 then
|
if vim.v.shell_error ~= 0 then
|
||||||
vim.notify("iferr failed: " .. data, vim.log.levels.ERROR)
|
error("iferr failed: " .. data, vim.log.levels.ERROR)
|
||||||
return
|
|
||||||
end
|
end
|
||||||
|
|
||||||
vim.fn.append(pos, data)
|
vim.fn.append(pos, data)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
local ts_utils = require "gopher._utils.ts"
|
local ts_utils = require "gopher._utils.ts"
|
||||||
local r = require "gopher._utils.runner"
|
local r = require "gopher._utils.runner"
|
||||||
local c = require("gopher.config").commands
|
local c = require("gopher.config").commands
|
||||||
local u = require "gopher._utils"
|
|
||||||
local struct_tags = {}
|
local struct_tags = {}
|
||||||
|
|
||||||
local function modify(...)
|
local function modify(...)
|
||||||
|
|
@ -56,10 +55,9 @@ local function modify(...)
|
||||||
or tagged["start"] == nil
|
or tagged["start"] == nil
|
||||||
or tagged["start"] == 0
|
or tagged["start"] == 0
|
||||||
then
|
then
|
||||||
u.deferred_notify("failed to set tags " .. vim.inspect(tagged), vim.log.levels.ERROR)
|
error("failed to set tags " .. vim.inspec(tagged), vim.log.levels.ERROR)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- write goted tags
|
|
||||||
vim.api.nvim_buf_set_lines(
|
vim.api.nvim_buf_set_lines(
|
||||||
0,
|
0,
|
||||||
tagged.start - 1,
|
tagged.start - 1,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue