Calling a function from a plugin, from another plugin

I have just created a very basic first neovim plugin ( decorated yank ).

I’d like to extend it to include a repository link, which I’d normally do with vim-fugitives :GitBrowse!.

Is there a way for my plugin to call GitBrowse! from the vim-fugitive plugin, so I can get the link without needing to replicate all of the work of that plugin?

Thanks in advance.

You can check check what the GBrowse command actually calling and call it from your code.

1 Like

I did try that but calling the underlying fugitive#BrowseCommand doesn’t seem to work. print(vim.fn.exists("*fugitive#BrowseCommand")) returns 0 which indicates it isn’t callable, right?

Since it’s an autoloaded function it doesn’t exists until you call it. You can try pcall to catch if the function call failed

local ok, _ = pcall(vim.fn['fugitive#BrowseCommand'], ...)

if not ok then

ahh ok, thank you :slight_smile: I appreciate the help