From b247db8531fd9b9a6b8e01c3808650517fe949a0 Mon Sep 17 00:00:00 2001 From: ray Date: Sun, 7 Dec 2025 18:53:18 +0000 Subject: [PATCH] update --- MIGRATION_PLAN.md | 5 +++-- init.lua | 1 + lua/keymaps.lua | 7 +++++++ lua/netrw-config.lua | 37 +++++++++++++++++++++++++++++++++++++ 4 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 lua/netrw-config.lua diff --git a/MIGRATION_PLAN.md b/MIGRATION_PLAN.md index 2c7dbb0..e23c962 100644 --- a/MIGRATION_PLAN.md +++ b/MIGRATION_PLAN.md @@ -116,8 +116,9 @@ Source of truth for the step-by-step rebuild. Keep this concise and up to date. - [x] Note: Oil.nvim is for evaluation; alternative is mini.files if too heavy ## Phase 4.2 — Configure netrw -- [ ] Configure netrw with tree view, preview split, and basic settings (no banner, sensible defaults) -- [ ] Add simple keymaps for opening netrw (e.g., in split, tab, or current window) +- [x] Configure netrw with tree view, preview split, and basic settings (no banner, sensible defaults) +- [x] Created `lua/netrw-config.lua` with settings: tree view, preview split, 25% width, human-readable sizes +- [x] Add simple keymaps for opening netrw: `e` (current window), `v` (vertical split), `te` (new tab) ## Phase 4.2.1 — PHP gf enhancement - [x] Add PHP `includeexpr` for intelligent `gf` behavior (handles `__DIR__`, `__FILE__`, `dirname(__FILE__)` patterns) diff --git a/init.lua b/init.lua index 4bf981c..233c95d 100644 --- a/init.lua +++ b/init.lua @@ -4,6 +4,7 @@ vim.g.maplocalleader = ' ' -- Load basic settings, keymaps, autocmds (kept minimal for now) require('settings') +require('netrw-config') require('keymaps') require('autocmds') diff --git a/lua/keymaps.lua b/lua/keymaps.lua index c017f72..4bcc35a 100644 --- a/lua/keymaps.lua +++ b/lua/keymaps.lua @@ -39,4 +39,11 @@ 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() + vim.cmd('tabnew') + vim.cmd('Explore ' .. vim.fn.expand('%:p:h')) +end, { desc = 'Tab explore (netrw in new tab)', silent = true }) + return {} diff --git a/lua/netrw-config.lua b/lua/netrw-config.lua new file mode 100644 index 0000000..165658a --- /dev/null +++ b/lua/netrw-config.lua @@ -0,0 +1,37 @@ +-- Netrw configuration for file browsing +-- Native Neovim file explorer (no plugins required) + +-- Hide the banner (that annoying help text at the top) +vim.g.netrw_banner = 0 + +-- Tree view by default (3 = tree style) +-- Options: 0=thin, 1=long, 2=wide, 3=tree +vim.g.netrw_liststyle = 3 + +-- Preview in horizontal split (underneath) +vim.g.netrw_preview = 0 + +-- Open preview splits below (1=below, 0=above) +vim.g.netrw_alto = 0 + +-- Window size for preview splits (percentage for preview window) +-- 50% split when pressing 'p' +vim.g.netrw_winsize = 50 + +-- Keep the current directory and browsing directory synced +-- This makes netrw respect your current working directory +vim.g.netrw_keepdir = 0 + +-- Open files in the same window (replace netrw buffer) +-- Options: 0=same window, 1=horizontal split, 2=vertical split, 3=new tab, 4=previous window +-- Using 0 so Enter opens file in netrw window itself +vim.g.netrw_browse_split = 0 + +-- Sort order: name (empty), time (t), size (s), exten (e) +vim.g.netrw_sort_by = 'name' + +-- Hide dotfiles by default (toggle with 'gh' in netrw) +vim.g.netrw_list_hide = [[^\.\.\=/\=$]] + +-- Use human-readable file sizes +vim.g.netrw_sizestyle = 'H'