Skip to content

Commit

Permalink
fix(builtin): update after grapple rewrite (#46)
Browse files Browse the repository at this point in the history
* fix: update grapple builtin for rewrite

* fix: better guard in builtin for when plugin does not exist
  • Loading branch information
cbochs authored Mar 1, 2024
1 parent eacc582 commit 515c3d9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions lua/portal/builtin/grapple.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ local function generator(opts, settings)
local Iterator = require("portal.iterator")
local Search = require("portal.search")

local ok, _ = require("grapple")
local ok, _ = pcall(require, "grapple")
if not ok then
require("portal.log").error("Unable to load 'grapple'. Please ensure that grapple.nvim is installed.")
return require("portal.log").error("Unable to load 'grapple'. Please ensure that grapple.nvim is installed.")
end

local tags = require("grapple").tags()
Expand Down Expand Up @@ -37,10 +37,10 @@ local function generator(opts, settings)
end

local buffer
if vim.fn.bufexists(v.file_path) ~= 0 then
buffer = vim.fn.bufnr(v.file_path)
if vim.fn.bufexists(v.path) ~= 0 then
buffer = vim.fn.bufnr(v.path)
else
buffer = vim.fn.bufadd(v.file_path)
buffer = vim.fn.bufadd(v.path)
end

if buffer == vim.fn.bufnr() then
Expand All @@ -52,10 +52,10 @@ local function generator(opts, settings)
buffer = buffer,
cursor = { row = v.cursor[1], col = v.cursor[2] },
callback = function(content)
require("grapple").select({ key = content.extra.key })
require("grapple").select({ path = content.extra.path })
end,
extra = {
key = v.key,
path = v.path,
},
})
end)
Expand Down
4 changes: 2 additions & 2 deletions lua/portal/builtin/harpoon.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ local function generator(opts, settings)
local Iterator = require("portal.iterator")
local Search = require("portal.search")

local ok, _ = require("harpoon")
local ok, _ = pcall(require, "harpoon")
if not ok then
require("portal.log").error("Unable to load 'harpoon'. Please ensure that harpoon is installed.")
return require("portal.log").error("Unable to load 'harpoon'. Please ensure that harpoon is installed.")
end

local marks = require("harpoon").get_mark_config().marks
Expand Down

0 comments on commit 515c3d9

Please sign in to comment.