utilyre / barbecue.nvim

Visual Studio Code inspired breadcrumbs plugin for the Neovim editor
MIT License
776 stars 31 forks source link

[FEAT]: Clickable directory Entries #88

Open thattomperson opened 1 year ago

thattomperson commented 1 year ago

Requirements

Problem

It would be nice to be able to click on the directories and have a callback fire

an example use-case would be to open nerdtree or oil.nvim to that directory

Solution Suggestion

adding an additional onClick to the Entry class should be simple, I'm not sure how you would want to implement it though

the current to = {} stuff could be made generic to to use the same click handlers with a default implementation

configuration could be done pretty simply with a table

function Entry:navigate()
  local handler = config.onclick[entry.type] or function (entry)
    vim.cmd.mark("'")

    vim.api.nvim_set_current_win(entry.to.win)
    vim.api.nvim_win_set_cursor(entry.to.win, entry.to.pos)
  end
  handler(self)
end

require('barbecue').setup({
  onclick = {
    dir = function (entry) 
      require('nerdtree').focus(entry.filepath)
    end,
  }
})

some additional parameters would be required on the Entry to make this useable, like the filepath one above

Workaround

No response