repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

refactor(neovim): modernize configuration and tests

eba8b4d7cb352d3d817a272f7d435c7a281a5145

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

unsigned

Browse filesCompare with HEAD

Changed files (73)

neovim/.luarc.json

Modified
2 - "diagnostics.globals": ["vim"],
3 - "workspace.library": ["${3rd}/busted/library", "${3rd}/luassert/library"]
2 + "runtime.version": "LuaJIT",
3 + "diagnostics.globals": ["vim", "describe", "it", "before_each", "after_each"],
4 + "workspace.checkThirdParty": false,
5 + "workspace.library": [
6 + "$VIMRUNTIME",
7 + "${3rd}/luv/library",
8 + "${3rd}/busted/library",
9 + "${3rd}/luassert/library"
10 + ]

neovim/AGENTS.md

Modified
25 25 │ │ ├── prequire.lua # Protected require with nil-safe proxy
26 26 │ │ ├── project.lua # Project root detection (weighted markers)
27 27 │ │ ├── puk.lua # Plugin loader (vim.schedule_wrap defer)
28 -│ │ ├── table/ # Table util wrappers (deep_copy, join)
28 +│ │ ├── table/ # Table util wrappers (join)
29 29 │ │ └── user_command.lua # Fluent user command DSL
30 30 │ ├── bugabinga/ # Configuration modules (std + plugins only)
31 31 │ │ ├── lsp.lua # LSP config loader (lsp/*.lua auto-discovery)

neovim/justfile

Modified
1 -set shell := ['nu', '--commands']
3 -# List available recipes.
4 -default:
5 - @just --list
7 -# Reproduce some neovim issue
8 -repro:
9 - nvim -u repro.lua
11 -puk:
12 - nu puk.nu
14 -puke:
15 - @nu puk.nu update
16 - @if ( "puk.plugins.updated.nuon" | path exists ) { mv puk.plugins.updated.nuon puk.plugins.nuon }
18 -# DANGER NEVER CALL! delete all current neovim state, cache and other ephemeral data. does NOT delete the configs
19 -nuke:
20 - rm --interactive --recursive --force (nvim "--headless" "--clean" +'lua print(vim.fn.stdpath[[data]])' +q | complete | get stderr)
21 - rm --interactive --recursive --force (nvim "--headless" "--clean" +'lua print(vim.fn.stdpath[[cache]])' +q | complete | get stderr)
22 - rm --interactive --recursive --force (nvim "--headless" "--clean" +'lua print(vim.fn.stdpath[[state]])' +q | complete | get stderr)
24 -# run all tests, or only the ones in the directory of file given
25 -test path="tests":
26 - timeit { nvim --headless --noplugin -u tests/minimal_init.lua -c "PlenaryBustedDirectory {{ path }} {minimal_init = 'tests/minimal_init.lua'}" +q }
28 -# run manual tests
29 -test-manual:
30 - nvim -c "set rtp^=." -c "luafile tests/manual/input.lua"
32 -# lint the nvim lua config code
33 -lint:
34 - lua-language-server --check=. --checklevel=Warning
36 -# run nvim healthcheck in console
37 -checkhealth:
38 - @nvim --headless -c "luafile print_checkhealth.lua"
40 -# run ast-grep refactoring on the neovim configuration
41 -refac:
42 - ast-grep scan --interactive
1 +set shell := ['nu', '--commands']
3 +# List available recipes.
4 +default:
5 + @just --list
7 +# Reproduce some neovim issue
8 +repro:
9 + nvim -u repro.lua
11 +puk:
12 + nu puk.nu
14 +puke:
15 + @nu puk.nu update
16 + @if ( "puk.plugins.updated.nuon" | path exists ) { mv puk.plugins.updated.nuon puk.plugins.nuon }
18 +# DANGER NEVER CALL! delete all current neovim state, cache and other ephemeral data. does NOT delete the configs
19 +nuke:
20 + rm --interactive --recursive --force (nvim "--headless" "--clean" +'lua print(vim.fn.stdpath[[data]])' +q | complete | get stderr)
21 + rm --interactive --recursive --force (nvim "--headless" "--clean" +'lua print(vim.fn.stdpath[[cache]])' +q | complete | get stderr)
22 + rm --interactive --recursive --force (nvim "--headless" "--clean" +'lua print(vim.fn.stdpath[[state]])' +q | complete | get stderr)
24 +# run all tests, or only the ones in the directory of file given
25 +test path="tests":
26 + timeit { nvim --headless --noplugin -u tests/minimal_init.lua -c "PlenaryBustedDirectory {{ path }} {minimal_init = 'tests/minimal_init.lua'}" +q }
28 +# run manual tests
29 +test-manual:
30 + nvim -c "set rtp^=." -c "luafile tests/manual/input.lua"
32 +# lint the nvim lua config code
33 +lint:
34 + with-env { VIMRUNTIME: (nvim --headless --clean +"lua io.stdout:write(vim.env.VIMRUNTIME)" +q | complete | get stdout) } { lua-language-server --check=. --checklevel=Warning }
36 +# run nvim healthcheck in console
37 +checkhealth:
38 + @nvim --headless -c "luafile print_checkhealth.lua"
40 +# run ast-grep refactoring on the neovim configuration
41 +refac:
42 + ast-grep scan --interactive

neovim/lsp/denols.lua

