Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #3 by add -dir option of impl #4

Merged
merged 1 commit into from
Dec 7, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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