Compare commits

..
5 Commits
Author SHA1 Message Date
Job79andClaude Opus 5.5 fab3dc1d94 chore: default :Review to unpushed commits
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 11:40:37 +01:00
Job79 c3bf6eec2e fix(mini): simplfiy dashbaord glob 2026-11-08 11:38:15 +01:00
Job Jobse ab59364e78 feat: add :Review command 2026-11-07 11:44:32 +01:00
Job Jobse cdcea08071 chore: change behaviour of dashboard 2026-11-07 10:32:03 +01:00
Job Jobse 00b85c7c7e chore: switch back to manual trigger lsp completion 2026-10-12 20:39:38 +02:00
7 changed files with 113 additions and 46 deletions

No files matched your search

+4 -1
View File
@@ -13,5 +13,8 @@ _G.Config = {
later = function(f) misc.safely('later', f) end,
autocmd = function(event, pattern, callback, desc, once)
vim.api.nvim_create_autocmd(event, { group = gr, pattern = pattern, callback = callback, desc = desc, once = once })
end
end,
command = function(name, callback, desc, opts)
vim.api.nvim_create_user_command(name, callback, vim.tbl_extend('force', { desc = desc }, opts or {}))
end,
}
+89 -35
View File
@@ -1,52 +1,106 @@
local ns = vim.api.nvim_create_namespace('git_status')
local hls = { M = 'DiagnosticWarn', ['?'] = 'DiagnosticInfo', D = 'DiagnosticError' }
local ns = vim.api.nvim_create_namespace('git')
local status_hl = { M = 'DiagnosticWarn', A = 'DiagnosticOk', D = 'DiagnosticError', ['?'] = 'DiagnosticInfo' }
local function show(buf_id, items, query)
MiniPick.default_show(buf_id, items, query)
vim.api.nvim_buf_clear_namespace(buf_id, ns, 0, -1)
local function git(args)
local result = vim.system(vim.list_extend({ 'git', '-c', 'core.quotepath=false' }, args)):wait()
if result.code ~= 0 then error(vim.trim(result.stderr), 0) end
return result.stdout
end
-- Picker lines look like ' M path'; colour the status letter
local function show(buf, items, query)
MiniPick.default_show(buf, items, query)
vim.api.nvim_buf_clear_namespace(buf, ns, 0, -1)
for i, item in ipairs(items) do
if item.hl then
vim.api.nvim_buf_set_extmark(buf_id, ns, i - 1, 1, { end_col = 3, hl_group = item.hl, priority = 202, hl_mode = 'combine' })
end
vim.api.nvim_buf_set_extmark(buf, ns, i - 1, 1, { end_col = 2, hl_group = status_hl[item.status], priority = 202, hl_mode = 'combine' })
end
end
-- Diff current file against the index (staged version)
-- Diff the current file against its staged version
local function diff()
vim.cmd.diffthis()
vim.cmd('vert Git show :./%')
vim.cmd.diffthis()
vim.cmd('diffthis')
vim.cmd('vertical Git show :./%')
vim.cmd('diffthis')
end
-- Pick an unstaged file; picking a deleted file stages the deletion
local function status()
local items = {}
for _, line in ipairs(vim.split(git({ 'status', '--short', '--untracked-files' }), '\n', { trimempty = true })) do
local s = line:sub(2, 2)
local path = line:sub(4):gsub('.* %-> ', ''):gsub('^"(.*)"$', '%1')
if s ~= ' ' then table.insert(items, { status = s, path = path, text = ' ' .. s .. ' ' .. path }) end
end
-- Deleted files can't be opened, so choosing one stages the deletion instead
local function choose(item)
if vim.uv.fs_stat(item.path) then return MiniPick.default_choose(item) end
vim.fn.system({ 'git', 'add', '--', item.path })
git({ 'add', '--', item.path })
end
return {
diff = diff,
status = function()
local lines = vim.fn.systemlist('git -c core.quotepath=false status -s -u')
if vim.v.shell_error ~= 0 then
return vim.notify('Not a git repository', vim.log.levels.WARN)
MiniPick.start({ source = { name = 'Git status', items = items, show = show, choose = choose } })
end
-- Write `path` as it is at `rev` to a temp file (empty if it doesn't exist there)
local function file_at(rev, path)
local file = vim.fn.tempname() .. '/' .. path
vim.fn.mkdir(vim.fs.dirname(file), 'p')
local content = rev and vim.F.npcall(git, { 'show', rev .. ':' .. path }) or ''
vim.fn.writefile(vim.split(content, '\n'), file, 'b')
return file
end
-- Open `right` in the current window and diff it against `left` in a split, replacing the previous split
local split
local function open_diff(left, right)
if split and vim.api.nvim_win_is_valid(split) then vim.api.nvim_win_close(split, true) end
vim.cmd('edit ' .. vim.fn.fnameescape(right))
vim.cmd('leftabove vertical diffsplit ' .. vim.fn.fnameescape(left))
split = vim.api.nvim_get_current_win()
vim.cmd('wincmd p')
end
-- Last review, refreshed by `review()` without args
local last = {}
-- Review changes since the merge-base with `base` (default @{upstream}, i.e. unpushed commits) up to `head`.
-- Without `head` the working tree is used, so the right side is your real, editable file.
local function review(base, head)
if base or not last.base then last = { base = base or '@{upstream}', head = head, seen = {} } end
local root = vim.trim(git({ 'rev-parse', '--show-toplevel' }))
local merge_base = vim.trim(git({ 'merge-base', last.base, last.head or 'HEAD' }))
local range = last.head and (merge_base .. '..' .. last.head) or merge_base
local items = {}
for _, l in ipairs(lines) do
-- Skip fully staged files (nothing left in the worktree column)
if l:sub(2, 2) ~= ' ' then
local s = l:sub(1, 2):match('%S+')
local p = l:sub(4):gsub('.* %-> ', ''):gsub('^"(.*)"$', '%1')
items[#items + 1] = {
text = string.format(' %-2s %s', s == '??' and '?' or s, p),
path = p,
hl = hls[l:sub(2, 2)],
}
for _, line in ipairs(vim.split(git({ 'diff', '--name-status', '--no-renames', range }), '\n', { trimempty = true })) do
local s, path = line:match('^(%a)\t(.*)$')
table.insert(items, { status = s, path = path, text = ' ' .. s .. ' ' .. path })
end
end
if #items == 0 then return vim.notify('No unstaged changes', vim.log.levels.INFO) end
MiniPick.start({ source = { items = items, name = 'Git Status', show = show, choose = choose } })
end,
}
-- ✓ is drawn on display (not part of the text) so it stays current when the picker is resumed
local function show_seen(buf, shown, query)
show(buf, shown, query)
for i, item in ipairs(shown) do
if last.seen[item.path] then
vim.api.nvim_buf_set_extmark(buf, ns, i - 1, 3, { virt_text = { { '✓' } }, virt_text_pos = 'overlay' })
end
end
end
local function preview(buf, item)
vim.api.nvim_buf_set_lines(buf, 0, -1, false, vim.split(git({ 'diff', range, '--', ':/' .. item.path }), '\n'))
vim.bo[buf].filetype = 'diff'
end
local function choose(item)
last.seen[item.path] = true
local real_file = root .. '/' .. item.path
local left = file_at(merge_base, item.path)
local right = (not last.head and vim.uv.fs_stat(real_file)) and real_file or file_at(last.head, item.path)
vim.schedule(function() open_diff(left, right) end)
end
local name = 'Review ' .. last.base .. '..' .. (last.head or 'worktree')
MiniPick.start({ source = { name = name, items = items, show = show_seen, preview = preview, choose = choose } })
end
return { status = status, diff = diff, review = review }
+3 -3
View File
@@ -5,7 +5,7 @@
"src": "https://github.com/stevearc/conform.nvim"
},
"mini.nvim": {
"rev": "ac5dffcc52b8378fbb15efeb0497a83e57a0b01c",
"rev": "6d5a29e86a7352739506c28e0bc50fe214b5216f",
"src": "https://github.com/nvim-mini/mini.nvim"
},
"nvim-dap": {
@@ -13,11 +13,11 @@
"src": "https://github.com/mfussenegger/nvim-dap"
},
"nvim-lspconfig": {
"rev": "ac9d2f7c4757db6320cab6697fe73e5e8adb2457",
"rev": "d8d2fda7aae57030452ce8cd6e770b1eb704514e",
"src": "https://github.com/neovim/nvim-lspconfig"
},
"nvim-treesitter": {
"rev": "9a168f6357ed21c3a636e1727bc7d382abc451b8",
"rev": "a9c4e1457e2e59f1b82c8f78dcdb3b2517555200",
"src": "https://github.com/nvim-treesitter/nvim-treesitter"
},
"rose-pine": {
-1
View File
@@ -31,7 +31,6 @@ vim.o.virtualedit = 'block' -- Allow cursor past end of line in visual block
vim.o.spelloptions = 'camel' -- Spell-check camelCase words per part
-- Completion
vim.o.autocomplete = true -- Show completion popup while typing
vim.o.complete = '.,w,b,kspell' -- Complete from buffer, windows, buffers, spell
vim.o.completeopt = 'menuone,noselect,fuzzy,popup' -- Show menu for one match, don't preselect, fuzzy match, description popup
vim.o.pumheight = 10 -- Max items visible in completion popup
+6
View File
@@ -0,0 +1,6 @@
-- :Review [base] [head] e.g. `:Review origin/develop`, `:Review origin/main origin/feat-x`
-- Without args it refreshes the last review (or starts one against @{upstream}: unpushed commits)
Config.command('Review', function(o) require('git').review(o.fargs[1], o.fargs[2]) end, 'Review changes against merge-base', {
nargs = '*',
complete = function() return vim.fn.systemlist('git branch -a --format=%(refname:short)') end,
})
+11 -6
View File
@@ -9,11 +9,17 @@ Config.now(function()
starter.setup({
items = {
function()
local dirs = vim.list_extend(vim.fn.glob('~/Code/*', 0, 1), vim.fn.glob('~/Documents/*/*', 0, 1))
return vim.iter(dirs):filter(function(p) return vim.fn.isdirectory(p) == 1 end):map(function(p)
local open = function() vim.fn.chdir(p) require('mini.files').open(p) end
return { name = vim.fn.fnamemodify(p, ':t'), action = open, section = 'Projects' }
end):totable()
local dirs = vim.fn.glob('~/Code/*/', false, true)
return vim.tbl_map(function(p)
return {
name = vim.fn.fnamemodify(p, ':h:t'),
section = 'Projects',
action = function()
vim.fn.chdir(p)
MiniStarter.close()
end,
}
end, dirs)
end,
starter.sections.builtin_actions(),
@@ -70,5 +76,4 @@ Config.now(function()
MiniFiles.set_bookmark('c', vim.fn.stdpath('config'), { desc = 'Config' })
MiniFiles.set_bookmark('w', vim.fn.getcwd, { desc = 'Working directory' })
end, 'Add default marks')
require('mini.misc').setup_auto_root()
end)
File renamed without changes.