dotfiles bugabingas dorkfiles
owned by bugabinga
README Source History Refs Compare Notes Search feat(neovim): let a pivi conversation show who said what
74c19c7c5a9333f29310c41ca5f83b86e994e3a8
Oliver Krylow <o.krylow@isp-insoft.de > · 21 Sep 2026
SSH signature · not checked
Browse files Compare with HEAD
Changed files (7) neovim/lua/bugabinga/nugu/init.lua Modified 209 209 _.BugabingaCodeActionSourceImports
= _.DiagnosticHint
210 210 _.BugabingaCodeActionDefault
= _.DiagnosticHint
216 + _.PiviUser {
bg = P.ui_backdrop }
217 + _.PiviUserBar {
fg = P.content_accent,
bold =
true }
218 + _.PiviUserLabel {
fg = P.content_accent,
bold =
true }
219 + _.PiviAssistantLabel {
fg = P.content_focus }
221 + _.PiviTool {
fg = P.content_unfocus }
222 + _.PiviToolIcon {
fg = P.content_focus }
223 + _.PiviToolOutcome {
fg = P.content_minor }
224 + _.PiviError {
fg = P.error }
225 + _.PiviErrorIcon {
fg = P.error,
bold =
true }
213 228 _.DbgViewerKind
= _.Title
214 229 _.DbgViewerTime
= _.Comment
neovim/lua/bugabinga/pivi/AGENTS.md Modified 112 112 31. **A local in Lua is not visible before its declaration.** Two functions have now been used above their definition and resolved to `nil` at runtime; if a helper is called from an earlier function, define it earlier.
114 - 32. **Contract tests guard assumptions,** not features. They skip unless `pi` is on `PATH` and opt-in is set. When Pi changes behavior, they fail before users do.
114 + 32. **Roles are named, not coloured.** `bugabinga.pivi.highlight` defines `PiviUser`, `PiviUserBar`, `PiviUserLabel`, `PiviAssistantLabel`, `PiviTool`, `PiviToolIcon`, `PiviToolOutcome`, `PiviError` and `PiviErrorIcon` as defaults and re-applies them on `ColorScheme`; nugu defines them for real.
115 + The intent any theme must keep: only a user message carries a background, because it is the one thing a reader scrolls back to find. An answer takes no colour at all. Tool output recedes furthest, and its outcome stays scannable.
116 + Never reach for `Comment` to mean dim: in nugu it is bold, italic and important, which is the opposite.
118 + 33. **Contract tests guard assumptions,** not features. They skip unless `pi` is on `PATH` and opt-in is set. When Pi changes behavior, they fail before users do.
neovim/lua/bugabinga/pivi/highlight.lua Added new file mode 100644 11 + PiviUser = {
from =
'CursorLine' ,
take =
'bg' , },
12 + PiviUserBar = {
from =
'Special' ,
take =
'fg' ,
bold =
true , },
13 + PiviUserLabel = {
from =
'Special' ,
take =
'fg' ,
bold =
true , },
14 + PiviAssistantLabel = {
from =
'Function' ,
take =
'fg' , },
15 + PiviTool = {
from =
'NonText' ,
take =
'fg' , },
16 + PiviToolIcon = {
from =
'Function' ,
take =
'fg' , },
17 + PiviToolOutcome = {
from =
'NonText' ,
take =
'fg' , },
18 + PiviError = {
from =
'ErrorMsg' ,
take =
'fg' , },
19 + PiviErrorIcon = {
from =
'ErrorMsg' ,
take =
'fg' ,
bold =
true , },
22 + local resolved = function ( name )
23 + local ok, value
= pcall ( vim.api.nvim_get_hl,
0 , {
name = name,
link =
false , } )
24 + if not ok
then return {}
end 29 + local apply = function ()
30 + for name, recipe
in pairs ( GROUPS )
do 31 + local source
= resolved( recipe.from )
32 + local colour
= source[recipe.take]
34 + local options
= {
default =
true ,
bold = recipe.bold, }
35 + if colour
then options[recipe.take]
= colour
end 37 + pcall ( vim.api.nvim_set_hl,
0 , name, options )
41 + local names = function ()
43 + for name
in pairs ( GROUPS )
do table .
insert ( found, name )
end 50 + vim.api.nvim_create_autocmd(
'ColorScheme' , {
51 + group = vim.api.nvim_create_augroup(
'pivi_highlight' , {
clear =
true , } ),
52 + desc =
'Keep pivi colours in step with the colour scheme.' ,
neovim/lua/bugabinga/pivi/render.lua Modified 2 2 local entry
= require 'bugabinga.pivi.entry' 3 3 local transcript
= require 'bugabinga.pivi.transcript' 4 4 local tool
= require 'bugabinga.pivi.tool' 5 5 local glyph
= require 'std.icon' 6 + require 'bugabinga.pivi.highlight' 7 8 local NAMESPACE
= 'pivi-render' 14 18 label = glyph.user
.. ' you' ,
16 - prefix =
'\u{258c} ' ,
17 - prefix_hl =
'Identifier' ,
19 + label_hl =
'PiviUserLabel' ,
20 + prefix =
'\u{2588} ' ,
21 + prefix_hl =
'PiviUserBar' ,
22 + line_hl =
'PiviUser' ,
20 - answer = {
label = glyph.star
.. ' pi' ,
label_hl =
'Title' , },
21 - tool = {
prefix =
'\u{25b8} ' ,
prefix_hl =
'Function' ,
line_hl =
'Comment' , },
22 - error = {
prefix = glyph.error
.. ' ' ,
prefix_hl =
'ErrorMsg' , },
25 + answer = {
label = glyph.star
.. ' pi' ,
label_hl =
'PiviAssistantLabel' , },
26 + tool = {
prefix =
'\u{25b8} ' ,
prefix_hl =
'PiviToolIcon' ,
line_hl =
'PiviTool' , },
27 + error = {
prefix = glyph.error
.. ' ' ,
prefix_hl =
'PiviErrorIcon' ,
line_hl =
'PiviError' , },
25 30 local namespace = function ()
95 100 local ended
= tool.outcome( item.meta )
97 102 pcall ( vim.api.nvim_buf_set_extmark, bufnr, namespace(), item.first
- 1 ,
0 , {
98 - virt_text = { {
' ' .. ended, item.meta.failed
and 'ErrorMsg' or 'Comment' , }, },
103 + virt_text = { {
' ' .. ended, item.meta.failed
and 'PiviError' or 'PiviToolOutcome' , }, },
99 104 virt_text_pos =
'eol' ,
100 105 right_gravity =
false ,
neovim/lua/bugabinga/pivi/skills/pivi/SKILL.md Modified 42 42 - Markdown is rendered rather than shown as markup, and fenced code is presented in its own language.
43 43 - Every submission, answer, tool call and error is an entry with its own bounds and metadata.
44 44 - Tool output lands inside its tool entry and arrives collapsed; the conversation itself stays open.
45 + - Roles are visually distinct: a user message carries a background and a solid bar so it can be found while scrolling, an answer is ordinary text, and tool work recedes. The colours belong to the colour scheme through the `Pivi*` highlight groups.
45 46 - A tool entry states what it acted on and, once finished, how it ended: an edit shows how many lines it added and removed, a truncated result says so, a failure says so.
46 47 - A completed edit shows its change, with added and removed lines distinct, and `:Pi diff` or `gD` opens it as a real editor comparison.
47 48 - Going to an edit lands on its first changed line; going from a truncated result reaches the file its full output was spilled to.
neovim/tests/bugabinga/pivi/editor/highlight_spec.lua Added new file mode 100644 2 + local highlight
= require 'bugabinga.pivi.highlight' 3 + local render
= require 'bugabinga.pivi.render' 4 + local entry
= require 'bugabinga.pivi.entry' 5 + local transcript
= require 'bugabinga.pivi.transcript' 6 + local fake
= dofile 'tests/helpers/pivi_fake.lua' 8 + local of = function ( name )
9 + return vim.api.nvim_get_hl(
0 , {
name = name,
link =
false , } )
12 + local block = function ( bufnr, kind, meta, lines )
13 + local id
= entry.open( bufnr, kind, meta )
14 + for _, text
in ipairs ( lines )
do entry.line( bufnr, id, text )
end 15 + entry.close( bufnr, id )
16 + render.decorate( bufnr, id )
21 + local lines_of = function ( bufnr )
23 + for _, mark
in ipairs ( render.marks( bufnr ) )
do 24 + local group
= ( mark[
4 ]
or {} ).line_hl_group
25 + if group
then found[mark[
2 ]
+ 1 ]
= group
end 30 + local texts_of = function ( bufnr )
32 + for _, mark
in ipairs ( render.marks( bufnr ) )
do 33 + local details
= mark[
4 ]
or {}
34 + for _, chunk
in ipairs ( details.virt_text
or {} )
do 35 + table .
insert ( found, chunk[
2 ] )
37 + for _, virtual
in ipairs ( details.virt_lines
or {} )
do 38 + for _, chunk
in ipairs ( virtual )
do table .
insert ( found, chunk[
2 ] )
end 44 + describe(
'pivi highlight' ,
function ()
47 + before_each(
function ()
48 + bufnr
= transcript.ensure
'coloured' 49 + transcript.clear( bufnr )
52 + after_each(
function ()
53 + transcript.forget_all()
54 + fake.close_extra_windows()
57 + it(
'defines a group for every role' ,
function ()
58 + for _, name
in ipairs ( highlight.names() )
do 59 + assert .is_true(
next ( of( name ) )
~= nil , name
.. ' has no colour' )
63 + it(
'leaves a colour scheme in charge' ,
function ()
64 + vim.api.nvim_set_hl(
0 ,
'PiviUser' , {
bg =
'#123456' , } )
68 + assert .equal(
tonumber (
'123456' ,
16 ), of(
'PiviUser' ).bg )
71 + it(
'makes a user message the only one with a background' ,
function ()
72 + local prompt
= block( bufnr,
'prompt' , {
text =
'find me' , }, {
'find me' , } )
73 + local answer
= block( bufnr,
'answer' , {}, {
'an answer' ,
'over two lines' , } )
74 + local tool
= block( bufnr,
'tool' , {
tool =
'read' , }, {
'read a.lua' , } )
76 + local applied
= lines_of( bufnr )
77 + local first
= select (
1 , entry.range( bufnr, prompt ) )
78 + local answered
= select (
1 , entry.range( bufnr, answer ) )
79 + local worked
= select (
1 , entry.range( bufnr, tool ) )
81 + assert .equal(
'PiviUser' , applied[first] )
82 + assert .is_nil( applied[answered] )
83 + assert .equal(
'PiviTool' , applied[worked] )
86 + assert .is_truthy( of(
'PiviUser' ).bg )
87 + assert .is_nil( of(
'PiviTool' ).bg )
90 + it(
'carries the user background across every line of the message' ,
function ()
91 + local prompt
= block( bufnr,
'prompt' , {
text =
'two lines' , }, {
'first' ,
'second' , } )
92 + local first, last
= entry.range( bufnr, prompt )
93 + local applied
= lines_of( bufnr )
95 + for row
= first, last
do 96 + assert .equal(
'PiviUser' , applied[row], (
'line %d is not marked' ):format( row ) )
100 + it(
'gives each role its own labelling' ,
function ()
101 + block( bufnr,
'prompt' , {
text =
'a' , }, {
'a' , } )
102 + block( bufnr,
'answer' , {}, {
'b' , } )
103 + block( bufnr,
'tool' , {
tool =
'read' , }, {
'read a.lua' , } )
106 + for _, group
in ipairs ( texts_of( bufnr ) )
do used[group]
= true end 108 + assert .is_true( used.PiviUserLabel )
109 + assert .is_true( used.PiviUserBar )
110 + assert .is_true( used.PiviAssistantLabel )
111 + assert .is_true( used.PiviToolIcon )
114 + it(
'keeps tool work quieter than an answer' ,
function ()
116 + local answer
= block( bufnr,
'answer' , {}, {
'an answer' , } )
117 + local applied
= lines_of( bufnr )
119 + assert .is_nil( applied[
select (
1 , entry.range( bufnr, answer ) )] )
120 + assert .is_truthy( of(
'PiviTool' ).fg )
123 + it(
'marks a failure without borrowing the tool colour' ,
function ()
124 + local failed
= block( bufnr,
'error' , {
error =
'boom' , }, {
'boom' , } )
125 + local applied
= lines_of( bufnr )
127 + assert .equal(
'PiviError' , applied[
select (
1 , entry.range( bufnr, failed ) )] )
neovim/tests/bugabinga/pivi/editor/render_spec.lua Modified 111 111 local first
= select (
1 , entry.range( bufnr, id ) )
112 - assert .equal(
'Comment' , groups[first] )
113 - assert .equal(
'Comment' , groups[first
+ 1 ] )
112 + assert .equal(
'PiviTool' , groups[first] )
113 + assert .equal(
'PiviTool' , groups[first
+ 1 ] )
114 114 assert .equal(
'DiffDelete' , groups[first
+ 2 ] )
115 115 assert .equal(
'DiffAdd' , groups[first
+ 3 ] )