Add keymap for Git files to quickfix list
Introduced a new keymap `<leader>gf` to send modified, deleted, and untracked Git files to the quickfix list with their status indicators. This enhances the Git workflow by complementing existing mappings.
This commit is contained in:
parent
82fc5b1953
commit
1e91693cf5
1
LOG.md
1
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.
|
Record every decision here with a short rationale. Append new entries; do not rewrite history.
|
||||||
|
|
||||||
|
- 2025-01-13: **Git files to quickfix**: Added `<leader>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 `<leader>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-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: PHP LSP = `intelephense` (good PHP ecosystem support; integrates includePaths).
|
||||||
- 2025-12-06: Enable Markdown LSP = `marksman` (lightweight, good MD features).
|
- 2025-12-06: Enable Markdown LSP = `marksman` (lightweight, good MD features).
|
||||||
|
|
|
||||||
|
|
@ -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 | `]d` | Diagnostics: next item | Uses `vim.diagnostic.goto_next` |
|
||||||
| n | `<leader>xd` | Diagnostic float | Opens hover window for cursor diagnostic |
|
| n | `<leader>xd` | Diagnostic float | Opens hover window for cursor diagnostic |
|
||||||
| n | `<leader>xt` | Toggle diagnostics | Flips `vim.diagnostic.enable()` |
|
| n | `<leader>xt` | Toggle diagnostics | Flips `vim.diagnostic.enable()` |
|
||||||
|
| n | `<leader>gf` | Git: Changed files → quickfix | Lists all modified/deleted/untracked files with status |
|
||||||
| n | `<leader>hi` | Highlight inspector | Shows highlight/capture stack under cursor |
|
| n | `<leader>hi` | Highlight inspector | Shows highlight/capture stack under cursor |
|
||||||
|
|
||||||
### `lua/netrw-config.lua`
|
### `lua/netrw-config.lua`
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,57 @@ map('n', '<leader>xt', function()
|
||||||
vim.diagnostic.enable(not vim.diagnostic.is_enabled())
|
vim.diagnostic.enable(not vim.diagnostic.is_enabled())
|
||||||
end, { desc = 'Diagnostics: Toggle display', silent = true })
|
end, { desc = 'Diagnostics: Toggle display', silent = true })
|
||||||
|
|
||||||
|
-- Git: Modified, deleted, and untracked files to quickfix
|
||||||
|
map('n', '<leader>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
|
-- Debug: Show highlight group and color under cursor
|
||||||
map('n', '<leader>hi', function()
|
map('n', '<leader>hi', function()
|
||||||
local cursor_pos = vim.api.nvim_win_get_cursor(0)
|
local cursor_pos = vim.api.nvim_win_get_cursor(0)
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,6 @@ return {
|
||||||
|
|
||||||
-- Quickfix/Location list
|
-- Quickfix/Location list
|
||||||
map('n', '<leader>hq', function() gs.setqflist('all') end, { desc = 'Gitsigns: All hunks to quickfix' })
|
map('n', '<leader>hq', function() gs.setqflist('all') end, { desc = 'Gitsigns: All hunks to quickfix' })
|
||||||
map('n', '<leader>hl', function() gs.setloclist(0) end, { desc = 'Gitsigns: Buffer hunks to loclist' })
|
|
||||||
|
|
||||||
-- Text object
|
-- Text object
|
||||||
map({ 'o', 'x' }, 'ih', ':<C-U>Gitsigns select_hunk<CR>', { desc = 'Gitsigns: Select hunk' })
|
map({ 'o', 'x' }, 'ih', ':<C-U>Gitsigns select_hunk<CR>', { desc = 'Gitsigns: Select hunk' })
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue