Giter VIP home page Giter VIP logo

Comments (1)

jamestrew avatar jamestrew commented on June 20, 2024

I commented a potential solution here nvim-telescope/telescope.nvim#2201 (comment)

But I'm currently now this

local actions = require("telescope.actions")
local action_state = require("telescope.actions.state")
local fb_utils = require("telescope._extensions.file_browser.utils")
local builtin = require("telescope.builtin")

-- helper function
local open_using = function(finder)
  return function(prompt_bufnr)

    -- gets selections based off tab-selected multi-select entries
    local selections = fb_utils.get_selected_files(prompt_bufnr, false)
    local search_dirs = vim.tbl_map(function(path)
      return path:absolute()
    end, selections)

    -- if nothing is multi-selected, just use the current `path` value
    if vim.tbl_isempty(search_dirs) then
      local current_finder = action_state.get_current_picker(prompt_bufnr).finder
      search_dirs = { current_finder.path }
    end
    actions.close(prompt_bufnr)
    finder({ search_dirs = search_dirs })
  end
end

require("telescope").setup({
  extensions = {
    file_browser = {
      mappings = {
        i = {
          ["<A-g>"] = open_using(builtin.live_grep),
          ["<A-f>"] = open_using(builtin.find_files),
        },
      },
    },
  },
})

The reason why we've resisted adding this to telescope because this can be a fairly opinionated workflow. Even for just myself, I've changed how the search_dirs option is determined for find_files, live_grep. I've yet to find, or hear a good solution that works for most everyone and that can be fairly easily incorporated into telescope, or at least worth the effort.

I hope that helps.

from telescope-file-browser.nvim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.