From 8bde5cc4d30174692a20a21898a88bfa105438d6 Mon Sep 17 00:00:00 2001 From: ray Date: Sun, 7 Dec 2025 19:54:33 +0000 Subject: [PATCH] update --- lua/keymaps.lua | 14 -------------- lua/netrw-config.lua | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/lua/keymaps.lua b/lua/keymaps.lua index c08aa9c..c017f72 100644 --- a/lua/keymaps.lua +++ b/lua/keymaps.lua @@ -39,18 +39,4 @@ map('n', 'K', function() if lsp_has(0, 'hoverProvider') then vim.lsp.buf.hover() end end, { desc = 'Hover (LSP)', silent = true }) --- Netrw file explorer keymaps --- Open netrw in new tab at current file's directory -map('n', 'te', function() - local current_file_dir = vim.fn.expand('%:p:h') - vim.cmd('tabnew') - vim.cmd('Explore ' .. vim.fn.fnameescape(current_file_dir)) -end, { desc = 'Tab explore (current file dir)', silent = true }) - --- Open netrw in new tab at project root (cwd) -map('n', 'tE', function() - vim.cmd('tabnew') - vim.cmd('Explore ' .. vim.fn.fnameescape(vim.fn.getcwd())) -end, { desc = 'Tab explore (project root)', silent = true }) - return {} diff --git a/lua/netrw-config.lua b/lua/netrw-config.lua index 165658a..22746b7 100644 --- a/lua/netrw-config.lua +++ b/lua/netrw-config.lua @@ -1,3 +1,5 @@ +local map = vim.keymap.set + -- Netrw configuration for file browsing -- Native Neovim file explorer (no plugins required) @@ -35,3 +37,17 @@ vim.g.netrw_list_hide = [[^\.\.\=/\=$]] -- Use human-readable file sizes vim.g.netrw_sizestyle = 'H' + +-- Netrw file explorer keymaps +-- Open netrw in new tab at current file's directory +map('n', 'te', function() + local current_file_dir = vim.fn.expand('%:p:h') + vim.cmd('tabnew') + vim.cmd('Explore ' .. vim.fn.fnameescape(current_file_dir)) +end, { desc = 'Tab explore (current file dir)', silent = true }) + +-- Open netrw in new tab at project root (cwd) +map('n', 'tE', function() + vim.cmd('tabnew') + vim.cmd('Explore ' .. vim.fn.fnameescape(vim.fn.getcwd())) +end, { desc = 'Tab explore (project root)', silent = true }) \ No newline at end of file