Skip to content

"s" mapping doesn't work properly when opening a folder using fzf. #1423

Open
@hellwraiz

Description

@hellwraiz

Self-Diagnosis

Before creating an issue, take some time to search these resources for an answer. It's possible that someone else has already seen and solved your issue.

Environment

local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
  vim.fn.system({
    "git",
    "clone",
    "--filter=blob:none",
    "https://github.com/folke/lazy.nvim.git",
    "--branch=stable", -- latest stable release
    lazypath,
  })
end
vim.opt.rtp:prepend(lazypath)



-- Install plugins --------------------------------------------------------------------------------


require("lazy").setup({

    -- used to be able to use icons everywhere
    "ryanoasis/vim-devicons",

    -- nerd tree stuff
    "tiagofumo/vim-nerdtree-syntax-highlight",
    "preservim/nerdtree",
    "Xuyuanp/nerdtree-git-plugin",

    -- fuzzy!!
    { 'junegunn/fzf', run = function() vim.fn['fzf#install']() end, },
    'junegunn/fzf.vim',

}

vim.keymap.set('n', '<leader>fd', ':FZFFolders<CR>', {noremap = true, silent = true})

function FZFFolders()
    vim.fn['fzf#run']({
        source = 'find . -type d -print',
        sink = 'e',
        options = '--preview "tree -C {} | head -100"'
    })
end
vim.api.nvim_create_user_command('FZFFolders', function()
    FZFFolders()
end, {})

Steps to Reproduce the Issue

  1. Open a file using nvim
  2. type :NERDTree to open the tree on the left side of the window
  3. navigate to it using
  4. use the provided fd shortcut to look for directories. Open some directory.
  5. Now that the nerdTree shows the newly opened directory press "i" on a file to open it in a split
  6. profit

Current Behavior (Include screenshots where appropriate.)

I receive the following error in the terminal below:

Error detected while processing function nerdtree#ui_glue#invokeKeyMap[1]..76[18]..75[3]..23_openVSplit[1]..105[1]..121[3]..177[6]..178[9]..172[3]..176[16]..218[1]..228[2]..function ner
dtree#ui_glue#invokeKeyMap[1]..76[18]..75[3]..23_openVSplit[1]..105[1]..121[3]..177[6]..178[9]..172[3]..176[16]..218[1]..228:
line 2:
E605: Exception not caught: NERDTree.TreeNotOpen

and after I press enter the same window that I had opened previously opens in another split window

and if I try to use "o" instead, it just replaces the nerdtree itself instead of the file next to it

Expected Result

open the chosen file in the tree in a split above the currently opened buffer.

or when using "o", replaces the currently opened file with the chosen on in the tree

Aditional stuff

I also found issue #1374 which seemed to have a similar problem, and had a solution provided, but it didn't work for me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions