2023-09-06 00:26:45 +02:00
|
|
|
-- Plugin: Neo-tree
|
|
|
|
-- https://github.com/rafi/vim-config
|
|
|
|
|
2023-09-07 13:20:56 +02:00
|
|
|
|
2023-09-06 00:26:45 +02:00
|
|
|
local winwidth = 30
|
|
|
|
|
|
|
|
-- Toggle width.
|
|
|
|
local toggle_width = function()
|
|
|
|
local max = winwidth * 2
|
|
|
|
local cur_width = vim.fn.winwidth(0)
|
|
|
|
local half = math.floor((winwidth + (max - winwidth) / 2) + 0.4)
|
|
|
|
local new_width = winwidth
|
|
|
|
if cur_width == winwidth then
|
|
|
|
new_width = half
|
|
|
|
elseif cur_width == half then
|
|
|
|
new_width = max
|
|
|
|
else
|
|
|
|
new_width = winwidth
|
|
|
|
end
|
|
|
|
vim.cmd(new_width .. ' wincmd |')
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Get current opened directory from state.
|
|
|
|
---@param state table
|
|
|
|
---@return string
|
|
|
|
local function get_current_directory(state)
|
|
|
|
local node = state.tree:get_node()
|
|
|
|
local path = node.path
|
|
|
|
if node.type ~= 'directory' or not node:is_expanded() then
|
|
|
|
local path_separator = package.config:sub(1, 1)
|
|
|
|
path = path:match('(.*)' .. path_separator)
|
|
|
|
end
|
|
|
|
return path
|
|
|
|
end
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
'nvim-neo-tree/neo-tree.nvim',
|
|
|
|
dependencies = {
|
|
|
|
'MunifTanjim/nui.nvim',
|
|
|
|
's1n7ax/nvim-window-picker',
|
|
|
|
},
|
|
|
|
cmd = 'Neotree',
|
|
|
|
keys = {
|
|
|
|
{
|
|
|
|
'<LocalLeader>e',
|
|
|
|
'<cmd>Neotree filesystem left toggle dir=./<CR>',
|
|
|
|
desc = 'Explorer NeoTree Toggle',
|
|
|
|
},
|
2023-09-06 01:26:46 +02:00
|
|
|
{
|
2023-09-06 10:19:56 +02:00
|
|
|
'<F5>',
|
|
|
|
'<cmd>Neotree filesystem left toggle dir=./<CR>',
|
|
|
|
desc = 'Explorer NeoTree Toggle',
|
2023-09-06 01:26:46 +02:00
|
|
|
},
|
2023-09-06 00:26:45 +02:00
|
|
|
},
|
|
|
|
deactivate = function()
|
|
|
|
vim.cmd([[Neotree close]])
|
|
|
|
end,
|
|
|
|
init = function()
|
|
|
|
vim.g.neo_tree_remove_legacy_commands = 1
|
|
|
|
if vim.fn.argc() == 1 then
|
|
|
|
local stat = vim.loop.fs_stat(tostring(vim.fn.argv(0)))
|
|
|
|
if stat and stat.type == 'directory' then
|
|
|
|
require('neo-tree')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
-- See: https://github.com/nvim-neo-tree/neo-tree.nvim
|
|
|
|
opts = {
|
|
|
|
close_if_last_window = true,
|
|
|
|
|
|
|
|
source_selector = {
|
|
|
|
winbar = false,
|
|
|
|
show_scrolled_off_parent_node = true,
|
|
|
|
padding = { left = 1, right = 0 },
|
|
|
|
sources = {
|
|
|
|
{ source = 'filesystem', display_name = ' Files' }, --
|
|
|
|
{ source = 'buffers', display_name = ' Buffers' }, --
|
|
|
|
{ source = 'git_status', display_name = ' Git' }, --
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2023-09-06 10:19:56 +02:00
|
|
|
-- event_handlers = {
|
|
|
|
-- -- Close neo-tree when opening a file.
|
|
|
|
-- {
|
|
|
|
-- event = 'file_opened',
|
|
|
|
-- handler = function()
|
|
|
|
-- require('neo-tree').close_all()
|
|
|
|
-- end,
|
|
|
|
-- },
|
|
|
|
-- },
|
2023-09-06 00:26:45 +02:00
|
|
|
|
|
|
|
default_component_configs = {
|
|
|
|
indent = {
|
|
|
|
padding = 0,
|
|
|
|
},
|
|
|
|
icon = {
|
|
|
|
folder_closed = '',
|
|
|
|
folder_open = '',
|
|
|
|
folder_empty = '',
|
|
|
|
folder_empty_open = '',
|
|
|
|
default = '',
|
|
|
|
},
|
|
|
|
modified = {
|
|
|
|
symbol = '•',
|
|
|
|
},
|
|
|
|
name = {
|
|
|
|
trailing_slash = true,
|
|
|
|
highlight_opened_files = true, -- NeoTreeFileNameOpened
|
|
|
|
use_git_status_colors = false,
|
|
|
|
},
|
|
|
|
git_status = {
|
|
|
|
symbols = {
|
|
|
|
-- Change type
|
|
|
|
added = 'A',
|
|
|
|
deleted = 'D',
|
|
|
|
modified = 'M',
|
|
|
|
renamed = 'R',
|
|
|
|
-- Status type
|
|
|
|
untracked = 'U',
|
|
|
|
ignored = 'I',
|
|
|
|
unstaged = '',
|
|
|
|
staged = 'S',
|
|
|
|
conflict = 'C',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
window = {
|
|
|
|
width = winwidth,
|
|
|
|
mappings = {
|
|
|
|
['q'] = 'close_window',
|
2023-09-06 01:26:46 +02:00
|
|
|
['?'] = 'noop',
|
2023-09-06 00:26:45 +02:00
|
|
|
['<Space>'] = 'noop',
|
|
|
|
|
|
|
|
['g?'] = 'show_help',
|
|
|
|
['<2-LeftMouse>'] = 'open',
|
|
|
|
['<CR>'] = 'open_with_window_picker',
|
|
|
|
['l'] = 'open_drop',
|
2023-09-06 01:26:46 +02:00
|
|
|
['h'] = 'close_node',
|
|
|
|
['C'] = 'close_node',
|
2023-09-06 10:19:56 +02:00
|
|
|
['<C-c>'] = 'set_root',
|
2023-09-06 00:26:45 +02:00
|
|
|
['z'] = 'close_all_nodes',
|
|
|
|
['<C-r>'] = 'refresh',
|
|
|
|
|
2023-09-07 14:11:49 +02:00
|
|
|
['o'] = 'noop',
|
|
|
|
['os'] = 'open_split',
|
|
|
|
['ov'] = 'open_vsplit',
|
|
|
|
['ot'] = 'open_tabnew',
|
2023-09-06 00:26:45 +02:00
|
|
|
|
|
|
|
['c'] = { 'copy', config = { show_path = 'relative' } },
|
|
|
|
['m'] = { 'move', config = { show_path = 'relative' } },
|
|
|
|
['a'] = { 'add', nowait = true, config = { show_path = 'relative' } },
|
|
|
|
['N'] = { 'add_directory', config = { show_path = 'relative' } },
|
|
|
|
['d'] = 'noop',
|
|
|
|
['dd'] = 'delete',
|
|
|
|
['r'] = 'rename',
|
2023-09-07 13:20:56 +02:00
|
|
|
-- TODO: <leader>y to copy path name
|
2023-09-06 00:26:45 +02:00
|
|
|
['y'] = 'copy_to_clipboard',
|
|
|
|
['x'] = 'cut_to_clipboard',
|
|
|
|
['P'] = 'paste_from_clipboard',
|
|
|
|
['<S-Tab>'] = 'prev_source',
|
|
|
|
['<Tab>'] = 'next_source',
|
|
|
|
|
|
|
|
['p'] = {
|
|
|
|
'toggle_preview',
|
|
|
|
nowait = true,
|
|
|
|
config = { use_float = true },
|
|
|
|
},
|
|
|
|
|
|
|
|
['w'] = toggle_width,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
filesystem = {
|
2023-09-06 20:14:57 +02:00
|
|
|
follow_current_file = {
|
2023-09-07 11:54:32 +02:00
|
|
|
enabled = false, -- This will find and focus the file in the active buffer every time
|
2023-09-06 20:14:57 +02:00
|
|
|
-- -- the current file is changed while the tree is open.
|
|
|
|
leave_dirs_open = true, -- `false` closes auto expanded dirs, such as with `:Neotree reveal`
|
|
|
|
},
|
2023-09-06 00:26:45 +02:00
|
|
|
window = {
|
|
|
|
mappings = {
|
|
|
|
['H'] = 'toggle_hidden',
|
|
|
|
['/'] = 'noop',
|
|
|
|
['f'] = 'fuzzy_finder',
|
|
|
|
['F'] = 'filter_on_submit',
|
|
|
|
['<C-x>'] = 'clear_filter',
|
|
|
|
['<C-c>'] = 'clear_filter',
|
|
|
|
['<BS>'] = 'navigate_up',
|
|
|
|
['.'] = 'set_root',
|
|
|
|
['[g'] = 'prev_git_modified',
|
|
|
|
[']g'] = 'next_git_modified',
|
|
|
|
|
|
|
|
['gf'] = function(state)
|
|
|
|
require('telescope.builtin').find_files({
|
|
|
|
cwd = get_current_directory(state),
|
|
|
|
})
|
|
|
|
end,
|
|
|
|
|
|
|
|
['gr'] = function(state)
|
|
|
|
require('telescope.builtin').live_grep({
|
|
|
|
cwd = get_current_directory(state),
|
|
|
|
})
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
},
|
2023-09-06 20:14:57 +02:00
|
|
|
group_empty_dirs = false,
|
2023-09-06 00:26:45 +02:00
|
|
|
use_libuv_file_watcher = true,
|
|
|
|
bind_to_cwd = false,
|
|
|
|
cwd_target = {
|
|
|
|
sidebar = 'window',
|
|
|
|
current = 'window',
|
|
|
|
},
|
|
|
|
|
|
|
|
filtered_items = {
|
|
|
|
visible = false,
|
|
|
|
show_hidden_count = true,
|
2023-09-06 18:36:52 +02:00
|
|
|
hide_dotfiles = true,
|
2023-09-06 00:26:45 +02:00
|
|
|
hide_gitignored = false,
|
|
|
|
hide_by_name = {
|
|
|
|
'.git',
|
|
|
|
'.hg',
|
|
|
|
'.svc',
|
|
|
|
'.DS_Store',
|
|
|
|
'thumbs.db',
|
|
|
|
'.sass-cache',
|
|
|
|
'node_modules',
|
|
|
|
'.pytest_cache',
|
|
|
|
'.mypy_cache',
|
|
|
|
'__pycache__',
|
|
|
|
'.stfolder',
|
|
|
|
'.stversions',
|
|
|
|
},
|
|
|
|
never_show = {},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
buffers = {
|
2023-09-06 20:14:57 +02:00
|
|
|
bind_to_cwd = true,
|
2023-09-06 00:26:45 +02:00
|
|
|
window = {
|
|
|
|
mappings = {
|
|
|
|
['<BS>'] = 'navigate_up',
|
|
|
|
['.'] = 'set_root',
|
|
|
|
['dd'] = 'buffer_delete',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|