New global variable for vertical cursor shift on GoIfErr (#347)

New variable will allow to customize exactly where cursor will end
up and allow user to set this exactly how they wish.

This change is backwards compatible as the default is the same
as was the hardcoded value.

Signed-off-by: Krystian Kulgawczuk <29754364+krystian-kulgawczuk@users.noreply.github.com>
This commit is contained in:
Krystian Kulgawczuk 2023-05-31 16:19:21 +02:00 committed by GitHub
parent 9fc0312c1a
commit 8a0498ee48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 5 additions and 1 deletions

View File

@ -844,6 +844,7 @@ require('go').setup({
on_stdout = function(err, data) _, _ = err, data end, -- callback when job started
on_stderr = function(err, data) _, _ = err, data end, -- callback for stderr
on_exit = function(code, signal, output) _, _, _ = code, signal, output end, -- callback for jobexit, output : string
iferr_vertical_shift = 4 -- defines where the cursor will end up vertically from the begining of if err statement
})
```

View File

@ -444,6 +444,7 @@ You can setup go.nvim with following options:
test_runner = "go", -- one of {`go`, `richgo`, `dlv`, `ginkgo`}
run_in_floaterm = false, -- set to true to run in float window.
luasnip = false, -- set true to enable included luasnip
iferr_vertical_shift = 4 -- defines where the cursor will end up vertically from the begining of if err statement after GoIfErr command
}
vim:tw=78:ts=8:sts=8:sw=8:ft=help:norl:expandtab

View File

@ -128,6 +128,7 @@ _GO_NVIM_CFG = {
on_stdout = function(err, data) _, _ = err, data end, -- callback when job started
on_stderr = function(err, data) _, _ = err, data end, -- callback for stderr
on_exit = function(code, signal, output) _, _, _ = code, signal, output end, -- callback for jobexit, output : string
iferr_vertical_shift = 4 -- defines where the cursor will end up vertically from the begining of if err statement after GoIfErr command
}
-- TODO: nvim_{add,del}_user_command https://github.com/neovim/neovim/pull/16752

View File

@ -26,7 +26,8 @@ local run = function()
vim.cmd('silent normal! j=2j')
vfn.setpos('.', pos)
vim.cmd('silent normal! 4j')
local vertical_shift = tostring(_GO_NVIM_CFG.iferr_vertical_shift) .. 'j'
vim.cmd('silent normal! ' .. vertical_shift)
--
end