diff --git a/LOG.md b/LOG.md index 80518f2..0b8276a 100644 --- a/LOG.md +++ b/LOG.md @@ -30,6 +30,8 @@ Record every decision here with a short rationale. Append new entries; do not re - netrw for tree view and preview splits; Oil for operations that would break buffer names - PHP `gf` enhancement via `includeexpr` for WordPress/PHP path resolution - **Working directory locked to project root**: Disabled `autochdir`, set `netrw_keepdir = 1`, captured initial cwd in `vim.g.project_root`, configured Telescope to always search from project root regardless of current buffer +- 2026-07-06: **Alternate-buffer netrw skip**: Added a lightweight real-file buffer tracker and mapped ``/`` so alternate-buffer jumps skip netrw explorer buffers when `#` points at netrw. Netrw buffers are also marked unlisted on FileType to reduce their impact on buffer navigation while preserving netrw browsing behavior. Fallback uses explicit `:buffer #` instead of `:normal! ` so regular alternate-file switching still works from the Lua mapping. +- 2026-07-07: **Netrw alternate detection fix**: Real netrw alternate buffers can lose `filetype=netrw` and remain as an unlisted `NetrwTreeListing` buffer. The alternate-buffer skip now detects that buffer name as netrw so `` returns to the previous real file instead of reopening an empty explorer buffer. - 2025-12-07: Treesitter Phase 5 decisions: - Focus on core languages: PHP, HTML, JavaScript, TypeScript, CSS, Markdown, Lua, Bash, JSON - Enable syntax highlighting with performance safeguard (disable for files >100KB) diff --git a/MIGRATION_PLAN.md b/MIGRATION_PLAN.md index 001dc84..1286e61 100644 --- a/MIGRATION_PLAN.md +++ b/MIGRATION_PLAN.md @@ -481,6 +481,7 @@ Source of truth for the step-by-step rebuild. Keep this concise and up to date. - [ ] Validate netrw browsing and preview splits - [ ] Validate Oil.nvim file operations - [x] Fix working directory behavior (disabled autochdir, locked Telescope to project root) +- [x] Make alternate-buffer jumps skip netrw explorer buffers when returning to the last real file ## Phase 12.5 — Language tooling validation - [ ] Validate HTML/PHP/JS/Markdown tooling diff --git a/README.md b/README.md index b233d8d..067fc05 100644 --- a/README.md +++ b/README.md @@ -74,6 +74,7 @@ Core keymaps available globally (not plugin-specific). These provide fallbacks f | n | `nt` | Open netrw in new tab at current file's directory | | n | `nT` | Open netrw in new tab at project root | | n | `nr` | Open netrw in current window at project root | +| n | `` / `` | Jump to alternate file, skipping netrw explorer buffers | **Note:** Project root is stored as the initial working directory when Neovim starts. This allows navigation back to the project root even after following symlinks to external directories. @@ -504,4 +505,4 @@ The working directory (`:pwd`) is locked to the directory where you opened Neovi - `netrw_keepdir = 1` prevents netrw from changing directory when browsing - Project root is captured at startup in `vim.g.project_root` (used by Telescope and netrw) - Telescope searches from the initial project root regardless of current buffer -- Use `:cd ` to manually change directory if needed (affects Telescope search scope) \ No newline at end of file +- Use `:cd ` to manually change directory if needed (affects Telescope search scope) diff --git a/lua/netrw-config.lua b/lua/netrw-config.lua index de3e558..94b9fcd 100644 --- a/lua/netrw-config.lua +++ b/lua/netrw-config.lua @@ -1,4 +1,46 @@ local map = vim.keymap.set +local last_file_buf +local previous_file_buf + +local function is_real_file_buffer(buf) + return vim.api.nvim_buf_is_valid(buf) + and vim.bo[buf].buflisted + and vim.bo[buf].buftype == '' + and vim.bo[buf].filetype ~= 'netrw' + and vim.api.nvim_buf_get_name(buf) ~= '' +end + +local function is_netrw_buffer(buf) + if not vim.api.nvim_buf_is_valid(buf) then + return false + end + + return vim.bo[buf].filetype == 'netrw' or vim.api.nvim_buf_get_name(buf):match('NetrwTreeListing$') ~= nil +end + +local function switch_to_buffer(buf) + vim.cmd('buffer ' .. buf) +end + +local function switch_to_native_alternate() + pcall(vim.cmd, 'buffer #') +end + +local function jump_to_alternate_file() + local alternate = vim.fn.bufnr('#') + + if is_real_file_buffer(alternate) then + switch_to_buffer(alternate) + return + end + + if is_netrw_buffer(alternate) and is_real_file_buffer(previous_file_buf) then + switch_to_buffer(previous_file_buf) + return + end + + switch_to_native_alternate() +end -- Netrw configuration for file browsing -- Native Neovim file explorer (no plugins required) @@ -56,10 +98,28 @@ end, { desc = 'Netrw: Tab at project root', silent = true }) map('n', 'nr', function() vim.cmd('Explore ' .. vim.fn.fnameescape(vim.g.project_root)) end, { desc = 'Netrw: Open at project root', silent = true }) + +map('n', '', jump_to_alternate_file, { desc = 'Buffer: Alternate file skipping netrw', silent = true }) +map('n', '', jump_to_alternate_file, { desc = 'Buffer: Alternate file skipping netrw', silent = true }) + +vim.api.nvim_create_autocmd('BufEnter', { + desc = 'Track recent real file buffers for alternate-buffer jumps', + callback = function(args) + local buf = args.buf + + if is_real_file_buffer(buf) and buf ~= last_file_buf then + previous_file_buf = last_file_buf + last_file_buf = buf + end + end, +}) + -- Enable line numbers in netrw buffers vim.api.nvim_create_autocmd('FileType', { pattern = 'netrw', + desc = 'Configure netrw buffer-local options', callback = function() + vim.bo.buflisted = false vim.opt_local.number = true vim.opt_local.relativenumber = true end, diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index c8eed65..b208327 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -93,6 +93,10 @@ return { configure("bashls") configure("marksman") configure("intelephense", { + init_options = { + storagePath = vim.fn.stdpath("cache") .. "/intelephense", + globalStoragePath = vim.fn.stdpath("data") .. "/intelephense", + }, single_file_support = false, }) diff --git a/spell/en.utf-8.add b/spell/en.utf-8.add index bcf6093..285bde4 100644 --- a/spell/en.utf-8.add +++ b/spell/en.utf-8.add @@ -813,3 +813,23 @@ Jax APA RIS mathjax +wp +Imagick +Gipitty +sudo +render_box_row +microservices +Saa +tradeoffs +deduplication +signoff +wireframing +LOA +max +Nau +hardcode +NauSYS +rdv +Marmaris +EL2 +RigPro diff --git a/spell/en.utf-8.add.spl b/spell/en.utf-8.add.spl index 83c1cda..e45b731 100644 Binary files a/spell/en.utf-8.add.spl and b/spell/en.utf-8.add.spl differ