repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

feat(neovim): make pivi reachable, self-explaining and legible at a glance

ae83d153f940400288ed5acd895d58b42710f219

Oliver Krylow <o.krylow@isp-insoft.de> ·

SSH signature · not checked

Browse filesCompare with HEAD

Changed files (17)

+400 / −17 text lines

Diff layout

neovim/lua/bugabinga/key_preview.lua

Modified

+2 / −0 text lines

5353 { mode = 'n', keys = '<Leader>d', desc = '+D2' },
5454 { mode = 'n', keys = '<Leader>x', desc = '+Neovim' },
5555 { mode = 'n', keys = '<Leader>m', desc = '+Marks' },
56 { mode = 'n', keys = '<Leader>p', desc = '+Pi' },
57 { mode = 'x', keys = '<Leader>p', desc = '+Pi' },
5658 { mode = 'n', keys = 'grw', desc = '+Workspace' },
5759 { mode = 'n', keys = 'grp', desc = '+Peek' },
5860 clue.gen_clues.builtin_completion(),

neovim/lua/bugabinga/options/keymaps.lua

Modified

+55 / −0 text lines

114114 end,
117-- pivi publishes <Plug> mappings and claims no keys of its own, so the choice
118-- of keys lives here with every other choice this configuration makes.
119map.normal {
120 description = 'Open the pi prompt',
121 category = 'pi',
122 keys = '<leader>pp',
123 command = '<Plug>(pivi-prompt)',
124 remap = true,
125}
127map.normal {
128 description = 'Show the pi transcript',
129 category = 'pi',
130 keys = '<leader>ps',
131 command = '<Plug>(pivi-show)',
132 remap = true,
133}
135map.normal {
136 description = 'Abort the current pi run',
137 category = 'pi',
138 keys = '<leader>pa',
139 command = '<Plug>(pivi-abort)',
140 remap = true,
141}
143map.normal {
144 description = 'Toggle following the agent',
145 category = 'pi',
146 keys = '<leader>pf',
147 command = '<Plug>(pivi-follow)',
148 remap = true,
149}
151map.normal {
152 description = 'Ask pi about neovim, pivi or pi',
153 category = 'pi',
154 keys = '<leader>ph',
155 command = ':Pi help ',
156}
158map.normal {
159 description = 'Ask pi about the project',
160 category = 'pi',
161 keys = '<leader>pk',
162 command = ':Pi ask ',
163}
165map.visual {
166 description = 'Ask pi about the selection',
167 category = 'pi',
168 keys = '<leader>pk',
169 command = ':Pi ask ',
170}
117172map.normal {
118173 description = 'save',
119174 category = 'file',

neovim/lua/bugabinga/pivi/AGENTS.md

Modified

+9 / −1 text lines

848422. **Entry shape changes without the buffer changing.** Re-anchoring an entry moves its bounds while touching no character, so anything cached per buffer must key on `entry.version` as well as `b:changedtick`.
8585 A fold cache keyed on the tick alone silently goes stale the moment an entry is rewritten.
8723. **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.
8723. **A hook only reaches buffers made after it.** `transcript.on_buffer`, `on_window` and `on_reset` listeners register at module load, so every module that binds keys or decorates must be required before the first transcript exists.
88 `bugabinga.pivi` requires them all up front; a spec that requires only one of them silently gets a buffer with fewer mappings.
9024. **A nameless buffer reads as the working directory.** `fnamemodify('', ':~:.')` returns the cwd, so an unnamed scratch buffer makes a statusline claim the user is editing a file in it, which is where `system32` came from under a launcher that starts in `C:\Windows\system32`.
91 Name every buffer pivi creates, floats included.
9325. **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.
8995## Commands
126132| Reported change | written as the tool formatted it and highlighted with `DiffAdd`/`DiffDelete` per line; `bugabinga.pivi.diff` rebuilds the prior content from the change itself and states when the file has moved on |
127133| Streaming output | rewrite only the entry tail, skip per-line decoration while it runs, and never run `fold.apply` mid-stream |
128134| Output language | parsed as a standalone string and applied as highlight extmarks, never as a fence, so transcript text stays what the tool produced |
135| Keys | pivi binds buffer-locally and publishes `<Plug>` mappings; the configuration chooses the keys in `options/keymaps.lua`. `]t` and `[t` are real global maps (`:tnext`, `:tprevious`) that pivi shadows inside its own buffers only |
136| Guide | `?` reads the mappings that exist in the buffer rather than a list written beside them, so it cannot drift |
130138## Gotchas

neovim/lua/bugabinga/pivi/command.lua

Modified

+11 / −1 text lines

66local publish = require 'bugabinga.pivi.publish'
77local runtime = require 'bugabinga.pivi.runtime'
88local comparison = require 'bugabinga.pivi.diff'
9local guide = require 'bugabinga.pivi.guide'
1011local INPUT_FILETYPE = 'pivi-input'
110111 return ''
111112 end, { buffer = bufnr, expr = true, desc = 'pivi slash command entry', } )
114 guide.bind( bufnr )
113116 vim.keymap.set( { 'n', 'i', }, '<c-s>', function()
114117 local lines = vim.api.nvim_buf_get_lines( bufnr, 0, -1, false )
115118 local text = vim.trim( table.concat( lines, '\n' ) )
303306 end
304307end
309subcommands.guide = function()
310 guide.show( vim.api.nvim_get_current_buf() )
311end
306313subcommands.follow = function( arguments )
307314 follow.toggle( arguments ~= '' and arguments or nil )
308315 notify( 'follow ' .. ( follow.mode() or 'off' ) )
318325local dispatch = function( options )
319326 local input = options.args or ''
320327 local name, rest = input:match '^(%S+)%s*(.*)$'
328 -- Bare `:Pi` is the way in: it starts a session when there is none and puts
329 -- the cursor where the user can type.
321330 if not name then
322 subcommands.show()
331 subcommands.prompt()
323332 return
324333 end
325334 local handler = subcommands[name]
348357 vim.keymap.set( 'n', '<Plug>(pivi-prompt)', function() subcommands.prompt() end, { desc = 'pivi open prompt', } )
349358 vim.keymap.set( 'n', '<Plug>(pivi-abort)', function() subcommands.abort() end, { desc = 'pivi abort run', } )
350359 vim.keymap.set( 'n', '<Plug>(pivi-follow)', function() subcommands.follow '' end, { desc = 'pivi toggle follow', } )
360 vim.keymap.set( 'n', '<Plug>(pivi-guide)', function() subcommands.guide() end, { desc = 'pivi show the guide', } )
351361end
353363return {

neovim/lua/bugabinga/pivi/detail.lua

Modified

+7 / −0 text lines

101101 local lines = describe( bufnr, item )
102102 if #lines == 0 then return nil end
104 -- A nameless buffer makes a statusline fall back to the working directory,
105 -- so even a transient float says what it is.
104106 local ok, float, window = pcall( vim.lsp.util.open_floating_preview, lines, 'markdown', {
105107 border = 'rounded',
106108 focus = false,
109111 max_height = 30,
110112 } )
111113 if not ok then return nil end
115 if float and vim.api.nvim_buf_is_valid( float ) then
116 pcall( vim.api.nvim_buf_set_name, float, 'pivi://' .. ( item.meta.tool or item.kind ) .. '/detail' )
117 end
112119 return float, window
113120end

neovim/lua/bugabinga/pivi/fold.lua

Modified

+10 / −6 text lines

11local entry = require 'bugabinga.pivi.entry'
22local transcript = require 'bugabinga.pivi.transcript'
33local tool = require 'bugabinga.pivi.tool'
4local glyph = require 'std.icon'
56local EXPRESSION = "v:lua.require'bugabinga.pivi.fold'.expr()"
67local TEXT = "v:lua.require'bugabinga.pivi.fold'.text()"
89local ICONS = {
9 prompt = '\u{258c}',
10 answer = '\u{258c}',
11 tool = '\u{25b8}',
12 error = '!',
10 prompt = glyph.user,
11 answer = glyph.star,
12 tool = glyph.command,
13 error = glyph.error,
1516local levels = {}
5859 local first = vim.v.foldstart or 1
5960 local item = entry.at( bufnr, first )
6061 local headline = vim.api.nvim_buf_get_lines( bufnr, first - 1, first, false )[1] or ''
61 local icon = item and ICONS[item.kind] or '\u{25b8}'
62 local icon = item and ICONS[item.kind] or glyph.command
6364 if item and item.kind == 'tool' then
65 icon = tool.icon( item.meta )
6466 local ended = tool.outcome( item.meta )
6567 if ended then headline = vim.trim( headline ) .. ' ' .. ended end
6668 end
68 return ( '%s %s (%d more lines)' ):format( icon, vim.trim( headline ), vim.v.foldend - first )
70 return ( '%s %s %s %d more lines' ):format(
71 icon, vim.trim( headline ), glyph.middle_ellipsis, vim.v.foldend - first
72 )
6973end
7175local windows_of = function( bufnr )

neovim/lua/bugabinga/pivi/guide.lua

Added
new file mode 100644

+97 / −0 text lines

1local transcript = require 'bugabinga.pivi.transcript'
2local glyph = require 'std.icon'
3
4--- What the keys of a pivi buffer are for.
5--- The guide reads the mappings that actually exist rather than a list written
6--- beside them, so it cannot drift from the buffer it describes.
7local describe = function( bufnr )
8 local found = {}
9 for _, mapping in ipairs( vim.api.nvim_buf_get_keymap( bufnr, 'n' ) ) do
10 local description = mapping.desc or ''
11 if description:find( 'pivi', 1, true ) and not mapping.lhs:find( '<Plug>', 1, true ) then
12 table.insert( found, { keys = mapping.lhs, what = description:gsub( '^pivi ', '' ), } )
13 end
14 end
15 table.sort( found, function( left, right ) return left.keys < right.keys end )
16 return found
17end
19local commands = function()
20 local ok, command = pcall( require, 'bugabinga.pivi.command' )
21 if not ok then return {} end
22 return command.names()
23end
25local lines = function( bufnr )
26 local written = { '# ' .. glyph.help .. ' pivi', '', }
28 local keys = describe( bufnr )
29 if #keys > 0 then
30 table.insert( written, '## ' .. glyph.keyword .. ' keys here' )
31 table.insert( written, '' )
32 for _, mapping in ipairs( keys ) do
33 table.insert( written, ( '- `%s` %s' ):format( mapping.keys, mapping.what ) )
34 end
35 table.insert( written, '' )
36 end
38 local names = commands()
39 if #names > 0 then
40 table.insert( written, '## ' .. glyph.command .. ' commands' )
41 table.insert( written, '' )
42 for _, name in ipairs( names ) do
43 table.insert( written, '- `:Pi ' .. name .. '`' )
44 end
45 table.insert( written, '' )
46 table.insert( written, 'Bare `:Pi` opens the prompt.' )
47 table.insert( written, '' )
48 end
50 table.insert( written, '## ' .. glyph.list .. ' elsewhere' )
51 table.insert( written, '' )
52 table.insert( written, '- `zR` / `zM` expand or collapse every entry' )
53 table.insert( written, '- `]c` / `[c` move between changes inside a comparison' )
54 table.insert( written, '- `:help pivi` if the documentation is installed' )
56 return written
57end
59--- Shows the guide without leaving the buffer it describes.
60--- @return number? bufnr
61--- @return number? winid
62local show = function( bufnr )
63 bufnr = bufnr or vim.api.nvim_get_current_buf()
64 if not vim.api.nvim_buf_is_valid( bufnr ) then return nil end
66 local ok, float, window = pcall( vim.lsp.util.open_floating_preview, lines( bufnr ), 'markdown', {
67 border = 'rounded',
68 focus = false,
69 focusable = true,
70 max_width = 80,
71 max_height = 30,
72 title = ' pivi ',
73 } )
74 if not ok then return nil end
76 if float and vim.api.nvim_buf_is_valid( float ) then
77 pcall( vim.api.nvim_buf_set_name, float, 'pivi://guide' )
78 end
80 return float, window
81end
83--- Buffer-local only, so `?` keeps searching backwards everywhere else.
84local bind = function( bufnr )
85 local action = function() show( bufnr ) end
86 vim.keymap.set( 'n', '?', action, { buffer = bufnr, desc = 'pivi show this guide', } )
87 vim.keymap.set( 'n', '<Plug>(pivi-guide)', action, { buffer = bufnr, desc = 'pivi show this guide', } )
88end
90transcript.on_buffer( bind )
92return {
93 describe = describe,
94 lines = lines,
95 show = show,
96 bind = bind,
97}

neovim/lua/bugabinga/pivi/init.lua

Modified

+2 / −0 text lines

1919local detail = require 'bugabinga.pivi.detail'
2020local tool = require 'bugabinga.pivi.tool'
2121local comparison = require 'bugabinga.pivi.diff'
22local guide = require 'bugabinga.pivi.guide'
2324--- Reads cached status only. Safe to call from a statusline.
2425local summary = function( name ) return publish.summary( name ) end
5354 detail = detail,
5455 tool = tool,
5556 comparison = comparison,
57 guide = guide,
5658 summary = summary,
5759 reset = reset,

neovim/lua/bugabinga/pivi/render.lua

Modified

+14 / −3 text lines

11local entry = require 'bugabinga.pivi.entry'
22local transcript = require 'bugabinga.pivi.transcript'
33local tool = require 'bugabinga.pivi.tool'
4local glyph = require 'std.icon'
56local NAMESPACE = 'pivi-render'
89--- Framing is decoration, never buffer text, so the transcript keeps the
910--- message exactly as it was authored and copying it stays faithful.
1011local FRAMES = {
11 prompt = { label = 'you', label_hl = 'Title', prefix = '\u{258c} ', prefix_hl = 'Identifier', every_line = true, },
12 answer = { label = 'pi', label_hl = 'Title', },
12 prompt = {
13 label = glyph.user .. ' you',
14 label_hl = 'Title',
15 prefix = '\u{258c} ',
16 prefix_hl = 'Identifier',
17 every_line = true,
18 },
19 answer = { label = glyph.star .. ' pi', label_hl = 'Title', },
1320 tool = { prefix = '\u{25b8} ', prefix_hl = 'Function', line_hl = 'Comment', },
14 error = { prefix = '! ', prefix_hl = 'ErrorMsg', },
21 error = { prefix = glyph.error .. ' ', prefix_hl = 'ErrorMsg', },
1724local namespace = function()
106113 -- only its opening line is decorated until it finishes.
107114 local final_row = options and options.head_only and item.first - 1 or item.last - 1
116 -- A tool entry shows what kind of work it was rather than a generic marker.
117 local opening = item.kind == 'tool' and ( tool.icon( item.meta ) .. ' ' ) or frame.prefix
109119 for row = item.first - 1, final_row do
110120 local heads = row == item.first - 1
111121 local prefix = frame.prefix and ( heads or frame.every_line ) and frame.prefix or nil
122 if heads and opening then prefix = opening end
113124 local line_hl = frame.line_hl
114125 if change and not heads then

neovim/lua/bugabinga/pivi/skills/pivi/SKILL.md

Modified

+3 / −0 text lines

5656| `gf` | go to the location the entry names |
5757| `K` | inspect the entry, including tool arguments and result |
5858| `gD` | compare a completed change as a real editor diff |
59| `?` | show the guide of keys and commands for this buffer |
5960| `zR` / `zM` | expand or collapse everything, as in any buffer |
6162These keys are buffer-local, and `<Plug>(pivi-toggle-entry)`, `<Plug>(pivi-next-entry)`, `<Plug>(pivi-previous-entry)`, `<Plug>(pivi-next-tool)`, `<Plug>(pivi-previous-tool)`, `<Plug>(pivi-goto-location)`, `<Plug>(pivi-inspect-entry)` and `<Plug>(pivi-compare-change)` exist alongside them.
6566| Command | Effect |
6667| --- | --- |
68| `:Pi` | open the prompt, starting a session when there is none |
6769| `:Pi ask {text}` | submit to the active session, creating one when needed |
6870| `:Pi steer {text}` / `:Pi follow-up {text}` | deliver during an active run |
6971| `:Pi help {question}` | this ephemeral run: no persisted session, no working-session history, queue, or status touched |
7274| `:Pi start` / `stop` / `sessions` / `show` | session lifetime and presentation |
7375| `:Pi abort` / `queue` / `clear` | run and queue control |
7476| `:Pi diff` | compare the change of the entry under the cursor |
77| `:Pi guide` | show the guide of keys and commands |
7578| `:Pi follow [window\|tab\|current]` | toggle follow mode |
7780`<Plug>(pivi-show)`, `<Plug>(pivi-prompt)`, `<Plug>(pivi-abort)`, and `<Plug>(pivi-follow)` exist; pivi sets no global mappings.

neovim/lua/bugabinga/pivi/tool.lua

Modified

+30 / −0 text lines

1local glyph = require 'std.icon'
2
13local MAX_SUBJECT = 60
5--- What each tool does, at a glance.
6--- A reader scans a transcript for the shape of the work, so the icon says
7--- what kind of work it was rather than which tool performed it.
8local ICONS = {
9 read = glyph.file,
10 write = glyph.edit,
11 edit = glyph.edit,
12 bash = glyph.shell,
13 powershell = glyph.shell,
14 grep = glyph.search,
15 find = glyph.search,
16 ls = glyph.folder,
17 nvim_help = glyph.help,
18 nvim_state = glyph.vim,
19 nvim_lua = glyph.vim,
20 nvim_findings = glyph.list,
21}
23local DEFAULT_ICON = glyph.command
25--- The icon for a tool entry.
26local icon = function( meta )
27 local name = meta and meta.tool
28 return ICONS[name] or DEFAULT_ICON
29end
331--- What a tool reports about its own work.
432--- Everything here is derived from that report; a tool that reports nothing
533--- gets no outcome rather than an invented one.
186214return {
187215 max_subject = MAX_SUBJECT,
216 icons = ICONS,
217 icon = icon,
188218 details = details_of,
189219 relative = relative,
190220 subject = subject,

neovim/lua/bugabinga/pivi_status.lua

Modified

+12 / −5 text lines

33--- statusline keeps working when pivi is absent, unloaded, or broken.
44local statusline = require 'bugabinga.statusline'
55local auto = require 'std.auto'
6local glyph = require 'std.icon'
7local SPINNER = { '⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏', }
8-- The progress frames the rest of the configuration already animates with.
9local SPINNER = {
10 glyph.progress_0, glyph.progress_1, glyph.progress_2, glyph.progress_3, glyph.progress_4,
11 glyph.progress_5, glyph.progress_6, glyph.progress_7, glyph.progress_8, glyph.progress_9,
12}
813local INTERVAL = 90
1015local state = {
3035end
3237local label = function( entry )
33 if entry.error then return '%#ErrorMsg#π ' .. ( entry.tool and entry.tool.name or 'error' ) .. '%*' end
34 if entry.compacting then return '%#WarningMsg#π compacting%*' end
35 if entry.run == 'retrying' then return '%#WarningMsg#π retry%*' end
38 if entry.error then
39 return '%#ErrorMsg#' .. glyph.error .. ' ' .. ( entry.tool and entry.tool.name or 'error' ) .. '%*'
40 end
41 if entry.compacting then return '%#WarningMsg#π ' .. glyph.lazy .. ' compacting%*' end
42 if entry.run == 'retrying' then return '%#WarningMsg#π ' .. glyph.warn .. ' retry%*' end
3643 if entry.tool then return '%#DiffChange#π ' .. tostring( entry.tool.name ) .. '%*' end
37 if entry.run == 'running' then return '%#DiffChange#π thinking%*' end
44 if entry.run == 'running' then return '%#DiffChange#π ' .. glyph.star .. ' thinking%*' end
3845 return 'π'
3946end

neovim/lua/bugabinga/statusline.lua

Modified

+6 / −1 text lines

4848end
5050local function file_component()
51 local path = vim.fn.fnamemodify(vim.api.nvim_buf_get_name(0), ':~:.')
51 local name = vim.api.nvim_buf_get_name(0)
52 -- An empty name modifies into the working directory, which reads as if the
53 -- buffer were a file in it. A nameless buffer says so instead.
54 if name == '' then return icon.file .. ' [No Name]' end
56 local path = vim.fn.fnamemodify(name, ':~:.')
5257 if #path > 40 then
5358 path = '...' .. path:sub(-37)
5459 end

neovim/tests/bugabinga/pivi/command_spec.lua

Modified

+16 / −0 text lines

115115 assert.is_true( vim.list_contains( names, 'command' ) )
116116 end )
118 it( 'opens the prompt when given no subcommand', function()
119 local channel = fake.new()
120 session.create { spawn = channel.spawn, name = 'spec', extension = false, skill = false, env = {}, }
122 command.dispatch { args = '', }
124 local opened
125 for _, bufnr in ipairs( vim.api.nvim_list_bufs() ) do
126 if vim.bo[bufnr].filetype == command.input_filetype then opened = bufnr end
127 end
129 assert.is_number( opened )
130 assert.is_true( vim.fn.bufwinid( opened ) > 0 )
131 vim.cmd.stopinsert()
132 end )
118134 it( 'reports an unknown subcommand', function()
119135 command.dispatch { args = 'levitate', }
120136 assert.equal( 1, #notices )

neovim/tests/bugabinga/pivi/editor/guide_spec.lua

Added
new file mode 100644

+87 / −0 text lines

1---@diagnostic disable: duplicate-set-field, need-check-nil, param-type-mismatch, assign-type-mismatch, redundant-parameter
2-- Every module that binds a key registers its hook on load, and a hook only
3-- reaches buffers created after it, so they all load before the first one.
4require 'bugabinga.pivi.fold'
5require 'bugabinga.pivi.navigate'
6require 'bugabinga.pivi.detail'
7require 'bugabinga.pivi.diff'
8local guide = require 'bugabinga.pivi.guide'
9local transcript = require 'bugabinga.pivi.transcript'
10local fake = dofile 'tests/helpers/pivi_fake.lua'
12local text_of = function( lines ) return table.concat( lines, '\n' ) end
14describe( 'pivi guide', function()
15 local bufnr
17 before_each( function()
18 bufnr = transcript.ensure 'guided'
19 transcript.clear( bufnr )
20 end )
22 after_each( function()
23 transcript.forget_all()
24 fake.close_extra_windows()
25 end )
27 it( 'reads the keys that actually exist in the buffer', function()
28 local described = {}
29 for _, mapping in ipairs( guide.describe( bufnr ) ) do
30 described[mapping.keys] = mapping.what
31 end
33 for _, keys in ipairs { '?', '<CR>', ']m', '[m', ']t', '[t', 'gf', 'gD', 'K', } do
34 assert.is_string( described[keys], keys .. ' is missing from the guide' )
35 end
36 end )
38 it( 'drops the plug mappings a reader cannot type', function()
39 for _, mapping in ipairs( guide.describe( bufnr ) ) do
40 assert.is_nil( mapping.keys:find( 'Plug', 1, true ) )
41 end
42 end )
44 it( 'lists every command the user command offers', function()
45 local written = text_of( guide.lines( bufnr ) )
47 for _, name in ipairs { 'ask', 'help', 'prompt', 'diff', 'guide', } do
48 assert.is_true( written:find( ':Pi ' .. name, 1, true ) ~= nil, name .. ' is missing' )
49 end
50 assert.is_true( written:find( 'Bare `:Pi` opens the prompt', 1, true ) ~= nil )
51 end )
53 it( 'explains what each key does, not only that it exists', function()
54 local written = text_of( guide.lines( bufnr ) )
56 assert.is_true( written:find( 'collapse or expand', 1, true ) ~= nil )
57 assert.is_true( written:find( 'next entry', 1, true ) ~= nil )
58 assert.is_true( written:find( 'compare', 1, true ) ~= nil )
59 end )
61 it( 'shows itself without leaving the transcript', function()
62 local win = transcript.show( bufnr )
63 vim.api.nvim_set_current_win( win )
65 local float, floating = guide.show( bufnr )
67 assert.is_number( float )
68 assert.equal( win, vim.api.nvim_get_current_win() )
69 assert.is_true( vim.api.nvim_buf_get_name( float ):find( 'pivi://guide', 1, true ) ~= nil )
71 if floating and vim.api.nvim_win_is_valid( floating ) then
72 vim.api.nvim_win_close( floating, true )
73 end
74 end )
76 it( 'leaves a backwards search alone outside pivi', function()
77 vim.cmd 'enew'
78 local ordinary = vim.api.nvim_get_current_buf()
80 for _, mapping in ipairs( vim.api.nvim_buf_get_keymap( ordinary, 'n' ) ) do
81 assert.is_not.equal( '?', mapping.lhs )
82 end
83 for _, mapping in ipairs( vim.api.nvim_get_keymap 'n' ) do
84 assert.is_not.equal( '?', mapping.lhs )
85 end
86 end )
87end )

neovim/tests/bugabinga/pivi/tool_spec.lua

Modified

+22 / −0 text lines

147147 end )
148148 end )
150 describe( 'icons', function()
151 it( 'shows the kind of work rather than the name of the tool', function()
152 local glyph = require 'std.icon'
154 assert.equal( glyph.edit, tool.icon { tool = 'edit', } )
155 assert.equal( glyph.edit, tool.icon { tool = 'write', } )
156 assert.equal( glyph.file, tool.icon { tool = 'read', } )
157 assert.equal( glyph.shell, tool.icon { tool = 'bash', } )
158 assert.equal( glyph.search, tool.icon { tool = 'grep', } )
159 assert.equal( glyph.search, tool.icon { tool = 'find', } )
160 assert.equal( glyph.folder, tool.icon { tool = 'ls', } )
161 assert.equal( glyph.help, tool.icon { tool = 'nvim_help', } )
162 end )
164 it( 'falls back for a tool it has never heard of', function()
165 local glyph = require 'std.icon'
167 assert.equal( glyph.command, tool.icon { tool = 'something_new', } )
168 assert.equal( glyph.command, tool.icon( nil ) )
169 end )
170 end )
150172 describe( 'truncation', function()
151173 it( 'knows a result was kept only in part', function()
152174 assert.is_true( tool.truncated {

neovim/tests/bugabinga/statusline_spec.lua

Modified

+17 / −0 text lines

2828 end)
2929 end)
31 describe('file_component', function()
32 it('names a buffer that has no name instead of the working directory', function()
33 vim.cmd 'enew'
34 local shown = BugabingaStatusline.render()
36 assert.is_true(shown:find('[No Name]', 1, true) ~= nil)
37 assert.is_nil(shown:find(vim.fn.fnamemodify(vim.uv.cwd() or '', ':~'), 1, true))
38 end)
40 it('names a buffer that has one', function()
41 vim.cmd 'enew'
42 vim.api.nvim_buf_set_name(0, 'pivi://work')
44 assert.is_true(BugabingaStatusline.render():find('pivi://work', 1, true) ~= nil)
45 end)
46 end)
3148 describe('git_component', function()
3249 local initial_cwd