WIP neo-tree WIP
This commit is contained in:
parent
fd62e8aa32
commit
feed555e48
3 changed files with 99 additions and 0 deletions
|
@ -48,6 +48,9 @@ with final.pkgs.lib; let
|
|||
lualine-nvim
|
||||
noice-nvim
|
||||
indent-blankline-nvim
|
||||
|
||||
# Editor
|
||||
neo-tree-nvim
|
||||
];
|
||||
|
||||
extraPackages = with pkgs; [
|
||||
|
|
5
nvim/lua/plugins/editor/init.lua
Normal file
5
nvim/lua/plugins/editor/init.lua
Normal file
|
@ -0,0 +1,5 @@
|
|||
local req = require('lib.marleyvim').localRequire('plugins.editor')
|
||||
|
||||
return {
|
||||
req('neo-tree-nvim'),
|
||||
}
|
91
nvim/lua/plugins/editor/neo-tree-nvim.lua
Normal file
91
nvim/lua/plugins/editor/neo-tree-nvim.lua
Normal file
|
@ -0,0 +1,91 @@
|
|||
local lazyvim_root = require('lib.lazyvim.root')
|
||||
|
||||
---@param root? boolean
|
||||
---@param grouped? boolean
|
||||
local function make_toggle_mapping(root, grouped)
|
||||
root = root or false
|
||||
grouped = grouped or false
|
||||
|
||||
local lhs = grouped and '<LEADER>fe' or '<LEADER>e'
|
||||
lhs = root and lhs or (lhs:gsub('%l$', string.upper))
|
||||
|
||||
return {
|
||||
lhs,
|
||||
function()
|
||||
require('neo-tree.command').execute({
|
||||
toggle = true,
|
||||
dir = root and (lazyvim_root.get()) or (vim.uv.cwd()),
|
||||
})
|
||||
end,
|
||||
desc = 'Explorer (' .. (root and 'root' or 'cwd') .. ')',
|
||||
}
|
||||
end
|
||||
|
||||
return {
|
||||
'neo-tree.nvim',
|
||||
cmd = 'Neotree',
|
||||
keys = {
|
||||
make_toggle_mapping(true, true), -- root / grouped
|
||||
make_toggle_mapping(false, true), -- cwd / grouped
|
||||
make_toggle_mapping(true, false), -- root / non-grouped
|
||||
make_toggle_mapping(false, false), -- cwd / non-grouped
|
||||
{
|
||||
'<LEADER>ge',
|
||||
function()
|
||||
require('neo-tree.command').execute({
|
||||
source = 'git_status',
|
||||
toggle = true,
|
||||
})
|
||||
end,
|
||||
desc = 'Git explorer',
|
||||
},
|
||||
{
|
||||
'<LEADER>be',
|
||||
function()
|
||||
require('neo-tree.command').execute({
|
||||
source = 'buffers',
|
||||
toggle = true,
|
||||
})
|
||||
end,
|
||||
desc = 'Buffer explorer',
|
||||
},
|
||||
},
|
||||
before = function()
|
||||
require('lz.n').trigger_load({ 'plenary.nvim', 'mini.icons', 'nui.nvim' })
|
||||
end,
|
||||
after = function()
|
||||
require('neo-tree').setup({
|
||||
sources = { 'filesystem', 'buffers', 'git_status' },
|
||||
open_files_do_not_replace_types = {
|
||||
'terminal',
|
||||
'Trouble',
|
||||
'trouble',
|
||||
'qf',
|
||||
'Outline',
|
||||
},
|
||||
|
||||
filesystem = {
|
||||
bind_to_cwd = false,
|
||||
follow_current_file = { enabled = true },
|
||||
use_libuv_file_watcher = true,
|
||||
},
|
||||
|
||||
window = {
|
||||
mappings = {
|
||||
['l'] = 'open',
|
||||
['h'] = 'close_node',
|
||||
['<SPACE>'] = 'none',
|
||||
['Y'] = {
|
||||
function(state)
|
||||
local node = state.tree:get_node()
|
||||
local path = node:get_id()
|
||||
vim.fn.setreg('+', path, 'c')
|
||||
end,
|
||||
desc = 'copy path to clipboard',
|
||||
},
|
||||
['P'] = { 'toggle_preview', config = { use_float = false } },
|
||||
},
|
||||
},
|
||||
})
|
||||
end,
|
||||
}
|
Loading…
Reference in a new issue