updated neotree

pull/1708/head
Oluwatobi 1 year ago
parent 00ed47465d
commit 081d908c86

@ -1,115 +0,0 @@
require("neo-tree").setup({
cmd = "Neotree",
keys = {
{
"<leader>o",
function()
if vim.bo.filetype == "neo-tree" then
vim.cmd.wincmd "p"
else
vim.cmd.Neotree "focus"
end
end,
desc = "Toggle Explorer Focus"
},
{ "<C-n>", "<cmd>Neotree toggle<cr>", desc = "Toggle Explorer" }
},
init = function() vim.g.neo_tree_remove_legacy_commands = true end,
opts = {
auto_clean_after_session_restore = true,
close_if_last_window = true,
source_selector = {
winbar = true,
content_layout = "center",
},
commands = {
parent_or_close = function(state)
local node = state.tree:get_node()
if (node.type == "directory" or node:has_children()) and node:is_expanded() then
state.commands.toggle_node(state)
else
require("neo-tree.ui.renderer").focus_node(state, node:get_parent_id())
end
end,
child_or_open = function(state)
local node = state.tree:get_node()
if node.type == "directory" or node:has_children() then
if not node:is_expanded() then -- if unexpanded, expand
state.commands.toggle_node(state)
else -- if expanded and has children, seleect the next child
require("neo-tree.ui.renderer").focus_node(state, node:get_child_ids()[1])
end
else -- if not a directory just open it
state.commands.open(state)
end
end,
copy_selector = function(state)
local node = state.tree:get_node()
local filepath = node:get_id()
local filename = node.name
local modify = vim.fn.fnamemodify
local results = {
e = { val = modify(filename, ":e"), msg = "Extension only" },
f = { val = filename, msg = "Filename" },
F = { val = modify(filename, ":r"), msg = "Filename w/o extension" },
h = { val = modify(filepath, ":~"), msg = "Path relative to Home" },
p = { val = modify(filepath, ":."), msg = "Path relative to CWD" },
P = { val = filepath, msg = "Absolute path" },
}
local messages = {
{ "\nChoose to copy to clipboard:\n", "Normal" },
}
for i, result in pairs(results) do
if result.val and result.val ~= "" then
vim.list_extend(messages, {
{ ("%s."):format(i), "Identifier" },
{ (" %s: "):format(result.msg) },
{ result.val, "String" },
{ "\n" },
})
end
end
vim.api.nvim_echo(messages, false, {})
local result = results[vim.fn.getcharstr()]
if result and result.val and result.val ~= "" then
vim.notify("Copied: " .. result.val)
vim.fn.setreg("+", result.val)
end
end,
},
window = {
width = 30,
mappings = {
["<space>"] = false, -- disable space until we figure out which-key disabling
["[b"] = "prev_source",
["]b"] = "next_source",
o = "open",
--[[ O = "system_open", ]]
h = "parent_or_close",
l = "child_or_open",
Y = "copy_selector",
},
},
filesystem = {
hijack_netrw_behavior = "open_current",
use_libuv_file_watcher = true,
follow_current_file = {
enabled = true, -- This will find and focus the file in the active buffer every time
-- -- the current file is changed while the tree is open.
leave_dirs_open = false, -- `false` closes auto expanded dirs, such as with `:Neotree reveal`
},
},
event_handlers = {
{
event = "neo_tree_buffer_enter",
handler = function(_)
vim.opt_local.signcolumn = "auto"
-- require("neo-tree").close_all()
end,
},
},
},
})

@ -32,6 +32,7 @@
"nvim-treesitter-textobjects": { "branch": "master", "commit": "34867c69838078df7d6919b130c0541c0b400c47" },
"nvim-ts-autotag": { "branch": "main", "commit": "dc5e1687ab76ee02e0f11c5ce137f530b36e98b3" },
"nvim-web-devicons": { "branch": "master", "commit": "5be6c4e685618b99c3210a69375b38a1202369b4" },
"nvim-window-picker": { "branch": "main", "commit": "41cfaa428577c53552200a404ae9b3a0b5719706" },
"plenary.nvim": { "branch": "master", "commit": "a3e3bc82a3f95c5ed0d7201546d5d2c19b20d683" },
"tailwind-tools.nvim": { "branch": "master", "commit": "7f1dda9ac3fb0460dfa4243656e8f00e36856385" },
"telescope-fzf-native.nvim": { "branch": "main", "commit": "cf48d4dfce44e0b9a2e19a008d6ec6ea6f01a83b" },

