summaryrefslogtreecommitdiff
path: root/config/essentials/vis/vis-go.lua
diff options
context:
space:
mode:
Diffstat (limited to 'config/essentials/vis/vis-go.lua')
-rw-r--r--config/essentials/vis/vis-go.lua16
1 files changed, 14 insertions, 2 deletions
diff --git a/config/essentials/vis/vis-go.lua b/config/essentials/vis/vis-go.lua
index b0b383f..bb0c7ab 100644
--- a/config/essentials/vis/vis-go.lua
+++ b/config/essentials/vis/vis-go.lua
@@ -1,3 +1,13 @@
+--[[
+Based on https://gitlab.com/timoha/vis-go
+Changes made:
+- stylua format
+- check if line, col in godef()
+- no formatting because already handled by format.lua
+- removed the goimports option
+- set env variable for godef that fixes "no definition found"
+--]]
+
local function jump_to(path, line, col)
if path then
vis:command(string.format("e %s", path))
@@ -28,7 +38,7 @@ local function godef()
local file = win.file
local pos = win.selection.pos
- local cmd = string.format("godef -i -o %d", pos)
+ local cmd = string.format("GO111MODULE=off godef -i -o %d", pos)
local status, out, err = vis:pipe(file, { start = 0, finish = file.size }, cmd)
if status ~= 0 or not out then
if err then
@@ -44,7 +54,9 @@ local function godef()
-- same file
line, col = string.match(out, "([^:]+):([^:]+)")
end
- jump_to(path, line, col)
+ if line and col then
+ jump_to(path, line, col)
+ end
end
local function godef_back()