My nvim configuration
refactor(claude): remove git blame like feature, set nonjumpable title text for quickfix list (the prompt), and use git like changes in quickfix list entries
3 files changed, +18 -18
+4-12claude-nvim/lua/claude/highlights.lua
| @@ -1,15 +1,12 @@ | ||
| 1 | 1 | local M = {} |
| 2 | 2 | |
| 3 | 3 | local ns = vim.api.nvim_create_namespace("claude_changes") |
| 4 | -local cfg = { highlight = true, blame = true } | |
| 4 | +local cfg = { highlight = true } | |
| 5 | 5 | |
| 6 | 6 | function M.setup(opts) |
| 7 | 7 | cfg.highlight = opts.highlight ~= false |
| 8 | - cfg.blame = opts.blame ~= false | |
| 9 | 8 | |
| 10 | 9 | vim.api.nvim_set_hl(0, "ClaudeChange", { default = true, bg = "#3a2410" }) |
| 11 | - vim.api.nvim_set_hl(0, "ClaudeChangeSign", { default = true, fg = "#e07b00" }) | |
| 12 | - vim.api.nvim_set_hl(0, "ClaudeBlame", { default = true, fg = "#7f5a2a", italic = true }) | |
| 13 | 10 | |
| 14 | 11 | vim.api.nvim_create_autocmd({ "BufReadPost", "BufWritePost", "BufEnter" }, { |
| 15 | 12 | callback = function(args) |
| @@ -49,7 +46,7 @@ end | ||
| 49 | 46 | |
| 50 | 47 | function M.apply_to_buf(buf) |
| 51 | 48 | if not vim.api.nvim_buf_is_valid(buf) then return end |
| 52 | - if not (cfg.highlight or cfg.blame) then return end | |
| 49 | + if not cfg.highlight then return end | |
| 53 | 50 | local name = vim.api.nvim_buf_get_name(buf) |
| 54 | 51 | if name == "" then return end |
| 55 | 52 | if vim.bo[buf].buftype ~= "" then return end |
| @@ -63,14 +60,9 @@ function M.apply_to_buf(buf) | ||
| 63 | 60 | local e = math.min(lc - 1, (h.finish or h.start or 1) - 1) |
| 64 | 61 | if e < s then e = s end |
| 65 | 62 | for ln = s, e do |
| 66 | - local opts = {} | |
| 67 | - if cfg.highlight then opts.line_hl_group = "ClaudeChange" end | |
| 68 | - if cfg.blame and ln == s then | |
| 69 | - local snippet = (h.prompt or ""):gsub("%s+", " "):sub(1, 80) | |
| 70 | - opts.virt_text = { { " ▏ " .. snippet, "ClaudeBlame" } } | |
| 71 | - opts.virt_text_pos = "eol" | |
| 63 | + if cfg.highlight then | |
| 64 | + pcall(vim.api.nvim_buf_set_extmark, buf, ns, ln, 0, { line_hl_group = "ClaudeChange" }) | |
| 72 | 65 | end |
| 73 | - pcall(vim.api.nvim_buf_set_extmark, buf, ns, ln, 0, opts) | |
| 74 | 66 | end |
| 75 | 67 | end |
| 76 | 68 | end |
+12-5claude-nvim/lua/claude/pickers.lua
| @@ -10,11 +10,19 @@ function M.set_qf_from_prompt(p) | ||
| 10 | 10 | local items = {} |
| 11 | 11 | for _, f in ipairs(p.files or {}) do |
| 12 | 12 | for _, h in ipairs(f.hunks or {}) do |
| 13 | + local added = h.added or 0 | |
| 14 | + local removed = h.removed or 0 | |
| 15 | + local stats | |
| 16 | + if added == 0 and removed == 0 then | |
| 17 | + stats = "" | |
| 18 | + else | |
| 19 | + stats = string.format("+%d -%d", added, removed) | |
| 20 | + end | |
| 13 | 21 | table.insert(items, { |
| 14 | 22 | filename = f.path, |
| 15 | 23 | lnum = h.start or 1, |
| 16 | 24 | end_lnum = h.finish or h.start or 1, |
| 17 | - text = snippet(p.text, 80), | |
| 25 | + text = stats, | |
| 18 | 26 | }) |
| 19 | 27 | end |
| 20 | 28 | end |
| @@ -22,10 +30,9 @@ function M.set_qf_from_prompt(p) | ||
| 22 | 30 | vim.notify("claude: prompt has no recorded changes", vim.log.levels.WARN) |
| 23 | 31 | return |
| 24 | 32 | end |
| 25 | - vim.fn.setqflist({}, " ", { | |
| 26 | - title = "Claude: " .. snippet(p.text, 60), | |
| 27 | - items = items, | |
| 28 | - }) | |
| 33 | + local title = (p.text or ""):gsub("%s+", " ") | |
| 34 | + table.insert(items, 1, { text = "▌ " .. title, valid = 0 }) | |
| 35 | + vim.fn.setqflist({}, " ", { title = title, items = items }) | |
| 29 | 36 | vim.cmd("copen") |
| 30 | 37 | pcall(function() require("claude.highlights").refresh_all() end) |
| 31 | 38 | end |
+2-1claude-nvim/lua/claude/runner.lua
| @@ -43,6 +43,7 @@ local function compute_change(before, after) | ||
| 43 | 43 | local hunks = {} |
| 44 | 44 | if type(indices) == "table" then |
| 45 | 45 | for _, h in ipairs(indices) do |
| 46 | + local count_a = h[2] | |
| 46 | 47 | local start_b = h[3] |
| 47 | 48 | local count_b = h[4] |
| 48 | 49 | local s, e |
| @@ -53,7 +54,7 @@ local function compute_change(before, after) | ||
| 53 | 54 | s = start_b |
| 54 | 55 | e = start_b + count_b - 1 |
| 55 | 56 | end |
| 56 | - table.insert(hunks, { start = s, finish = e }) | |
| 57 | + table.insert(hunks, { start = s, finish = e, added = count_b, removed = count_a }) | |
| 57 | 58 | end |
| 58 | 59 | end |
| 59 | 60 | if #hunks == 0 then return nil end |