Is there a way to highlight a directory of a found file?

For example I look for a specific file with telescope and when I open it, my nvim-tree is updated and shows me parent directory?


1 Answer 1


You can jump to the file in current buffer by using :NvimTreeFindFile. To do this automatically upon opening the file in telescope, you need to "overload" the open action of Telescope (called select_default, on - carriage return) to run NvimTreeFindFile command just after you open the file. You can do so by using transform_mod:

In ~/.config/nvim/init.vim put this configuration:

lua << EOF

local transform_mod = require('telescope.actions.mt').transform_mod
local actions = require('telescope.actions')
local mod = {}
mod.open_in_nvim_tree = function(prompt_bufnr)
    local cur_win = vim.api.nvim_get_current_win()

mod = transform_mod(mod)

    defaults = {
        mappings = {
            i = {
                ["<CR>"] = actions.select_default + mod.open_in_nvim_tree,
            n = {
                ["<CR>"] = actions.select_default + mod.open_in_nvim_tree,

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.