diff --git a/LOG.md b/LOG.md index 6222096..59cb29f 100644 --- a/LOG.md +++ b/LOG.md @@ -9,6 +9,7 @@ Authoritative notes for the Neovim migration. Use this alongside `MIGRATION_PLAN Record every decision here with a short rationale. Append new entries; do not rewrite history. +- 2025-01-13: **Git files to quickfix**: Added `gf` keymap to send all modified, deleted, and untracked Git files to quickfix list with status indicators. Uses `git status --porcelain` to parse file status (Modified, Deleted, Added, Untracked, etc.) and displays it in the quickfix text column. Complements existing `hq` (Gitsigns hunks to quickfix) with file-level Git status workflow. - 2025-01-12: **Custom Tabline Function**: Implemented configurable custom tabline to replace Neovim's hardcoded path shortening (e.g., `a/p/file.txt`). Function in `lua/utils.lua` allows controlling: (1) number of full parent directories via `utils.tabline_full_parents` (default: 1), and (2) shortening length via `utils.tabline_shorten_length` (default: 3 characters). Example: with defaults, `/path/to/my/project/src/file.txt` becomes `pat/to/my/project/src/file.txt`. User preference for seeing enough context in shortened paths while keeping tab width manageable. - 2025-12-06: PHP LSP = `intelephense` (good PHP ecosystem support; integrates includePaths). - 2025-12-06: Enable Markdown LSP = `marksman` (lightweight, good MD features). diff --git a/README.md b/README.md index ad07b0f..5a1f849 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,7 @@ Core keymaps available globally (not plugin-specific). These provide fallbacks f | n | `]d` | Diagnostics: next item | Uses `vim.diagnostic.goto_next` | | n | `xd` | Diagnostic float | Opens hover window for cursor diagnostic | | n | `xt` | Toggle diagnostics | Flips `vim.diagnostic.enable()` | +| n | `gf` | Git: Changed files → quickfix | Lists all modified/deleted/untracked files with status | | n | `hi` | Highlight inspector | Shows highlight/capture stack under cursor | ### `lua/netrw-config.lua` diff --git a/lua/keymaps.lua b/lua/keymaps.lua index 595335d..382ca7c 100644 --- a/lua/keymaps.lua +++ b/lua/keymaps.lua @@ -50,6 +50,57 @@ map('n', 'xt', function() vim.diagnostic.enable(not vim.diagnostic.is_enabled()) end, { desc = 'Diagnostics: Toggle display', silent = true }) +-- Git: Modified, deleted, and untracked files to quickfix +map('n', 'gf', function() + -- Use git status --porcelain to get all changes with status indicators + -- Format: "XY filename" where X=index status, Y=worktree status + -- Status codes: M=modified, D=deleted, A=added, ??=untracked, etc. + local handle = io.popen('git status --porcelain 2>/dev/null') + if not handle then + vim.notify('Failed to run git status', vim.log.levels.ERROR) + return + end + + local result = handle:read('*a') + handle:close() + + if result == '' then + vim.notify('No git changes found', vim.log.levels.INFO) + return + end + + local qf_list = {} + local status_map = { + ['M'] = 'Modified', + ['A'] = 'Added', + ['D'] = 'Deleted', + ['R'] = 'Renamed', + ['C'] = 'Copied', + ['U'] = 'Unmerged', + ['?'] = 'Untracked', + } + + for line in result:gmatch('[^\n]+') do + -- Parse porcelain format: "XY filename" or "XY original -> renamed" + local index_status = line:sub(1, 1) + local work_status = line:sub(2, 2) + local filename = line:sub(4) -- Skip "XY " prefix + + -- Determine status text (worktree takes precedence over index) + local status_code = work_status ~= ' ' and work_status or index_status + local status_text = status_map[status_code] or 'Changed' + + table.insert(qf_list, { + filename = filename, + lnum = 1, + text = status_text, + }) + end + + vim.fn.setqflist(qf_list, 'r') + vim.cmd('copen') +end, { desc = 'Git: Changed files to quickfix (with status)', silent = true }) + -- Debug: Show highlight group and color under cursor map('n', 'hi', function() local cursor_pos = vim.api.nvim_win_get_cursor(0) diff --git a/lua/plugins/gitsigns.lua b/lua/plugins/gitsigns.lua index cc9de28..c8777fc 100644 --- a/lua/plugins/gitsigns.lua +++ b/lua/plugins/gitsigns.lua @@ -52,7 +52,6 @@ return { -- Quickfix/Location list map('n', 'hq', function() gs.setqflist('all') end, { desc = 'Gitsigns: All hunks to quickfix' }) - map('n', 'hl', function() gs.setloclist(0) end, { desc = 'Gitsigns: Buffer hunks to loclist' }) -- Text object map({ 'o', 'x' }, 'ih', ':Gitsigns select_hunk', { desc = 'Gitsigns: Select hunk' })