+5
doc/gopher.nvim.txt
+5
doc/gopher.nvim.txt
+5
lua/gopher/config.lua
+5
lua/gopher/config.lua
+7
-1
lua/gopher/iferr.lua
+7
-1
lua/gopher/iferr.lua
···
15
15
local pos = vim.fn.getcurpos()[2]
16
16
local fpath = vim.fn.expand "%"
17
17
18
-
local rs = r.sync({ c.commands.iferr, "-pos", curb }, {
18
+
local cmd = { c.commands.iferr, "-pos", curb }
19
+
if c.iferr.message ~= nil and type(c.iferr.message) == "string" then
20
+
table.insert(cmd, "-message")
21
+
table.insert(cmd, c.iferr.message)
22
+
end
23
+
24
+
local rs = r.sync(cmd, {
19
25
stdin = u.readfile_joined(fpath),
20
26
})
21
27
+7
spec/fixtures/iferr/message_input.go
+7
spec/fixtures/iferr/message_input.go
+10
spec/fixtures/iferr/message_output.go
+10
spec/fixtures/iferr/message_output.go
+14
spec/integration/iferr_test.lua
+14
spec/integration/iferr_test.lua
···
23
23
t.eq(t.readfile(tmp), fixtures.output)
24
24
end
25
25
26
+
T["iferr"]["works with custom message"] = function()
27
+
local tmp = t.tmpfile()
28
+
local fixtures = t.get_fixtures "iferr/message"
29
+
t.writefile(tmp, fixtures.input)
30
+
31
+
child.lua [[ require("gopher").setup { iferr = { message = 'fmt.Errorf("failed to %w", err)' } } ]]
32
+
child.cmd("silent edit " .. tmp)
33
+
child.fn.setpos(".", { child.fn.bufnr "%", 6, 2, 0 })
34
+
child.cmd "GoIfErr"
35
+
child.cmd "write"
36
+
37
+
t.eq(t.readfile(tmp), fixtures.output)
38
+
end
39
+
26
40
return T