Skip Navigation

Reveal File In NeoTree From Telescope

I made a quick plugin to open files found on Telescope inside Neotree:

local open_in_neo_tree = function(prompt_bufnr)
    local action_state = require "telescope.actions.state"
    local Path = require "plenary.path"
    local actions = require "telescope.actions"

    local entry = action_state.get_selected_entry()[1]
    local entry_path = Path:new(entry):parent():absolute()
    actions._close(prompt_bufnr, true)
    entry_path = Path:new(entry):parent():absolute() 
    entry_path = entry_path:gsub("\\", "\\\\")

    vim.cmd("Neotree close")

    file_name = nil
    for s in string.gmatch(entry, "[^/]+") do
        file_name = s
    end

    vim.cmd("Neotree filesystem reveal reveal_file=" .. entry_path .. "/" .. file_name)
end

require("telescope").setup {
  defaults = {
    layout_strategy = "vertical",
    mappings = {
      i = {
        [""] = open_in_neo_tree,
      },
....
2

You're viewing a single thread.