Changed to neo-tree explorer
This commit is contained in:
parent
f7684a5e9d
commit
b7e907d548
@ -1,5 +1,7 @@
|
||||
vim.g.mapleader = ' '
|
||||
vim.g.maplocalleader = ' '
|
||||
vim.g.loaded_netrw = 1
|
||||
vim.g.loaded_netrwPlugin = 1
|
||||
|
||||
-- Set highlight on search
|
||||
vim.o.hlsearch = false
|
||||
@ -317,13 +319,84 @@ require('lazy').setup({
|
||||
},
|
||||
|
||||
{
|
||||
"nvim-tree/nvim-tree.lua",
|
||||
version = "*",
|
||||
"nvim-neo-tree/neo-tree.nvim",
|
||||
branch = "v2.x",
|
||||
dependencies = {
|
||||
"nvim-lua/plenary.nvim",
|
||||
"nvim-tree/nvim-web-devicons",
|
||||
"MunifTanjim/nui.nvim",
|
||||
},
|
||||
config = function()
|
||||
require("nvim-tree").setup {}
|
||||
require("neo-tree").setup {
|
||||
close_if_last_window = true,
|
||||
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
|
||||
o = "open",
|
||||
h = "parent_or_close",
|
||||
l = "child_or_open",
|
||||
Y = "copy_selector",
|
||||
},
|
||||
},
|
||||
}
|
||||
end,
|
||||
},
|
||||
|
||||
@ -667,3 +740,4 @@ vim.keymap.set('n', '<C-m>', ":make<cr>", { desc = 'Format code', silent = true
|
||||
vim.keymap.set('n', '<C-n>', ":make clean<cr>", { desc = 'Format code', silent = true })
|
||||
vim.keymap.set('n', '<leader>n', ":tabnew<cr>", { desc = 'Format code', silent = true })
|
||||
vim.keymap.set('n', '<leader>c', ":tabclose<cr>", { desc = 'Format code', silent = true })
|
||||
vim.keymap.set('n', '<leader>e', ":NeoTreeShowToggle<cr>", { desc = 'File explorer', silent = true })
|
||||
|
||||
@ -218,8 +218,8 @@ function theme.setup()
|
||||
|
||||
-- nvim-tree.lua: https://github.com/nvim-tree/nvim-tree.lua
|
||||
NvimTreeEmptyFolderName = { fg = p.foreground },
|
||||
NvimTreeEndOfBuffer = { fg = p.black, bg = p.black },
|
||||
NvimTreeEndOfBufferNC = { fg = p.black, bg = p.black },
|
||||
NvimTreeEndOfBuffer = { fg = p.background, bg = p.background },
|
||||
NvimTreeEndOfBufferNC = { fg = p.background, bg = p.background },
|
||||
NvimTreeFolderIcon = { fg = p.color4, bg = p.background },
|
||||
NvimTreeFolderName = { fg = p.foreground },
|
||||
NvimTreeGitDeleted = { fg = p.color1 },
|
||||
@ -227,14 +227,14 @@ function theme.setup()
|
||||
NvimTreeGitNew = { fg = p.color4 },
|
||||
NvimTreeImageFile = { fg = p.foreground },
|
||||
NvimTreeIndentMarker = { fg = p.color0 },
|
||||
NvimTreeNormal = { fg = p.foreground, bg = p.black },
|
||||
NvimTreeNormalNC = { fg = p.foreground, bg = p.black },
|
||||
NvimTreeNormal = { fg = p.foreground, bg = p.background },
|
||||
NvimTreeNormalNC = { fg = p.foreground, bg = p.background },
|
||||
NvimTreeOpenedFolderName = { fg = p.foreground },
|
||||
NvimTreeRootFolder = { fg = p.color12 },
|
||||
NvimTreeSpecialFile = { fg = p.color5 },
|
||||
NvimTreeStatusLineNC = { bg = p.background, fg = p.color16 },
|
||||
NvimTreeSymlink = { fg = p.color3 },
|
||||
NvimTreeWinSeparator = { fg = p.background },
|
||||
NvimTreeWinSeparator = { fg = p.black },
|
||||
|
||||
-- nvim-treesitter: https://github.com/nvim-treesitter/nvim-treesitter
|
||||
["@attribute"] = { fg = p.color4 },
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user