From 0a3afcec71347f6515abb1b8a715b04d4802941b Mon Sep 17 00:00:00 2001 From: Tyler Hallada Date: Fri, 1 Dec 2023 15:26:01 -0500 Subject: [PATCH] Removing drex in favor of nvim-tree For vinegar-style directory navigation. It seems like nvim-tree has gotten better at this since I last tried it, and I prefer nvim-tree over drex. --- lua/install-plugins.lua | 7 ------- lua/plugins/drex-nvim.lua | 44 --------------------------------------- lua/plugins/nvim-tree.lua | 29 +++++++++++++------------- 3 files changed, 14 insertions(+), 66 deletions(-) delete mode 100644 lua/plugins/drex-nvim.lua diff --git a/lua/install-plugins.lua b/lua/install-plugins.lua index 5c8bdfb..cc6a179 100644 --- a/lua/install-plugins.lua +++ b/lua/install-plugins.lua @@ -435,13 +435,6 @@ 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 { 'norcalli/nvim-colorizer.lua', config = function() diff --git a/lua/plugins/drex-nvim.lua b/lua/plugins/drex-nvim.lua deleted file mode 100644 index 9d608ee..0000000 --- a/lua/plugins/drex-nvim.lua +++ /dev/null @@ -1,44 +0,0 @@ -local drex = require('drex') -local elements = require('drex.elements') - --- open the home directory -vim.keymap.set('n', '~', 'Drex ~', { desc = "Open home [~] directory in drex" }) --- 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, { desc = "Open current directory in drex" }) - -require('drex.config').configure({ - hijack_netrw = true, - keybindings = { - ['n'] = { - ['~'] = 'Drex ~', - ['-'] = 'lua require("drex.elements").open_parent_directory()', - ['.'] = function() - local element = require('drex.utils').get_element(vim.api.nvim_get_current_line()) - local left = vim.api.nvim_replace_termcodes('', true, false, true) - vim.api.nvim_feedkeys(': ' .. element .. string.rep(left, #element + 1), 'n', true) - end, - [''] = 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, -}) diff --git a/lua/plugins/nvim-tree.lua b/lua/plugins/nvim-tree.lua index 513549f..2e9116e 100644 --- a/lua/plugins/nvim-tree.lua +++ b/lua/plugins/nvim-tree.lua @@ -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,15 +17,14 @@ 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 --- swapping this out with drex.nvim instead --- vim.keymap.set('n', '-', function() toggle_replace() end, { noremap = true, silent = true }) +vim.keymap.set('n', '-', function() toggle_replace() end, { noremap = true, silent = true }) vim.keymap.set('n', 'n', [[NvimTreeToggle]], { noremap = true, silent = true, desc = "Toggle [N]vim Tree" })