Replace nvim-tree with drex.nvim for vim-vinegar replacement
This commit is contained in:
parent
a7dcacdd91
commit
75dacaf7bc
@ -390,6 +390,13 @@ return require('packer').startup(function(use)
|
||||
require('plugins.rest-nvim')
|
||||
end,
|
||||
}
|
||||
use {
|
||||
'theblob42/drex.nvim',
|
||||
requires = 'kyazdani42/nvim-web-devicons',
|
||||
config = function()
|
||||
require('plugins.drex-nvim')
|
||||
end,
|
||||
}
|
||||
use {
|
||||
'folke/which-key.nvim',
|
||||
config = function()
|
||||
|
44
lua/plugins/drex-nvim.lua
Normal file
44
lua/plugins/drex-nvim.lua
Normal file
@ -0,0 +1,44 @@
|
||||
local drex = require('drex')
|
||||
local elements = require('drex.elements')
|
||||
|
||||
-- open the home directory
|
||||
vim.keymap.set('n', '~', '<CMD>Drex ~<CR>', {})
|
||||
-- open parent DREX buffer and focus current file
|
||||
vim.keymap.set('n', '-', function()
|
||||
local path = vim.fn.expand('%:p')
|
||||
if path == '' then
|
||||
drex.open_directory_buffer() -- open at cwd
|
||||
else
|
||||
drex.open_directory_buffer(vim.fn.fnamemodify(path, ':h'))
|
||||
elements.focus_element(0, path)
|
||||
end
|
||||
end, {})
|
||||
|
||||
require('drex.config').configure({
|
||||
hijack_netrw = true,
|
||||
keybindings = {
|
||||
['n'] = {
|
||||
['~'] = '<CMD>Drex ~<CR>',
|
||||
['-'] = '<CMD>lua require("drex.elements").open_parent_directory()<CR>',
|
||||
['.'] = function()
|
||||
local element = require('drex.utils').get_element(vim.api.nvim_get_current_line())
|
||||
local left = vim.api.nvim_replace_termcodes('<left>', true, false, true)
|
||||
vim.api.nvim_feedkeys(': ' .. element .. string.rep(left, #element + 1), 'n', true)
|
||||
end,
|
||||
['<CR>'] = function()
|
||||
local line = vim.api.nvim_get_current_line()
|
||||
|
||||
if require('drex.utils').is_open_directory(line) then
|
||||
elements.collapse_directory()
|
||||
else
|
||||
elements.expand_element()
|
||||
end
|
||||
end,
|
||||
}
|
||||
},
|
||||
on_enter = function()
|
||||
vim.opt_local.number = false
|
||||
vim.opt_local.relativenumber = false
|
||||
vim.opt_local.signcolumn = 'no'
|
||||
end,
|
||||
})
|
@ -1,4 +1,5 @@
|
||||
require('lualine').setup({
|
||||
extensions = { 'drex' },
|
||||
sections = {
|
||||
lualine_c = {
|
||||
require('auto-session-library').current_session_name,
|
||||
|
@ -1,9 +1,9 @@
|
||||
require('nvim-tree').setup({
|
||||
hijack_netrw = true,
|
||||
hijack_directories = {
|
||||
enable = true,
|
||||
auto_open = true,
|
||||
},
|
||||
-- hijack_netrw = true,
|
||||
-- hijack_directories = {
|
||||
-- enable = true,
|
||||
-- auto_open = true,
|
||||
-- },
|
||||
view = {
|
||||
mappings = {
|
||||
list = {
|
||||
@ -17,14 +17,15 @@ require('nvim-tree').setup({
|
||||
},
|
||||
})
|
||||
|
||||
local function toggle_replace()
|
||||
local view = require('nvim-tree.view')
|
||||
if view.is_visible() then
|
||||
view.close()
|
||||
else
|
||||
require('nvim-tree').open_replacing_current_buffer()
|
||||
end
|
||||
end
|
||||
-- local function toggle_replace()
|
||||
-- local view = require('nvim-tree.view')
|
||||
-- if view.is_visible() then
|
||||
-- view.close()
|
||||
-- else
|
||||
-- require('nvim-tree').open_replacing_current_buffer()
|
||||
-- end
|
||||
-- end
|
||||
|
||||
vim.keymap.set('n', '-', function() toggle_replace() end, { noremap = true, silent = true })
|
||||
-- swapping this out with drex.nvim instead
|
||||
-- vim.keymap.set('n', '-', function() toggle_replace() end, { noremap = true, silent = true })
|
||||
vim.keymap.set('n', '<leader>n', [[<Cmd>NvimTreeToggle<CR>]], { noremap = true, silent = true })
|
||||
|
Loading…
Reference in New Issue
Block a user