@ -1,52 +1,70 @@
return {
"nvim-neo-tree/neo-tree.nvim",
branch = "v3.x",
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-tree/nvim-web-devicons",
"MunifTanjim/nui.nvim",
"3rd/image.nvim",
'nvim-neo-tree/neo-tree.nvim',
branch = 'v3.x',
dependencies = {
'nvim-lua/plenary.nvim',
'nvim-tree/nvim-web-devicons',
'MunifTanjim/nui.nvim',
'3rd/image.nvim',
{
's1n7ax/nvim-window-picker',
version = '2.*',
config = function()
require('window-picker').setup {
filter_rules = {
include_current_win = false,
autoselect_one = true,
bo = {
filetype = { 'neo-tree', 'neo-tree-popup', 'notify' },
buftype = { 'terminal', 'quickfix' },
},
},
}
end,
},
cmd = "Neotree",
},
cmd = 'Neotree',
keys = {
{
"<leader>o",
'<leader>o',
function()
if vim.bo.filetype == "neo-tree" then
vim.cmd.wincmd "p"
if vim.bo.filetype == 'neo-tree' then
vim.cmd.wincmd 'p'
else
vim.cmd.Neotree "focus"
vim.cmd.Neotree 'focus'
end
end,
desc = "Toggle Explorer Focus"
desc = 'Toggle Explorer Focus',
},
{ "<C-n>", "<cmd>Neotree toggle<cr>", desc = "Toggle Explorer" }
{ '<C-n>', '<cmd>Neotree toggle<cr>', desc = 'Toggle Explorer' },
},
init = function() vim.g.neo_tree_remove_legacy_commands = true end,
init = function()
vim.g.neo_tree_remove_legacy_commands = true
end,
opts = {
auto_clean_after_session_restore = true,
close_if_last_window = true,
source_selector = {
winbar = true,
content_layout = "center",
content_layout = 'center',
},
commands = {
parent_or_close = function(state)
local node = state.tree:get_node()
if (node.type == "directory" or node:has_children()) and node:is_expanded() then
if (node.type == 'directory' or node:has_children()) and node:is_expanded() then
state.commands.toggle_node(state)
else
require("neo-tree.ui.renderer").focus_node(state, node:get_parent_id())
require('neo-tree.ui.renderer').focus_node(state, node:get_parent_id())
end
end,
child_or_open = function(state)
local node = state.tree:get_node()
if node.type == "directory" or node:has_children() then
if node.type == 'directory' or node:has_children() then
if not node:is_expanded() then -- if unexpanded, expand
state.commands.toggle_node(state)
else -- if expanded and has children, seleect the next child
require("neo-tree.ui.renderer").focus_node(state, node:get_child_ids()[1])
else -- if expanded and has children, seleect the next child
require('neo-tree.ui.renderer').focus_node(state, node:get_child_ids()[1])
end
else -- if not a directory just open it
state.commands.open(state)
@ -59,62 +77,62 @@ return {
local modify = vim.fn.fnamemodify
local results = {
e = { val = modify(filename, ":e"), msg = "Extension only" },
f = { val = filename, msg = "Filename" },
F = { val = modify(filename, ":r"), msg = "Filename w/o extension" },
h = { val = modify(filepath, ":~"), msg = "Path relative to Home" },
p = { val = modify(filepath, ":."), msg = "Path relative to CWD" },
P = { val = filepath, msg = "Absolute path" },
e = { val = modify(filename, ':e'), msg = 'Extension only' },
f = { val = filename, msg = 'Filename' },
F = { val = modify(filename, ':r'), msg = 'Filename w/o extension' },
h = { val = modify(filepath, ':~'), msg = 'Path relative to Home' },
p = { val = modify(filepath, ':.'), msg = 'Path relative to CWD' },
P = { val = filepath, msg = 'Absolute path' },
}
local messages = {
{ "\nChoose to copy to clipboard:\n", "Normal" },
{ '\nChoose to copy to clipboard:\n', 'Normal' },
}
for i, result in pairs(results) do
if result.val and result.val ~= "" then
if result.val and result.val ~= '' then
vim.list_extend(messages, {
{ ("%s."):format(i), "Identifier" },
{ (" %s: "):format(result.msg) },
{ result.val, "String" },
{ "\n" },
{ ('%s.'):format(i), 'Identifier' },
{ (' %s: '):format(result.msg) },
{ result.val, 'String' },
{ '\n' },
})
end
end
vim.api.nvim_echo(messages, false, {})
local result = results[vim.fn.getcharstr()]
if result and result.val and result.val ~= "" then
vim.notify("Copied: " .. result.val)
vim.fn.setreg("+", result.val)
if result and result.val and result.val ~= '' then
vim.notify('Copied: ' .. result.val)
vim.fn.setreg('+', result.val)
end
end,
},
window = {
width = 30,
mappings = {
["<space>"] = false, -- disable space until we figure out which-key disabling
["[b"] = "prev_source",
["]b"] = "next_source",
o = "open",
['<space>'] = false, -- disable space until we figure out which-key disabling
['[b'] = 'prev_source',
[']b'] = 'next_source',
o = 'open',
--[[ O = "system_open", ]]
h = "parent_or_close",
l = "child_or_open",
Y = "copy_selector",
h = 'parent_or_close',
l = 'child_or_open',
Y = 'copy_selector',
},
},
filesystem = {
hijack_netrw_behavior = "open_current",
hijack_netrw_behavior = 'open_current',
use_libuv_file_watcher = true,
follow_current_file = {
enabled = true, -- This will find and focus the file in the active buffer every time
enabled = true, -- This will find and focus the file in the active buffer every time
-- -- the current file is changed while the tree is open.
leave_dirs_open = false, -- `false` closes auto expanded dirs, such as with `:Neotree reveal`
leave_dirs_open = false, -- `false` closes auto expanded dirs, such as with `:Neotree reveal`
},
},
event_handlers = {
{
event = "neo_tree_buffer_enter",
event = 'neo_tree_buffer_enter',
handler = function(_)
vim.opt_local.signcolumn = "auto"
vim.opt_local.signcolumn = 'auto'
-- require("neo-tree").close_all()
end,
},

Loading…
Cancel
Save