Modified
26 26 uri = uri,
29 - local result = client.request_sync('deno/virtualTextDocument', params)
29 + local result = client:request_sync('deno/virtualTextDocument', params)
30 30 virtual_text_document_handler(uri, result, client)
55 55 command = 'deno.cache',
56 56 arguments = { {}, vim.uri_from_bufnr(bufnr) },
58 - client.request('workspace/executeCommand', params, function(err, _result, ctx)
58 + client:request('workspace/executeCommand', params, function(err, _result, ctx)
59 59 if err then
60 60 local uri = ctx.params.arguments[2]
61 - vim.api.nvim_err_writeln('cache command failed for ' .. vim.uri_to_fname(uri))
61 + vim.notify('cache command failed for ' .. vim.uri_to_fname(uri), vim.log.levels.ERROR)
63 63 end, bufnr)

neovim/lsp/jdtls.lua

Modified
82 82 end,
83 83 filetypes = { 'java' },
84 - root_markers = vim.fn.has 'nvim-0.11.3' == 1 and { root_markers1, root_markers2 }
85 - or vim.list_extend( root_markers1, root_markers2 ),
84 + root_markers = { root_markers1, root_markers2 },
86 85 init_options = {},

neovim/lsp/lua_ls.lua

Modified
1 1 local project = require 'std.project'
2 -local normalize = vim.fs.normalize
3 -local realpath = vim.uv.fs_realpath
5 3 return {
6 4 cmd = { 'lua-language-server' },
15 13 hint = { enable = true, setType = true },
18 - on_init = function ( client )
19 - if client.workspace_folders then
20 - local root = client.workspace_folders[1].name
21 - local abs_root = assert( realpath( root ) )
22 - local path = normalize( abs_root )
23 - local abs_config = assert( realpath( vim.fn.stdpath 'config' ) )
24 - local config_path = normalize( abs_config )
25 - if path ~= config_path then
26 - return
27 - end
28 - end
30 - client.config.settings.Lua = vim.tbl_deep_extend( 'force', client.config.settings.Lua, {
31 - runtime = {
32 - version = 'LuaJIT',
33 - path = {
34 - 'lua/?.lua',
35 - 'lua/?/init.lua',
36 - },
37 - },
38 - diagnostics = {
39 - globals = {
40 - 'vim',
41 - 'describe',
42 - 'it',
43 - },
44 - },
45 - workspace = {
46 - checkThirdParty = false,
47 - library = {
48 - vim.env.VIMRUNTIME,
49 - '${3rd}/luv/library',
50 - },
51 - },
52 - } )
53 - end,

neovim/lsp/qmlls.lua

Modified
6 6 ---@type vim.lsp.Config
7 7 return {
8 - cmd = { '/usr/lib/qt6/bin/qmlls' },
8 + cmd = { 'qmlls' },
9 9 filetypes = { 'qml' },
10 10 root_markers = { 'justfile', 'qmldir', '.git' },

neovim/lua/bugabinga/code_action.lua

Modified
63 63 local encoding = clients[1].offset_encoding or 'utf-16'
64 64 local params = vim.lsp.util.make_range_params(0, encoding)
65 + ---@cast params lsp.CodeActionParams
65 66 params.context = { diagnostics = get_line_diagnostics(bufnr) }
67 68 if vim.b[bufnr].bugabinga_code_action_cancel then
111 112 vim.api.nvim_create_autocmd({ 'CursorHold', 'TextChanged', 'DiagnosticChanged' }, {
112 113 group = group,
113 - buffer = bufnr,
114 + buf = bufnr,
114 115 callback = function() update(bufnr) end,
117 118 vim.api.nvim_create_autocmd('InsertEnter', {
118 119 group = group,
119 - buffer = bufnr,
120 + buf = bufnr,
120 121 callback = function()
121 122 vim.api.nvim_buf_clear_namespace(bufnr, NS, 0, -1)
125 126 vim.api.nvim_create_autocmd('InsertLeave', {
126 127 group = group,
127 - buffer = bufnr,
128 + buf = bufnr,
128 129 callback = function() update(bufnr) end,
131 132 vim.api.nvim_create_autocmd('LspDetach', {
132 133 group = group,
133 - buffer = bufnr,
134 + buf = bufnr,
134 135 callback = function()
135 136 vim.api.nvim_buf_clear_namespace(bufnr, NS, 0, -1)

neovim/lua/bugabinga/cycle.lua

Modified
180 180 local function apply_highlights(bufnr, hl_ns, highlights)
181 181 for _, h in ipairs(highlights) do
182 182 if h.icon_hl then
183 - local icon_end = 3
184 - vim.api.nvim_buf_add_highlight(bufnr, hl_ns, h.icon_hl, h.line_idx, 0, 2)
183 + vim.hl.range(bufnr, hl_ns, h.icon_hl, { h.line_idx, 0 }, { h.line_idx, 2 })
186 - vim.api.nvim_buf_add_highlight(bufnr, hl_ns, 'CycleBufferFileName', h.line_idx, h.name_start - 1, h.name_end_exclusive - 1)
185 + vim.hl.range(
186 + bufnr,
187 + hl_ns,
188 + 'CycleBufferFileName',
189 + { h.line_idx, h.name_start - 1 },
190 + { h.line_idx, h.name_end_exclusive - 1 }
190 195 local function clear_highlights()
191 196 if state.hl_ns and state.popup_buf and vim.api.nvim_buf_is_valid(state.popup_buf) then
192 - vim.api.nvim_buf_clear_highlight(state.popup_buf, state.hl_ns, 0, -1)
197 + vim.api.nvim_buf_clear_namespace(state.popup_buf, state.hl_ns, 0, -1)
260 265 if state.selecting_idx < 1 then state.selecting_idx = #state.buffers
261 266 elseif state.selecting_idx > #state.buffers then state.selecting_idx = 1 end
262 267 if state.popup_buf and vim.api.nvim_buf_is_valid(state.popup_buf) then
263 - local width = math.min(55, vim.o.columns - 4)
268 + local width = math.min(55, vim.o.columns - 4)
264 269 local lines, highlights = render_list(state.buffers, state.selecting_idx, width)
265 270 clear_highlights()
266 271 local was_modifiable = vim.bo[state.popup_buf].modifiable
275 - local timer = vim.uv.new_timer()
280 + local timer = assert(vim.uv.new_timer())
276 281 timer:start(SETTLE_MS, 0, vim.schedule_wrap(function()
277 282 timer:stop()
278 283 timer:close()

neovim/lua/bugabinga/d2.lua

Modified
166 166 local validate = function(args)
167 167 if not check_d2_binary() then return end
168 - local bufnr = (args and args.bufnr) or vim.api.nvim_get_current_buf()
168 + local bufnr = (args and args.buf) or vim.api.nvim_get_current_buf()
169 169 local file = vim.api.nvim_buf_get_name(bufnr)
170 170 if file == '' then
171 171 return
255 255 pattern = PREVIEW_BUF_NAME,
256 256 description = 'D2 preview buffer keymaps',
257 257 command = function(args)
258 - local preview_buf = args.bufnr
259 - map.normal { keys = '<leader>dp', command = preview_toggle, buffer = preview_buf, description = 'Toggle D2 preview' }
260 - map.normal { keys = '<leader>du', command = preview_update, buffer = preview_buf, description = 'Update D2 preview' }
261 - map.normal { keys = 'q', command = close_preview_window, buffer = preview_buf, description = 'Close D2 preview' }
258 + map.normal { keys = '<leader>dp', command = preview_toggle, buffer = args.buf, description = 'Toggle D2 preview' }
259 + map.normal { keys = '<leader>du', command = preview_update, buffer = args.buf, description = 'Update D2 preview' }
260 + map.normal { keys = 'q', command = close_preview_window, buffer = args.buf, description = 'Close D2 preview' }

neovim/lua/bugabinga/health.lua

Modified
3 3 -- use the neovim healthcheck module to integrate into :checkhealth.
4 4 -- check the system for dependencies, that:
5 5 -- * i like to use with neovim.
6 6 -- * plugins need.
8 -local programs_to_check = {}
8 +local executable = require 'std.executable'
10 -local function program_installed(name_of_executable)
11 - return (vim.fn.executable(name_of_executable) ~= 0)
12 -end
10 +local programs_to_check = {}
14 12 local function check_program(name, name_of_executable)
15 13 local display_name = name and (name .. '(' .. name_of_executable .. ')') or name_of_executable
16 14 vim.health.start(display_name .. ' report')
17 - if program_installed(name_of_executable) then
15 + if executable(name_of_executable) then
18 16 vim.health.ok(display_name .. ' found on system')
19 17 else
20 18 vim.health.error(display_name .. ' is not installed on the system')

neovim/lua/bugabinga/lsp/commands.lua

Modified
1 1 local user_command = require 'std.user_command'
3 +local function client_names( clients )
4 + return vim.iter( clients )
5 + :map( function( client ) return client.name end )
6 + :unique()
7 + :totable()
8 +end
3 10 local restart_clients = function( opts )
4 11 local server = opts.args
5 12 if server and server ~= '' then
8 15 return
10 17 local clients = opts.bang and vim.lsp.get_clients() or vim.lsp.get_clients { bufnr = 0 }
11 - local names = {}
12 - local seen = {}
13 - for _, client in ipairs( clients ) do
14 - if not seen[client.name] then
15 - seen[client.name] = true
16 - names[#names + 1] = client.name
17 - end
18 - end
18 + local names = client_names( clients )
19 19 if #names == 0 then return end
20 20 vim.lsp.enable( names, false )
21 21 vim.lsp.enable( names, true )
25 25 nargs = '?',
26 26 bang = true,
27 27 complete = function()
28 - local clients = vim.lsp.get_clients()
29 - local seen = {}
30 - local names = {}
31 - for _, client in ipairs( clients ) do
32 - if not seen[client.name] then
33 - seen[client.name] = true
34 - names[#names + 1] = client.name
35 - end
36 - end
37 - return names
28 + return client_names( vim.lsp.get_clients() )
38 29 end,
39 30 })( restart_clients )
41 32 user_command.LspReload 'Reload current lsp server and buffer' ( function()
42 33 local clients = vim.lsp.get_clients { bufnr = 0 }
43 - local names = {}
44 - local seen = {}
45 - for _, client in ipairs( clients ) do
46 - if not seen[client.name] then
47 - seen[client.name] = true
48 - names[#names + 1] = client.name
49 - end
50 - end
34 + local names = client_names( clients )
51 35 if #names == 0 then return end
52 36 vim.lsp.enable( names, false )
53 37 vim.lsp.enable( names, true )
75 59 vim.notify( vim.inspect( client.settings ) )
76 60 end )
78 -user_command.LspInfo 'Show basic info about running LSP servers in a popup' ( function()
79 - require 'bugabinga.lsp.info'.show( vim.lsp.get_clients() )
62 +user_command.LspInfo 'Show LSP health' ( function()
63 + vim.cmd.checkhealth 'vim.lsp'
80 64 end )

neovim/lua/bugabinga/lsp/info.lua

Deleted
deleted file mode 100644
1 -local icon = require 'std.icon'
2 -local table = require 'std.table'
4 -local cap_fields = {
5 - hoverProvider = 'Hover',
6 - definitionProvider = 'Go to Definition',
7 - referencesProvider = 'References',
8 - completionProvider = 'Completion',
9 - renameProvider = 'Rename',
10 - codeActionProvider = 'Code Actions',
11 - documentFormattingProvider = 'Formatting',
12 - documentSymbolProvider = 'Document Symbols',
13 - workspaceSymbolProvider = 'Workspace Symbols',
14 - inlayHintProvider = 'Inlay Hints',
15 - semanticTokensProvider = 'Semantic Tokens',
16 - signatureHelpProvider = 'Signature Help',
17 - declarationProvider = 'Go to Declaration',
18 - typeDefinitionProvider = 'Go to Type Definition',
19 - implementationProvider = 'Go to Implementation',
20 - documentHighlightProvider = 'Document Highlight',
21 - codeLensProvider = 'Code Lens',
22 - documentLinkProvider = 'Document Links',
23 - foldingRangeProvider = 'Folding Range',
24 - selectionRangeProvider = 'Selection Range',
25 - callHierarchyProvider = 'Call Hierarchy',
26 - documentRangeFormattingProvider = 'Range Formatting',
27 - documentOnTypeFormattingProvider = 'On-Type Formatting',
28 - diagnosticProvider = 'Pull Diagnostics',
29 - executeCommandProvider = 'Execute Command',
32 -local show = function( clients )
33 - if #clients == 0 then
34 - vim.notify( 'No active LSP clients', vim.log.levels.INFO )
35 - return
36 - end
38 - local buf = vim.api.nvim_create_buf( false, true )
40 - local width = math.floor( vim.o.columns * 0.8 )
41 - local height = math.floor( vim.o.lines * 0.8 )
42 - local row = math.floor( (vim.o.lines - height) / 2 )
43 - local col = math.floor( (vim.o.columns - width) / 2 )
44 - local win = vim.api.nvim_open_win( buf, true, {
45 - relative = 'editor',
46 - width = width,
47 - height = height,
48 - row = row,
49 - col = col,
50 - style = 'minimal',
51 - border = 'rounded',
52 - title = icon.lsp .. ' LSP Info',
53 - title_pos = 'center',
54 - } )
56 - local lines = {}
57 - for i, client in ipairs( clients ) do
58 - if i > 1 then table.insert( lines, '' ) end
59 - table.insert( lines, string.format( '# %s %s', icon.lsp, client.name ) )
61 - local root = client.config.root_dir or 'No root'
62 - table.insert( lines, string.format( '**Root:** %s', root ) )
64 - if client.config.filetypes then
65 - table.insert( lines, string.format( '**Filetypes:** %s', table.concat( client.config.filetypes, ', ' ) ) )
66 - end
68 - table.insert( lines, string.format( '**ID:** %d', client.id ) )
69 - local cmd = client.config.cmd
70 - if type( cmd ) == 'table' and cmd[1] then
71 - table.insert( lines, string.format( '**Binary:** %s', cmd[1] ) )
72 - end
74 - if client.workspace_folders and #client.workspace_folders > 0 then
75 - table.insert( lines, '**Workspace Folders:**' )
76 - for _, wf in ipairs( client.workspace_folders ) do
77 - table.insert( lines, string.format( ' - %s', wf.name ) )
78 - end
79 - end
81 - local caps = client.server_capabilities
82 - local cap_list = {}
83 - for field, name in pairs( cap_fields ) do
84 - if caps[field] then cap_list[#cap_list + 1] = name end
85 - end
86 - table.insert( lines, string.format( '**Capabilities (%d):**', #cap_list ) )
87 - table.insert( lines, ' ' .. table.concat( cap_list, ', ' ) )
89 - if client.server_info and client.server_info.version then
90 - table.insert( lines, string.format( '**Version:** %s', client.server_info.version ) )
91 - end
92 - end
94 - vim.api.nvim_buf_set_lines( buf, 0, -1, false, lines )
95 - vim.api.nvim_buf_set_lines( buf, 0, -1, false, lines )
96 - vim.api.nvim_set_option_value( 'filetype', 'markdown', { buf = buf } )
97 - vim.api.nvim_set_option_value( 'spell', false, { win = win } )
98 - vim.api.nvim_set_option_value( 'wrap', true, { win = win } )
99 - vim.api.nvim_set_option_value( 'readonly', true, { buf = buf } )
100 - vim.api.nvim_set_option_value( 'modifiable', false, { buf = buf } )
101 - vim.keymap.set( 'n', 'q', '<cmd>close<CR>', { buffer = buf, noremap = true, silent = true } )
102 - vim.keymap.set( 'n', '<Esc>', '<cmd>close<CR>', { buffer = buf, noremap = true, silent = true } )
103 - vim.api.nvim_set_current_win( win )
104 -end
106 -return { show = show }

neovim/lua/bugabinga/lsp/init.lua

Modified
1 1 local dbg = require 'std.dbg'
2 2 local icon = require 'std.icon'
3 -local table = require 'std.table'
5 4 require 'bugabinga.lsp.attach'
6 5 require 'bugabinga.lsp.commands'
7 -require 'bugabinga.lsp.info'
9 7 if dbg.get() then
10 - vim.lsp.set_log_level 'debug'
8 + vim.lsp.log.set_level 'debug'
13 11 vim.lsp.config( '*', {
28 -local lsp_configs = vim.api.nvim_get_runtime_file( 'lsp/*.lua', true )
29 -local servers = {}
30 -for _, path in ipairs( lsp_configs ) do
31 - local server_name = vim.fn.fnamemodify( path, ':t:r' )
32 - table.insert( servers, server_name )
33 -end
26 +local servers = vim.iter( vim.lsp.get_configs() )
27 + :map( function ( config ) return config.name end )
28 + :totable()
35 29 vim.lsp.enable( servers )
37 31 local completion_icons = {

neovim/lua/bugabinga/options/core.lua

Modified
14 14 -- NEOVIM EDITOR OPTIONS
16 --- Keep track of file changes outside of vim
17 -vim.opt.autoread = true
19 16 -- encode files in UTF-8
20 17 vim.opt.fileencoding = 'utf-8'
30 27 -- collisions.
31 28 vim.opt.backupdir = vim.fn.stdpath 'state' .. '/backup//'
33 --- do not make a backup before writing to a file
34 -vim.opt.writebackup = true
36 --- save a swap file after every 100 typed characters.
37 -vim.opt.swapfile = true
38 30 vim.opt.updatecount = 100
40 32 -- enable persistent undo. save undo history across neovim instances
87 79 vim.opt.iskeyword:append '-'
89 81 -- Tabs and Spaces, i like 'em 2 spaces wide
90 --- only insert spaces for tabs if language configuration explicitly declares so
91 -vim.opt.expandtab = false
92 82 local tab_size = 2
93 83 vim.opt.tabstop = tab_size
94 84 vim.opt.shiftwidth = tab_size
95 85 vim.opt.softtabstop = tab_size
96 86 vim.opt.shiftround = true
97 --- insert whitespace type based on whitespace on previous line
98 -vim.opt.smarttab = true
100 88 vim.opt.wrap = false
101 89 -- wrapped lines will continue on indentation
102 90 vim.opt.breakindent = true
104 --- do not keep distance to borders while scrolling
105 -vim.opt.scrolloff = 0
106 -vim.opt.sidescrolloff = 0
108 92 -- try to guess indentation based on context
109 93 vim.opt.smartindent = true
110 --- Keep indentation of new lines in line with previous lines
111 -vim.opt.autoindent = true
112 94 vim.opt.copyindent = true
114 96 -- open splits to the right and below
119 101 -- enable mouse
120 102 vim.opt.mouse = 'a'
121 --- disable popup menu on right click
122 -vim.opt.mousemodel = 'popup_setpos'
124 --- highlight all search matches
125 -vim.opt.hlsearch = true
126 104 -- enable smart case in searches
127 105 vim.opt.ignorecase = true
128 106 vim.opt.smartcase = true
129 -vim.opt.incsearch = true
130 107 vim.opt.showmatch = true
131 -vim.opt.hidden = true
133 --- Show the effects of substitutions incrementally
134 -vim.opt.inccommand = 'nosplit'
136 109 -- ask me to force failed commands
137 110 vim.opt.confirm = true
139 --- show trailing whitespace
140 -vim.opt.list = false
141 112 vim.opt.listchars = {
142 113 space = icon.space,
143 114 eol = icon.eol,
153 124 vim.opt.showcmd = false
155 126 -- autocomplete menu in command buffer
156 -vim.opt.wildmode = 'full'
157 127 vim.opt.wildignorecase = true
158 128 vim.opt.wildoptions = 'fuzzy,pum'
203 173 -- truncate messages at end
204 174 -- vim.opt.shortmess:append 't'
206 --- show cmd window to prevent jitter UI
207 -vim.opt.cmdheight = 1
209 --- do not conceal special characters by default. ftplugin can enable this on demand.
210 -vim.opt.conceallevel = 0
212 176 -- I do not care for folding
213 177 vim.opt.foldenable = false
215 179 -- show visual indicators for lines too long
216 180 vim.opt.colorcolumn = { '80', '120', '140' }
218 --- highlight the current line
219 -vim.opt.cursorline = false
221 182 -- pop up menu height
222 183 vim.opt.pumheight = 10
224 --- no transparent popups and floating windows
225 -vim.opt.pumblend = 0
226 -vim.opt.winblend = 0
228 185 -- use this in various places for consistent border style
229 186 vim.g.border_style = {
230 187 { '🬷', 'FloatBorderCorner' }, -- top left

neovim/lua/bugabinga/options/grep.lua

Modified
1 -if vim.fn.executable 'rg' then
1 +local executable = require 'std.executable'
3 +if executable 'rg' then
2 4 -- use ripgrep instead of grep
3 5 vim.opt.grepprg = 'rg --hidden --vimgrep --no-heading --smart-case -- '
4 6 vim.opt.grepformat = '%f:%l:%c:%m'

neovim/lua/bugabinga/options/shell.lua

Modified
1 -if vim.fn.executable 'nu' then
1 +local executable = require 'std.executable'
3 +if executable 'nu' then
2 4 -- integrate Nushell with nvim
3 5 vim.opt.shell = 'nu --error-style plain --table-mode none'
4 6 -- flags for nu:
17 19 -- NOTE: `ansi strip` removes all ansi coloring from nushell errors
18 20 vim.opt.shellpipe =
19 21 '| complete | get stderr stdout | str join (char nl) | ansi strip | tee { save --force --raw "%s" }'
20 - -- WARN: disable the usage of temp files for shell commands
21 - -- because Nu doesn't support `input redirection` which Neovim uses to send buffer content to a command:
22 - -- `{shell_command} < {temp_file_with_selected_buffer_content}`
23 - -- When set to `false` the stdin pipe will be used instead.
24 - -- NOTE: some info about `shelltemp`: https://github.com/neovim/neovim/issues/1008
25 - vim.opt.shelltemp = false
26 22 vim.opt.shellxquote = ''
27 - vim.opt.shellxescape = ''
28 - vim.opt.shellquote = ''
31 25 require 'bugabinga.health'.add_dependency

neovim/lua/bugabinga/options/spelling.lua

Modified
1 1 local table = require 'std.table'
2 2 local joinpath = vim.fs.joinpath
4 --- disable spell checking initially
5 -vim.opt.spell = false
6 4 vim.opt.spelloptions:append 'camel'
7 5 vim.opt.spellcapcheck = ''
8 6 -- English, German, Polish and tech words

neovim/lua/bugabinga/options/win32.lua

Modified
6 6 name = 'win32yank',
7 7 name_of_executable = 'win32yank.exe',
9 - vim.g.clipboard = {
10 - name = 'win32yank-wsl',
11 - copy = {
12 - ['+'] = 'win32yank.exe -i --crlf',
13 - ['*'] = 'win32yank.exe -i --crlf',
14 - },
15 - paste = {
16 - ['+'] = 'win32yank.exe -o --lf',
17 - ['*'] = 'win32yank.exe -o --lf',
18 - },
19 - cache_enabled = true,
20 - }
9 + vim.g.clipboard = 'win32yank'

neovim/lua/bugabinga/statusline.lua

Modified
8 8 git_branch = {}, -- per-directory cache
9 9 lsp_count = 0,
11 -local cached_cwd = vim.uv.cwd()
11 +local cached_cwd = assert(vim.uv.cwd())
13 13 -- Component functions
14 14 local function mode_component()
64 64 timeout = 2000,
65 65 }, function(result)
66 66 if result.code == 0 then
67 - local branch = result.stdout:gsub('\n', ''):sub(1, 15)
67 + local branch = (result.stdout or ''):gsub('\n', ''):sub(1, 15)
68 68 cache.git_branch[cwd] = icon.branch .. ' ' .. branch
70 70 cache.git_branch[cwd] = ''
137 137 events = 'DirChanged',
138 138 command = function()
139 - cached_cwd = vim.uv.cwd()
139 + cached_cwd = assert(vim.uv.cwd())
140 140 cache.git_branch = {}
141 141 vim.cmd.redrawstatus()

neovim/lua/std/auto.lua

Modified
92 92 vim.api.nvim_create_autocmd(autocommand.events, {
93 93 desc = autocommand.description,
94 94 group = autocommand.buffer and nil or group,
95 - buffer = autocommand.buffer,
95 + buf = autocommand.buffer,
96 96 pattern = autocommand.pattern,
97 97 once = autocommand.once,
98 98 command = command,

neovim/lua/std/cheatsheet.lua

Deleted
deleted file mode 100644
1 -local categories = {
2 - lsp = 'LSP',
3 - fuzzy = 'FZF',
4 - files = 'FILE',
5 - terminal = 'TERM',
6 - editing = 'EDIT',
7 - search = 'FIND',
8 - session = 'SESS',
9 - diff = 'DIFF',
10 - operator = 'OP',
11 - fun = 'FUN',
12 -}
14 -local category_patterns = {
15 - '^lsp: ', 'lsp',
16 - '^fuzzy: ', 'fuzzy',
17 - '^files: ', 'files',
18 - '^terminal: ', 'terminal',
19 - '^editing: ', 'editing',
20 - '^search: ', 'search',
21 - '^session: ', 'session',
22 - '^diff: ', 'diff',
23 - '^operator: ', 'operator',
24 - '^fun: ', 'fun',
25 -}
27 -local get_category_icon = function(category)
28 - return categories[category] or category:upper()
29 -end
31 -local parse_description = function(desc)
32 - if not desc or desc == '' then
33 - return 'general', '*no description*'
34 - end
36 - for i = 1, #category_patterns, 2 do
37 - local pattern, category = category_patterns[i], category_patterns[i + 1]
38 - if desc:match(pattern) then
39 - return category, desc:gsub(pattern, '')
40 - end
41 - end
43 - return 'general', desc
44 -end
46 -return {
47 - categories = categories,
48 - category_patterns = category_patterns,
49 - get_category_icon = get_category_icon,
50 - parse_description = parse_description,
51 -}

neovim/lua/std/const.lua

Modified
1 +local executable = require 'std.executable'
1 3 local uname = vim.uv.os_uname()
2 4 local win32 = uname.sysname:match 'Win' and true or false
3 5 local wsl = uname.release:match 'WSL2' and true or false
37 39 local function query_os_background()
38 40 if win32 or wsl then
39 41 return 'light'
40 - elseif vim.fn.executable 'busctl' ~= 0 then
42 + elseif executable 'busctl' then
41 43 local cmd = {
42 44 'busctl', '--user', '--expect-reply=true', 'call',
43 45 'org.freedesktop.portal.Desktop',

neovim/lua/std/dbg/format.lua

Modified
49 49 --- - Index off by 1-3: suggests correct index (e.g., {3} with 2 items suggests {2})
50 50 --- - Wrong key name: suggests closest key using Levenshtein distance (threshold 2)
52 ----@param format string format string with placeholders
53 ----@param data table varargs list packed as {...}
54 ----@return string formatted message
55 ----@see vim.inspect
57 52 ---Parses a key expression into segments.
58 53 ---Grammar:
59 54 --- expression := key_segment ('.' key_segment)*
150 145 ---Suggests a similar key from a table based on Levenshtein distance.
151 146 ---Only suggests keys within threshold distance (<= 2).
152 147 ---@param tbl table the table to search
153 ----@param wrong_key string the key that was not found
148 +---@param wrong_key any the key that was not found
154 149 ---@return string? suggested key or nil if none close enough
155 150 local function suggest_key(tbl, wrong_key)
156 151 if type(wrong_key) ~= 'string' then return nil end
167 162 return nil
165 +---@param format string format string with placeholders
166 +---@param data table varargs list packed as {...}
167 +---@return string formatted message
168 +---@see vim.inspect
170 169 local function format_message(format, data)
171 170 vim.validate('format', format, 'string')
172 171 vim.validate('data', data, 'table')

neovim/lua/std/dbg/viewer.lua

Modified
128 128 local WINBAR_FORMAT = '%%#%s#%%{v:lua.require("std.dbg.viewer").get_winbar()}%%#Normal#'
130 +---@type { key: string, prefix: string, suffix: string }[]
130 131 local FILTER_WINBAR_SPECS = {
131 132 { key = 'all', prefix = ' all:"', suffix = '"' },
132 133 { key = 'kind', prefix = ' kind:', suffix = '' },
134 135 { key = 'filename',prefix = ' file:', suffix = '' },
138 +local function sanitize_src(src)
139 + if not src or src == '' then return 'unknown' end
140 + return (src:gsub('^@', ''):gsub('^%[string .+%]$', 'unknown'))
141 +end
137 143 local FILTER_SPECS = {
139 145 key = 'all',
157 163 return KIND_TO_HL[kind_name] or 'DiagnosticInfo'
160 -local function sanitize_src(src)
161 - if not src or src == '' then return 'unknown' end
162 - return (src:gsub('^@', ''):gsub('^%[string .+%]$', 'unknown'))
163 -end
165 166 local function make_winbar()
166 167 return string.format(WINBAR_FORMAT, NS_HL.kind_icon)
169 170 local function get_winbar()
170 171 if not H.state or not H.state.win_id then return '' end
171 - local s = H.state
172 + local s = assert(H.state)
172 173 local parts = {}
173 174 local has_filter = false
175 + local filters = s.filters or {}
175 177 for _, spec in ipairs(FILTER_WINBAR_SPECS) do
176 - local val = s.filters[spec.key]
178 + local val = filters[spec.key]
177 179 if val and val ~= '' then
178 180 parts[#parts + 1] = spec.prefix .. val .. spec.suffix
179 181 has_filter = true
183 185 local filter_str = has_filter and table.concat(parts, '') or ''
184 186 local count = s.filtered_count or 0
185 - local total = s.events and #s.events or 0
187 + local total = #(s.events or {})
186 188 local count_str = count == total and tostring(total) or count .. '/' .. total
188 190 return ' ' .. kinds.get('DEBUG').icon .. ' Debug [' .. count_str .. ' events]' .. filter_str
257 259 return lines, line_events, highlights
260 -local function apply_highlights(buf_id, highlights, events)
261 - vim.api.nvim_buf_clear_highlight(buf_id, H.ns_id, 0, -1)
262 +local function apply_highlight(buf_id, group, lnum, start_col, end_col)
263 + if end_col == -1 then
264 + end_col = #(vim.api.nvim_buf_get_lines(buf_id, lnum, lnum + 1, false)[1] or '')
265 + end
266 + vim.hl.range(buf_id, H.ns_id, group, { lnum, start_col }, { lnum, end_col })
267 +end
269 +local function apply_highlights(buf_id, highlights)
270 + vim.api.nvim_buf_clear_namespace(buf_id, H.ns_id, 0, -1)
263 272 for _, hl in ipairs(highlights) do
264 273 local lnum = hl.line - 1
266 275 if hl.location then
267 - vim.api.nvim_buf_add_highlight(buf_id, H.ns_id, NS_HL.location, lnum, 0, -1)
276 + apply_highlight(buf_id, NS_HL.location, lnum, 0, -1)
268 277 elseif hl.kind then
269 - vim.api.nvim_buf_add_highlight(buf_id, H.ns_id, get_kind_hl_group(hl.kind), lnum, hl.icon_start - 1, hl.icon_end - 1)
270 - vim.api.nvim_buf_add_highlight(buf_id, H.ns_id, NS_HL.kind_name, lnum, hl.kind_name_start - 1, hl.kind_name_end - 1)
271 - vim.api.nvim_buf_add_highlight(buf_id, H.ns_id, NS_HL.time, lnum, hl.time_start - 1, hl.time_end - 1)
278 + apply_highlight(buf_id, get_kind_hl_group(hl.kind), lnum, hl.icon_start - 1, hl.icon_end - 1)
279 + apply_highlight(buf_id, NS_HL.kind_name, lnum, hl.kind_name_start - 1, hl.kind_name_end - 1)
280 + apply_highlight(buf_id, NS_HL.time, lnum, hl.time_start - 1, hl.time_end - 1)
273 - vim.api.nvim_buf_add_highlight(buf_id, H.ns_id, NS_HL.message, lnum, 0, -1)
282 + apply_highlight(buf_id, NS_HL.message, lnum, 0, -1)
358 367 vim.api.nvim_buf_set_lines(H.state.buf_id, 0, -1, false, lines)
359 368 vim.bo[H.state.buf_id].modifiable = was_modifiable
361 - apply_highlights(H.state.buf_id, highlights, events)
370 + apply_highlights(H.state.buf_id, highlights)
363 372 if H.state.win_id and vim.api.nvim_win_is_valid(H.state.win_id) then
364 373 vim.wo[H.state.win_id].winbar = make_winbar()
456 465 H.state.highlights = all_highlights
458 - vim.api.nvim_buf_clear_highlight(H.state.buf_id, H.ns_id, 0, -1)
459 - for _, hl in ipairs(all_highlights) do
460 - local lnum = hl.line - 1
461 - if hl.location then
462 - vim.api.nvim_buf_add_highlight(H.state.buf_id, H.ns_id, NS_HL.location, lnum, 0, -1)
463 - elseif hl.kind then
464 - vim.api.nvim_buf_add_highlight(H.state.buf_id, H.ns_id, get_kind_hl_group(hl.kind), lnum, hl.icon_start - 1, hl.icon_end - 1)
465 - vim.api.nvim_buf_add_highlight(H.state.buf_id, H.ns_id, NS_HL.kind_name, lnum, hl.kind_name_start - 1, hl.kind_name_end - 1)
466 - vim.api.nvim_buf_add_highlight(H.state.buf_id, H.ns_id, NS_HL.time, lnum, hl.time_start - 1, hl.time_end - 1)
467 - else
468 - vim.api.nvim_buf_add_highlight(H.state.buf_id, H.ns_id, NS_HL.message, lnum, 0, -1)
469 - end
470 - end
467 + apply_highlights(H.state.buf_id, all_highlights)
472 469 H.state.filtered_count = H.state.filtered_count + #new_display_events
513 510 if err then return end
514 511 on_file_change()
516 - local watcher = vim.uv.new_fs_event()
513 + local watcher = assert(vim.uv.new_fs_event())
517 514 watcher:start(path, {}, callback)
518 515 return watcher

neovim/lua/std/executable.lua

Added
new file mode 100644
1 +return function(name)
2 + vim.validate('name', name, 'string')
3 + return vim.fn.executable(name) == 1
4 +end

neovim/lua/std/light_up.lua

Modified
53 53 return namespace
56 ---- @return table groups A map of all highlight group names, mapping to themselves g:match('^([%w@%._]+)%s').
56 +--- @return table groups A map of all highlight group names, mapping to themselves.
57 57 local function get_vim_highlight_groups()
58 58 local groups = {}
60 - local highlight_command_output = vim.fn.execute 'highlight'
61 - for line in highlight_command_output:gmatch '[^\n]+' do
62 - local match = line:match '^([%w@%._]+)%s'
63 - if match then groups[match] = match end
59 + for name in pairs( vim.api.nvim_get_hl( 0, {} ) ) do
60 + groups[name] = name
66 62 return groups

neovim/lua/std/localrc.lua

Deleted
deleted file mode 100644
1 -local dbg = require 'std.dbg'
3 ---- loads given lua file path in current working directory into the current neovim lua runtime.
4 ---- @param file_name string path to lua file, that should be loaded
5 ---- @param validator function|string|table a validation function, that checks, if the loaded value fulfills your requirements.
6 ---- If `validator` is a string or table, then it should contain the allowed types of the value.
7 ---- @return any returns the evaluated value of the loaded lua file or `nil`, if it does not exists or did not pass
8 ---- validation.
9 -return function ( file_name, validator )
10 - local filepath = vim.fn.fnamemodify( file_name, ':p' )
11 - local file = vim.secure.read( filepath )
12 - if not file then
13 - return nil
14 - end
15 - local fn, err = loadstring( file )
16 - if not fn or err then
17 - dbg( 'unable to load %s. %s', file_name, err )
18 - return nil
19 - end
20 - local value = fn()
21 - local validator_type = type( validator )
22 - if validator_type == 'string' or validator_type == 'table' then
23 - local expected_types = validator_type == 'table' and validator or { validator, }
24 - local value_type = type( value )
25 - local is_valid = vim.iter( expected_types ):any( function ( t ) return t == value_type end )
26 - return is_valid and value or nil
27 - end
28 - return validator( value ) and value or nil
29 -end

neovim/lua/std/map.lua

Modified
47 47 local options = vim.tbl_extend( 'keep', map.options, {
48 48 silent = true,
49 49 desc = map.description,
50 - buffer = map.buffer,
50 + buf = map.buffer,
51 51 remap = map.remap,
68 68 self.modes = {}
70 70 return function ()
71 - local delete_options = options.buffer and { buffer = options.buffer } or {}
71 + local delete_options = options.buf and { buf = options.buf } or {}
72 72 if type( keys ) == 'table' then
73 73 for _, key in ipairs( keys ) do
74 74 vim.keymap.del( modes, key, delete_options )

neovim/lua/std/project.lua

Modified
91 91 -- ```
92 92 ---@param path string? The starting path, from where to begin the search. If `nil`, the path of the current buffer is
93 93 ---used.
94 ----@param markers table<string,number> List of markers, that define the root, that is searched for.
94 +---@param markers { name: string, weight: number }[] List of markers that define the searched root.
95 95 ---@param stop string? The last directory on the path to root, when to stop searching. if `nil`, the users home
96 96 ---directory is used.
97 97 ---@return string? # Directory, that contains the `markers` and lies on the path from `path` to `stop`.
174 174 --- Determines the project root directory of the current buffer file. A "project" is not clearly defined for all programming languages, so this function uses a heuristic approach.
175 175 ---@param path string? path to start searching from. If `nil`, then path of current buffer is used.
176 ----@param markers table<string, number>? list of markers. a marker is a table with `name` and `weight` key. `name` can be a file or directory name, that indicates, that if a file/folder with that name exists in a directory, that directory is likely to be a project root. `weight` is a means to express confidence in that likelihood. Values should be between 1 and 3. Internally, there are some project-agnostic markers defined (e.g. README, LICENSE, .git, ...) that will be merged with `custom_markers`.
176 +---@param markers { name: string, weight: number }[]? list of weighted project markers.
178 178 ---@return string? # The project root of the current buffer, or `nil`, if none could be determined.

neovim/lua/std/puk.lua

Modified
1 -local load_pack = function(plugin_name, load_plugin)
1 +local load_pack = function(plugin_name)
2 2 vim.validate('plugin_name', plugin_name, 'string')
3 - vim.cmd.packadd { plugin_name, bang = not load_plugin }
3 + vim.cmd.packadd { plugin_name, bang = vim.v.vim_did_init == 0 }
4 4 return require(plugin_name)
9 9 defer = function(plugin_name)
10 10 return vim.schedule_wrap(function(f)
11 - f(load_pack(plugin_name, true))
11 + f(load_pack(plugin_name))
12 12 end)
13 13 end,
16 16 __call = function(_, plugin_name)
17 - return load_pack(plugin_name, false)
17 + return load_pack(plugin_name)
18 18 end,

neovim/lua/std/string.lua

Deleted
deleted file mode 100644
1 -local function is_blank(string)
2 - return string == nil or string == '' or vim.trim(string) == ''
3 -end
5 -return {
6 - is_blank = is_blank,
7 -}

neovim/lua/std/table/deep_copy.lua

Deleted
deleted file mode 100644
1 -local function deep_copy(any)
2 - if type(any) ~= 'table' then return any end
4 - local result = {}
5 - for key, value in pairs(any) do
6 - result[key] = deep_copy(value)
7 - end
8 - return result
9 -end
11 -return deep_copy

neovim/lua/std/table/init.lua

Modified
1 ---- Facade over various table functions in lua, neovim and some of my own.
1 +--- Facade over table functions used by this config.
2 2 return {
3 - deep_copy = require 'std.table.deep_copy',
4 3 join = require 'std.table.join',
6 - contains = vim.tbl_contains,
7 - count = vim.tbl_count,
8 - deep_extend = vim.tbl_deep_extend,
9 - extend = vim.tbl_extend,
10 5 filter = vim.tbl_filter,
11 - get = vim.tbl_get,
12 - is_array = vim.tbl_isarray,
13 - is_empty = vim.tbl_isempty,
14 - keys = vim.tbl_keys,
15 6 map = vim.tbl_map,
16 - values = vim.tbl_values,
18 8 concat = table.concat,
19 9 insert = table.insert,
20 - maxn = table.maxn,
21 10 remove = table.remove,
22 11 sort = table.sort,

neovim/lua/std/timeago.lua

Modified
13 13 ---@return number
14 14 local function round( num ) return math.floor( num + 0.5 ) end
16 ----@param time osdate
16 +---@param time integer
17 17 ---@return string
18 18 local function format( time )
19 19 local now = os.time()

neovim/puk.nu

Modified
4 4 # an out-of-band plugin manager for neovim.
5 5 # cannot do a lot, compared to "normal" neovim plugin managers, but:
6 6 # - it does not depend on git, only on tar and curl (and nushell right now, but that could change)
7 7 # - tar and curl should be available on any system that neovim is installed, even win32
8 8 # - does not incur runtime costs on neovim
9 9 # - uses built-in vim packages
10 +def refuse-running-neovim [] {
11 + let processes = ps | where { |process|
12 + let name = $process.name | path basename | str lowercase
13 + $name in [ 'nvim' 'nvim.exe' ]
14 + }
15 + if not ($processes | is-empty) {
16 + let pids = $processes.pid | each { into string } | str join ', '
17 + [
18 + $"Error: Neovim is running, PIDs: ($pids). Plugin installation stopped."
19 + 'Why: updating Treesitter parsers while Neovim holds parser DLLs can leave stale files and break health checks.'
20 + 'Action: close every Neovim instance, then rerun `just puk`.'
21 + ] | str join (char nl) | print --stderr
22 + exit 1
23 + }
10 26 def main [] {
27 + refuse-running-neovim
11 28 let data_path = nvim --headless --clean +'lua print(vim.fn.stdpath "data")' +q | complete | get stderr
12 29 let cache_path = nvim --headless --clean +'lua print(vim.fn.stdpath "cache")' +q | complete | get stderr
13 30 if not ($cache_path | path exists) {

neovim/puk.plugins.nuon

Modified
2 - [name, source, repo, branch, commit, build];
3 - [nvim-treesitter, github, nvim-treesitter/nvim-treesitter, main, "4916d6592ede8c07973490d9322f187e07dfefac", [
2 + [name, source, repo, branch, commit, build];
3 + [nvim-treesitter, github, nvim-treesitter/nvim-treesitter, main, "0d0969030ad955b510d7c8012b40252a25c12a6d", [
4 4 nvim,
5 5 --headless,
10 10 "+:TSUpdate",
13 - [nvim-treesitter-textobjects, github, nvim-treesitter/nvim-treesitter-textobjects, main, "851e865342e5a4cb1ae23d31caf6e991e1c99f1e", null],
14 - [nvim-ts-autotag, github, windwp/nvim-ts-autotag, main, "88c1453db4ba7dd24131086fe51fdf74e587d275", null],
15 - [oil, github, "stevearc/oil.nvim", master, "0fcc83805ad11cf714a949c98c605ed717e0b83e", null],
16 - [nvim-surround, github, kylechui/nvim-surround, main, "9291040de8cd8a4439eb64c441e8d5d2bf884a5a", null],
17 - [conform, github, "stevearc/conform.nvim", master, "dca1a190aa85f9065979ef35802fb77131911106", null],
18 - [plenary, github, "nvim-lua/plenary.nvim", master, "74b06c6c75e4eeb3108ec01852001636d85a932b", null],
19 - ["mini.splitjoin", github, "echasnovski/mini.splitjoin", main, "8bd5a3d581b9f3dd3bc91fe495e210b8b0ee981d", null],
20 - ["mini.pick", github, "echasnovski/mini.pick", main, "437d44eb57312f23e6b931704694fc294922cd88", null],
21 - ["mini.extra", github, "echasnovski/mini.extra", main, "bc4e872500fd6d2ce252604e0ffa100f64f02280", null],
22 - ["mini.hipatterns", github, "echasnovski/mini.hipatterns", main, "9eff319bbe66adfaf781a0d0e174baa08ba94909", null],
23 - ["mini.clue", github, "echasnovski/mini.clue", main, "43bd6cf1c3ccdea46d403c32dbc4629fa6afa09d", null],
24 - ["mini.bracketed", github, "echasnovski/mini.bracketed", main, "efb969a6a9583a5d48bfbe36363769351e38f967", null],
25 - ["mini.diff", github, "echasnovski/mini.diff", main, "ab11575a6c147ecfba894d676d0c93e855021d34", null],
26 - ["mini.jump2d", github, "echasnovski/mini.jump2d", main, "c0df3170873b712b61951781aeee9942a92ba1f1", null],
27 - ["mini.move", github, "echasnovski/mini.move", main, "74d140143b1bb905c3d0aebcfc2f216fd237080e", null],
28 - ["mini.icons", github, "echasnovski/mini.icons", main, "bac6317300e205335df425296570d84322730067", null],
29 - [nvim-autopairs, github, windwp/nvim-autopairs, master, "59bce2eef357189c3305e25bc6dd2d138c1683f5", null],
30 - [specs, github, "cxwx/specs.nvim", main, "4a2f6f71eaa054a9355a2f424b4723e68f7ce22c", null],
31 - [rulebook, github, chrisgrieser/nvim-rulebook, main, "083dd66b498bc142386a7c96dddab73acbf4ec20", null],
32 - [profile, github, "stevearc/profile.nvim", master, "30433d7513f0d14665c1cfcea501c90f8a63e003", null],
33 - [grug-far, github, "MagicDuck/grug-far.nvim", main, "21790e59dd0109a92a70cb874dd002af186314f5", null],
34 - [incline, github, "b0o/incline.nvim", main, "8b54c59bcb23366645ae10edca6edfb9d3a0853e", null],
35 - [dap, github, mfussenegger/nvim-dap, master, "45a69eba683a2c448dd9ecfc4de89511f0646b5f", null],
36 - [dapui, github, rcarriga/nvim-dap-ui, master, "1a66cabaa4a4da0be107d5eda6d57242f0fe7e49", null],
37 - [nio, github, nvim-neotest/nvim-nio, master, "21f5324bfac14e22ba26553caf69ec76ae8a7662", null],
38 - [dap-disasm, github, Jorenar/nvim-dap-disasm, master, "1119f3f2b22e411adcd123cdcf6d0425b61a31a7", null],
39 - [nvim-dap-virtual-text, github, theHamsta/nvim-dap-virtual-text, master, "fbdb48c2ed45f4a8293d0d483f7730d24467ccb6", null],
40 - ["mini.notify", github, "echasnovski/mini.notify", main, "9e68ab0a54f90567b4fec2de22c851dba8480439", null]
41 -]
13 + [nvim-treesitter-textobjects, github, nvim-treesitter/nvim-treesitter-textobjects, main, "5c7b0263797dfd1bd6202f2b219f3b53a80b2187", null],
14 + [nvim-ts-autotag, github, windwp/nvim-ts-autotag, main, "88c1453db4ba7dd24131086fe51fdf74e587d275", null],
15 + [oil, github, "stevearc/oil.nvim", master, "b73018b75affd13fa38e2fc94ef753b465f770d7", null],
16 + [nvim-surround, github, kylechui/nvim-surround, main, "8b47db616ef658b8fc27e61db2896aa2f40134de", null],
17 + [conform, github, "stevearc/conform.nvim", master, "016802de402556da54c36bd7359b441266b01cdd", null],
18 + [plenary, github, "nvim-lua/plenary.nvim", master, "74b06c6c75e4eeb3108ec01852001636d85a932b", null],
19 + ["mini.splitjoin", github, "echasnovski/mini.splitjoin", main, "9301717c7612ccb72e89629df89416585dd54c9b", null],
20 + ["mini.pick", github, "echasnovski/mini.pick", main, "b27dc13b3d6dafc10e868b6ddc682cc4f047f4d1", null],
21 + ["mini.extra", github, "echasnovski/mini.extra", main, "9c6affac2b176142f48b185bd7abc5db7ec20ac8", null],
22 + ["mini.hipatterns", github, "echasnovski/mini.hipatterns", main, "7c840c71d6a91f53d734cab2b6fe2290d285ec3b", null],
23 + ["mini.clue", github, "echasnovski/mini.clue", main, "1c136d62729c8c3b0c2d91379bc37efac15d916e", null],
24 + ["mini.bracketed", github, "echasnovski/mini.bracketed", main, "203eb35f386b4fc9abcff1518c84d5537d41c80a", null],
25 + ["mini.diff", github, "echasnovski/mini.diff", main, "626b8a5b93874c4d05ca25aedec56cfff0b378fb", null],
26 + ["mini.jump2d", github, "echasnovski/mini.jump2d", main, "861123628b5ef905982080d726de683383bfcc22", null],
27 + ["mini.move", github, "echasnovski/mini.move", main, "48fcaac289a19b8eff2fd5fe203267d478a8abdc", null],
28 + ["mini.icons", github, "echasnovski/mini.icons", main, "98faae31e9be1cc054ae63485e58ceb185efcad0", null],
29 + [nvim-autopairs, github, windwp/nvim-autopairs, master, "430522f95fe4fb7c511ec64f8c1a90cc6a66c05c", null],
30 + [specs, github, "cxwx/specs.nvim", main, "4a2f6f71eaa054a9355a2f424b4723e68f7ce22c", null],
31 + [rulebook, github, chrisgrieser/nvim-rulebook, main, "0572382adde2eb03bde68da23c2aaac3577f503a", null],
32 + [profile, github, "stevearc/profile.nvim", master, "30433d7513f0d14665c1cfcea501c90f8a63e003", null],
33 + [grug-far, github, "MagicDuck/grug-far.nvim", main, "11595bf747edc270bce2069d1020502ad4ae56cf", null],
34 + [incline, github, "b0o/incline.nvim", main, "debd628e9395f7a9da57bdc31ce75ca6b40a880b", null],
35 + [dap, github, mfussenegger/nvim-dap, master, "c9a0738e45f1bd41d792a126941348dce661cf9b", null],
36 + [dapui, github, rcarriga/nvim-dap-ui, master, "cc9dd33aade7f20bae414d0cba163bc60d4d4b43", null],
37 + [nio, github, nvim-neotest/nvim-nio, master, "edcc181a875301dd21840189aa2f2f9ad69fc172", null],
38 + [dap-disasm, github, Jorenar/nvim-dap-disasm, master, "b86a1e3f03f268635f9b362ccc8ffa5f240dd25d", null],
39 + [nvim-dap-virtual-text, github, theHamsta/nvim-dap-virtual-text, master, "fbdb48c2ed45f4a8293d0d483f7730d24467ccb6", null],
40 + ["mini.notify", github, "echasnovski/mini.notify", main, "13df5edffc3e27937b166a0f25a8329b46e15a4e", null]

neovim/tests/bugabinga/cmdline/format_spec.lua

Modified
3 3 local format = require 'bugabinga.cmdline.format'
5 5 describe('format.detect', function()
6 6 it('detects : as cmdline', function()
7 7 local result = format.detect(':', 'hello', '')
8 - assert.equals('cmdline', result.type)
9 - assert.equals('', result.icon)
8 + assert.equal('cmdline', result.type)
9 + assert.equal('', result.icon)
12 12 it('detects / as search_down', function()
13 13 local result = format.detect('/', 'hello', '')
14 - assert.equals('search_down', result.type)
15 - assert.equals('', result.icon)
14 + assert.equal('search_down', result.type)
15 + assert.equal('', result.icon)
18 18 it('detects ? as search_up', function()
19 19 local result = format.detect('?', 'hello', '')
20 - assert.equals('search_up', result.type)
21 - assert.equals('', result.icon)
20 + assert.equal('search_up', result.type)
21 + assert.equal('', result.icon)
24 24 it('detects ! as shell', function()
25 25 local result = format.detect('!', 'ls -la', '')
26 - assert.equals('shell', result.type)
27 - assert.equals('', result.icon)
26 + assert.equal('shell', result.type)
27 + assert.equal('', result.icon)
30 30 it('detects :help as help', function()
31 31 local result = format.detect(':', 'help mytopic', '')
32 - assert.equals('help', result.type)
33 - assert.equals('󰋖', result.icon)
32 + assert.equal('help', result.type)
33 + assert.equal('󰋖', result.icon)
36 36 it('detects :h as help', function()
37 37 local result = format.detect(':', 'h', '')
38 - assert.equals('help', result.type)
39 - assert.equals('󰋖', result.icon)
38 + assert.equal('help', result.type)
39 + assert.equal('󰋖', result.icon)
42 42 it('detects :he as help', function()
43 43 local result = format.detect(':', 'he', '')
44 - assert.equals('help', result.type)
45 - assert.equals('󰋖', result.icon)
44 + assert.equal('help', result.type)
45 + assert.equal('󰋖', result.icon)
48 48 it('detects :hel as help', function()
49 49 local result = format.detect(':', 'hel', '')
50 - assert.equals('help', result.type)
51 - assert.equals('󰋖', result.icon)
50 + assert.equal('help', result.type)
51 + assert.equal('󰋖', result.icon)
54 54 it('detects :help alone as help', function()
55 55 local result = format.detect(':', 'help', '')
56 - assert.equals('help', result.type)
57 - assert.equals('󰋖', result.icon)
56 + assert.equal('help', result.type)
57 + assert.equal('󰋖', result.icon)
60 60 it('detects :h with topic as help', function()
61 61 local result = format.detect(':', 'h usr_01', '')
62 - assert.equals('help', result.type)
63 - assert.equals('󰋖', result.icon)
62 + assert.equal('help', result.type)
63 + assert.equal('󰋖', result.icon)
66 66 it('detects :!cmd as shell', function()
67 67 local result = format.detect(':', '!ls', '')
68 - assert.equals('shell', result.type)
69 - assert.equals('', result.icon)
68 + assert.equal('shell', result.type)
69 + assert.equal('', result.icon)
72 72 it('detects :lua as lua', function()
73 73 local result = format.detect(':', 'lua print("hi")', '')
74 - assert.equals('lua', result.type)
75 - assert.equals('', result.icon)
74 + assert.equal('lua', result.type)
75 + assert.equal('', result.icon)
78 78 it('detects :lua alone as lua', function()
79 79 local result = format.detect(':', 'lua', '')
80 - assert.equals('lua', result.type)
81 - assert.equals('', result.icon)
80 + assert.equal('lua', result.type)
81 + assert.equal('', result.icon)
84 84 it('detects := as lua', function()
85 85 local result = format.detect(':', '= { foo = 1 }', '')
86 - assert.equals('lua', result.type)
87 - assert.equals('', result.icon)
86 + assert.equal('lua', result.type)
87 + assert.equal('', result.icon)
90 90 it('does not detect :luafile as lua', function()
91 91 local result = format.detect(':', 'luafile', '')
92 - assert.equals('cmdline', result.type)
92 + assert.equal('cmdline', result.type)
95 95 it('does not detect :luado as lua', function()
96 96 local result = format.detect(':', 'luado', '')
97 - assert.equals('cmdline', result.type)
97 + assert.equal('cmdline', result.type)
100 100 it('detects input when prompt is non-empty', function()
101 101 local result = format.detect(':', 'some input', 'Enter name: ')
102 - assert.equals('input', result.type)
103 - assert.equals('', result.icon)
102 + assert.equal('input', result.type)
103 + assert.equal('', result.icon)
106 106 it('returns cmdline for unknown firstc', function()
107 107 local result = format.detect('-', 'some text', '')
108 - assert.equals('cmdline', result.type)
108 + assert.equal('cmdline', result.type)
111 111 it('returns input for empty firstc and prompt', function()
112 112 local result = format.detect('', 'some text', '')
113 - assert.equals('input', result.type)
113 + assert.equal('input', result.type)
116 116 it('handles nil content gracefully', function()
117 117 local result = format.detect(':', nil, '')
118 - assert.equals('cmdline', result.type)
118 + assert.equal('cmdline', result.type)
122 122 describe('format.prompt_lines', function()
123 123 it('returns empty table for nil prompt', function()
124 124 local result = format.prompt_lines(nil, 80)
125 - assert.equals(0, #result)
125 + assert.equal(0, #result)
128 128 it('returns empty table for empty prompt', function()
129 129 local result = format.prompt_lines('', 80)
130 - assert.equals(0, #result)
130 + assert.equal(0, #result)
133 133 it('returns single entry for short prompt', function()
134 134 local result = format.prompt_lines('Enter name: ', 80)
135 - assert.equals(1, #result)
136 - assert.equals('Enter name: ', result[1])
135 + assert.equal(1, #result)
136 + assert.equal('Enter name: ', result[1])
139 139 it('returns single entry when prompt fits exactly at max_width', function()
140 140 local prompt = 'abc'
141 141 local max_w = 3
142 142 local result = format.prompt_lines(prompt, max_w)
143 - assert.equals(1, #result)
144 - assert.equals('abc', result[1])
143 + assert.equal(1, #result)
144 + assert.equal('abc', result[1])
147 147 it('splits on newline', function()
148 148 local result = format.prompt_lines('line 1\nline 2', 80)
149 - assert.equals(2, #result)
150 - assert.equals('line 1', result[1])
151 - assert.equals('line 2', result[2])
149 + assert.equal(2, #result)
150 + assert.equal('line 1', result[1])
151 + assert.equal('line 2', result[2])
154 154 it('double newline produces blank line', function()
155 155 local result = format.prompt_lines('a\n\nb', 80)
156 - assert.equals(3, #result)
157 - assert.equals('a', result[1])
158 - assert.equals('', result[2])
159 - assert.equals('b', result[3])
156 + assert.equal(3, #result)
157 + assert.equal('a', result[1])
158 + assert.equal('', result[2])
159 + assert.equal('b', result[3])
162 162 it('trailing newline is stripped', function()
163 163 local result = format.prompt_lines('hello\n', 80)
164 - assert.equals(1, #result)
165 - assert.equals('hello', result[1])
164 + assert.equal(1, #result)
165 + assert.equal('hello', result[1])
168 168 it('wraps long line at word boundary', function()
168 168 local max_w = 20
169 169 local result = format.prompt_lines(long, max_w)
170 170 for _, line in ipairs(result) do
171 - assert.is_true(vim.fn.strdisplaywidth(line) <= max_w, 'line exceeds max_width: ' .. line)
171 + assert(vim.fn.strdisplaywidth(line) <= max_w, 'line exceeds max_width: ' .. line)
173 173 local concatenated = table.concat(result, ' ')
174 - assert.equals(long, concatenated)
174 + assert.equal(long, concatenated)
177 177 it('hard-breaks single word exceeding max_width', function()
178 178 local long = 'supercalifragilisticexpialidocious'
179 179 local max_w = 10
180 180 local result = format.prompt_lines(long, max_w)
181 - assert.is_true(#result > 1, 'single long word should be broken into multiple pieces')
181 + assert(#result > 1, 'single long word should be broken into multiple pieces')
182 182 for _, line in ipairs(result) do
183 - assert.is_true(vim.fn.strdisplaywidth(line) <= max_w, 'line exceeds max_width: ' .. line)
183 + assert(vim.fn.strdisplaywidth(line) <= max_w, 'line exceeds max_width: ' .. line)
187 187 it('uses non-deprecated validation signature', function()
188 188 local validate = vim.validate
189 - vim.validate = function(name, value, validator, optional_or_msg)
190 - assert.equals('string', type(name))
189 + rawset(vim, 'validate', function(name, value, validator, optional_or_msg)
190 + assert.equal('string', type(name))
191 191 return validate(name, value, validator, optional_or_msg)
192 - end
192 + end)
194 194 local ok, err = pcall(function()
195 195 format.prompt_lines('hello', 80)
198 - vim.validate = validate
199 - assert.is_true(ok, err)
198 + rawset(vim, 'validate', validate)
199 + assert(ok, err)
202 202 it('no wrapping when prompt shorter than max_width', function()
203 203 local result = format.prompt_lines('short', 80)
204 - assert.equals(1, #result)
205 - assert.equals('short', result[1])
204 + assert.equal(1, #result)
205 + assert.equal('short', result[1])
209 209 describe('format.PROMPT_MAX_RATIO', function()
210 210 it('is 0.85', function()
211 - assert.equals(0.85, format.PROMPT_MAX_RATIO)
211 + assert.equal(0.85, format.PROMPT_MAX_RATIO)

neovim/tests/bugabinga/cmdline/highlight_spec.lua

Modified
101 101 local first_count = #extmarks_first
102 102 highlight.apply(buf, ns, text, 'lua', row, col_offset)
103 103 local extmarks_second = vim.api.nvim_buf_get_extmarks(buf, ns, 0, -1, { details = true })
104 - assert.equals(first_count, #extmarks_second)
104 + assert.equal(first_count, #extmarks_second)
107 107 it('handles nil lang gracefully', function()

neovim/tests/bugabinga/cmdline/popupmenu_spec.lua

Modified
23 23 local initial_win_count = #vim.api.nvim_list_wins()
24 24 popupmenu.on_show({{'foo', 'Variable', ''}, {'bar', 'Function', ''}}, 0, 0, 0, -1)
25 25 local wins = vim.api.nvim_list_wins()
26 - assert.equals(initial_win_count + 1, #wins, 'should create a new window')
26 + assert.equal(initial_win_count + 1, #wins, 'should create a new window')
27 27 local new_win = wins[#wins]
28 28 local config = vim.api.nvim_win_get_config(new_win)
29 - assert.is_table(config, 'window config should be a table')
29 + assert(type(config) == 'table', 'window config should be a table')
30 30 local buf = vim.api.nvim_win_get_buf(new_win)
31 31 local lines = vim.api.nvim_buf_get_lines(buf, 0, -1, false)
32 - assert.is_true(#lines > 0, 'buffer should have lines')
32 + assert(#lines > 0, 'buffer should have lines')
35 35 it('hides safely when no window exists', function()
80 80 local initial_buf_count = #vim.api.nvim_list_bufs()
81 81 popupmenu.on_show({{'foo', 'Variable', ''}}, 0, 0, 0, -1)
82 82 local buf_count_after_show = #vim.api.nvim_list_bufs()
83 - assert.is_true(buf_count_after_show > initial_buf_count, 'should create a new buffer')
83 + assert(buf_count_after_show > initial_buf_count, 'should create a new buffer')
84 84 local wins_before_hide = #vim.api.nvim_list_wins()
85 85 popupmenu.on_hide()
86 86 local wins_after_hide = #vim.api.nvim_list_wins()
87 - assert.is_true(wins_after_hide < wins_before_hide, 'window should be hidden')
88 - assert.is_true(buf_count_after_show > #vim.api.nvim_list_bufs(), 'buffer should be deleted')
87 + assert(wins_after_hide < wins_before_hide, 'window should be hidden')
88 + assert(buf_count_after_show > #vim.api.nvim_list_bufs(), 'buffer should be deleted')
89 89 local ok = pcall(popupmenu.on_hide)
90 - assert.is_true(ok, 'on_hide should be idempotent')
90 + assert(ok, 'on_hide should be idempotent')
125 125 local popupmenu = require 'bugabinga.cmdline.popupmenu'
126 126 popupmenu.on_show({{'foobar', '', ''}}, 0, 0, 0, -1, 'foo')
127 127 local buf = find_buf()
128 - assert.is_not_nil(buf, 'popupmenu buffer should exist')
128 + assert(buf ~= nil, 'popupmenu buffer should exist')
129 129 local extmarks = get_extmarks(buf)
130 130 local match_marks = vim.iter(extmarks):filter(function(m)
131 131 return m[4].hl_group == 'PmenuMatch'
132 132 end):totable()
133 - assert.equals(1, #match_marks, 'should have one PmenuMatch extmark')
134 - assert.equals(0, match_marks[1][3], 'PmenuMatch should start at col 0')
135 - assert.equals(3, match_marks[1][4].end_col, 'PmenuMatch should span 3 bytes (foo)')
133 + assert.equal(1, #match_marks, 'should have one PmenuMatch extmark')
134 + assert.equal(0, match_marks[1][3], 'PmenuMatch should start at col 0')
135 + assert.equal(3, match_marks[1][4].end_col, 'PmenuMatch should span 3 bytes (foo)')
138 138 it('applies PmenuKind extmark over kind icon', function()
144 144 local kind_marks = vim.iter(extmarks):filter(function(m)
145 145 return m[4].hl_group == 'PmenuKind'
146 146 end):totable()
147 - assert.equals(1, #kind_marks, 'should have one PmenuKind extmark')
148 - assert.equals(0, kind_marks[1][3], 'PmenuKind should start at col 0')
149 - assert.is_true(kind_marks[1][4].end_col > 1, 'PmenuKind should span icon + space')
147 + assert.equal(1, #kind_marks, 'should have one PmenuKind extmark')
148 + assert.equal(0, kind_marks[1][3], 'PmenuKind should start at col 0')
149 + assert(kind_marks[1][4].end_col > 1, 'PmenuKind should span icon + space')
152 152 it('applies no extmarks when prefix empty and no kind', function()
155 155 local buf = find_buf()
156 156 assert.is_not_nil(buf)
157 157 local extmarks = get_extmarks(buf)
158 - assert.equals(0, #extmarks, 'should have no extmarks')
158 + assert.equal(0, #extmarks, 'should have no extmarks')
161 161 it('applies both PmenuMatch and PmenuKind when both apply', function()
168 168 local hl_groups = vim.iter(extmarks):map(function(m)
169 169 return m[4].hl_group
170 170 end):totable()
171 - assert.is_true(vim.list_contains(hl_groups, 'PmenuMatch'), 'should have PmenuMatch')
172 - assert.is_true(vim.list_contains(hl_groups, 'PmenuKind'), 'should have PmenuKind')
171 + assert(vim.list_contains(hl_groups, 'PmenuMatch'), 'should have PmenuMatch')
172 + assert(vim.list_contains(hl_groups, 'PmenuKind'), 'should have PmenuKind')
175 175 it('applies no PmenuMatch when prefix does not match abbr', function()
181 181 local match_marks = vim.iter(extmarks):filter(function(m)
182 182 return m[4].hl_group == 'PmenuMatch'
183 183 end):totable()
184 - assert.equals(0, #match_marks, 'should have no PmenuMatch when prefix does not match')
184 + assert.equal(0, #match_marks, 'should have no PmenuMatch when prefix does not match')
187 187 it('offsets PmenuMatch by kind icon when kind present', function()
193 193 local match_marks = vim.iter(extmarks):filter(function(m)
194 194 return m[4].hl_group == 'PmenuMatch'
195 195 end):totable()
196 - assert.equals(1, #match_marks)
196 + assert.equal(1, #match_marks)
197 197 local kind_marks = vim.iter(extmarks):filter(function(m)
198 198 return m[4].hl_group == 'PmenuKind'
199 199 end):totable()
200 - assert.equals(1, #kind_marks, 'should have a PmenuKind extmark')
201 - assert.equals(kind_marks[1][4].end_col, match_marks[1][3], 'PmenuMatch should start where PmenuKind ended')
202 - assert.equals(match_marks[1][3] + 3, match_marks[1][4].end_col, 'PmenuMatch should span 3 bytes')
200 + assert.equal(1, #kind_marks, 'should have a PmenuKind extmark')
201 + assert.equal(kind_marks[1][4].end_col, match_marks[1][3], 'PmenuMatch should start where PmenuKind ended')
202 + assert.equal(match_marks[1][3] + 3, match_marks[1][4].end_col, 'PmenuMatch should span 3 bytes')
205 205 it('highlights multiple items each with their own match extmark', function()
211 211 local match_marks = vim.iter(extmarks):filter(function(m)
212 212 return m[4].hl_group == 'PmenuMatch'
213 213 end):totable()
214 - assert.equals(2, #match_marks, 'each item should have its own PmenuMatch extmark')
214 + assert.equal(2, #match_marks, 'each item should have its own PmenuMatch extmark')
217 217 it('does not error when prefix is nil', function()
219 219 local ok = pcall(function()
220 220 popupmenu.on_show({{'foo', '', ''}}, 0, 0, 0, -1)
222 - assert.is_true(ok, 'should not error with nil prefix')
222 + assert(ok, 'should not error with nil prefix')
223 223 local buf = find_buf()
224 224 assert.is_not_nil(buf)
225 225 local extmarks = get_extmarks(buf)
226 226 local match_marks = vim.iter(extmarks):filter(function(m)
227 227 return m[4].hl_group == 'PmenuMatch'
228 228 end):totable()
229 - assert.equals(0, #match_marks, 'should have no PmenuMatch with nil/empty prefix')
229 + assert.equal(0, #match_marks, 'should have no PmenuMatch with nil/empty prefix')
271 271 local popupmenu = require 'bugabinga.cmdline.popupmenu'
272 272 popupmenu.on_show({{'a','',''}, {'b','',''}, {'c','',''}}, 0, 0, 0, -1, '')
273 273 local buf = find_buf()
274 - assert.is_not_nil(buf, 'popupmenu should exist')
274 + assert(buf ~= nil, 'popupmenu should exist')
275 275 local scroll_marks = get_scroll_extmarks(buf)
276 - assert.equals(0, #scroll_marks, 'no scrollbar when items fit (pumheight unlimited = all visible)')
276 + assert.equal(0, #scroll_marks, 'no scrollbar when items fit (pumheight unlimited = all visible)')

neovim/tests/bugabinga/cmdline/position_spec.lua

Modified
19 19 local pos = require 'bugabinga.cmdline.position'
20 20 for _ = 1, 10 do
21 21 local result = pos.at_cursor(40)
22 - assert.is_true(result.row >= 0, 'row should never be negative')
22 + assert(result.row >= 0, 'row should never be negative')
24 24 end)
25 25 end)
43 43 local pos = require 'bugabinga.cmdline.position'
44 44 local anchor = { screenpos = { row = 10, col = 20 }, cursor = 5 }
45 45 pos.set_cmdline_anchor(anchor)
46 - assert.equals(anchor, pos.get_cmdline_anchor())
46 + assert.equal(anchor, pos.get_cmdline_anchor())
47 47 end)
48 48 end)
61 61 local pos = require 'bugabinga.cmdline.position'
62 62 local anchor = { screenpos = { row = 5, col = 10 }, cursor = 3 }
63 63 pos.set_cmdline_anchor(anchor)
64 - local result = pos.get_cmdline_anchor()
65 - assert.equals(5, result.screenpos.row)
66 - assert.equals(10, result.screenpos.col)
67 - assert.equals(3, result.cursor)
64 + local result = assert(pos.get_cmdline_anchor())
65 + assert.equal(5, result.screenpos.row)
66 + assert.equal(10, result.screenpos.col)
67 + assert.equal(3, result.cursor)
68 68 end)
69 69 end)

neovim/tests/bugabinga/cmdline/render_spec.lua

Modified
26 26 }, 1, ':', '', 0, 1)
27 27 render.show(cmdline_state)
28 28 local pos = require('bugabinga.cmdline.position')
29 - local anchor = pos.get_cmdline_anchor()
29 + local anchor = assert(pos.get_cmdline_anchor())
30 30 assert.is_not_nil(anchor)
31 31 assert.is_not_nil(anchor.win)
32 32 render.hide()
40 40 }, 1, ':', '', 0, 1)
41 41 render.show(cmdline_state)
42 42 local pos = require('bugabinga.cmdline.position')
43 - local anchor = pos.get_cmdline_anchor()
43 + local anchor = assert(pos.get_cmdline_anchor())
44 44 local buf = anchor.buf
45 45 local lines = vim.api.nvim_buf_get_lines(buf, 0, 1, false)
46 46 assert.is_true(#lines > 0)
60 60 }, 4, ':', '', 0, 1)
61 61 render.show(cmdline_state)
62 62 local pos = require('bugabinga.cmdline.position')
63 - local anchor = pos.get_cmdline_anchor()
63 + local anchor = assert(pos.get_cmdline_anchor())
64 64 local buf = anchor.buf
65 65 local lines = vim.api.nvim_buf_get_lines(buf, 0, 1, false)
66 - assert.equals(' :vim ', lines[1])
66 + assert.equal(' :vim ', lines[1])
67 67 local cursor_byte = cmdline_state:cursor_byte()
68 68 local expected_col = 1 + cursor_byte
69 - assert.equals(1 + 4, expected_col)
70 - assert.equals(7, #lines[1])
69 + assert.equal(1 + 4, expected_col)
70 + assert.equal(7, #lines[1])
71 71 render.hide()
88 88 }, 1, ':', '', 0, 1)
89 89 render.show(cmdline_state1)
90 90 local pos = require('bugabinga.cmdline.position')
91 - local anchor1 = pos.get_cmdline_anchor()
91 + local anchor1 = assert(pos.get_cmdline_anchor())
92 92 local win1 = anchor1.win
93 93 local wh1 = vim.wo[win1].winhighlight
94 94 local cmdline_state2 = state.new({
95 95 { {}, 'h' },
96 96 }, 2, ':', '', 0, 1)
97 97 render.show(cmdline_state2)
98 - local anchor2 = pos.get_cmdline_anchor()
98 + local anchor2 = assert(pos.get_cmdline_anchor())
99 99 local win2 = anchor2.win
100 100 local wh2 = vim.wo[win2].winhighlight
101 - assert.is_true(wh1 ~= wh2, 'winhighlight should differ between cmdline and help formats')
101 + assert(wh1 ~= wh2, 'winhighlight should differ between cmdline and help formats')
102 102 render.hide()
165 165 }, 1, ':', '', 0, 1)
166 166 render.show(cmdline_state)
167 167 local pos = require('bugabinga.cmdline.position')
168 - local anchor = pos.get_cmdline_anchor()
168 + local anchor = assert(pos.get_cmdline_anchor())
169 169 local wh = vim.wo[anchor.win].winhighlight
170 170 local border_hl = wh:match 'FloatBorder:(%w+)'
171 171 local corner_hl = wh:match 'FloatBorderCorner:(%w+)'
172 - assert.is_not_nil(border_hl, 'FloatBorder highlight not found in: ' .. wh)
173 - assert.is_not_nil(corner_hl, 'FloatBorderCorner highlight not found in: ' .. wh)
174 - assert.is_true(border_hl ~= corner_hl, 'border and corner should differ')
172 + assert(border_hl ~= nil, 'FloatBorder highlight not found in: ' .. wh)
173 + assert(corner_hl ~= nil, 'FloatBorderCorner highlight not found in: ' .. wh)
174 + assert(border_hl ~= corner_hl, 'border and corner should differ')
175 175 render.hide()
183 183 }, 1, ':', '', 0, 1)
184 184 render.show(cmdline_state)
185 185 local pos = require('bugabinga.cmdline.position')
186 - local anchor = pos.get_cmdline_anchor()
186 + local anchor = assert(pos.get_cmdline_anchor())
187 187 local wh = vim.wo[anchor.win].winhighlight
188 188 local corner_hl = wh:match 'FloatBorderCorner:(%w+)'
189 - assert.equals('CmdlineBorderCornerCmdline', corner_hl)
189 + assert.equal('CmdlineBorderCornerCmdline', corner_hl)
190 190 render.hide()
198 198 }, 2, ':', '', 0, 1)
199 199 render.show(cmdline_state)
200 200 local pos = require('bugabinga.cmdline.position')
201 - local anchor = pos.get_cmdline_anchor()
201 + local anchor = assert(pos.get_cmdline_anchor())
202 202 local wh = vim.wo[anchor.win].winhighlight
203 203 local corner_hl = wh:match 'FloatBorderCorner:(%w+)'
204 - assert.equals('CmdlineBorderCornerHelp', corner_hl)
204 + assert.equal('CmdlineBorderCornerHelp', corner_hl)
205 205 render.hide()
213 213 }, 1, ':', '', 0, 1)
214 214 render.show(cmdline_state1)
215 215 local pos = require('bugabinga.cmdline.position')
216 - local anchor1 = pos.get_cmdline_anchor()
216 + local anchor1 = assert(pos.get_cmdline_anchor())
217 217 local wh1 = vim.wo[anchor1.win].winhighlight
218 218 local corner1 = wh1:match 'FloatBorderCorner:(%w+)'
219 219 local cmdline_state2 = state.new({
220 220 { {}, 'h' },
221 221 }, 2, ':', '', 0, 1)
222 222 render.show(cmdline_state2)
223 - local anchor2 = pos.get_cmdline_anchor()
223 + local anchor2 = assert(pos.get_cmdline_anchor())
224 224 local wh2 = vim.wo[anchor2.win].winhighlight
225 225 local corner2 = wh2:match 'FloatBorderCorner:(%w+)'
226 - assert.is_true(corner1 ~= corner2, 'corner should change: ' .. corner1 .. ' vs ' .. corner2)
226 + assert(corner1 ~= corner2, 'corner should change: ' .. corner1 .. ' vs ' .. corner2)
227 227 render.hide()
257 257 }, 8, ':', 'Name: ', 0, 1)
258 258 render.show(cmdline_state)
259 259 local pos = require('bugabinga.cmdline.position')
260 - local anchor = pos.get_cmdline_anchor()
260 + local anchor = assert(pos.get_cmdline_anchor())
261 261 local buf = anchor.buf
262 262 local lines = vim.api.nvim_buf_get_lines(buf, 0, 1, false)
263 - assert.is_true(lines[1]:find('Name:') == nil, 'prompt should not appear in buffer: ' .. lines[1])
264 - assert.is_true(lines[1]:find('my input') ~= nil, 'user input should appear in buffer')
263 + assert(lines[1]:find('Name:') == nil, 'prompt should not appear in buffer: ' .. lines[1])
264 + assert(lines[1]:find('my input') ~= nil, 'user input should appear in buffer')
265 265 render.hide()
273 273 }, 6, ':', '', 0, 1)
274 274 render.show(cmdline_state)
275 275 local pos = require('bugabinga.cmdline.position')
276 - local anchor = pos.get_cmdline_anchor()
276 + local anchor = assert(pos.get_cmdline_anchor())
277 277 local buf = anchor.buf
278 278 local lines = vim.api.nvim_buf_get_lines(buf, 0, 1, false)
279 279 assert.is_true(lines[1]:find(':hello') ~= nil)
288 288 }, 0, ':', 'Prompt: ', 0, 1)
289 289 render.show(cmdline_state)
290 290 local fmt_type = render.get_format_type()
291 - assert.equals('input', fmt_type)
291 + assert.equal('input', fmt_type)
292 292 render.hide()
300 300 }, 2, ':', 'Prompt: ', 0, 1)
301 301 render.show(cmdline_state)
302 302 local pos = require('bugabinga.cmdline.position')
303 - local anchor = pos.get_cmdline_anchor()
303 + local anchor = assert(pos.get_cmdline_anchor())
304 304 local cursor = vim.api.nvim_win_get_cursor(anchor.win)
305 - assert.equals(2 + 2, cursor[2], 'cursor should be 2 + cursor_byte')
305 + assert.equal(2 + 2, cursor[2], 'cursor should be 2 + cursor_byte')
306 306 render.hide()
336 336 }, 5, ':', 'Line 1\nLine 2\nLine 3', 0, 1)
337 337 render.show(cmdline_state)
338 338 local pos = require('bugabinga.cmdline.position')
339 - local anchor = pos.get_cmdline_anchor()
339 + local anchor = assert(pos.get_cmdline_anchor())
340 340 local buf = anchor.buf
341 341 local prompt_ns = vim.api.nvim_create_namespace('bugabinga.cmdline.prompt')
342 342 local extmarks = vim.api.nvim_buf_get_extmarks(buf, prompt_ns, 0, -1, { details = true })
343 - assert.is_true(#extmarks > 0, 'should have virt_lines extmark for multi-line prompt')
344 - local mark = extmarks[1]
345 - local opts = mark[4]
346 - assert.is_not_nil(opts.virt_lines, 'extmark should have virt_lines')
347 - assert.is_true(opts.virt_lines_above, 'virt_lines should be above')
343 + assert(#extmarks > 0, 'should have virt_lines extmark for multi-line prompt')
344 + local mark = assert(extmarks[1])
345 + local opts = assert(mark[4])
346 + assert(opts.virt_lines ~= nil, 'extmark should have virt_lines')
347 + assert(opts.virt_lines_above, 'virt_lines should be above')
348 348 render.hide()
356 356 }, 1, ':', 'Line 1\nLine 2', 0, 1)
357 357 render.show(cmdline_state)
358 358 local pos = require('bugabinga.cmdline.position')
359 - local anchor = pos.get_cmdline_anchor()
359 + local anchor = assert(pos.get_cmdline_anchor())
360 360 local height = vim.api.nvim_win_get_config(anchor.win).height
361 - assert.equals(2 + 1, height, 'height should be 2 (prompt lines) + 1 (input line)')
361 + assert.equal(2 + 1, height, 'height should be 2 (prompt lines) + 1 (input line)')
362 362 render.hide()
370 370 }, 1, ':', 'first line\nsecond line', 0, 1)
371 371 render.show(cmdline_state)
372 372 local pos = require('bugabinga.cmdline.position')
373 - local anchor = pos.get_cmdline_anchor()
373 + local anchor = assert(pos.get_cmdline_anchor())
374 374 local buf = anchor.buf
375 375 local prompt_ns = vim.api.nvim_create_namespace('bugabinga.cmdline.prompt')
376 376 local extmarks = vim.api.nvim_buf_get_extmarks(buf, prompt_ns, 0, -1, { details = true })
377 - local opts = extmarks[1][4]
378 - assert.equals(2, #opts.virt_lines, 'should have 2 virt_lines for 2 prompt lines')
377 + local mark = assert(extmarks[1])
378 + local opts = assert(mark[4])
379 + local virt_lines = assert(opts.virt_lines)
380 + assert.equal(2, #virt_lines, 'should have 2 virt_lines for 2 prompt lines')
379 381 render.hide()
387 389 }, 1, ':', 'a\n\nb', 0, 1)
388 390 render.show(cmdline_state)
389 391 local pos = require('bugabinga.cmdline.position')
390 - local anchor = pos.get_cmdline_anchor()
392 + local anchor = assert(pos.get_cmdline_anchor())
391 393 local buf = anchor.buf
392 394 local prompt_ns = vim.api.nvim_create_namespace('bugabinga.cmdline.prompt')
393 395 local extmarks = vim.api.nvim_buf_get_extmarks(buf, prompt_ns, 0, -1, { details = true })
394 - local opts = extmarks[1][4]
395 - assert.equals(3, #opts.virt_lines, 'should have 3 virt_lines: a, blank, b')
396 + local mark = assert(extmarks[1])
397 + local opts = assert(mark[4])
398 + local virt_lines = assert(opts.virt_lines)
399 + assert.equal(3, #virt_lines, 'should have 3 virt_lines: a, blank, b')
396 400 render.hide()
426 430 }, 1, ':', 'Line 1\nLine 2', 0, 1)
427 431 render.show(cmdline_state)
428 432 local pos = require('bugabinga.cmdline.position')
429 - local anchor = pos.get_cmdline_anchor()
433 + local anchor = assert(pos.get_cmdline_anchor())
430 434 local buf = anchor.buf
431 435 render.hide()
432 436 local prompt_ns = vim.api.nvim_create_namespace('bugabinga.cmdline.prompt')
433 437 local extmarks = vim.api.nvim_buf_get_extmarks(buf, prompt_ns, 0, -1, {})
434 - assert.equals(0, #extmarks, 'prompt namespace should be empty after hide')
438 + assert.equal(0, #extmarks, 'prompt namespace should be empty after hide')

neovim/tests/bugabinga/cmdline/state_spec.lua

Modified
10 10 { {}, 'hello ' },
11 11 { {}, 'world' },
12 12 }, 11, ':', '', 0, 1)
13 - assert.equals('hello world', s:text())
13 + assert.equal('hello world', s:text())
14 14 end)
16 16 it('stores cursor position', function()
17 17 local s = state.new({}, 5, ':', '', 0, 1)
18 - assert.equals(5, s:cursor_byte())
18 + assert.equal(5, s:cursor_byte())
19 19 end)
21 21 it('stores firstc, prompt, level', function()
22 22 local s = state.new({}, 0, '/', 'search: ', 2, 3)
23 - assert.equals('/', s.firstc)
24 - assert.equals('search: ', s.prompt)
25 - assert.equals(3, s.level)
23 + assert.equal('/', s.firstc)
24 + assert.equal('search: ', s.prompt)
25 + assert.equal(3, s.level)
26 26 end)
28 28 it('handles empty content', function()
29 29 local s = state.new({}, 0, ':', '', 0, 1)
30 - assert.equals('', s:text())
30 + assert.equal('', s:text())
31 31 end)
33 33 it('uses non-deprecated validation signature', function()
34 34 local validate = vim.validate
35 - vim.validate = function(name, value, validator, optional_or_msg)
36 - assert.equals('string', type(name))
35 + rawset(vim, 'validate', function(name, value, validator, optional_or_msg)
36 + assert.equal('string', type(name))
37 37 return validate(name, value, validator, optional_or_msg)
38 - end
38 + end)
40 40 local ok, err = pcall(function()
41 41 state.new({}, 0, ':', '', 0, 1)
42 42 end)
44 - vim.validate = validate
45 - assert.is_true(ok, err)
44 + rawset(vim, 'validate', validate)
45 + assert(ok, err)
46 46 end)
48 48 it('handles single chunk content', function()
49 49 local s = state.new({
50 50 { {}, 'only' },
51 51 }, 4, ':', '', 0, 1)
52 - assert.equals('only', s:text())
52 + assert.equal('only', s:text())
53 53 end)
54 54 end)
63 63 { {}, 'foo' },
64 64 { {}, 'bar' },
65 65 }, 6, ':', '', 0, 1)
66 - assert.equals('foobar', s:text())
66 + assert.equal('foobar', s:text())
67 67 end)
69 69 it('cursor_byte() returns byte offset', function()
70 70 local s = state.new({}, 7, ':', '', 0, 1)
71 - assert.equals(7, s:cursor_byte())
71 + assert.equal(7, s:cursor_byte())
72 72 end)
74 74 it('is_search() returns true for /', function()

neovim/tests/bugabinga/cursor_restore_spec.lua

Modified
36 36 command = restore_cursor_handler,
39 - vim.api.nvim_exec_autocmds('BufReadPost', { buffer = buf })
39 + vim.api.nvim_exec_autocmds('BufReadPost', { buf = buf })
40 40 local ok, stage2 = pcall(vim.api.nvim_get_autocmds, { group = 'restore_cursor_stage2' })
41 41 if ok then
42 - assert.equals(0, #stage2)
42 + assert.equal(0, #stage2)
54 54 command = restore_cursor_handler,
57 - vim.api.nvim_exec_autocmds('BufReadPost', { buffer = buf })
57 + vim.api.nvim_exec_autocmds('BufReadPost', { buf = buf })
58 58 local ok, stage2 = pcall(vim.api.nvim_get_autocmds, { group = 'restore_cursor_stage2' })
59 59 if ok then
60 - assert.equals(0, #stage2)
60 + assert.equal(0, #stage2)
74 74 command = restore_cursor_handler,
77 - vim.api.nvim_exec_autocmds('BufReadPost', { buffer = buf })
77 + vim.api.nvim_exec_autocmds('BufReadPost', { buf = buf })
78 78 local ok, stage2 = pcall(vim.api.nvim_get_autocmds, { group = 'restore_cursor_stage2' })
79 79 if ok then
80 - assert.equals(0, #stage2)
80 + assert.equal(0, #stage2)
94 94 command = restore_cursor_handler,
97 - vim.api.nvim_exec_autocmds('BufReadPost', { buffer = buf })
97 + vim.api.nvim_exec_autocmds('BufReadPost', { buf = buf })
98 98 local stage2 = vim.api.nvim_get_autocmds({ group = 'restore_cursor_stage2' })
99 - assert.equals(1, #stage2)
100 - assert.equals(buf, stage2[1].buffer)
99 + assert.equal(1, #stage2)
100 + assert.equal(buf, stage2[1].buf)
119 119 command = restore_cursor_handler,
122 - vim.api.nvim_exec_autocmds('BufReadPost', { buffer = buf })
123 - vim.api.nvim_exec_autocmds('BufWinEnter', { buffer = buf })
122 + vim.api.nvim_exec_autocmds('BufReadPost', { buf = buf })
123 + vim.api.nvim_exec_autocmds('BufWinEnter', { buf = buf })
125 125 local cursor = vim.api.nvim_win_get_cursor(win)
126 - assert.equals(3, cursor[1])
127 - assert.equals(4, cursor[2])
126 + assert.equal(3, cursor[1])
127 + assert.equal(4, cursor[2])

neovim/tests/bugabinga/cycle_spec.lua

Modified
41 41 local bufnr = vim.api.nvim_get_current_buf()
42 42 vim.api.nvim_set_current_buf(bufnr)
43 43 for _, b in ipairs(BugabingaCycle.history) do
44 - assert.is_not_equal(bufnr, b)
44 + assert.are_not_equal(bufnr, b)
51 51 vim.bo[bufnr].buflisted = false
52 52 vim.api.nvim_set_current_buf(bufnr)
53 53 for _, b in ipairs(BugabingaCycle.history) do
54 - assert.is_not_equal(bufnr, b)
54 + assert.are_not_equal(bufnr, b)
63 63 local bufnr3 = create_buffer('mruseq3.lua')
64 64 vim.api.nvim_set_current_buf(bufnr3)
65 65 local last = BugabingaCycle.history[#BugabingaCycle.history]
66 - assert.is_equal(bufnr3, last)
66 + assert.equal(bufnr3, last)
69 69 it('should remove deleted buffers from history', function()
75 75 vim.api.nvim_set_current_buf(bufnr3)
76 76 vim.api.nvim_buf_delete(bufnr2, { force = true })
77 77 for _, b in ipairs(BugabingaCycle.history) do
78 - assert.is_not_equal(bufnr2, b)
78 + assert.are_not_equal(bufnr2, b)
99 99 local win_count_before = #vim.api.nvim_list_wins()
100 100 BugabingaCycle.cycle(1)
101 101 local win_count_after = #vim.api.nvim_list_wins()
102 - assert.is_true(win_count_after > win_count_before, 'popup should open')
102 + assert(win_count_after > win_count_before, 'popup should open')
105 105 it('should cycle forward through buffer list', function()
123 123 vim.api.nvim_set_current_buf(bufnr3)
124 124 BugabingaCycle.cycle(1)
125 125 local ok, err = pcall(BugabingaCycle.cycle, 1)
126 - assert.is_true(ok, 'second cycle should not error: ' .. tostring(err))
126 + assert(ok, 'second cycle should not error: ' .. tostring(err))
127 127 BugabingaCycle.cancel()
157 157 BugabingaCycle.cycle(1)
158 158 BugabingaCycle.cancel()
159 159 local restored = vim.api.nvim_get_current_buf()
160 - assert.is_equal(original, restored)
160 + assert.equal(original, restored)
163 163 it('should not crash when timer is already nil', function()
187 187 BugabingaCycle.cycle(1)
188 188 vim.wait(1100)
189 189 local current = vim.api.nvim_get_current_buf()
190 - assert.is_equal(bufnr1, current)
190 + assert.equal(bufnr1, current)
193 193 it('should not switch when no popup was opened', function()
197 197 local original = vim.api.nvim_get_current_buf()
198 198 BugabingaCycle.cycle(1)
199 199 local current = vim.api.nvim_get_current_buf()
200 - assert.is_equal(original, current)
200 + assert.equal(original, current)
205 205 it('shorten_path should return basename for paths outside cwd', function()
206 206 local short = '/a/b/c.lua'
207 207 local result = BugabingaCycle.shorten_path(short, 50)
208 - assert.is_equal('c.lua', result)
208 + assert.equal('c.lua', result)
211 211 it('shorten_path should keep full relative path when it fits', function()
212 212 local path = '/home/user/project/file.lua'
213 213 local result = BugabingaCycle.shorten_path(path, 30)
214 - assert.is_true(#result <= 30, 'should fit: ' .. result .. ' (' .. #result .. ')')
215 - assert.is_true(result:find('file.lua', 1, true) ~= nil, 'basename must be present: ' .. result)
214 + assert(#result <= 30, 'should fit: ' .. result .. ' (' .. #result .. ')')
215 + assert(result:find('file.lua', 1, true) ~= nil, 'basename must be present: ' .. result)
218 218 it('shorten_path should return basename for paths outside cwd', function()
219 219 local long = '/home/user/very/deep/nested/path/to/file.lua'
220 220 local result = BugabingaCycle.shorten_path(long, 25)
221 221 local basename = 'file.lua'
222 - assert.is_equal(basename, result, 'should return basename: ' .. result)
222 + assert.equal(basename, result, 'should return basename: ' .. result)
225 225 it('shorten_path should truncate dirname, result may exceed max if basename is long', function()
226 226 local path = '/home/user/very/deep/nested/path/to/file.lua'
227 227 local result = BugabingaCycle.shorten_path(path, 15)
228 228 local basename = vim.fn.fnamemodify(path, ':t')
229 - assert.is_true(result:find(basename, 1, true) ~= nil, 'basename should be present: ' .. result)
230 - assert.is_true(#result <= 20, 'should be shortened: ' .. result .. ' (' .. #result .. ')')
229 + assert(result:find(basename, 1, true) ~= nil, 'basename should be present: ' .. result)
230 + assert(#result <= 20, 'should be shortened: ' .. result .. ' (' .. #result .. ')')
233 233 it('get_icon should return a string', function()

neovim/tests/bugabinga/d2_spec.lua

Modified
10 10 local mock_d2_system = function(output, code)
11 11 local original_system = vim.system
12 - vim.system = function(cmd, opts)
12 + rawset(vim, 'system', function(cmd, opts)
13 13 local handle = {
14 14 wait = function()
15 15 return { code = code or 0, stdout = output or '', stderr = '' }
18 18 return handle
19 - end
19 + end)
20 20 return function()
21 - vim.system = original_system
21 + rawset(vim, 'system', original_system)
89 89 describe('user commands', function()
90 90 it('should register D2Preview command', function()
91 91 require 'bugabinga.d2'
92 - local ok = pcall(vim.cmd, 'command D2Preview')
93 - assert.is_true(ok, 'D2Preview command should exist')
92 + local ok = pcall(function() vim.cmd 'command D2Preview' end)
93 + assert(ok, 'D2Preview command should exist')
96 96 it('should register D2PreviewToggle command', function()
97 97 require 'bugabinga.d2'
98 - local ok = pcall(vim.cmd, 'command D2PreviewToggle')
99 - assert.is_true(ok, 'D2PreviewToggle command should exist')
98 + local ok = pcall(function() vim.cmd 'command D2PreviewToggle' end)
99 + assert(ok, 'D2PreviewToggle command should exist')
102 102 it('should register D2Validate command without error', function()
103 103 require 'bugabinga.d2'
104 - local ok, err = pcall(vim.cmd, 'D2Validate')
105 - assert.is_true(ok, 'D2Validate should not error: ' .. tostring(err))
104 + local ok, err = pcall(function() vim.cmd 'D2Validate' end)
105 + assert(ok, 'D2Validate should not error: ' .. tostring(err))
108 108 it('should register D2ValidateToggle command without error', function()
109 109 require 'bugabinga.d2'
110 - local ok, err = pcall(vim.cmd, 'D2ValidateToggle')
111 - assert.is_true(ok, 'D2ValidateToggle should not error: ' .. tostring(err))
110 + local ok, err = pcall(function() vim.cmd 'D2ValidateToggle' end)
111 + assert(ok, 'D2ValidateToggle should not error: ' .. tostring(err))
120 120 vim.bo.filetype = 'd2'
121 121 local ok, err = pcall(BugabingaD2.validate)
122 122 restore()
123 - assert.is_true(ok, 'validate should not crash on unnamed buffer: ' .. tostring(err))
123 + assert(ok, 'validate should not crash on unnamed buffer: ' .. tostring(err))
126 126 it('should clear previous diagnostics on re-validate', function()
128 128 local bufnr = create_d2_buffer('clear_test.d2', { 'x -> y' })
129 129 vim.diagnostic.reset(nil, bufnr)
130 130 local diag_count = #vim.diagnostic.get(bufnr)
131 - assert.is_equal(0, diag_count)
131 + assert.equal(0, diag_count)
136 136 it('should toggle auto-validate without error', function()
137 137 require 'bugabinga.d2'
138 138 local ok, err = pcall(BugabingaD2.validate_toggle)
139 - assert.is_true(ok, 'validate_toggle should not error: ' .. tostring(err))
139 + assert(ok, 'validate_toggle should not error: ' .. tostring(err))
140 140 ok, err = pcall(BugabingaD2.validate_toggle)
141 - assert.is_true(ok, 'validate_toggle should not error on second call: ' .. tostring(err))
141 + assert(ok, 'validate_toggle should not error on second call: ' .. tostring(err))
146 146 it('should create d2_preview_autosave autocmds', function()
147 147 require 'bugabinga.d2'
148 148 local autocmds = vim.api.nvim_get_autocmds { group = 'd2_preview_autosave' }
149 - assert.is_true(#autocmds > 0, 'd2_preview_autosave autocmds should exist')
149 + assert(#autocmds > 0, 'd2_preview_autosave autocmds should exist')
152 152 it('should create d2_validate_autosave autocmds', function()
153 153 require 'bugabinga.d2'
154 154 local autocmds = vim.api.nvim_get_autocmds { group = 'd2_validate_autosave' }
155 - assert.is_true(#autocmds > 0, 'd2_validate_autosave autocmds should exist')
155 + assert(#autocmds > 0, 'd2_validate_autosave autocmds should exist')
156 + end)
158 + it('should scope preview keymaps to the event buffer', function()
159 + require 'bugabinga.d2'
160 + local preview_buf = vim.api.nvim_create_buf(false, true)
161 + local autocmd = vim.api.nvim_get_autocmds { group = 'd2_preview_keymaps' }[1]
162 + autocmd.callback { buf = preview_buf }
164 + local keymaps = vim.api.nvim_buf_get_keymap(preview_buf, 'n')
165 + assert.is_true(vim.iter(keymaps):any(function(keymap) return keymap.lhs == 'q' end))
162 172 local results = BugabingaD2._parse_validate_output(stderr)
163 173 assert.is_table(results)
164 174 assert.is_true(#results >= 1)
165 - assert.is_equal(26, results[1].lnum)
166 - assert.is_equal(10, results[1].col)
175 + assert.equal(26, results[1].lnum)
176 + assert.equal(10, results[1].col)
169 179 it('should parse error with URL prefix', function()
171 181 local results = BugabingaD2._parse_validate_output(stderr)
172 182 assert.is_table(results)
173 183 assert.is_true(#results >= 1)
174 - assert.is_equal(26, results[1].lnum)
175 - assert.is_equal(8, results[1].col)
184 + assert.equal(26, results[1].lnum)
185 + assert.equal(8, results[1].col)
178 188 it('should return empty table for no errors', function()
179 189 local stderr = ''
180 190 local results = BugabingaD2._parse_validate_output(stderr)
181 191 assert.is_table(results)
182 - assert.is_equal(0, #results)
192 + assert.equal(0, #results)

neovim/tests/bugabinga/sessions_spec.lua

Modified
16 16 it('should roundtrip hello correctly', function()
17 17 local encoded = encode('hello')
18 18 local decoded = decode(encoded)
19 - assert.equals('hello', decoded)
19 + assert.equal('hello', decoded)
20 20 end)
22 22 it('should replace base64 / with . in test/path', function()
23 23 -- base64 of "test/path" contains / which should become .
24 24 local encoded = encode('test/path')
25 25 -- Verify no / remains (it should be replaced with .)
26 - assert.not_matches('%/', encoded)
26 + assert.is_not_matches('%/', encoded)
27 27 -- Verify roundtrip works
28 - assert.equals('test/path', decode(encoded))
28 + assert.equal('test/path', decode(encoded))
29 29 end)
31 31 it('should replace + and / in test+path/value', function()
32 32 -- base64 of "test+path/value" contains + and / which should become - and .
33 33 local encoded = encode('test+path/value')
34 34 -- Verify no + or / remains
35 - assert.not_matches('%+', encoded)
36 - assert.not_matches('%/', encoded)
35 + assert.is_not_matches('%+', encoded)
36 + assert.is_not_matches('%/', encoded)
37 37 -- Verify roundtrip works
38 - assert.equals('test+path/value', decode(encoded))
38 + assert.equal('test+path/value', decode(encoded))
39 39 end)
41 41 it('should handle empty string', function()
42 42 local encoded = encode('')
43 - assert.equals('', encoded)
43 + assert.equal('', encoded)
44 44 end)
46 46 it('should roundtrip unicode correctly', function()
47 47 local original = '日本語'
48 48 local encoded = encode(original)
49 49 local decoded = decode(encoded)
50 - assert.equals(original, decoded)
50 + assert.equal(original, decoded)
51 51 end)
53 53 it('should error when called with non-string (number)', function()
61 61 it('should roundtrip hello correctly', function()
62 62 local encoded = encode('hello')
63 63 local decoded = decode(encoded)
64 - assert.equals('hello', decoded)
64 + assert.equal('hello', decoded)
65 65 end)
67 67 it('should roundtrip unicode correctly', function()
68 68 local original = '日本語'
69 69 local encoded = encode(original)
70 70 local decoded = decode(encoded)
71 - assert.equals(original, decoded)
71 + assert.equal(original, decoded)
72 72 end)
74 74 it('should error when called with non-string (nil)', function()

neovim/tests/bugabinga/statusline_spec.lua

Modified
17 17 BugabingaStatusline.register(function() return 'bar' end)
18 18 BugabingaStatusline.register(function() return '' end)
19 19 local result = BugabingaStatusline.plugins_component()
20 - assert.is_equal('foo bar', result)
20 + assert.equal('foo bar', result)
21 21 end)
23 23 it('returns empty string when all components return empty', function()
24 24 BugabingaStatusline.register(function() return '' end)
25 25 BugabingaStatusline.register(function() return '' end)
26 26 local result = BugabingaStatusline.plugins_component()
27 - assert.is_equal('', result)
27 + assert.equal('', result)
28 28 end)
29 29 end)
43 43 it('returns empty string on first call (async loading)', function()
44 44 local result = BugabingaStatusline.git_component()
45 - assert.is_equal('', result)
45 + assert.equal('', result)
46 46 end)
48 48 it('returns cached branch string when available', function()
49 49 local fake_branch = icon.branch .. ' test-branch'
50 50 BugabingaStatusline._get_cache().git_branch[initial_cwd] = fake_branch
51 51 local result = BugabingaStatusline.git_component()
52 - assert.is_equal(fake_branch, result)
52 + assert.equal(fake_branch, result)
53 53 end)
55 55 it('DirChanged clears git branch cache', function()
56 56 local fake_branch = icon.branch .. ' test-branch'
57 57 BugabingaStatusline._get_cache().git_branch[initial_cwd] = fake_branch
58 - assert.is_true(vim.tbl_count(BugabingaStatusline._get_cache().git_branch) > 0, 'cache should have entry before')
58 + assert(vim.tbl_count(BugabingaStatusline._get_cache().git_branch) > 0, 'cache should have entry before')
59 59 vim.api.nvim_exec_autocmds('DirChanged', {})
60 - assert.equals(0, vim.tbl_count(BugabingaStatusline._get_cache().git_branch), 'cache should be cleared after DirChanged')
60 + assert.equal(0, vim.tbl_count(BugabingaStatusline._get_cache().git_branch), 'cache should be cleared after DirChanged')
61 61 end)
62 62 end)
63 63 end)

neovim/tests/lsp/denols_spec.lua

Modified
9 9 it('has cmd set to deno lsp', function()
10 10 assert.is_table(denols.cmd)
11 - assert.equals('deno', denols.cmd[1])
12 - assert.equals('lsp', denols.cmd[2])
11 + assert.equal('deno', denols.cmd[1])
12 + assert.equal('lsp', denols.cmd[2])
15 15 it('has NO_COLOR=true in cmd_env', function()
16 16 assert.is_table(denols.cmd_env)
17 - assert.equals(true, denols.cmd_env.NO_COLOR)
17 + assert.equal(true, denols.cmd_env.NO_COLOR)
20 20 it('has correct filetypes', function()
30 30 assert.is_table(denols.filetypes)
31 31 for _, v in ipairs(expected) do
32 - assert.is_true(vim.tbl_contains(denols.filetypes, v), string.format('missing filetypes: %s', v))
32 + assert(vim.tbl_contains(denols.filetypes, v), string.format('missing filetypes: %s', v))
37 37 local expected = { 'deno.json', 'deno.jsonc' }
38 38 assert.is_table(denols.root_markers)
39 39 for _, v in ipairs(expected) do
40 - assert.is_true(vim.tbl_contains(denols.root_markers, v), string.format('missing root_markers: %s', v))
40 + assert(vim.tbl_contains(denols.root_markers, v), string.format('missing root_markers: %s', v))
44 44 it('has deno settings with enable=true', function()
45 45 assert.is_table(denols.settings)
46 46 assert.is_table(denols.settings.deno)
47 - assert.equals(true, denols.settings.deno.enable)
47 + assert.equal(true, denols.settings.deno.enable)
50 50 it('has suggest.imports.hosts configured for deno.land', function()
51 51 local hosts = denols.settings.deno.suggest.imports.hosts
52 52 assert.is_table(hosts)
53 - assert.equals(true, hosts['https://deno.land'])
53 + assert.equal(true, hosts['https://deno.land'])
56 56 it('has handlers for deno: URI resolution', function()
70 70 denols.on_attach(mock_client, mock_bufnr)
71 71 local commands = vim.api.nvim_buf_get_commands(mock_bufnr, {})
72 72 assert.is_table(commands)
73 - assert.is_table(commands.DenolsCache)
73 + assert.is_table(commands['DenolsCache'])
74 74 vim.api.nvim_buf_delete(mock_bufnr, { force = true })
113 113 denols_handler(err, result, ctx, config)
114 114 vim.lsp.handlers['textDocument/definition'] = original_handler
115 115 assert.is_table(captured)
116 - assert.equals('file:///path/to/file.ts', captured[1].uri)
116 + ---@cast captured table
117 + assert.equal('file:///path/to/file.ts', captured[1].uri)
119 120 it('calls virtual_text_document for deno: URIs and preserves them', function()
131 132 denols_handler(err, result, ctx, config)
132 133 vim.lsp.handlers['textDocument/definition'] = original_handler
133 134 assert.is_table(captured)
135 + ---@cast captured table
134 136 assert.is_true(captured[1].uri:match('^deno:') ~= nil)

neovim/tests/manual/capture_highlights.lua

Modified
24 24 '-- Nugu highlight baseline',
25 25 '-- Date: ' .. os.date '!%Y-%m-%dT%H:%M:%SZ',
26 26 '-- Groups: ' .. #names,
27 - '-- termguicolors: ' .. tostring(vim.opt.termguicolors:get()),
27 + '-- termguicolors: ' .. tostring(vim.o.termguicolors),
64 64 local outpath = vim.fn.argv()[1] or '/tmp/nugu_highlights_baseline.txt'
65 -local f = io.open(outpath, 'w')
65 +local f = assert(io.open(outpath, 'w'))
66 66 f:write(table.concat(lines, '\n') .. '\n')
67 67 f:close()
68 68 print('Captured ' .. #names .. ' highlight groups to ' .. outpath)

neovim/tests/manual/compare_highlights.lua

Modified
158 158 lines[#lines + 1] = string.format('Missing: %d', missing_count)
159 159 lines[#lines + 1] = string.format('Skipped: %d (non-nugu colors)', skipped_count)
161 -local f = io.open(outpath, 'w')
161 +local f = assert(io.open(outpath, 'w'))
162 162 f:write(table.concat(lines, '\n') .. '\n')
163 163 f:close()
164 164 print(table.concat(lines, '\n'))

neovim/tests/manual/input.lua

Modified
59 59 vim.wo[WIN].cursorline = false
60 60 vim.keymap.set('n', 'q', function()
61 61 M.close()
62 - end, { buffer = buf, nowait = true })
62 + end, { buf = buf, nowait = true })
63 63 return WIN

neovim/tests/std/auto_spec.lua

Modified
37 37 buffer = buf,
38 38 command = function() fired = true end,
40 - vim.api.nvim_exec_autocmds('BufWinEnter', { buffer = buf })
40 + vim.api.nvim_exec_autocmds('BufWinEnter', { buf = buf })
41 41 assert.is_true(fired)
42 42 vim.api.nvim_buf_delete(buf, { force = true })
51 51 once = true,
52 52 command = function() count = count + 1 end,
54 - vim.api.nvim_exec_autocmds('BufWinEnter', { buffer = buf })
55 - assert.equals(1, count)
56 - vim.api.nvim_exec_autocmds('BufWinEnter', { buffer = buf })
57 - assert.equals(1, count)
54 + vim.api.nvim_exec_autocmds('BufWinEnter', { buf = buf })
55 + assert.equal(1, count)
56 + vim.api.nvim_exec_autocmds('BufWinEnter', { buf = buf })
57 + assert.equal(1, count)
58 58 vim.api.nvim_buf_delete(buf, { force = true })
69 69 local autocmds = vim.api.nvim_get_autocmds({ event = 'BufWinEnter' })
70 70 local found = false
71 71 for _, a in ipairs(autocmds) do
72 - if a.buffer == buf then
72 + if a.buf == buf then
73 73 found = true
74 74 break
109 109 command = function() end,
111 111 local autocmds = vim.api.nvim_get_autocmds({ group = 'test_group' })
112 - assert.equals(1, #autocmds)
113 - assert.equals('my test description', autocmds[1].desc)
112 + assert.equal(1, #autocmds)
113 + assert.equal('my test description', autocmds[1].desc)
157 157 command = 'let g:auto_test_vim_cmd = 42',
159 159 vim.cmd('doautocmd User VimCmdTest')
160 - assert.equals(42, vim.g.auto_test_vim_cmd)
160 + assert.equal(42, vim.g.auto_test_vim_cmd)
161 161 vim.g.auto_test_vim_cmd = nil

neovim/tests/std/cheatsheet_spec.lua

Deleted
deleted file mode 100644
1 --- Test the actual module at lua/std/cheatsheet.lua
2 -local cheatsheet = require 'std.cheatsheet'
4 -local get_category_icon = cheatsheet.get_category_icon
5 -local parse_description = cheatsheet.parse_description
7 -describe('std.cheatsheet helpers', function()
8 - describe('get_category_icon', function()
9 - it('should return LSP for lsp', function()
10 - assert.equals('LSP', get_category_icon('lsp'))
11 - end)
13 - it('should return FZF for fuzzy', function()
14 - assert.equals('FZF', get_category_icon('fuzzy'))
15 - end)
17 - it('should return FILE for files', function()
18 - assert.equals('FILE', get_category_icon('files'))
19 - end)
21 - it('should return uppercase fallback for unknown category', function()
22 - assert.equals('UNKNOWN', get_category_icon('unknown'))
23 - end)
24 - end)
26 - describe('parse_description', function()
27 - it('should parse lsp: hover', function()
28 - local cat, desc = parse_description('lsp: hover')
29 - assert.equals('lsp', cat)
30 - assert.equals('hover', desc)
31 - end)
33 - it('should parse fuzzy: find files', function()
34 - local cat, desc = parse_description('fuzzy: find files')
35 - assert.equals('fuzzy', cat)
36 - assert.equals('find files', desc)
37 - end)
39 - it('should parse files: open', function()
40 - local cat, desc = parse_description('files: open')
41 - assert.equals('files', cat)
42 - assert.equals('open', desc)
43 - end)
45 - it('should parse terminal: new terminal', function()
46 - local cat, desc = parse_description('terminal: new terminal')
47 - assert.equals('terminal', cat)
48 - assert.equals('new terminal', desc)
49 - end)
51 - it('should parse editing: something', function()
52 - local cat, desc = parse_description('editing: something')
53 - assert.equals('editing', cat)
54 - assert.equals('something', desc)
55 - end)
57 - it('should parse search: grep', function()
58 - local cat, desc = parse_description('search: grep')
59 - assert.equals('search', cat)
60 - assert.equals('grep', desc)
61 - end)
63 - it('should parse session: save', function()
64 - local cat, desc = parse_description('session: save')
65 - assert.equals('session', cat)
66 - assert.equals('save', desc)
67 - end)
69 - it('should parse diff: show', function()
70 - local cat, desc = parse_description('diff: show')
71 - assert.equals('diff', cat)
72 - assert.equals('show', desc)
73 - end)
75 - it('should parse operator: move', function()
76 - local cat, desc = parse_description('operator: move')
77 - assert.equals('operator', cat)
78 - assert.equals('move', desc)
79 - end)
81 - it('should parse fun: easter egg', function()
82 - local cat, desc = parse_description('fun: easter egg')
83 - assert.equals('fun', cat)
84 - assert.equals('easter egg', desc)
85 - end)
87 - it('should return general for text without prefix', function()
88 - local cat, desc = parse_description('no prefix text')
89 - assert.equals('general', cat)
90 - assert.equals('no prefix text', desc)
91 - end)
93 - it('should return *no description* for empty string', function()
94 - local cat, desc = parse_description('')
95 - assert.equals('general', cat)
96 - assert.equals('*no description*', desc)
97 - end)
99 - it('should return *no description* for nil', function()
100 - local cat, desc = parse_description(nil)
101 - assert.equals('general', cat)
102 - assert.equals('*no description*', desc)
103 - end)
104 - end)
105 -end)

neovim/tests/std/const_spec.lua

Modified
30 30 vim.env.NVIM_BACKGROUND = 'dark'
31 31 package.loaded['std.const'] = nil
32 32 local fresh = require('std.const')
33 - assert.equals('dark', fresh.os_background)
33 + assert.equal('dark', fresh.os_background)
34 34 end)
36 36 it('should create a cache file after query', function()
39 39 assert.is_nil(f)
40 40 package.loaded['std.const'] = nil
41 41 require('std.const')
42 - f = io.open(cache_path, 'r')
43 - assert.is_not_nil(f)
42 + f = assert(io.open(cache_path, 'r'))
44 43 local cached = f:read('*l')
45 44 f:close()
46 45 assert.is_true(cached == 'dark' or cached == 'light')
47 46 end)
49 48 it('should return cached value on subsequent calls', function()
50 - local f = io.open(cache_path, 'w')
49 + local f = assert(io.open(cache_path, 'w'))
51 50 f:write('light\n')
52 51 f:close()
53 52 package.loaded['std.const'] = nil
54 53 local fresh = require('std.const')
55 - assert.equals('light', fresh.os_background)
54 + assert.equal('light', fresh.os_background)
56 55 end)
57 56 end)
62 61 end)
64 63 it('should clear the cache file', function()
65 - local f = io.open(cache_path, 'w')
64 + local f = assert(io.open(cache_path, 'w'))
66 65 f:write('dark\n')
67 66 f:close()
68 67 const.invalidate_os_background()

neovim/tests/std/dbg/encode_spec.lua

Modified
16 16 local original = { kind = 'DEBUG', date = 1234567890 }
17 17 local encoded = encode(original)
18 18 local decoded = decode(encoded)
19 - assert.equals(original.kind, decoded.kind)
20 - assert.equals(original.date, decoded.date)
19 + assert.equal(original.kind, decoded.kind)
20 + assert.equal(original.date, decoded.date)
21 21 end)
23 23 it('should handle nested tables in data field', function()
29 29 local encoded = encode(original)
30 30 local decoded = decode(encoded)
31 - assert.equals(original.kind, decoded.kind)
32 - assert.equals(original.data[1].a, decoded.data[1].a)
33 - assert.equals(original.data[2].b, decoded.data[2].b)
31 + assert.equal(original.kind, decoded.kind)
32 + assert.equal(original.data[1].a, decoded.data[1].a)
33 + assert.equal(original.data[2].b, decoded.data[2].b)
34 34 end)
36 36 it('should handle nil values in tables via luanil', function()
42 42 local encoded = encode(original)
43 43 local decoded = decode(encoded)
44 44 assert.is_nil(decoded.data[1])
45 - assert.equals('yes', decoded.data.value)
45 + assert.equal('yes', decoded.data.value)
46 46 end)
48 48 it('should escape forward slashes', function()
64 64 local encoded = encode(original)
65 65 local decoded = decode(encoded)
66 - assert.equals(original.kind, decoded.kind)
67 - assert.equals(original.format, decoded.format)
68 - assert.equals(original.filename, decoded.filename)
69 - assert.equals(original.fn, decoded.fn)
70 - assert.equals(original.line, decoded.line)
66 + assert.equal(original.kind, decoded.kind)
67 + assert.equal(original.format, decoded.format)
68 + assert.equal(original.filename, decoded.filename)
69 + assert.equal(original.fn, decoded.fn)
70 + assert.equal(original.line, decoded.line)
71 71 end)
72 72 end)
75 75 it('should decode a valid JSON line', function()
76 76 local line = '{"kind":"DEBUG","date":1234567890}'
77 77 local decoded = decode(line)
78 - assert.equals('DEBUG', decoded.kind)
79 - assert.equals(1234567890, decoded.date)
78 + assert.equal('DEBUG', decoded.kind)
79 + assert.equal(1234567890, decoded.date)
80 80 end)
82 82 it('should handle empty data arrays', function()
84 84 local encoded = encode(original)
85 85 local decoded = decode(encoded)
86 86 assert.is_table(decoded.data)
87 - assert.equals(0, #decoded.data)
87 + assert.equal(0, #decoded.data)
88 88 end)
90 90 it('should handle numeric fields correctly', function()
91 91 local original = { kind = 'ERROR', date = 0, line = 0 }
92 92 local encoded = encode(original)
93 93 local decoded = decode(encoded)
94 - assert.equals(0, decoded.date)
95 - assert.equals(0, decoded.line)
94 + assert.equal(0, decoded.date)
95 + assert.equal(0, decoded.line)
96 96 end)
97 97 end)
98 98 end)

neovim/tests/std/dbg/file_spec.lua

Modified
63 63 write_event(event, test_file)
64 64 local events = read_all(test_file)
65 - assert.equals(1, #events)
66 - assert.equals('DEBUG', events[1].kind)
67 - assert.equals(42, events[1].line)
65 + assert.equal(1, #events)
66 + assert.equal('DEBUG', events[1].kind)
67 + assert.equal(42, events[1].line)
70 70 it('should write multiple events, each on its own line', function()
89 89 write_event(event1, test_file)
90 90 write_event(event2, test_file)
91 91 local events = read_all(test_file)
92 - assert.equals(2, #events)
93 - assert.equals('DEBUG', events[1].kind)
94 - assert.equals('ERROR', events[2].kind)
92 + assert.equal(2, #events)
93 + assert.equal('DEBUG', events[1].kind)
94 + assert.equal('ERROR', events[2].kind)
97 97 it('should append, not overwrite', function()
100 100 write_event(event1, test_file)
101 101 write_event(event2, test_file)
102 102 local events = read_all(test_file)
103 - assert.equals(2, #events)
103 + assert.equal(2, #events)
106 106 it('should return empty list when file does not exist', function()
107 107 local events = read_all('/nonexistent/path/that/does/not/exist.jsonl')
108 - assert.equals(0, #events)
108 + assert.equal(0, #events)
111 111 it('should reopen fd when file is externally recreated', function()
117 117 vim.fn.delete(get_path())
118 118 write_event(event2)
119 119 local events = read_all(get_path())
120 - assert.equals(1, #events, 'new writes go to newly created file after deletion')
121 - assert.equals('e2', events[1].message)
120 + assert.equal(1, #events, 'new writes go to newly created file after deletion')
121 + assert.equal('e2', events[1].message)
124 124 it('should handle events with nested data', function()
134 134 write_event(event, test_file)
135 135 local events = read_all(test_file)
136 - assert.equals(1, #events)
137 - assert.equals(1, events[1].data[1].a)
138 - assert.equals(2, events[1].data[2].b)
136 + assert.equal(1, #events)
137 + assert.equal(1, events[1].data[1].a)
138 + assert.equal(2, events[1].data[2].b)
141 141 it('should store date as os.time() integer', function()
176 176 write_event({ kind = 'DEBUG', date = os.time(), message = 'event ' .. i, data = {}, filename = '/t.lua', fn = 'f', line = 1 }, test_file)
178 178 local new_events, total = read_new(3, test_file)
179 - assert.equals(2, #new_events)
180 - assert.equals(5, total)
181 - assert.equals('event 4', new_events[1].message)
182 - assert.equals('event 5', new_events[2].message)
179 + assert.equal(2, #new_events)
180 + assert.equal(5, total)
181 + assert.equal('event 4', new_events[1].message)
182 + assert.equal('event 5', new_events[2].message)
185 185 it('should return all events when last_count is 0', function()
187 187 write_event({ kind = 'DEBUG', date = os.time(), message = 'e' .. i, data = {}, filename = '/t.lua', fn = 'f', line = 1 }, test_file)
189 189 local new_events, total = read_new(0, test_file)
190 - assert.equals(3, #new_events)
191 - assert.equals(3, total)
190 + assert.equal(3, #new_events)
191 + assert.equal(3, total)
194 194 it('should return empty when last_count equals total events', function()
196 196 write_event({ kind = 'DEBUG', date = os.time(), message = 'e' .. i, data = {}, filename = '/t.lua', fn = 'f', line = 1 }, test_file)
198 198 local new_events, total = read_new(3, test_file)
199 - assert.equals(0, #new_events)
200 - assert.equals(3, total)
199 + assert.equal(0, #new_events)
200 + assert.equal(3, total)
203 203 it('should return empty and 0 when file does not exist', function()
204 204 local new_events, total = read_new(0, '/nonexistent/path.jsonl')
205 - assert.equals(0, #new_events)
206 - assert.equals(0, total)
205 + assert.equal(0, #new_events)
206 + assert.equal(0, total)

neovim/tests/std/dbg/format_spec.lua

Modified
4 4 local format_message = require 'std.dbg.format'
6 6 describe( 'std.dbg.format', function ()
7 7 describe( '{N} basic indexing', function ()
8 8 it( 'should resolve {1}', function ()
9 9 local result = format_message( 'test {1}', { 'hello' } )
10 - assert.equals( 'test hello', result )
10 + assert.equal( 'test hello', result )
11 11 end )
13 13 it( 'should resolve {2}', function ()
14 14 local result = format_message( 'test {2}', { 'first', 'second' } )
15 - assert.equals( 'test second', result )
15 + assert.equal( 'test second', result )
16 16 end )
18 18 it( 'should resolve multiple indices', function ()
19 19 local result = format_message( '{1} {2}', { 'A', 'B' } )
20 - assert.equals( 'A B', result )
20 + assert.equal( 'A B', result )
21 21 end )
23 23 it( 'should resolve reversed order', function ()
24 24 local result = format_message( '{2} {1}', { 'A', 'B' } )
25 - assert.equals( 'B A', result )
25 + assert.equal( 'B A', result )
26 26 end )
28 28 it( 'should resolve with literals mixed in', function ()
29 29 local result = format_message( 'prefix {1} middle {2} suffix', { 'a', 'b' } )
30 - assert.equals( 'prefix a middle b suffix', result )
30 + assert.equal( 'prefix a middle b suffix', result )
31 31 end )
33 33 it( 'should allow same index multiple times', function ()
34 34 local result = format_message( '{1} + {1}', { 'five' } )
35 - assert.equals( 'five + five', result )
35 + assert.equal( 'five + five', result )
36 36 end )
38 38 it( 'should error for missing index on non-array table', function ()
37 37 format_message( '{1}', { name = 'value' } )
38 38 end )
39 39 assert.is_false( ok )
40 - assert.is_not_nil( err:find 'out of range' )
40 + assert.is_not_nil( tostring( err ):find 'out of range' )
41 41 end )
43 43 it( 'should error when {N} exceeds data', function ()
45 45 format_message( '{3}', { 'a', 'b' } )
46 46 end )
47 47 assert.is_false( ok )
48 - assert.is_not_nil( err:find 'out of range' )
49 - assert.is_not_nil( err:find 'did you mean' )
48 + assert.is_not_nil( tostring( err ):find 'out of range' )
49 + assert.is_not_nil( tostring( err ):find 'did you mean' )
50 50 end )
52 52 it( 'should error when {1} on empty data', function ()
54 54 format_message( '{1}', {} )
55 55 end )
56 56 assert.is_false( ok )
57 - assert.is_not_nil( err:find 'out of range' )
57 + assert.is_not_nil( tostring( err ):find 'out of range' )
58 58 end )
60 60 it( 'should error on empty placeholder', function ()
62 62 format_message( '{}', { 'x' } )
63 63 end )
64 64 assert.is_false( ok )
65 - assert.is_not_nil( err:find 'not allowed' )
65 + assert.is_not_nil( tostring( err ):find 'not allowed' )
66 66 end )
68 68 it( 'should error when first key is not numeric', function ()
70 70 format_message( '{name}', { name = 'value' } )
71 71 end )
72 72 assert.is_false( ok )
73 - assert.is_not_nil( err:find 'must be a numeric index' )
73 + assert.is_not_nil( tostring( err ):find 'must be a numeric index' )
74 74 end )
75 75 end )
85 85 it( 'should resolve {0} multiple times', function ()
86 86 local result = format_message( '{0} and {0}', { x = 1 } )
87 87 local parts = vim.split( result, ' and ' )
88 - assert.equals( 2, #parts )
88 + assert.equal( 2, #parts )
89 89 end )
91 91 it( 'should error when {0} followed by keys', function ()
93 93 format_message( '{0.key}', { a = 1 } )
94 94 end )
95 95 assert.is_false( ok )
96 - assert.is_not_nil( err:find 'cannot be followed' )
96 + assert.is_not_nil( tostring( err ):find 'cannot be followed' )
97 97 end )
98 98 end )
100 100 describe( '{N.key} chained access', function ()
101 101 it( 'should resolve {1.a} on single table wrapped', function ()
102 102 local result = format_message( 'test {1.a}', { { a = 'hello' } } )
103 - assert.equals( 'test hello', result )
103 + assert.equal( 'test hello', result )
106 106 it( 'should resolve {2.b} with multiple varargs', function ()
107 107 local result = format_message( 'test {2.b}', { 'x', { b = 'y' } } )
108 - assert.equals( 'test y', result )
108 + assert.equal( 'test y', result )
111 111 it( 'should resolve {1.a} and {2.b}', function ()
112 112 local result = format_message( '{1.a} {2.b}', { { a = 1 }, { b = 2 } } )
113 - assert.equals( '1 2', result )
113 + assert.equal( '1 2', result )
116 116 it( 'should resolve deeply chained {1.a.b}', function ()
117 117 local result = format_message( '{1.a.b}', { { a = { b = 'deep' } } } )
118 - assert.equals( 'deep', result )
118 + assert.equal( 'deep', result )
121 121 it( 'should resolve {1.1} on array inside vararg', function ()
122 122 local result = format_message( '{1.1}', { { 'first', 'second' } } )
123 - assert.equals( 'first', result )
123 + assert.equal( 'first', result )
126 126 it( 'should resolve {1.2} on array inside vararg', function ()
127 127 local result = format_message( '{1.2}', { { 'first', 'second', 'third' } } )
128 - assert.equals( 'second', result )
128 + assert.equal( 'second', result )
131 131 it( 'should resolve {1.1.name} nested', function ()
132 132 local result = format_message( '{1.1.name}', { { { name = 'nested' } } } )
133 - assert.equals( 'nested', result )
133 + assert.equal( 'nested', result )
136 136 it( 'should resolve complex chain {2.1.jan.name}', function ()
137 137 local result = format_message( '{2.1.jan.name}', { 'x', { age = 39, { jan = { name = 'jan', age = 11 } } } } )
138 - assert.equals( 'jan', result )
138 + assert.equal( 'jan', result )
141 141 it( 'should resolve complex chain {2.1.jan.age}', function ()
142 142 local result = format_message( '{2.1.jan.age}', { 'x', { age = 39, { jan = { name = 'jan', age = 11 } } } } )
143 - assert.equals( '11', result )
143 + assert.equal( '11', result )
146 146 it( 'should error for missing chained key', function ()
148 148 format_message( '{1.z}', { { a = 'hello' } } )
150 150 assert.is_false( ok )
151 - assert.is_not_nil( err:find 'not found' )
151 + assert.is_not_nil( tostring( err ):find 'not found' )
154 154 it( 'should error when indexing into non-table', function ()
156 156 format_message( '{1.a}', { 'string' } )
158 158 assert.is_false( ok )
159 - assert.is_not_nil( err:find 'not found' )
159 + assert.is_not_nil( tostring( err ):find 'not found' )
162 162 it( 'should error when {N} index has no value', function ()
164 164 format_message( '{1.a}', { a = 'hello' } )
166 166 assert.is_false( ok )
167 - assert.is_not_nil( err:find 'out of range' )
167 + assert.is_not_nil( tostring( err ):find 'out of range' )
172 172 describe( 'happy path', function ()
173 173 it( 'should resolve dot in key via {1.["a.b"]}', function ()
174 174 local result = format_message( '{1.["a.b"]}', { { ['a.b'] = 1 } } )
175 - assert.equals( '1', result )
175 + assert.equal( '1', result )
178 178 it( 'should resolve numeric string key via {1.["1"]}', function ()
179 179 local result = format_message( '{1.["1"]}', { { ['1'] = 'str' } } )
180 - assert.equals( 'str', result )
180 + assert.equal( 'str', result )
183 183 it( 'should resolve whitespace key via {1.[" spaces "]', function ()
184 184 local result = format_message( '{1.[" spaces "]}', { { [' spaces '] = '#' } } )
185 - assert.equals( '#', result )
185 + assert.equal( '#', result )
188 188 it( 'should resolve reserved keyword via {1.["function"]}', function ()
189 189 local result = format_message( '{1.["function"]}', { { ['function'] = 2 } } )
190 - assert.equals( '2', result )
190 + assert.equal( '2', result )
193 193 it( 'should resolve empty string key via {1.[""]}', function ()
194 194 local result = format_message( '{1.[""]}', { { [''] = 'empty' } } )
195 - assert.equals( 'empty', result )
195 + assert.equal( 'empty', result )
198 198 it( 'should resolve single-quoted key via {1.["my key"]}', function ()
199 199 local result = format_message( "{1.['my key']}", { { ['my key'] = 'v' } } )
200 - assert.equals( 'v', result )
200 + assert.equal( 'v', result )
203 203 it( 'should resolve mixed bare and bracket via {1.a.["x.y"].z}', function ()
204 204 local t = { a = { ['x.y'] = { z = 'ok' } } }
205 205 local result = format_message( '{1.a.["x.y"].z}', { t } )
206 - assert.equals( 'ok', result )
206 + assert.equal( 'ok', result )
209 209 it( 'should resolve multiple consecutive brackets via {1.["a b"].["c d"]}', function ()
210 210 local t = { ['a b'] = { ['c d'] = 'deep' } }
211 211 local result = format_message( '{1.["a b"].["c d"]}', { t } )
212 - assert.equals( 'deep', result )
212 + assert.equal( 'deep', result )
215 215 it( 'should resolve bracket key as first after N via {1.["hello world"]}', function ()
216 216 local result = format_message( '{1.["hello world"]}', { { ['hello world'] = 'hw' } } )
217 - assert.equals( 'hw', result )
217 + assert.equal( 'hw', result )
220 220 it( 'should resolve unicode in bracket via {1.["日本 語"]}', function ()
221 221 local result = format_message( '{1.["日本 語"]}', { { ['日本 語'] = 'jp' } } )
222 - assert.equals( 'jp', result )
222 + assert.equal( 'jp', result )
227 227 it( 'should distinguish ["2"] (string key) from .2 (integer key)', function ()
228 228 local t = { [2] = 'integer', ['2'] = 'string' }
229 229 local result = format_message( '{1.["2"]}', { t } )
230 - assert.equals( 'string', result )
230 + assert.equal( 'string', result )
237 237 format_message( '{1.["key}', { 'x' } )
239 239 assert.is_false( ok )
240 - assert.is_not_nil( err:find 'parse' )
240 + assert.is_not_nil( tostring( err ):find 'parse' )
243 243 it( 'should error on empty brackets', function ()
245 245 format_message( '{1.[]}', { 'x' } )
247 247 assert.is_false( ok )
248 - assert.is_not_nil( err:find 'parse' )
248 + assert.is_not_nil( tostring( err ):find 'parse' )
251 251 it( 'should error on missing quote', function ()
253 253 format_message( '{1.[key]}', { 'x' } )
255 255 assert.is_false( ok )
256 - assert.is_not_nil( err:find 'parse' )
256 + assert.is_not_nil( tostring( err ):find 'parse' )
259 259 it( 'should error on key not found via bracket', function ()
261 261 format_message( '{1.["missing"]}', { { a = 1 } } )
263 263 assert.is_false( ok )
264 - assert.is_not_nil( err:find 'not found' )
264 + assert.is_not_nil( tostring( err ):find 'not found' )
284 284 describe( 'primitive types', function ()
285 285 it( 'should convert numbers to strings', function ()
286 286 local result = format_message( '{1}', { 42 } )
287 - assert.equals( '42', result )
287 + assert.equal( '42', result )
290 290 it( 'should convert booleans to strings', function ()
291 291 local result = format_message( '{1}', { true } )
292 - assert.equals( 'true', result )
292 + assert.equal( 'true', result )
295 295 it( 'should convert false to strings', function ()
296 296 local result = format_message( '{1}', { false } )
297 - assert.equals( 'false', result )
297 + assert.equal( 'false', result )
304 304 format_message( '{-1}', { 'value' } )
306 306 assert.is_false( ok )
307 - assert.is_not_nil( err:find 'out of range' )
307 + assert.is_not_nil( tostring( err ):find 'out of range' )
310 310 it( 'should error for zero index on empty data', function ()
312 312 format_message( '{0}', {} )
314 314 assert.is_false( ok )
315 - assert.is_not_nil( err:find 'empty data' )
315 + assert.is_not_nil( tostring( err ):find 'empty data' )
318 318 it( 'should error for non-integer index', function ()
327 327 format_message( '{999999}', { 'value' } )
329 329 assert.is_false( ok )
330 - assert.is_not_nil( err:find 'out of range' )
330 + assert.is_not_nil( tostring( err ):find 'out of range' )
335 335 it( 'should handle long key names', function ()
336 336 local longkey = string.rep( 'a', 1000 )
337 337 local result = format_message( '{1.' .. longkey .. '}', { { [longkey] = 'longvalue' } } )
338 - assert.equals( 'longvalue', result )
338 + assert.equal( 'longvalue', result )
341 341 it( 'should handle unicode keys', function ()
342 342 local result = format_message( '{1.日本語}', { { ['日本語'] = 'japanese' } } )
343 - assert.equals( 'japanese', result )
343 + assert.equal( 'japanese', result )
346 346 it( 'should handle alternating numeric and string keys deeply', function ()
347 347 local t = { a = { 1, { b = { 1, { c = 'deep' } } } } }
348 348 local result = format_message( '{1.a.2.b.2.c}', { t } )
349 - assert.equals( 'deep', result )
349 + assert.equal( 'deep', result )
354 354 it( 'should handle very long format string', function ()
355 355 local literal = string.rep( 'x', 10000 )
356 356 local result = format_message( literal .. '{1}' .. literal, { 'Y' } )
357 - assert.equals( literal .. 'Y' .. literal, result )
357 + assert.equal( literal .. 'Y' .. literal, result )
360 360 it( 'should handle many placeholders in one format', function ()
367 367 local data = {}
368 368 for i = 1, 100 do data[i] = i end
369 369 local result = format_message( table.concat( parts, ' ' ), data )
370 - assert.equals( table.concat( expected, ' ' ), result )
370 + assert.equal( table.concat( expected, ' ' ), result )
373 373 it( 'should handle consecutive placeholders with no separator', function ()
374 374 local result = format_message( '{1}{2}{3}', { 'A', 'B', 'C' } )
375 - assert.equals( 'ABC', result )
375 + assert.equal( 'ABC', result )
385 385 t = { t }
386 386 local result = format_message( '{1.nested.nested.level}', t )
387 - assert.equals( '1', result )
387 + assert.equal( '1', result )
390 390 it( 'should handle deeply nested tables (10 levels)', function ()
395 395 t = { t }
396 396 local result = format_message( '{1' .. string.rep( '.nested', 9 ) .. '.level}', t )
397 - assert.equals( '1', result )
397 + assert.equal( '1', result )
401 401 describe( 'edge cases', function ()
402 402 it( 'should return empty string for empty format', function ()
403 403 local result = format_message( '', {} )
404 - assert.equals( '', result )
404 + assert.equal( '', result )
407 407 it( 'should return format unchanged when no placeholders', function ()
408 408 local result = format_message( 'no placeholders here', { 'ignored' } )
409 - assert.equals( 'no placeholders here', result )
409 + assert.equal( 'no placeholders here', result )
412 412 it( 'should handle placeholder at start and end', function ()
413 413 local result = format_message( '{1} middle {2}', { 'first', 'last' } )
414 - assert.equals( 'first middle last', result )
414 + assert.equal( 'first middle last', result )
417 417 it( 'should handle consecutive placeholders', function ()
418 418 local result = format_message( '{1}{2}{3}', { 'A', 'B', 'C' } )
419 - assert.equals( 'ABC', result )
419 + assert.equal( 'ABC', result )
424 424 local lev = format_message.levenshtein
426 426 it( 'returns 0 for identical strings', function ()
427 - assert.equals( 0, lev( 'hello', 'hello' ) )
428 - assert.equals( 0, lev( '', '' ) )
429 - assert.equals( 0, lev( 'a', 'a' ) )
427 + assert.equal( 0, lev( 'hello', 'hello' ) )
428 + assert.equal( 0, lev( '', '' ) )
429 + assert.equal( 0, lev( 'a', 'a' ) )
432 432 it( 'returns length difference for empty string', function ()
433 - assert.equals( 3, lev( '', 'abc' ) )
434 - assert.equals( 3, lev( 'abc', '' ) )
433 + assert.equal( 3, lev( '', 'abc' ) )
434 + assert.equal( 3, lev( 'abc', '' ) )
437 437 it( 'returns 1 for single character difference', function ()
438 - assert.equals( 1, lev( 'cat', 'car' ) )
439 - assert.equals( 1, lev( 'name', 'nam' ) )
440 - assert.equals( 1, lev( 'name', 'names' ) )
438 + assert.equal( 1, lev( 'cat', 'car' ) )
439 + assert.equal( 1, lev( 'name', 'nam' ) )
440 + assert.equal( 1, lev( 'name', 'names' ) )
443 443 it( 'returns 2 for swapped characters', function ()
444 - assert.equals( 2, lev( 'name', 'nmae' ) )
445 - assert.equals( 2, lev( 'cat', 'act' ) )
444 + assert.equal( 2, lev( 'name', 'nmae' ) )
445 + assert.equal( 2, lev( 'cat', 'act' ) )
448 448 it( 'handles kitten vs sitting (distance 3)', function ()
449 - assert.equals( 3, lev( 'kitten', 'sitting' ) )
449 + assert.equal( 3, lev( 'kitten', 'sitting' ) )
452 452 it( 'returns correct distances for various pairs', function ()
453 - assert.equals( 1, lev( 'foo', 'fo' ) )
454 - assert.equals( 1, lev( 'foo', 'fOo' ) )
455 - assert.equals( 4, lev( 'hello', 'world' ) )
453 + assert.equal( 1, lev( 'foo', 'fo' ) )
454 + assert.equal( 1, lev( 'foo', 'fOo' ) )
455 + assert.equal( 4, lev( 'hello', 'world' ) )
462 462 format_message( '{1.namme}', { { name = 'hi' } } )
464 464 assert.is_false( ok )
465 - assert.is_not_nil( err:find 'Key not found' )
466 - assert.is_not_nil( err:find "did you mean 'name'" )
465 + assert.is_not_nil( tostring( err ):find 'Key not found' )
466 + assert.is_not_nil( tostring( err ):find "did you mean 'name'" )
469 469 it( 'suggests from multiple keys', function ()
471 471 format_message( '{1.ags}', { { age = 10, name = 'bob' } } )
473 473 assert.is_false( ok )
474 - assert.is_not_nil( err:find 'Key not found' )
475 - assert.is_not_nil( err:find "did you mean 'age'" )
474 + assert.is_not_nil( tostring( err ):find 'Key not found' )
475 + assert.is_not_nil( tostring( err ):find "did you mean 'age'" )
478 478 it( 'suggests correct key for minor typo', function ()
480 480 format_message( '{1.nam}', { { name = 'bob' } } )
482 482 assert.is_false( ok )
483 - assert.is_not_nil( err:find 'Key not found' )
484 - assert.is_not_nil( err:find "did you mean 'name'" )
483 + assert.is_not_nil( tostring( err ):find 'Key not found' )
484 + assert.is_not_nil( tostring( err ):find "did you mean 'name'" )
487 487 it( 'does not suggest when key is too different', function ()
489 489 format_message( '{1.xyz}', { { name = 'bob' } } )
491 491 assert.is_false( ok )
492 - assert.is_not_nil( err:find 'Key not found' )
493 - assert.is_nil( err:find 'did you mean' )
492 + assert.is_not_nil( tostring( err ):find 'Key not found' )
493 + assert.is_nil( tostring( err ):find 'did you mean' )
496 496 it( 'suggests in deeply nested path', function ()
498 498 format_message( '{1.a.nmae}', { { a = { name = 'nested' } } } )
500 500 assert.is_false( ok )
501 - assert.is_not_nil( err:find 'Key not found' )
502 - assert.is_not_nil( err:find "did you mean 'name'" )
501 + assert.is_not_nil( tostring( err ):find 'Key not found' )
502 + assert.is_not_nil( tostring( err ):find "did you mean 'name'" )
505 505 it( 'index suggestion still works when index exceeds data', function ()
507 507 format_message( '{3}', { 'a', 'b' } )
509 509 assert.is_false( ok )
510 - assert.is_not_nil( err:find 'out of range' )
511 - assert.is_not_nil( err:find 'did you mean {2}' )
510 + assert.is_not_nil( tostring( err ):find 'out of range' )
511 + assert.is_not_nil( tostring( err ):find 'did you mean {2}' )
514 514 it( 'no index suggestion when too far out of range', function ()
516 516 format_message( '{6}', { 'a', 'b' } )
518 518 assert.is_false( ok )
519 - assert.is_not_nil( err:find 'out of range' )
520 - assert.is_nil( err:find 'did you mean' )
519 + assert.is_not_nil( tostring( err ):find 'out of range' )
520 + assert.is_nil( tostring( err ):find 'did you mean' )

neovim/tests/std/dbg/init_spec.lua

Modified
14 14 return content
17 + local function require_debug_file(path)
18 + return assert(read_debug_file(path))
19 + end
17 21 before_each( function ()
18 22 package.loaded['std.dbg'] = nil
19 23 package.loaded['std.dbg.init'] = nil
49 53 it( 'should write event when debug mode is on', function ()
50 54 vim.g.bugabinga_debug_mode = true
51 55 dbg( 'test {1}', 'hello' )
52 - local content = read_debug_file(dbg_file)
53 - assert.is_not_nil( content )
56 + local content = require_debug_file(dbg_file)
54 57 assert.is_not_nil( content:match '"kind"' )
55 58 assert.is_not_nil( content:match '"message"' )
56 59 assert.is_not_nil( content:match '"data"' )
59 62 it( 'should write event with date as os.time() integer', function ()
60 63 vim.g.bugabinga_debug_mode = true
61 64 dbg 'test'
62 - local content = read_debug_file(dbg_file)
63 - assert.is_not_nil( content )
65 + local content = require_debug_file(dbg_file)
64 66 local json = vim.json.decode( content )
65 67 assert.is_number( json.date )
66 68 end )
68 70 it( 'should have all required fields in written event', function ()
69 71 vim.g.bugabinga_debug_mode = true
70 72 dbg( 'test {1}', 'y' )
71 - local content = read_debug_file(dbg_file)
72 - assert.is_not_nil( content )
73 + local content = require_debug_file(dbg_file)
73 74 local json = vim.json.decode( content )
74 - assert.equals( 'DEBUG', json.kind )
75 - assert.equals( 'test y', json.message )
75 + assert.equal( 'DEBUG', json.kind )
76 + assert.equal( 'test y', json.message )
76 77 assert.is_table( json.data )
77 78 assert.is_string( json.filename )
78 79 assert.is_string( json.fn )
88 89 it( 'should log with specified kind', function ()
89 90 vim.g.bugabinga_debug_mode = true
90 91 dbg.kind( 'ERROR', 'error message' )
91 - local content = read_debug_file(dbg_file)
92 - assert.is_not_nil( content )
92 + local content = require_debug_file(dbg_file)
93 93 local json = vim.json.decode( content )
94 - assert.equals( 'ERROR', json.kind )
94 + assert.equal( 'ERROR', json.kind )
95 95 end )
97 97 it( 'should log TRACE kind', function ()
98 98 vim.g.bugabinga_debug_mode = true
99 99 dbg.kind( 'TRACE', 'trace message' )
100 - local content = read_debug_file(dbg_file)
101 - assert.is_not_nil( content )
100 + local content = require_debug_file(dbg_file)
102 101 local json = vim.json.decode( content )
103 - assert.equals( 'TRACE', json.kind )
102 + assert.equal( 'TRACE', json.kind )

neovim/tests/std/dbg/kinds_spec.lua

Modified
36 36 describe('get()', function()
37 37 it('should return DEBUG kind details', function()
38 38 local result = kinds.get('DEBUG')
39 - assert.equals(kinds.DEBUG, result)
39 + assert.equal(kinds.DEBUG, result)
42 42 it('should return TRACE kind details', function()
43 43 local result = kinds.get('TRACE')
44 - assert.equals(kinds.TRACE, result)
44 + assert.equal(kinds.TRACE, result)
47 47 it('should return ERROR kind details', function()
48 48 local result = kinds.get('ERROR')
49 - assert.equals(kinds.ERROR, result)
49 + assert.equal(kinds.ERROR, result)
52 52 it('should error on unknown kind', function()
62 62 it('should return all kind names', function()
63 63 local result = kinds.list()
64 64 assert.is_table(result)
65 - assert.equals(3, #result)
65 + assert.equal(3, #result)
66 66 assert.is_true(vim.tbl_contains(result, 'DEBUG'))
67 67 assert.is_true(vim.tbl_contains(result, 'TRACE'))
68 68 assert.is_true(vim.tbl_contains(result, 'ERROR'))

neovim/tests/std/dbg/viewer_spec.lua

Modified
4 4 local viewer = require 'std.dbg.viewer'
5 5 local file = require 'std.dbg.file'
6 6 local encode = require 'std.dbg.encode'
8 8 describe( 'std.dbg.viewer', function ()
9 9 local test_log_path
10 + local original_input
11 12 before_each( function ()
12 13 package.loaded['std.dbg.viewer'] = nil
11 12 test_log_path = file.get_path()
12 13 file.clear_log()
13 14 vim.g.bugabinga_debug_mode = true
14 - vim.ui.input = function( opts, on_choice )
15 + original_input = vim.ui.input
16 + rawset(vim.ui, 'input', function( _, on_choice )
15 17 on_choice( nil )
16 - end
18 + end)
17 19 end )
19 21 after_each( function ()
20 22 pcall(viewer.close)
21 23 file.clear_log()
22 24 vim.g.bugabinga_debug_mode = false
25 + rawset(vim.ui, 'input', original_input)
23 26 end )
25 28 local function write_event(event)
26 - local f = io.open(test_log_path, 'a')
29 + local f = assert(io.open(test_log_path, 'a'))
27 30 f:write(encode.encode(event) .. '\n')
28 31 f:close()
57 60 write_event(make_event())
58 61 viewer.open()
59 62 local buf_id = vim.api.nvim_win_get_buf(vim.api.nvim_get_current_win())
60 - assert.equals('nofile', vim.bo[buf_id].buftype)
61 - assert.equals(false, vim.bo[buf_id].buflisted)
63 + assert.equal('nofile', vim.bo[buf_id].buftype)
64 + assert.equal(false, vim.bo[buf_id].buflisted)
62 65 end )
64 67 it( 'open() sets buffer filetype to DbgViewer', function ()
65 68 write_event(make_event())
66 69 viewer.open()
67 70 local buf_id = vim.api.nvim_win_get_buf(vim.api.nvim_get_current_win())
68 - assert.equals('DbgViewer', vim.bo[buf_id].filetype)
71 + assert.equal('DbgViewer', vim.bo[buf_id].filetype)
69 72 end )
71 74 it( 'close() closes the window', function ()
100 103 local first_win = vim.api.nvim_get_current_win()
101 104 viewer.open()
102 105 local second_win = vim.api.nvim_get_current_win()
103 - assert.equals(first_win, second_win)
106 + assert.equal(first_win, second_win)
279 282 it( '<CR> jumps to source', function ()
280 283 local jump_path = vim.fn.fnamemodify(vim.fn.getcwd(), ':p') .. 'test_jump_target.lua'
281 - local f = io.open(jump_path, 'w')
284 + local f = assert(io.open(jump_path, 'w'))
282 285 f:write 'local x = 1\nlocal y = 2\n'
283 286 f:close()
284 287 write_event(make_event({ filename = jump_path, line = 2, message = 'jump test' }))
292 295 local curbuf_after = vim.api.nvim_get_current_buf()
293 296 local name = vim.api.nvim_buf_get_name(curbuf_after)
294 - assert.is_not_nil(name, 'buffer should have a name after jump')
295 - assert.is_not_nil(name:match 'test_jump_target', 'should jump to test file: ' .. tostring(name))
297 + assert(name ~= nil, 'buffer should have a name after jump')
298 + assert(name:match 'test_jump_target' ~= nil, 'should jump to test file: ' .. tostring(name))
296 299 vim.fn.delete(jump_path)
328 331 describe( 'Phase 5: edge cases', function ()
329 332 it( 'handles events with missing fields gracefully', function ()
330 - local f = io.open(test_log_path, 'a')
333 + local f = assert(io.open(test_log_path, 'a'))
331 334 f:write(vim.json.encode({ kind = 'DEBUG', message = 'partial' }) .. '\n')
332 335 f:close()
333 336 viewer.open()
359 362 local path3 = vim.fn.fnamemodify(vim.fn.getcwd(), ':p') .. 'jump_test_3.lua'
360 363 local path4 = vim.fn.fnamemodify(vim.fn.getcwd(), ':p') .. 'jump_test_4.lua'
361 364 for _, p in ipairs({ path1, path2, path3, path4 }) do
362 - local f = io.open(p, 'w')
365 + local f = assert(io.open(p, 'w'))
363 366 f:write('line1\nline2\nline3\nline4\nline5\n')
364 367 f:close()
377 380 local curbuf = vim.api.nvim_get_current_buf()
378 381 local name = vim.api.nvim_buf_get_name(curbuf)
379 - assert.is_not_nil(name:match 'jump_test_4', 'should jump to newest event (path4), got: ' .. tostring(name))
382 + assert(name:match 'jump_test_4' ~= nil, 'should jump to newest event (path4), got: ' .. tostring(name))
380 383 for _, p in ipairs({ path1, path2, path3, path4 }) do
381 384 vim.fn.delete(p)
385 388 it( 'watcher remains alive after auto-refresh', function ()
386 389 write_event(make_event({ message = 'e1' }))
387 390 viewer.open()
388 - assert.is_not_nil(viewer._get_state().watcher, 'watcher should exist after open')
391 + assert(assert(viewer._get_state()).watcher, 'watcher should exist after open')
389 392 write_event(make_event({ message = 'e2' }))
390 393 viewer._on_file_change()
391 - assert.is_not_nil(viewer._get_state().watcher, 'watcher should still exist after file change')
394 + assert(assert(viewer._get_state()).watcher, 'watcher should still exist after file change')
394 397 it( 'original event highlights survive auto-refresh', function ()
397 400 viewer.open()
398 401 local buf_id = vim.api.nvim_win_get_buf(vim.api.nvim_get_current_win())
399 402 local extmarks_before = vim.api.nvim_buf_get_extmarks(buf_id, -1, 0, -1, { details = true })
400 - assert.is_true(#extmarks_before > 0, 'should have highlights on initial render')
403 + assert(#extmarks_before > 0, 'should have highlights on initial render')
401 404 write_event(make_event({ kind = 'TRACE', message = 'event3' }))
402 405 viewer._on_file_change()
403 406 local extmarks_after = vim.api.nvim_buf_get_extmarks(buf_id, -1, 0, -1, { details = true })
404 - assert.is_true(#extmarks_after >= #extmarks_before, 'should retain original highlights after prepend')
407 + assert(#extmarks_after >= #extmarks_before, 'should retain original highlights after prepend')
407 410 it( 'sanitizes [string "..."] source to unknown', function ()
421 424 for _, l in ipairs(lines) do
422 425 if l:match 'unknown' then found_unknown = true break end
424 - assert.is_true(found_unknown, 'should show "unknown" for [string "..."] source')
427 + assert(found_unknown, 'should show "unknown" for [string "..."] source')
427 430 it( 'filtered_indices stay consistent after auto-refresh', function ()
428 431 write_event(make_event({ kind = 'DEBUG', message = 'debug1' }))
429 432 viewer.open()
430 433 viewer.clear_filters()
431 - local state_before = viewer._get_state()
434 + local state_before = assert(viewer._get_state())
432 435 local filtered_count_before = state_before.filtered_count
433 436 write_event(make_event({ kind = 'DEBUG', message = 'debug2' }))
434 437 viewer._on_file_change()
435 - local state_after = viewer._get_state()
436 - assert.equals(filtered_count_before + 1, state_after.filtered_count, 'filtered_count should increment for new matching event')
438 + local state_after = assert(viewer._get_state())
439 + assert.equal(filtered_count_before + 1, state_after.filtered_count, 'filtered_count should increment for new matching event')

neovim/tests/std/executable_spec.lua

Added
new file mode 100644
1 +local executable = require 'std.executable'
3 +describe('std.executable', function()
4 + it('returns a boolean for available and missing executables', function()
5 + assert.is_true(executable 'nvim')
6 + assert.is_false(executable 'definitely-missing-executable')
7 + end)
9 + it('rejects non-string names', function()
10 + assert.has_error(function() executable(42) end)
11 + end)
12 +end)

neovim/tests/std/ignored_spec.lua

Modified
33 33 it('should only contain entries with special regex chars', function()
34 34 local pattern = '[%^%$%*%+%.%?]'
35 35 for _, v in ipairs(ignored.filetypes_patterns) do
36 - assert.is_not_nil(v:find(pattern), string.format("'%s' should have special regex chars", v))
36 + assert(v:find(pattern) ~= nil, string.format("'%s' should have special regex chars", v))
38 38 end)
62 62 describe('filetypes_kv integrity', function()
63 63 it('all entries in filetypes_kv should be truthy', function()
64 64 for _, ft in ipairs(ignored.filetypes) do
65 - assert.is_true(ignored.filetypes_kv[ft], string.format("filetypes_kv['%s'] should be true", ft))
65 + assert(ignored.filetypes_kv[ft], string.format("filetypes_kv['%s'] should be true", ft))
67 67 end)
68 68 end)

neovim/tests/std/light_up_spec.lua

Modified
21 21 local words = { test_word = 'Title' }
22 22 local ns = light_up.buffer(bufnr, words)
23 23 local marks = vim.api.nvim_buf_get_extmarks(bufnr, ns, 0, -1, { details = true })
24 - assert.equals(1, #marks, 'should have exactly one highlight mark')
25 - assert.equals(1, marks[1][2], 'should be on line 1 (where test_word appears)')
26 - assert.equals(0, marks[1][3], 'test_word starts at column 0')
24 + assert.equal(1, #marks, 'should have exactly one highlight mark')
25 + assert.equal(1, marks[1][2], 'should be on line 1 (where test_word appears)')
26 + assert.equal(0, marks[1][3], 'test_word starts at column 0')
27 27 end)
29 29 it('should highlight multiple different words on the same line', function()
30 30 local words = { keyword1 = 'Title', keyword2 = 'Comment' }
31 31 local ns = light_up.buffer(bufnr, words)
32 32 local marks = vim.api.nvim_buf_get_extmarks(bufnr, ns, 0, -1, { details = true })
33 - assert.equals(2, #marks, 'both keyword1 and keyword2 on same line should be highlighted')
33 + assert.equal(2, #marks, 'both keyword1 and keyword2 on same line should be highlighted')
34 34 end)
36 36 it('should highlight all instances of same word on same line', function()
38 38 local words = { foo = 'Title' }
39 39 local ns = light_up.buffer(bufnr, words)
40 40 local marks = vim.api.nvim_buf_get_extmarks(bufnr, ns, 0, -1, { details = true })
41 - assert.equals(3, #marks, 'all three foo occurrences should be highlighted')
41 + assert.equal(3, #marks, 'all three foo occurrences should be highlighted')
42 42 end)
43 43 end)
46 46 it('should return a non-empty table', function()
47 47 local groups = light_up.get_vim_highlight_groups()
48 48 assert.is_table(groups)
49 - assert.is_true(next(groups) ~= nil, 'should have at least one highlight group')
49 + assert(next(groups) ~= nil, 'should have at least one highlight group')
50 50 end)
52 52 it('should contain common highlight groups', function()

neovim/tests/std/map_spec.lua

Modified
25 25 return nil
28 + local function get_keymap( mode, lhs )
29 + return assert( find_keymap( mode, lhs ) )
30 + end
28 32 describe( 'mode aliases', function ()
29 33 it( 'should support "n" as alias for normal mode', function ()
30 34 local deleter = map.n { keys = '<test-map-keys>', command = 'echo "test"' }
31 35 assert.is_function( deleter )
32 - local mapping = find_keymap( 'n', '<test-map-keys>' )
36 + local mapping = get_keymap( 'n', '<test-map-keys>' )
33 37 assert.is_not_nil( mapping )
34 - assert.equals( '<test-map-keys>', mapping.lhsraw )
38 + assert.equal( '<test-map-keys>', mapping.lhsraw )
35 39 end )
37 41 it( 'should support "normal" as explicit normal mode', function ()
38 42 local deleter = map.normal { keys = '<test-map-keys>', command = 'echo "test"' }
39 43 assert.is_function( deleter )
40 - local mapping = find_keymap( 'n', '<test-map-keys>' )
44 + local mapping = get_keymap( 'n', '<test-map-keys>' )
41 45 assert.is_not_nil( mapping )
42 - assert.equals( '<test-map-keys>', mapping.lhsraw )
46 + assert.equal( '<test-map-keys>', mapping.lhsraw )
43 47 end )
45 49 it( 'should support "i" as alias for insert mode', function ()
46 50 local deleter = map.i { keys = 'k', command = 'echo "insert"' }
47 51 assert.is_function( deleter )
48 - local mapping = find_keymap( 'i', 'k' )
52 + local mapping = get_keymap( 'i', 'k' )
49 53 assert.is_not_nil( mapping )
50 - assert.equals( 'k', mapping.lhsraw )
54 + assert.equal( 'k', mapping.lhsraw )
51 55 end )
53 57 it( 'should support "insert" as explicit insert mode', function ()
54 58 local deleter = map.insert { keys = 'k', command = 'echo "insert"' }
55 59 assert.is_function( deleter )
56 - local mapping = find_keymap( 'i', 'k' )
60 + local mapping = get_keymap( 'i', 'k' )
57 61 assert.is_not_nil( mapping )
58 - assert.equals( 'k', mapping.lhsraw )
62 + assert.equal( 'k', mapping.lhsraw )
59 63 end )
61 65 it( 'should support "x" as alias for visual mode', function ()
62 66 local deleter = map.x { keys = '<test-map-keys>', command = 'echo "visual"' }
63 67 assert.is_function( deleter )
64 - local mapping = find_keymap( 'x', '<test-map-keys>' )
68 + local mapping = get_keymap( 'x', '<test-map-keys>' )
65 69 assert.is_not_nil( mapping )
66 - assert.equals( '<test-map-keys>', mapping.lhsraw )
70 + assert.equal( '<test-map-keys>', mapping.lhsraw )
67 71 end )
69 73 it( 'should support "visual" as explicit visual mode', function ()
70 74 local deleter = map.visual { keys = '<test-map-keys>', command = 'echo "visual"' }
71 75 assert.is_function( deleter )
72 - local mapping = find_keymap( 'x', '<test-map-keys>' )
76 + local mapping = get_keymap( 'x', '<test-map-keys>' )
73 77 assert.is_not_nil( mapping )
74 - assert.equals( '<test-map-keys>', mapping.lhsraw )
78 + assert.equal( '<test-map-keys>', mapping.lhsraw )
75 79 end )
77 81 it( 'should support "v" as alias for visual_select mode', function ()
78 82 local deleter = map.v { keys = '<test-map-keys>', command = 'echo "v"' }
79 83 assert.is_function( deleter )
80 - local mapping = find_keymap( 'v', '<test-map-keys>' )
84 + local mapping = get_keymap( 'v', '<test-map-keys>' )
81 85 assert.is_not_nil( mapping )
82 - assert.equals( '<test-map-keys>', mapping.lhsraw )
86 + assert.equal( '<test-map-keys>', mapping.lhsraw )
83 87 end )
85 89 it( 'should support "s" as alias for select mode', function ()
86 90 local deleter = map.s { keys = '<test-map-keys>', command = 'echo "s"' }
87 91 assert.is_function( deleter )
88 - local mapping = find_keymap( 's', '<test-map-keys>' )
92 + local mapping = get_keymap( 's', '<test-map-keys>' )
89 93 assert.is_not_nil( mapping )
90 - assert.equals( '<test-map-keys>', mapping.lhsraw )
94 + assert.equal( '<test-map-keys>', mapping.lhsraw )
91 95 end )
93 97 it( 'should support "o" as alias for operator_pending mode', function ()
94 98 local deleter = map.o { keys = '<test-map-keys>', command = 'echo "o"' }
95 99 assert.is_function( deleter )
96 - local mapping = find_keymap( 'o', '<test-map-keys>' )
100 + local mapping = get_keymap( 'o', '<test-map-keys>' )
97 101 assert.is_not_nil( mapping )
98 - assert.equals( '<test-map-keys>', mapping.lhsraw )
102 + assert.equal( '<test-map-keys>', mapping.lhsraw )
101 105 it( 'should support "c" as alias for command_line mode', function ()
102 106 local deleter = map.c { keys = '<test-map-keys>', command = 'echo "c"' }
103 107 assert.is_function( deleter )
104 - local mapping = find_keymap( 'c', '<test-map-keys>' )
108 + local mapping = get_keymap( 'c', '<test-map-keys>' )
105 109 assert.is_not_nil( mapping )
106 - assert.equals( '<test-map-keys>', mapping.lhsraw )
110 + assert.equal( '<test-map-keys>', mapping.lhsraw )
109 113 it( 'should support "t" as alias for terminal mode', function ()
110 114 local deleter = map.t { keys = '<test-map-keys>', command = 'echo "t"' }
111 115 assert.is_function( deleter )
112 - local mapping = find_keymap( 't', '<test-map-keys>' )
116 + local mapping = get_keymap( 't', '<test-map-keys>' )
113 117 assert.is_not_nil( mapping )
114 - assert.equals( '<test-map-keys>', mapping.lhsraw )
118 + assert.equal( '<test-map-keys>', mapping.lhsraw )
119 123 it( 'should chain normal and visual modes', function ()
120 124 local deleter = map.normal.visual { keys = 'gd', command = 'echo "chained"' }
121 125 assert.is_function( deleter )
122 - local normal_mapping = find_keymap( 'n', 'gd' )
123 - local visual_mapping = find_keymap( 'x', 'gd' )
126 + local normal_mapping = get_keymap( 'n', 'gd' )
127 + local visual_mapping = get_keymap( 'x', 'gd' )
124 128 assert.is_not_nil( normal_mapping )
125 129 assert.is_not_nil( visual_mapping )
128 132 it( 'should chain multiple modes', function ()
129 133 local deleter = map.n.x.v { keys = 'gx', command = 'echo "multi"' }
130 134 assert.is_function( deleter )
131 - local n_mapping = find_keymap( 'n', 'gx' )
132 - local x_mapping = find_keymap( 'x', 'gx' )
133 - local v_mapping = find_keymap( 'v', 'gx' )
135 + local n_mapping = get_keymap( 'n', 'gx' )
136 + local x_mapping = get_keymap( 'x', 'gx' )
137 + local v_mapping = get_keymap( 'v', 'gx' )
134 138 assert.is_not_nil( n_mapping )
135 139 assert.is_not_nil( x_mapping )
136 140 assert.is_not_nil( v_mapping )
139 143 it( 'should return self after adding mode for further chaining', function ()
140 144 local result = map.normal
141 - assert.equals( map, result )
145 + assert.equal( map, result )
142 146 result = map.normal.visual
143 - assert.equals( map, result )
147 + assert.equal( map, result )
146 150 it( 'should not duplicate mode when same mode is chained multiple times', function ()
150 154 for _, mode in ipairs( modes ) do
151 155 if mode == 'n' then n_count = n_count + 1 end
153 - assert.equals( 1, n_count, 'mode "n" should appear exactly once in modes array before bind' )
157 + assert.equal( 1, n_count, 'mode "n" should appear exactly once in modes array before bind' )
158 162 it( 'should accept keys as string', function ()
159 163 local deleter = map.normal { keys = '<test-map-keys>', command = 'echo "string keys"' }
160 164 assert.is_function( deleter )
161 - local mapping = find_keymap( 'n', '<test-map-keys>' )
165 + local mapping = get_keymap( 'n', '<test-map-keys>' )
162 166 assert.is_not_nil( mapping )
163 - assert.equals( '<test-map-keys>', mapping.lhsraw )
167 + assert.equal( '<test-map-keys>', mapping.lhsraw )
166 170 it( 'should accept keys as table (array of keys)', function ()
167 171 local deleter = map.normal { keys = { '<test-map-keys>', '<test-map-keys-2>' }, command = 'echo "table keys"' }
168 172 assert.is_function( deleter )
169 - local mapping1 = find_keymap( 'n', '<test-map-keys>' )
170 - local mapping2 = find_keymap( 'n', '<test-map-keys-2>' )
173 + local mapping1 = get_keymap( 'n', '<test-map-keys>' )
174 + local mapping2 = get_keymap( 'n', '<test-map-keys-2>' )
171 175 assert.is_not_nil( mapping1 )
172 176 assert.is_not_nil( mapping2 )
173 - assert.equals( '<test-map-keys>', mapping1.lhsraw )
174 - assert.equals( '<test-map-keys-2>', mapping2.lhsraw )
177 + assert.equal( '<test-map-keys>', mapping1.lhsraw )
178 + assert.equal( '<test-map-keys-2>', mapping2.lhsraw )
179 183 it( 'should accept command as string', function ()
180 184 local deleter = map.normal { keys = '<test-map-keys>', command = 'echo "string command"' }
181 185 assert.is_function( deleter )
182 - local mapping = find_keymap( 'n', '<test-map-keys>' )
186 + local mapping = get_keymap( 'n', '<test-map-keys>' )
183 187 assert.is_not_nil( mapping )
184 - assert.equals( 'echo "string command"', mapping.rhs )
188 + assert.equal( 'echo "string command"', mapping.rhs )
187 191 it( 'should accept command as function', function ()
192 196 local deleter = map.normal { keys = '<test-map-keys>', command = test_func }
193 197 assert.is_function( deleter )
194 - local mapping = find_keymap( 'n', '<test-map-keys>' )
198 + local mapping = get_keymap( 'n', '<test-map-keys>' )
195 199 assert.is_not_nil( mapping )
196 200 assert.is_function( mapping.callback )
197 201 mapping.callback()
203 207 it( 'should set silent=true by default', function ()
204 208 local deleter = map.normal { keys = '<test-map-keys>', command = 'echo "silent"' }
205 209 assert.is_function( deleter )
206 - local mapping = find_keymap( 'n', '<test-map-keys>' )
210 + local mapping = get_keymap( 'n', '<test-map-keys>' )
207 211 assert.is_not_nil( mapping )
208 212 assert.is_true( mapping.silent == 1 or mapping.silent == true )
216 220 description = 'TestDescription',
218 222 assert.is_function( deleter )
219 - local mapping = find_keymap( 'n', '<test-map-keys>' )
223 + local mapping = get_keymap( 'n', '<test-map-keys>' )
220 224 assert.is_not_nil( mapping )
221 - assert.equals( 'TestCategory: TestDescription', mapping.desc )
225 + assert.equal( 'TestCategory: TestDescription', mapping.desc )
224 228 it( 'should use description alone when category is not present', function ()
228 232 description = 'JustDescription',
230 234 assert.is_function( deleter )
231 - local mapping = find_keymap( 'n', '<test-map-keys>' )
235 + local mapping = get_keymap( 'n', '<test-map-keys>' )
232 236 assert.is_not_nil( mapping )
233 - assert.equals( 'JustDescription', mapping.desc )
237 + assert.equal( 'JustDescription', mapping.desc )
236 240 it( 'should support buffer option for buffer-local keymap', function ()
263 267 assert.is_function( deleter )
264 - local mapping = find_keymap( 'n', '<test-map-keys>' )
268 + local mapping = get_keymap( 'n', '<test-map-keys>' )
265 269 assert.is_not_nil( mapping )
266 270 assert.is_true( mapping.noremap == 1 or mapping.noremap == true )
273 277 remap = true,
275 279 assert.is_function( deleter )
276 - local mapping = find_keymap( 'n', '<test-map-keys>' )
280 + local mapping = get_keymap( 'n', '<test-map-keys>' )
277 281 assert.is_not_nil( mapping )
282 286 it( 'should return a cleanup function (deleter)', function ()
283 287 local deleter = map.normal { keys = '<test-map-keys>', command = 'echo "delete"' }
284 288 assert.is_function( deleter )
285 - local mapping_before = find_keymap( 'n', '<test-map-keys>' )
289 + local mapping_before = get_keymap( 'n', '<test-map-keys>' )
286 290 assert.is_not_nil( mapping_before )
287 291 deleter()
288 292 local mapping_after = find_keymap( 'n', '<test-map-keys>' )
294 298 keys = { '<test-map-keys>', '<test-map-keys-2>' },
295 299 command = 'echo "delete multiple"',
297 - local mapping1_before = find_keymap( 'n', '<test-map-keys>' )
298 - local mapping2_before = find_keymap( 'n', '<test-map-keys-2>' )
301 + local mapping1_before = get_keymap( 'n', '<test-map-keys>' )
302 + local mapping2_before = get_keymap( 'n', '<test-map-keys-2>' )
299 303 assert.is_not_nil( mapping1_before )
300 304 assert.is_not_nil( mapping2_before )
301 305 deleter()
323 - assert.is_true( found_before, 'keymap should exist before deletion' )
327 + assert(found_before, 'keymap should exist before deletion')
324 328 deleter()
325 329 local keymaps_after = vim.api.nvim_buf_get_keymap( 0, 'n' )
326 330 local found_after = false
333 - assert.is_false( found_after, 'keymap should be deleted after calling deleter' )
337 + assert(not found_after, 'keymap should be deleted after calling deleter')
338 342 it( 'should use normal_visual_select_operator_pending when no modes specified', function ()
339 343 local deleter = map { keys = '<test-map-keys>', command = 'echo "default modes"' }
340 344 assert.is_function( deleter )
341 - local n_mapping = find_keymap( 'n', '<test-map-keys>' )
342 - local x_mapping = find_keymap( 'x', '<test-map-keys>' )
343 - local v_mapping = find_keymap( 'v', '<test-map-keys>' )
344 - local o_mapping = find_keymap( 'o', '<test-map-keys>' )
345 + local n_mapping = get_keymap( 'n', '<test-map-keys>' )
346 + local x_mapping = get_keymap( 'x', '<test-map-keys>' )
347 + local v_mapping = get_keymap( 'v', '<test-map-keys>' )
348 + local o_mapping = get_keymap( 'o', '<test-map-keys>' )
345 349 assert.is_not_nil( n_mapping )
346 350 assert.is_not_nil( x_mapping )
347 351 assert.is_not_nil( v_mapping )
359 363 it( 'should error when map.keys is not string or table', function ()
360 - local ok, err = pcall( function () map.normal { keys = 123, command = 'echo "error"' } end )
364 + local invalid = 123
365 + ---@cast invalid any
366 + local ok, err = pcall( function () map.normal { keys = invalid, command = 'echo "error"' } end )
361 367 assert.is_false( ok )
362 - assert.is_not_nil( vim.split( err, '\n' )[1]:match 'map.keys: expected' )
368 + assert.is_not_nil( vim.split( tostring( err ), '\n' )[1]:match 'map.keys: expected' )
365 371 it( 'should error when map.command is not function or string', function ()
366 372 local ok, err = pcall( function () map.normal { keys = '<test-map-keys>', command = nil } end )
367 373 assert.is_false( ok )
368 - assert.is_not_nil( vim.split( err, '\n' )[1]:match 'map.command: expected' )
374 + assert.is_not_nil( vim.split( tostring( err ), '\n' )[1]:match 'map.command: expected' )
371 377 it( 'should error when map is not a table', function ()
372 - local ok, err = pcall( function () map( 123 ) end )
378 + local invalid = 123
379 + ---@cast invalid any
380 + local ok, err = pcall( function () map( invalid ) end )
373 381 assert.is_false( ok )
374 - assert.is_not_nil( vim.split( err, '\n' )[1]:match 'map: expected' )
382 + assert.is_not_nil( vim.split( tostring( err ), '\n' )[1]:match 'map: expected' )
377 385 it( 'should error on assignment to map', function ()
378 386 local ok, err = pcall( function () map.foo = 'bar' end )
379 387 assert.is_false( ok )
380 - assert.is_not_nil( err:match 'Assignments are not supported for std.map' )
388 + assert.is_not_nil( tostring( err ):match 'Assignments are not supported for std.map' )

neovim/tests/std/prequire_spec.lua

Modified
16 16 it('should return the first successfully loaded module as first_mod', function()
17 17 local result = prequire('std.const', 'std.map')
18 18 assert.is_table(result)
19 - assert.equals('table', type(result))
19 + assert.equal('table', type(result))
22 22 it('should handle multiple existing modules', function()
25 25 modules = { const, map }
27 27 assert.is_table(modules)
28 + ---@cast modules table
28 29 assert.is_table(modules[1])
29 30 assert.is_table(modules[2])
39 40 it('should not crash when calling on proxy (__call returns self)', function()
40 41 local proxy = prequire('missing_module_12345')
41 42 local call_result = proxy()
42 - assert.equals(proxy, call_result)
43 + assert.equal(proxy, call_result)
45 46 it('should not crash when indexing on proxy (__index returns self)', function()
46 47 local proxy = prequire('missing_module_12345')
47 48 local result = proxy.foo
48 - assert.equals(proxy, result)
49 + assert.equal(proxy, result)
49 50 local nested = proxy.foo.bar.baz
50 - assert.equals(proxy, nested)
51 + assert.equal(proxy, nested)
53 54 it('should return recursive proxy for nested access', function()
54 55 local proxy = prequire('missing_module_67890')
55 - assert.equals(proxy, proxy.foo)
56 - assert.equals(proxy, proxy.foo.bar)
57 - assert.equals(proxy, proxy.foo.bar.baz.qux)
56 + assert.equal(proxy, proxy.foo)
57 + assert.equal(proxy, proxy.foo.bar)
58 + assert.equal(proxy, proxy.foo.bar.baz.qux)
62 63 it('should return the same proxy on repeated calls for same missing module', function()
63 64 local proxy1 = prequire('missing_module_same_123')
64 65 local proxy2 = prequire('missing_module_same_123')
65 - assert.equals(proxy1, proxy2)
66 + assert.equal(proxy1, proxy2)
68 69 it('should return different proxies for different missing modules', function()
70 71 local proxy2 = prequire('missing_module_b_456')
71 72 assert.is_not_nil(proxy1)
72 73 assert.is_not_nil(proxy2)
73 - assert.is_not.equals(proxy1, proxy2)
74 + assert.are_not_equal(proxy1, proxy2)
80 81 prequire('std.const', 'std.map', function(const, map)
81 82 received = { const = const, map = map }
84 + ---@cast received table
83 85 assert.is_table(received.const)
84 86 assert.is_table(received.map)
91 93 received = missing
93 95 -- Callback was not called because module is missing
94 - assert.equals('not_called', received)
96 + assert.equal('not_called', received)
95 97 -- But we got a proxy back
96 98 assert.is_table(result)
97 - assert.equals(result, result.anything)
99 + assert.equal(result, result.anything)
100 102 it('should call callback only when ALL modules load successfully', function()
104 106 called_with_args = { const }
106 108 assert.is_table(called_with_args)
109 + ---@cast called_with_args table
107 110 assert.is_table(called_with_args[1])
112 115 prequire('std.const', 'std.map', 'std.table', function(...)
113 116 received_args = { ... }
115 - assert.equals(3, #received_args)
118 + ---@cast received_args table
119 + assert.equal(3, #received_args)
118 122 it('should handle mixed existing and missing - callback NOT called', function()
119 123 -- When there's a missing module, callback is skipped and proxy is returned
124 + ---@type any
120 125 local received = 'not_called'
121 126 local result = prequire('std.const', 'missing_mod_xyz', function(const, missing)
122 127 received = { const = const, missing = missing }
124 - assert.equals('not_called', received)
129 + assert.equal('not_called', received)
125 130 -- Result is the proxy for the missing module
126 131 assert.is_table(result)
137 142 it('should return proxy when module fails to load', function()
138 143 local result = prequire('definitely_missing_module_xyz')
139 144 assert.is_table(result)
140 - assert.equals(result, result.anyfield)
145 + assert.equal(result, result.anyfield)
145 150 it('should call vim.notify_once for missing modules', function()
146 151 local notify_called = false
147 152 local original_notify_once = vim.notify_once
148 - vim.notify_once = function(msg, level)
153 + rawset(vim, 'notify_once', function(msg, level)
149 154 notify_called = true
150 155 return original_notify_once(msg, level)
151 - end
156 + end)
153 158 prequire('missing_notify_module')
155 - vim.notify_once = original_notify_once
160 + rawset(vim, 'notify_once', original_notify_once)
156 161 assert.is_true(notify_called)

neovim/tests/std/project_spec.lua

Modified
2 2 local project = require('std.project')
3 3 local join = require('std.table').join
5 5 local function tmpdir()
6 - return vim.fn.tempname()
6 + return vim.fs.normalize(vim.fn.tempname())
9 9 local function mkdir(path)
53 53 touch(root_path .. '/.git')
54 54 local markers = { { name = '.git', weight = 3 } }
55 55 local result = project.find_root(root_path .. '/a/b/c/file.lua', markers, stop_path)
56 - assert.equals(root_path, result)
56 + assert.equal(root_path, result)
59 59 it('prefers closer markers when weights are equal', function()
65 65 mkdir(root_path .. '/a/.git')
66 66 touch(root_path .. '/a/.git')
67 67 local result = project.find_root(root_path .. '/a/b/c/file.lua', markers, stop_path)
68 - assert.equals(root_path .. '/a', result)
68 + assert.equal(vim.fs.joinpath(root_path, 'a'), result)
71 71 it('does not traverse beyond stop directory', function()
91 91 local markers = { { name = '.git', weight = 3 } }
92 92 -- first call
93 93 local first = project.find_root(root_path .. '/a/file.lua', markers, stop_path)
94 - assert.equals(root_path, first)
94 + assert.equal(root_path, first)
95 95 -- second call should return cached value without error
96 96 local second = project.find_root(root_path .. '/a/file.lua', markers, stop_path)
97 - assert.equals(root_path, second)
97 + assert.equal(root_path, second)
100 100 it('markers with weight 0 do not contribute to score', function()
107 107 touch(root_path .. '/Makefile')
108 108 local result = project.find_root(root_path .. '/a/file.lua', markers_with_zero, stop_path)
109 - assert.equals(root_path, result)
109 + assert.equal(root_path, result)
112 112 it('returns path at stop boundary without traversal', function()
137 137 it('finds project root using default markers', function()
138 138 touch(root_path .. '/.git')
139 139 local result = project.find_project_root(root_path .. '/a/b/file.lua')
140 - assert.equals(root_path, result)
140 + assert.equal(root_path, result)
143 143 it('finds project root with custom markers', function()
145 145 local result = project.find_project_root(root_path .. '/a/file.lua', {
146 146 { name = 'Makefile', weight = 3 },
148 - assert.equals(root_path, result)
148 + assert.equal(root_path, result)
151 151 it('returns nil when no project markers exist', function()
160 160 -- (the function will fall back to vcs project root which still uses default markers internally)
161 161 -- Actually find_vcs_project_root calls find_project_root(path, {}) which still uses default markers
162 162 -- So this will find .git
163 - assert.equals(root_path, result)
163 + assert.equal(root_path, result)
166 166 it('cache hit returns same result without re-traversal', function()
167 167 touch(root_path .. '/.git')
168 168 local first = project.find_project_root(root_path .. '/a/file.lua')
169 - assert.equals(root_path, first)
169 + assert.equal(root_path, first)
170 170 local second = project.find_project_root(root_path .. '/a/file.lua')
171 - assert.equals(root_path, second)
171 + assert.equal(root_path, second)
192 192 mkdir(root_path .. '/lua')
193 193 touch(root_path .. '/.luarc.json')
194 194 local result = project.find_lua_project_root(root_path .. '/a/file.lua')
195 - assert.equals(root_path, result)
195 + assert.equal(root_path, result)
198 198 it('find_lua_project_root returns nil when no lua markers', function()
204 204 touch(root_path .. '/pom.xml')
205 205 mkdir(root_path .. '/.idea')
206 206 local result = project.find_java_project_root(root_path .. '/a/file.java')
207 - assert.equals(root_path, result)
207 + assert.equal(root_path, result)
210 210 it('find_java_project_root returns nil when no java markers', function()
215 215 it('find_zig_project_root finds zig markers', function()
216 216 touch(root_path .. '/build.zig')
217 217 local result = project.find_zig_project_root(root_path .. '/a/file.zig')
218 - assert.equals(root_path, result)
218 + assert.equal(root_path, result)
221 221 it('find_zig_project_root returns nil when no zig markers', function()
226 226 it('find_vcs_project_root finds vcs markers', function()
227 227 touch(root_path .. '/.jj')
228 228 local result = project.find_vcs_project_root(root_path .. '/a/file.lua')
229 - assert.equals(root_path, result)
229 + assert.equal(root_path, result)
246 246 mkdir(root_path .. '/lua')
247 247 touch(root_path .. '/.luarc.json')
248 248 local result = project.find_root_by_filetype(root_path .. '/a/file.lua', 'lua')
249 - assert.equals(root_path, result)
249 + assert.equal(root_path, result)
252 252 it('returns correct rooter for java filetype', function()
253 253 touch(root_path .. '/pom.xml')
254 254 local result = project.find_root_by_filetype(root_path .. '/a/file.java', 'java')
255 - assert.equals(root_path, result)
255 + assert.equal(root_path, result)
258 258 it('returns correct rooter for zig filetype', function()
259 259 touch(root_path .. '/build.zig')
260 260 local result = project.find_root_by_filetype(root_path .. '/a/file.zig', 'zig')
261 - assert.equals(root_path, result)
261 + assert.equal(root_path, result)
264 264 it('falls back to generic rooter for unknown filetype', function()
265 265 touch(root_path .. '/.git')
266 266 local result = project.find_root_by_filetype(root_path .. '/a/file.foo', 'unknown_lang')
267 267 -- should fall back to vcs -> find_project_root with default markers
268 - assert.equals(root_path, result)
268 + assert.equal(root_path, result)
271 271 it('falls back to find_project_root when no vcs markers for unknown filetype', function()
308 308 mkdir(root_path .. '/a/.git')
309 309 touch(root_path .. '/a/.git')
310 310 local result = project.find_root(root_path .. '/a/b/file.lua', markers, stop_path)
311 - assert.equals(root_path, result)
311 + assert.equal(root_path, result)
337 337 local markers = { { name = '.git', weight = 3 } }
338 338 -- Call multiple times to populate cache
339 339 local r1 = project.find_root(root_path .. '/a/b/file.lua', markers, stop_path)
340 - assert.equals(root_path, r1)
340 + assert.equal(root_path, r1)
342 342 -- Same call - should be cache hit
343 343 local r2 = project.find_root(root_path .. '/a/b/file.lua', markers, stop_path)
344 - assert.equals(root_path, r2)
344 + assert.equal(root_path, r2)
346 346 -- Different subdir - same root, cache miss but same traversal result
347 347 local r3 = project.find_root(root_path .. '/a/file.lua', markers, stop_path)
348 - assert.equals(root_path, r3)
348 + assert.equal(root_path, r3)
351 351 it('different markers produce different results', function()
361 361 local r2 = project.find_root(root2 .. '/a/file.lua', markers, stop_path)
363 363 assert.is_nil(r1)
364 - assert.equals(root2, r2)
364 + assert.equal(root2, r2)
366 366 vim.fn.delete(root2, 'rf')
384 384 { path = '/project', marker_count = 3, distance_to_buffer_file = 2 },
386 386 local result = select_best_root(scores)
387 - assert.equals('/project', result)
387 + assert.equal('/project', result)
390 390 it('prefers higher likelihood (marker_count * 1/distance)', function()
395 395 -- /far: 6 * (1/3) = 2
396 396 -- /close: 3 * (1/1) = 3 -> wins
397 397 local result = select_best_root(scores)
398 - assert.equals('/close', result)
398 + assert.equal('/close', result)
401 401 it('DEFINITELY (7) at root beats LIKELY (3) close', function()
420 420 -- /project: 7 * 1 = 7
421 421 -- /project/sub: 6 * 0.5 = 3 -> /project wins
422 422 local result = select_best_root(scores3)
423 - assert.equals('/project', result)
423 + assert.equal('/project', result)
426 426 it('multiple LIKELY (3) close beats single DEFINITELY (7) far', function()
431 431 -- /project: 7 * 0.25 = 1.75
432 432 -- /project/sub: 6 * 1 = 6 -> sub wins
433 433 local result = select_best_root(scores)
434 - assert.equals('/project/sub', result)
434 + assert.equal('/project/sub', result)
437 437 it('equal likelihood picks first (closest to root in traversal order)', function()
442 442 -- Equal likelihood, first in traversal order wins
443 443 local result = select_best_root(scores)
444 - assert.equals('/first', result)
444 + assert.equal('/first', result)
447 447 it('marker_count 0 at any distance produces 0 likelihood', function()
452 452 -- /zero: 0 * 1 = 0
453 453 -- /has_markers: 3 * 0.33 = 1 -> wins
454 454 local result = select_best_root(scores)
455 - assert.equals('/has_markers', result)
455 + assert.equal('/has_markers', result)
458 458 it('distance 1 (closest possible) maximizes score multiplier', function()
463 463 -- /root: 3 * 1 = 3
464 464 -- /deep: 3 * 0.2 = 0.6 -> /root wins
465 465 local result = select_best_root(scores)
466 - assert.equals('/root', result)
466 + assert.equal('/root', result)
469 469 it('handles very large marker counts', function()
474 474 -- /project: 100 * 0.1 = 10
475 475 -- /project/sub: 99 * 1 = 99 -> sub wins
476 476 local result = select_best_root(scores)
477 - assert.equals('/project/sub', result)
477 + assert.equal('/project/sub', result)
480 480 it('handles fractional likelihood from large distance', function()
485 485 -- /project: 7 * 0.01 = 0.07
486 486 -- /project/sub: 1 * 1 = 1 -> sub wins easily
487 487 local result = select_best_root(scores)
488 - assert.equals('/project/sub', result)
488 + assert.equal('/project/sub', result)

neovim/tests/std/puk_spec.lua

Added
new file mode 100644
1 +describe('std.puk', function()
2 + local original_v
3 + local original_packadd
5 + before_each(function()
6 + original_v = vim.v
7 + original_packadd = vim.cmd.packadd
8 + package.loaded['std.puk'] = nil
9 + package.loaded['test-puk-plugin'] = nil
10 + package.preload['test-puk-plugin'] = function() return {} end
11 + end)
13 + after_each(function()
14 + vim.v = original_v
15 + vim.cmd.packadd = original_packadd
16 + package.loaded['std.puk'] = nil
17 + package.loaded['test-puk-plugin'] = nil
18 + package.preload['test-puk-plugin'] = nil
19 + end)
21 + local function packadd_options(did_init)
22 + local options
23 + vim.v = { vim_did_init = did_init }
24 + vim.cmd.packadd = function(value) options = value end
25 + require('std.puk')('test-puk-plugin')
26 + return options
27 + end
29 + it('defers plugin scripts while init is running', function()
30 + assert.is_true(packadd_options(0).bang)
31 + end)
33 + it('loads plugin scripts after init has finished', function()
34 + assert.is_false(packadd_options(1).bang)
35 + end)
36 +end)

neovim/tests/std/string_spec.lua

Deleted
deleted file mode 100644
1 -local string = require('std.string')
3 -describe('std.string', function()
4 - describe('is_blank', function()
5 - it('should return true for nil', function()
6 - assert.is_true(string.is_blank(nil))
7 - end)
9 - it('should return true for empty string', function()
10 - assert.is_true(string.is_blank(''))
11 - end)
13 - it('should return true for whitespace-only string', function()
14 - assert.is_true(string.is_blank(' '))
15 - assert.is_true(string.is_blank('\t'))
16 - assert.is_true(string.is_blank(' \t '))
17 - end)
19 - it('should return false for non-empty string', function()
20 - assert.is_false(string.is_blank('hello'))
21 - end)
23 - it('should return false for string with surrounding whitespace', function()
24 - assert.is_false(string.is_blank(' hello '))
25 - end)
26 - end)
27 -end)

neovim/tests/std/table/deep_copy_spec.lua

Deleted
deleted file mode 100644
1 -local deep_copy = require('std.table.deep_copy')
3 -describe('std.table.deep_copy', function()
4 - describe('primitives', function()
5 - it('should return numbers unchanged', function()
6 - local result = deep_copy(42)
7 - assert.equals(42, result)
8 - end)
10 - it('should return strings unchanged', function()
11 - local result = deep_copy('hello')
12 - assert.equals('hello', result)
13 - end)
15 - it('should return nil unchanged', function()
16 - local result = deep_copy(nil)
17 - assert.is_nil(result)
18 - end)
19 - end)
21 - describe('tables', function()
22 - it('should return empty table with different reference', function()
23 - local original = {}
24 - local result = deep_copy(original)
25 - assert.is_table(result)
26 - assert.is_true(result ~= original)
27 - end)
29 - it('should copy map tables', function()
30 - local original = { a = 1, b = 2 }
31 - local result = deep_copy(original)
32 - assert.is_table(result)
33 - assert.equals(1, result.a)
34 - assert.equals(2, result.b)
35 - assert.is_true(result ~= original)
36 - end)
38 - it('should copy array tables', function()
39 - local original = { 1, 2, 3 }
40 - local result = deep_copy(original)
41 - assert.is_table(result)
42 - assert.equals(1, result[1])
43 - assert.equals(2, result[2])
44 - assert.equals(3, result[3])
45 - assert.is_true(result ~= original)
46 - end)
48 - it('should deep copy nested tables', function()
49 - local original = { a = { b = { c = 1 } } }
50 - local result = deep_copy(original)
51 - assert.equals(1, result.a.b.c)
52 - assert.is_true(result ~= original)
53 - assert.is_true(result.a ~= original.a)
54 - assert.is_true(result.a.b ~= original.a.b)
55 - end)
57 - it('should copy shared references as separate tables', function()
58 - local shared = {}
59 - local original = { shared, shared }
60 - local result = deep_copy(original)
61 - assert.is_true(result[1] ~= result[2])
62 - assert.is_true(result[1] ~= original[1])
63 - assert.is_true(result[2] ~= original[2])
64 - end)
65 - end)
66 -end)

neovim/tests/std/table/join_spec.lua

Modified
4 4 local join = require('std.table.join')
6 6 describe('std.table.join', function()
7 7 describe('basic joins', function()
8 8 it('should join two empty tables', function()
9 9 local result = join({}, {})
10 - assert.equals('{}', vim.inspect(result))
10 + assert.equal('{}', vim.inspect(result))
11 11 end)
13 13 it('should join empty table with non-empty table (left empty)', function()
14 14 local result = join({}, {1})
15 - assert.equals('{ 1 }', vim.inspect(result))
15 + assert.equal('{ 1 }', vim.inspect(result))
16 16 end)
18 18 it('should join empty table with non-empty table (right empty)', function()
19 19 local result = join({1}, {})
20 - assert.equals('{ 1 }', vim.inspect(result))
20 + assert.equal('{ 1 }', vim.inspect(result))
21 21 end)
23 23 it('should join two tables of equal size', function()
24 24 local result = join({1, 2}, {3, 4})
25 - assert.equals('{ 1, 2, 3, 4 }', vim.inspect(result))
25 + assert.equal('{ 1, 2, 3, 4 }', vim.inspect(result))
26 26 end)
28 28 it('should join tables with mismatched sizes (left smaller)', function()
29 29 local result = join({1}, {2, 3})
30 - assert.equals('{ 1, 2, 3 }', vim.inspect(result))
30 + assert.equal('{ 1, 2, 3 }', vim.inspect(result))
31 31 end)
33 33 it('should join tables with mismatched sizes (right smaller)', function()
34 34 local result = join({1, 2}, {3})
35 - assert.equals('{ 1, 2, 3 }', vim.inspect(result))
35 + assert.equal('{ 1, 2, 3 }', vim.inspect(result))
36 36 end)
37 37 end)
39 39 local tableB = {3, 4}
40 40 local originalA = vim.deepcopy(tableA)
41 41 join(tableA, tableB)
42 - assert.equals(vim.inspect(originalA), vim.inspect(tableA))
42 + assert.equal(vim.inspect(originalA), vim.inspect(tableA))
43 43 end)
45 45 it('should not modify the right table', function()
47 47 local tableB = {3, 4}
48 48 local originalB = vim.deepcopy(tableB)
49 49 join(tableA, tableB)
50 - assert.equals(vim.inspect(originalB), vim.inspect(tableB))
50 + assert.equal(vim.inspect(originalB), vim.inspect(tableB))
51 51 end)
52 52 end)
57 57 local tableB = {3, 4}
58 58 local result = join(tableA, tableB)
59 59 assert.is_not_nil(result)
60 - assert.equals('table', type(result))
60 + assert.equal('table', type(result))
61 61 assert.is_true(result ~= tableA)
62 62 assert.is_true(result ~= tableB)
63 63 end)

neovim/tests/std/timeago_spec.lua

Modified
5 5 it('should return "now" when diff < 45 seconds', function()
6 6 local time = os.time() - 44
7 7 local result = timeago.format(time)
8 - assert.equals('now', result)
8 + assert.equal('now', result)
9 9 end)
11 11 it('should return "1 mi" (singular) when diff ≈ 60s', function()
12 12 local time = os.time() - 60
13 13 local result = timeago.format(time)
14 - assert.equals('1 mi', result)
14 + assert.equal('1 mi', result)
15 15 end)
17 17 it('should return "2 mis" (plural) when diff ≈ 90s', function()
18 18 local time = os.time() - 90
19 19 local result = timeago.format(time)
20 - assert.equals('2 mis', result)
20 + assert.equal('2 mis', result)
21 21 end)
23 23 it('should return "1 hr" (singular) when diff ≈ 60min', function()
24 24 local time = os.time() - 60 * 60
25 25 local result = timeago.format(time)
26 - assert.equals('1 hr', result)
26 + assert.equal('1 hr', result)
27 27 end)
29 29 it('should return "2 hrs" (plural) when diff ≈ 90min', function()
30 30 local time = os.time() - 90 * 60
31 31 local result = timeago.format(time)
32 - assert.equals('2 hrs', result)
32 + assert.equal('2 hrs', result)
33 33 end)
35 35 it('should return "1 dy" (singular) when diff ≈ 24hrs', function()
36 36 local time = os.time() - 24 * 60 * 60
37 37 local result = timeago.format(time)
38 - assert.equals('1 dy', result)
38 + assert.equal('1 dy', result)
39 39 end)
41 41 it('should return "2 dys" (plural) when diff ≈ 48hrs', function()
42 42 local time = os.time() - 48 * 60 * 60
43 43 local result = timeago.format(time)
44 - assert.equals('2 dys', result)
44 + assert.equal('2 dys', result)
45 45 end)
47 47 it('should return "1 wk" (singular) when diff ≈ 10 days', function()
48 48 -- 10 days = 1.43 weeks, which is < 1.5 threshold for singular
49 49 local time = os.time() - 10 * 24 * 60 * 60
50 50 local result = timeago.format(time)
51 - assert.equals('1 wk', result)
51 + assert.equal('1 wk', result)
52 52 end)
54 54 it('should return "1 mo" (singular) when diff ≈ 35 days', function()
55 55 -- 35 days = 5 weeks = 1.17 months, which is < 1.5 threshold for singular
56 56 local time = os.time() - 35 * 24 * 60 * 60
57 57 local result = timeago.format(time)
58 - assert.equals('1 mo', result)
58 + assert.equal('1 mo', result)
59 59 end)
61 61 it('should return "1 yr" (singular) when diff ≈ 365 days', function()
62 62 local time = os.time() - 365 * 24 * 60 * 60
63 63 local result = timeago.format(time)
64 - assert.equals('1 yr', result)
64 + assert.equal('1 yr', result)
65 65 end)
67 67 it('should return "2 yrs" (plural) when diff ≈ 730 days', function()
68 68 local time = os.time() - 730 * 24 * 60 * 60
69 69 local result = timeago.format(time)
70 - assert.equals('2 yrs', result)
70 + assert.equal('2 yrs', result)
71 71 end)
72 72 end)
73 73 end)

neovim/tests/std/user_command_spec.lua

Modified
36 36 assert.is_function(deleter)
37 37 local info = get_user_command('FullChainCommand')
38 38 assert.is_not_nil(info)
39 - assert.equals('FullChainCommand', info.name)
40 - assert.equals('*', info.nargs)
41 - assert.equals('file', info.complete)
39 + assert.equal('FullChainCommand', info.name)
40 + assert.equal('*', info.nargs)
41 + assert.equal('file', info.complete)
44 44 it('should return a deleter function that removes the command', function()
61 61 assert.is_function(deleter)
62 62 local info = get_user_command('TestCommand')
63 63 assert.is_not_nil(info)
64 - assert.equals('TestCommand', info.name)
64 + assert.equal('TestCommand', info.name)
145 145 local info = get_user_command('TestCommand')
146 146 assert.is_not_nil(info)
147 - assert.equals('*', info.nargs)
147 + assert.equal('*', info.nargs)
148 148 assert.is_true(info.bang == 1 or info.bang == true)
158 158 local info2 = get_user_command('AnotherCommand')
159 159 assert.is_not_nil(info1)
160 160 assert.is_not_nil(info2)
161 - assert.equals('TestCommand', info1.name)
162 - assert.equals('AnotherCommand', info2.name)
161 + assert.equal('TestCommand', info1.name)
162 + assert.equal('AnotherCommand', info2.name)
164 164 deleter1()
165 165 deleter2()
191 191 local deleter = user_command.buffer(0).TestBufCmd 'A buffer command' (function() end)
192 192 local buf_cmds = get_buf_commands(0)
193 193 assert.is_table(buf_cmds['TestBufCmd'])
194 - assert.equals('TestBufCmd', buf_cmds['TestBufCmd'].name)
194 + assert.equal('TestBufCmd', buf_cmds['TestBufCmd'].name)
197 197 it('should return a deleter that removes the buffer command', function()
228 228 } (function() end)
229 229 local buf_cmds = get_buf_commands(0)
230 230 assert.is_not_nil(buf_cmds['OptsBufCmd'])
231 - assert.equals('*', buf_cmds['OptsBufCmd'].nargs)
231 + assert.equal('*', buf_cmds['OptsBufCmd'].nargs)
232 232 deleter()
245 245 it('should pass opts to command function', function()
246 - local received_opts = nil
246 + ---@type vim.api.keyset.create_user_command.command_args?
247 + local received_opts
247 248 local deleter = user_command.buffer(0).TestBufCmd 'Opts test' (function(opts)
248 249 received_opts = opts
250 251 vim.cmd('TestBufCmd')
251 252 assert.is_table(received_opts)
252 - assert.equals('TestBufCmd', received_opts.name)
253 + assert.equal('TestBufCmd', assert(received_opts).name)
253 254 deleter()