Skip to content

Commit

Permalink
Merge pull request #4 from gh-liu/main
Browse files Browse the repository at this point in the history
Fix #3 by add `-dir` option of impl
  • Loading branch information
edolphin-ydf authored Dec 7, 2021
2 parents 06b1973 + 9a827bf commit 9061877
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lua/telescope/_extensions/goimpl_builtin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,10 @@ local function goimpl(tsnode, packageName, interface)
local rec2 = ts_utils.get_node_text(tsnode)[1]
local rec1 = string.lower(string.sub(rec2, 1, 2))

local setup = 'impl' .. " '" .. rec1 .. " *" .. rec2 .. "' " .. packageName .. '.' .. interface
-- get the package source directory
local dirname = vim.fn.fnameescape(vim.fn.expand('%:p:h'))

local setup = 'impl' .. ' -dir ' .. dirname .. " '" .. rec1 .. " *" .. rec2 .. "' " .. packageName .. '.' .. interface
local data = vim.fn.systemlist(setup)

data = handle_job_data(data)
Expand All @@ -121,7 +124,7 @@ local function goimpl(tsnode, packageName, interface)
-- if not found the '$packageName.$interface' type, then try without the packageName
-- this works when in a main package, it's containerName will return the directory name which the interface file exist in.
if string.find(data[1], "unrecognized interface:") or string.find(data[1], "couldn't find") then
setup = 'impl' .. " '" .. rec1 .. " *" .. rec2 .. "' " .. interface
setup = 'impl' .. ' -dir ' .. dirname .. " '" .. rec1 .. " *" .. rec2 .. "' " .. interface
data = vim.fn.systemlist(setup)

data = handle_job_data(data)
Expand Down

0 comments on commit 9061877

Please sign in to comment.