jvgrootveld / telescope-zoxide

An extension for telescope.nvim that allows you operate zoxide within Neovim.
MIT License
315 stars 16 forks source link

How to execute additional commands after a directory is selected from the list? #4

Closed macintacos closed 3 years ago

macintacos commented 3 years ago

I would like to execute :Prosession . after I hit <CR> on a list item after running :Telescope zoxide list. How do I do that automatically?

jvgrootveld commented 3 years ago

@macintacos For now, this is not possible. But I think it is a good idea. I will look into it to add custom methods with optional pre- and post methods.

For now you could do this (temporary) manually by:

  1. Checkout the repository
  2. Load the local repository as plugin. Packer would be: a. Example: use '~/projects/_repos/telescope-zoxide b. Save: :w c. Reload currently changed file: :luafile % d. Install package: :PackerInstall
  3. Add command vim.cmd("Prosession .") after list.lua#L114

Note: Above is not testes, so some steps could have faults

jvgrootveld commented 3 years ago

@macintacos I added new functionality to add, extend and update Telescope Zoxide config including mappings. You can try this on the current feature branch feature/add-user-configuration. I will merge this shortly after some testing.

Your requested functionality can now be achieved by adding the following setup:

require("telescope._extensions.zoxide.config").setup({
  mappings = {
    default = {
      after_action = function(selection)
        vim.cmd("Prosession " .. selection.path)
      end
    }
  }
})

Or using the supplied helper function:

local z_utils = require("telescope._extensions.zoxide.utils")

require("telescope._extensions.zoxide.config").setup({
  mappings = {
    default = { after_action = z_utils.create_basic_command("Prosession") },
  }
})
macintacos commented 3 years ago

That's fantastic, thanks!

jvgrootveld commented 3 years ago

PR merged. telescope-zoxide can now be optionally configured.