neo-tree.nvim
neo-tree.nvim copied to clipboard
Allow tab to autocomplete directory name when 'use_popups_for_input = false'
Did you check docs and existing issues?
- [X] I have read all the docs.
- [X] I have searched the existing issues.
- [X] I have searched the existing discussions.
Neovim Version (nvim -v)
0.9.1
Operating System / Version
MacOS Monterey
Describe the Bug
When I want to add a file, the UI show like this:
then I press <Tab>, I want to autocomplete the directory name like I can do in command line (eg.cd):
Screenshots, Traceback
No response
Steps to Reproduce
1.show Neotree. 2.press a to add file. 3.use settings 'use_popups_for_input = false' to input file name.
Expected Behavior
use tab to autocomplte or select directory name.
Your Configuration
return {
"nvim-neo-tree/neo-tree.nvim",
tag = "3.6",
dependencies = {
"nvim-lua/plenary.nvim",
"MunifTanjim/nui.nvim",
},
config = function()
local neotree = require("neo-tree")
local do_setcd = function(state)
local node = state.tree:get_node()
local p
if node.type == 'directory' then
p = node.path
else
p = node:get_parent_id()
end
print(p) -- show in command line
vim.cmd(string.format('exec(":lcd %s")',p))
return p
end
neotree.setup({
-- https://github.com/nvim-neo-tree/neo-tree.nvim/blob/a7d6f05e57487326fd70b24195c3b7a86a88b156/lua/neo-tree/defaults.lua
hide_root_node = true,
retain_hidden_root_indent = false,
enable_git_status = false,
enable_modified_markers = false,
use_popups_for_input = false, -- not floats for input
-- selft defined command
-- Thanks:https://github.com/nvim-neo-tree/neo-tree.nvim/issues/791
commands = {
find_files = function(state)
do_setcd(state)
require('telescope.builtin').find_files()
end,
grep = function(state)
do_setcd(state)
require('telescope.builtin').live_grep()
end,
spectre = function(state)
local p = do_setcd(state)
require('spectre').open({
is_insert_mode = true,
cwd = p,
is_close = false, -- close an exists instance of spectre and open new
})
end,
},
window = {
--c(d), z(p)
mappings = {
["o"] = "open",
["x"] = "close_node",
["I"] = "toggle_hidden",
["r"] = "refresh",
[",p"] = "find_files",
[",g"] = "grep",
[",f"] = "spectre",
["<c-a>"] = {
"add",
config = {
show_path = 'relative'
}
},
["<c-d>"] = "delete",
["<c-m>"] = {
"move",
config = {
show_path = 'relative'
}
},
["<c-c>"] = {
"copy",
config = {
show_path = 'relative'
}
},
["d"] = function() end,
["m"] = function() end,
["a"] = function() end,
["u"] = function() end,
["C"] = function() end,
["c"] = function() end,
},
},
filesystem = {
filtered_items = {
show_hidden_count = false,
},
components = {
-- hide file icon
icon = function(config, node, state)
if node.type == 'file' then
return {
text = "",
highlight = config.highlight,
}
end
return require('neo-tree.sources.common.components').icon(config, node, state)
end,
} -- components
}, -- filesystem
event_handlers = {{
event = "neo_tree_buffer_enter",
handler = function(arg)
vim.cmd [[
setlocal relativenumber
]]
end,
}},
})
-- set keymaps
local keymap = vim.keymap -- for conciseness
keymap.set("n", "<leader>e", "<cmd>Neotree toggle filesystem right<cr>")
keymap.set("n", "<F3>", "<cmd>Neotree toggle filesystem right<cr>")
keymap.set("n", "<space>e", "<cmd>Neotree filesystem reveal right<cr>")
keymap.set("n", "<F4>", "<cmd>Neotree filesystem reveal right<cr>")
end,
}
-- EOP
That sounds a lot like a feature request to me, not a bug.
@cseickel , any advance ?
I'd like to request this feature as well. It would be great if <TAB> worked for all commands involving file paths, or at least allow to delegate this functionality to other plugin.