Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save echasnovski/daf45b865f5b41871a9db9a1bb56ed1a to your computer and use it in GitHub Desktop.
Save echasnovski/daf45b865f5b41871a9db9a1bb56ed1a to your computer and use it in GitHub Desktop.
'mini.nvim' diffs of running different `stylua` values of possibly new "collapse_simple_statement" option.
diff --git a/benchmarks/starter/init-files/init_dashboard-alpha.lua b/benchmarks/starter/init-files/init_dashboard-alpha.lua
index 78c26dc..fa9497f 100644
--- a/benchmarks/starter/init-files/init_dashboard-alpha.lua
+++ b/benchmarks/starter/init-files/init_dashboard-alpha.lua
@@ -20,4 +20,2 @@ vim.api.nvim_set_keymap('n', '<Leader>sl', ':Telescope command_history<CR>', { n
-- Close Neovim just after fully opening it. Randomize to make "more real".
-vim.defer_fn(function()
- vim.cmd([[quit]])
-end, 100 + 200 * math.random())
+vim.defer_fn(function() vim.cmd([[quit]]) end, 100 + 200 * math.random())
diff --git a/benchmarks/starter/init-files/init_dashboard-original.lua b/benchmarks/starter/init-files/init_dashboard-original.lua
index a34c590..afaf266 100644
--- a/benchmarks/starter/init-files/init_dashboard-original.lua
+++ b/benchmarks/starter/init-files/init_dashboard-original.lua
@@ -16,4 +16,2 @@ vim.api.nvim_set_keymap('n', '<Leader>cn', ':DashboardNewFile<CR>', { noremap =
-- Close Neovim just after fully opening it. Randomize to make "more real".
-vim.defer_fn(function()
- vim.cmd([[quit]])
-end, 100 + 200 * math.random())
+vim.defer_fn(function() vim.cmd([[quit]]) end, 100 + 200 * math.random())
diff --git a/benchmarks/starter/init-files/init_dashboard-starter.lua b/benchmarks/starter/init-files/init_dashboard-starter.lua
index 5b8f14e..f9593e2 100644
--- a/benchmarks/starter/init-files/init_dashboard-starter.lua
+++ b/benchmarks/starter/init-files/init_dashboard-starter.lua
@@ -17,4 +17,2 @@ starter.setup({
-- Close Neovim just after fully opening it. Randomize to make "more real".
-vim.defer_fn(function()
- vim.cmd([[quit]])
-end, 100 + 200 * math.random())
+vim.defer_fn(function() vim.cmd([[quit]]) end, 100 + 200 * math.random())
diff --git a/benchmarks/starter/init-files/init_empty.lua b/benchmarks/starter/init-files/init_empty.lua
index 1fd5681..f7f2c15 100644
--- a/benchmarks/starter/init-files/init_empty.lua
+++ b/benchmarks/starter/init-files/init_empty.lua
@@ -3,4 +3,2 @@ vim.cmd([[set packpath=/tmp/nvim/site]])
-- Close Neovim just after fully opening it. Randomize to make "more real".
-vim.defer_fn(function()
- vim.cmd([[quit]])
-end, 100 + 200 * math.random())
+vim.defer_fn(function() vim.cmd([[quit]]) end, 100 + 200 * math.random())
diff --git a/benchmarks/starter/init-files/init_starter-default.lua b/benchmarks/starter/init-files/init_starter-default.lua
index c64bc2d..515afb3 100644
--- a/benchmarks/starter/init-files/init_starter-default.lua
+++ b/benchmarks/starter/init-files/init_starter-default.lua
@@ -6,4 +6,2 @@ require('mini.starter').setup()
-- Close Neovim just after fully opening it. Randomize to make "more real".
-vim.defer_fn(function()
- vim.cmd([[quit]])
-end, 100 + 200 * math.random())
+vim.defer_fn(function() vim.cmd([[quit]]) end, 100 + 200 * math.random())
diff --git a/benchmarks/starter/init-files/init_startify-alpha.lua b/benchmarks/starter/init-files/init_startify-alpha.lua
index acd73be..ec7b477 100644
--- a/benchmarks/starter/init-files/init_startify-alpha.lua
+++ b/benchmarks/starter/init-files/init_startify-alpha.lua
@@ -9,4 +9,2 @@ alpha.setup(startify.opts)
-- Close Neovim just after fully opening it. Randomize to make "more real".
-vim.defer_fn(function()
- vim.cmd([[quit]])
-end, 100 + 200 * math.random())
+vim.defer_fn(function() vim.cmd([[quit]]) end, 100 + 200 * math.random())
diff --git a/benchmarks/starter/init-files/init_startify-original.lua b/benchmarks/starter/init-files/init_startify-original.lua
index a6e52f8..fe2640f 100644
--- a/benchmarks/starter/init-files/init_startify-original.lua
+++ b/benchmarks/starter/init-files/init_startify-original.lua
@@ -6,4 +6,2 @@ vim.g.startify_custom_header = ''
-- Close Neovim just after fully opening it. Randomize to make "more real".
-vim.defer_fn(function()
- vim.cmd([[quit]])
-end, 100 + 200 * math.random())
+vim.defer_fn(function() vim.cmd([[quit]]) end, 100 + 200 * math.random())
diff --git a/benchmarks/starter/init-files/init_startify-starter.lua b/benchmarks/starter/init-files/init_startify-starter.lua
index 30b6105..743daf8 100644
--- a/benchmarks/starter/init-files/init_startify-starter.lua
+++ b/benchmarks/starter/init-files/init_startify-starter.lua
@@ -19,4 +19,2 @@ starter.setup({
-- Close Neovim just after fully opening it. Randomize to make "more real".
-vim.defer_fn(function()
- vim.cmd([[quit]])
-end, 100 + 200 * math.random())
+vim.defer_fn(function() vim.cmd([[quit]]) end, 100 + 200 * math.random())
diff --git a/lua/mini/base16.lua b/lua/mini/base16.lua
index 4e5b77e..92ba2bb 100644
--- a/lua/mini/base16.lua
+++ b/lua/mini/base16.lua
@@ -198,8 +198,4 @@ function MiniBase16.mini_palette(background, foreground, accent_chroma)
local present_hues = {}
- if bg.c > 0 then
- table.insert(present_hues, bg.h)
- end
- if fg.c > 0 then
- table.insert(present_hues, fg.h)
- end
+ if bg.c > 0 then table.insert(present_hues, bg.h) end
+ if fg.c > 0 then table.insert(present_hues, fg.h) end
local hues = H.make_different_hues(present_hues, 4)
@@ -291,5 +287,3 @@ H.base16_names = {
function H.validate_base16_palette(x, x_name)
- if type(x) ~= 'table' then
- error(string.format('(mini.base16) `%s` is not a table.', x_name))
- end
+ if type(x) ~= 'table' then error(string.format('(mini.base16) `%s` is not a table.', x_name)) end
@@ -346,5 +340,3 @@ function H.apply_palette(palette, use_cterm)
-- - No need to `syntax reset` because *all* syntax groups are defined later.
- if vim.g.colors_name then
- vim.cmd('highlight clear')
- end
+ if vim.g.colors_name then vim.cmd('highlight clear') end
-- As this doesn't create colorscheme, don't store any name. Not doing it
@@ -683,5 +675,3 @@ function H.make_compound_palette(palette, use_cterm)
local cterm_table = use_cterm
- if type(use_cterm) == 'boolean' then
- cterm_table = MiniBase16.rgb_palette_to_cterm_palette(palette)
- end
+ if type(use_cterm) == 'boolean' then cterm_table = MiniBase16.rgb_palette_to_cterm_palette(palette) end
@@ -709,5 +699,3 @@ function H.make_different_hues(present_hues, n)
-- Decide if it is the best
- if dist > best_dist then
- best_hues, best_dist = new_hues, dist
- end
+ if dist > best_dist then best_hues, best_dist = new_hues, dist end
end
@@ -938,5 +926,3 @@ function H.dist_circle_set(set1, set2)
d = H.dist_circle(x, y)
- if dist > d then
- dist = d
- end
+ if dist > d then dist = d end
end
@@ -951,5 +937,3 @@ function H.nearest_rgb_id(rgb_target, rgb_palette)
dist = math.abs(rgb_target.r - rgb.r) + math.abs(rgb_target.g - rgb.g) + math.abs(rgb_target.b - rgb.b)
- if dist < best_dist then
- best_id, best_dist = id, dist
- end
+ if dist < best_dist then best_id, best_dist = id, dist end
end
diff --git a/lua/mini/bufremove.lua b/lua/mini/bufremove.lua
index f6834f3..a0cc57c 100644
--- a/lua/mini/bufremove.lua
+++ b/lua/mini/bufremove.lua
@@ -188,5 +188,3 @@ function H.unshow_and_cmd(buf_id, force, cmd)
- if force == nil then
- force = false
- end
+ if force == nil then force = false end
if type(force) ~= 'boolean' then
@@ -228,5 +226,3 @@ function H.is_valid_id(x, type)
- if not is_valid then
- H.message(string.format('%s is not a valid %s id.', tostring(x), type))
- end
+ if not is_valid then H.message(string.format('%s is not a valid %s id.', tostring(x), type)) end
return is_valid
@@ -259,5 +255,3 @@ end
-function H.message(msg)
- vim.cmd('echomsg ' .. vim.inspect('(mini.bufremove) ' .. msg))
-end
+function H.message(msg) vim.cmd('echomsg ' .. vim.inspect('(mini.bufremove) ' .. msg)) end
diff --git a/lua/mini/comment.lua b/lua/mini/comment.lua
index f0e60aa..f4ffe09 100644
--- a/lua/mini/comment.lua
+++ b/lua/mini/comment.lua
@@ -119,5 +119,3 @@ function MiniComment.operator(mode)
local mark_left, mark_right = '[', ']'
- if mode == 'visual' then
- mark_left, mark_right = '<', '>'
- end
+ if mode == 'visual' then mark_left, mark_right = '<', '>' end
@@ -322,5 +320,3 @@ function H.get_lines_info(lines, comment_parts)
-- Update comment info: lines are comment if every single line is comment
- if is_comment then
- is_comment = comment_check(l)
- end
+ if is_comment then is_comment = comment_check(l) end
end
@@ -371,5 +367,3 @@ function H.make_uncomment_function(comment_parts)
-- Remove indent if line is a commented empty line
- if new_line == '' then
- indent = ''
- end
+ if new_line == '' then indent = '' end
return ('%s%s'):format(indent, new_line)
@@ -386,5 +380,3 @@ function H.map(mode, key, rhs, opts)
-- Use mapping description only in Neovim>=0.7
- if vim.fn.has('nvim-0.7') == 0 then
- opts.desc = nil
- end
+ if vim.fn.has('nvim-0.7') == 0 then opts.desc = nil end
@@ -393,5 +385,3 @@ end
-function H.message(msg)
- vim.cmd('echomsg ' .. vim.inspect('(mini.comment) ' .. msg))
-end
+function H.message(msg) vim.cmd('echomsg ' .. vim.inspect('(mini.comment) ' .. msg)) end
diff --git a/lua/mini/completion.lua b/lua/mini/completion.lua
index 3eb89f1..4154483 100644
--- a/lua/mini/completion.lua
+++ b/lua/mini/completion.lua
@@ -274,5 +274,3 @@ MiniCompletion.config = {
--minidoc_replace_start fallback_action = --<function: like `<C-n>` completion>,
- fallback_action = function()
- vim.api.nvim_feedkeys(H.keys.ctrl_n, 'n', false)
- end,
+ fallback_action = function() vim.api.nvim_feedkeys(H.keys.ctrl_n, 'n', false) end,
--minidoc_replace_end
@@ -318,5 +316,3 @@ function MiniCompletion.auto_completion()
-- and force new completion
- if char_is_trigger then
- H.cancel_lsp()
- end
+ if char_is_trigger then H.cancel_lsp() end
H.completion.fallback, H.completion.force = not char_is_trigger, char_is_trigger
@@ -377,5 +373,3 @@ function MiniCompletion.auto_info()
-- Don't stop timer when closing info window because it is needed
- vim.defer_fn(function()
- H.close_action_window(H.info, true)
- end, 0)
+ vim.defer_fn(function() H.close_action_window(H.info, true) end, 0)
@@ -728,5 +722,3 @@ function H.stop_completion(keep_source)
H.completion.fallback, H.completion.force = true, false
- if not keep_source then
- H.completion.source = nil
- end
+ if not keep_source then H.completion.source = nil end
end
@@ -795,5 +787,3 @@ function H.cancel_lsp(caches)
if vim.tbl_contains({ 'sent', 'received' }, c.lsp.status) then
- if c.lsp.cancel_fun then
- c.lsp.cancel_fun()
- end
+ if c.lsp.cancel_fun then c.lsp.cancel_fun() end
c.lsp.status = 'canceled'
@@ -811,5 +801,3 @@ function H.process_lsp_response(request_result, processor)
for client_id, item in pairs(request_result) do
- if not item.err and item.result then
- vim.list_extend(res, processor(item.result, client_id) or {})
- end
+ if not item.err and item.result then vim.list_extend(res, processor(item.result, client_id) or {}) end
end
@@ -836,5 +824,3 @@ function H.lsp_completion_response_items_to_complete_items(items, client_id)
info = H.table_get(docs, { 'value' })
- if not info and type(docs) == 'string' then
- info = docs
- end
+ if not info and type(docs) == 'string' then info = docs end
info = info or ''
@@ -1116,5 +1102,3 @@ function H.show_signature_window()
-- Ensure that window doesn't open when it shouldn't
- if vim.fn.mode() == 'i' then
- H.open_action_window(H.signature, opts)
- end
+ if vim.fn.mode() == 'i' then H.open_action_window(H.signature, opts) end
end
@@ -1146,5 +1130,3 @@ function H.process_signature_response(response)
local n_signatures = vim.tbl_count(response.signatures or {})
- if signature_id < 0 or signature_id >= n_signatures then
- signature_id = 0
- end
+ if signature_id < 0 or signature_id >= n_signatures then signature_id = 0 end
local signature = response.signatures[signature_id + 1]
@@ -1180,5 +1162,3 @@ function H.process_signature_response(response)
-- Make zero-indexed and end-exclusive
- if first then
- first, last = first - 1, last
- end
+ if first then first, last = first - 1, last end
elseif type(param_label) == 'table' then
@@ -1186,5 +1166,3 @@ function H.process_signature_response(response)
end
- if first then
- hl_range = { first = first, last = last }
- end
+ if first then hl_range = { first = first, last = last } end
end
@@ -1266,5 +1244,3 @@ function H.floating_dimensions(lines, max_height, max_width)
l_width = vim.fn.strdisplaywidth(l)
- if i <= height and width < l_width then
- width = l_width
- end
+ if i <= height and width < l_width then width = l_width end
end
@@ -1285,9 +1261,5 @@ end
function H.close_action_window(cache, keep_timer)
- if not keep_timer then
- cache.timer:stop()
- end
+ if not keep_timer then cache.timer:stop() end
- if cache.winnr then
- vim.api.nvim_win_close(cache.winnr, true)
- end
+ if cache.winnr then vim.api.nvim_win_close(cache.winnr, true) end
cache.winnr = nil
@@ -1295,5 +1267,3 @@ function H.close_action_window(cache, keep_timer)
-- For some reason 'buftype' might be reset. Ensure that buffer is scratch.
- if cache.bufnr then
- vim.fn.setbufvar(cache.bufnr, '&buftype', 'nofile')
- end
+ if cache.bufnr then vim.fn.setbufvar(cache.bufnr, '&buftype', 'nofile') end
end
@@ -1379,5 +1349,3 @@ function H.map(mode, key, rhs, opts)
-- Use mapping description only in Neovim>=0.7
- if vim.fn.has('nvim-0.7') == 0 then
- opts.desc = nil
- end
+ if vim.fn.has('nvim-0.7') == 0 then opts.desc = nil end
diff --git a/lua/mini/cursorword.lua b/lua/mini/cursorword.lua
index a7b072d..459fbfe 100644
--- a/lua/mini/cursorword.lua
+++ b/lua/mini/cursorword.lua
@@ -206,5 +206,3 @@ end
-function H.apply_config(config)
- MiniCursorword.config = config
-end
+function H.apply_config(config) MiniCursorword.config = config end
diff --git a/lua/mini/doc.lua b/lua/mini/doc.lua
index e413a90..0a3e064 100644
--- a/lua/mini/doc.lua
+++ b/lua/mini/doc.lua
@@ -193,5 +193,3 @@ MiniDoc.config = {
-- Infer metadata based on afterlines
- if b:has_lines() and #b.info.afterlines > 0 then
- H.infer_header(b)
- end
+ if b:has_lines() and #b.info.afterlines > 0 then H.infer_header(b) end
end,
@@ -201,5 +199,3 @@ MiniDoc.config = {
--minidoc_replace_start section_pre = --<function: replaces current aliases>,
- section_pre = function(s)
- H.alias_replace(s)
- end,
+ section_pre = function(s) H.alias_replace(s) end,
--minidoc_replace_end
@@ -224,5 +220,3 @@ MiniDoc.config = {
--minidoc_replace_start ['@diagnostic'] = --<function: ignores any section content>,
- ['@diagnostic'] = function(s)
- s:clear_lines()
- end,
+ ['@diagnostic'] = function(s) s:clear_lines() end,
--minidoc_replace_end
@@ -245,5 +239,3 @@ MiniDoc.config = {
if output == nil then return end
- if type(output) == 'string' then
- output = vim.split(output, '\n')
- end
+ if type(output) == 'string' then output = vim.split(output, '\n') end
if type(output) ~= 'table' then
@@ -278,5 +270,3 @@ MiniDoc.config = {
--minidoc_replace_start ['@private'] = --<function: registers block for removal>,
- ['@private'] = function(s)
- s.parent:clear_lines()
- end,
+ ['@private'] = function(s) s.parent:clear_lines() end,
--minidoc_replace_end
@@ -290,5 +280,3 @@ MiniDoc.config = {
--minidoc_replace_start ['@seealso'] = --<function>,
- ['@seealso'] = function(s)
- H.add_section_heading(s, 'See also')
- end,
+ ['@seealso'] = function(s) H.add_section_heading(s, 'See also') end,
--minidoc_replace_end
@@ -320,10 +308,6 @@ MiniDoc.config = {
--minidoc_replace_start ['@toc'] = --<function: clears all section lines>,
- ['@toc'] = function(s)
- s:clear_lines()
- end,
+ ['@toc'] = function(s) s:clear_lines() end,
--minidoc_replace_end
--minidoc_replace_start ['@toc_entry'] = --<function: registers lines for table of contents>,
- ['@toc_entry'] = function(s)
- H.toc_register(s)
- end,
+ ['@toc_entry'] = function(s) H.toc_register(s) end,
--minidoc_replace_end
@@ -336,5 +320,3 @@ MiniDoc.config = {
--minidoc_replace_start ['@usage'] = --<function>,
- ['@usage'] = function(s)
- H.add_section_heading(s, 'Usage')
- end,
+ ['@usage'] = function(s) H.add_section_heading(s, 'Usage') end,
--minidoc_replace_end
@@ -422,5 +404,3 @@ MiniDoc.config = {
if buf_path == output_path then
- vim.api.nvim_buf_call(buf_id, function()
- vim.cmd('noautocmd silent edit | set ft=help')
- end)
+ vim.api.nvim_buf_call(buf_id, function() vim.cmd('noautocmd silent edit | set ft=help') end)
end
@@ -666,5 +646,3 @@ function MiniDoc.afterlines_to_code(struct)
- if struct.type == 'section' then
- struct = struct.parent
- end
+ if struct.type == 'section' then struct = struct.parent end
local src = table.concat(struct.info.afterlines, '\n')
@@ -773,5 +751,3 @@ end
-function H.apply_config(config)
- MiniDoc.config = config
-end
+function H.apply_config(config) MiniDoc.config = config end
@@ -927,5 +903,3 @@ function H.apply_structure_hooks(doc, hooks)
local hook = hooks.sections[section.info.id]
- if hook ~= nil then
- hook(section)
- end
+ if hook ~= nil then hook(section) end
@@ -1055,8 +1029,6 @@ end
function H.infer_header(b)
- local has_signature = b:has_descendant(
- function(x) return type(x) == 'table' and x.type == 'section' and x.info.id == '@signature' end
- )
- local has_tag = b:has_descendant(
- function(x) return type(x) == 'table' and x.type == 'section' and x.info.id == '@tag' end
- )
+ local has_signature =
+ b:has_descendant(function(x) return type(x) == 'table' and x.type == 'section' and x.info.id == '@signature' end)
+ local has_tag =
+ b:has_descendant(function(x) return type(x) == 'table' and x.type == 'section' and x.info.id == '@tag' end)
@@ -1083,10 +1055,6 @@ function H.infer_header(b)
-- First insert signature (so that it will appear after tag section)
- if not has_signature then
- b:insert(1, H.as_struct({ signature }, 'section', { id = '@signature' }))
- end
+ if not has_signature then b:insert(1, H.as_struct({ signature }, 'section', { id = '@signature' })) end
-- Insert tag
- if not has_tag then
- b:insert(1, H.as_struct({ tag }, 'section', { id = '@tag' }))
- end
+ if not has_tag then b:insert(1, H.as_struct({ tag }, 'section', { id = '@tag' })) end
end
@@ -1126,5 +1094,3 @@ function H.new_struct(struct_type, info)
-- Allow both `x:insert(child)` and `x:insert(1, child)`
- if child == nil then
- child, index = index, #self + 1
- end
+ if child == nil then child, index = index, #self + 1 end
@@ -1177,5 +1143,3 @@ function H.sync_parent_index(x)
for i, _ in ipairs(x) do
- if type(x[i]) == 'table' then
- x[i].parent_index = i
- end
+ if type(x[i]) == 'table' then x[i].parent_index = i end
end
@@ -1213,5 +1177,3 @@ function H.ensure_indent(text, n_indent_target)
-- Condition "current n-indent equals line length" detects empty line
- if (n_indent_cur < n_indent) and (n_indent_cur < l:len()) then
- n_indent = n_indent_cur
- end
+ if (n_indent_cur < n_indent) and (n_indent_cur < l:len()) then n_indent = n_indent_cur end
end
@@ -1222,5 +1184,3 @@ function H.ensure_indent(text, n_indent_target)
for i, l in ipairs(lines) do
- if l ~= '' then
- lines[i] = indent .. l:sub(n_indent + 1)
- end
+ if l ~= '' then lines[i] = indent .. l:sub(n_indent + 1) end
end
@@ -1240,5 +1200,3 @@ function H.align_text(text, width, direction)
local n_left = math.max(0, 78 - H.visual_text_width(text))
- if direction == 'center' then
- n_left = math.floor(0.5 * n_left)
- end
+ if direction == 'center' then n_left = math.floor(0.5 * n_left) end
@@ -1264,5 +1222,3 @@ function H.match_first_pattern(text, pattern_set, init)
for id, st in ipairs(start_tbl) do
- if st < min_start then
- min_start, min_id = st, id
- end
+ if st < min_start then min_start, min_id = st, id end
end
@@ -1315,5 +1271,3 @@ function H.full_path(path) return vim.fn.resolve(vim.fn.fnamemodify(path, ':p'))
-function H.message(msg)
- vim.cmd('echomsg ' .. vim.inspect('(mini.doc) ' .. msg))
-end
+function H.message(msg) vim.cmd('echomsg ' .. vim.inspect('(mini.doc) ' .. msg)) end
diff --git a/lua/mini/fuzzy.lua b/lua/mini/fuzzy.lua
index 4c4d489..fdb7f24 100644
--- a/lua/mini/fuzzy.lua
+++ b/lua/mini/fuzzy.lua
@@ -220,5 +220,3 @@ end
-function H.apply_config(config)
- MiniFuzzy.config = config
-end
+function H.apply_config(config) MiniFuzzy.config = config end
@@ -274,5 +272,3 @@ function H.find_best_positions(letters, candidate)
-- match (hence better score).
- if width < best_width then
- best_pos_last, best_width = pos_last, width
- end
+ if width < best_width then best_pos_last, best_width = pos_last, width end
@@ -321,5 +317,3 @@ function H.make_filter_indexes(word, candidate_array)
local positions = H.find_best_positions(letters, cand)
- if positions then
- table.insert(res, { index = i, score = H.score_positions(positions) })
- end
+ if positions then table.insert(res, { index = i, score = H.score_positions(positions) }) end
end
diff --git a/lua/mini/indentscope.lua b/lua/mini/indentscope.lua
index 1056abb..032fe4e 100644
--- a/lua/mini/indentscope.lua
+++ b/lua/mini/indentscope.lua
@@ -392,5 +392,3 @@ function MiniIndentscope.auto_draw(opts)
-- Allow delay
- if draw_opts.delay > 0 then
- H.undraw_scope(draw_opts)
- end
+ if draw_opts.delay > 0 then H.undraw_scope(draw_opts) end
@@ -430,5 +428,3 @@ end
--- Undraw currently visible scope manually
-function MiniIndentscope.undraw()
- H.undraw_scope()
-end
+function MiniIndentscope.undraw() H.undraw_scope() end
@@ -558,5 +554,3 @@ function MiniIndentscope.operator(side, add_to_jumplist)
local count = vim.v.count1
- if add_to_jumplist then
- vim.cmd('normal! m`')
- end
+ if add_to_jumplist then vim.cmd('normal! m`') end
@@ -594,5 +588,3 @@ function MiniIndentscope.textobject(use_border)
local start, finish = 'top', 'bottom'
- if use_border and scope.border.bottom == nil then
- start, finish = 'bottom', 'top'
- end
+ if use_border and scope.border.bottom == nil then start, finish = 'bottom', 'top' end
@@ -762,5 +754,3 @@ function H.cast_ray(line, indent, direction, opts)
local final_line, increment = 1, -1
- if direction == 'down' then
- final_line, increment = vim.fn.line('$'), 1
- end
+ if direction == 'down' then final_line, increment = vim.fn.line('$'), 1 end
@@ -770,5 +760,3 @@ function H.cast_ray(line, indent, direction, opts)
if new_indent < indent then return l, min_indent end
- if new_indent < min_indent then
- min_indent = new_indent
- end
+ if new_indent < min_indent then min_indent = new_indent end
end
@@ -833,5 +821,3 @@ function H.indicator_compute(scope)
-- Currently Neovim doesn't work when text for extmark is empty string
- if prefix:len() > 0 then
- table.insert(virt_text, 1, { prefix, 'MiniIndentscopePrefix' })
- end
+ if prefix:len() > 0 then table.insert(virt_text, 1, { prefix, 'MiniIndentscopePrefix' }) end
@@ -877,5 +863,3 @@ function H.draw_indicator_animation(indicator, draw_fun, animation_fun)
local success = draw_fun(origin - step)
- if step > 0 then
- success = success and draw_fun(origin + step)
- end
+ if step > 0 then success = success and draw_fun(origin + step) end
@@ -1077,5 +1061,3 @@ function H.animation_geometrical_powers(type, opts)
-- d_1 = math.pow(0.5 * total_time_corr + 1, 1 / 3)
- if n_steps % 2 == 1 then
- total_time = total_time + math.pow(0.5 * total_time + 1, 1 / n_half) - 1
- end
+ if n_steps % 2 == 1 then total_time = total_time + math.pow(0.5 * total_time + 1, 1 / n_half) - 1 end
return math.pow(0.5 * total_time + 1, 1 / n_half)
@@ -1108,5 +1090,3 @@ end
-- Utilities ------------------------------------------------------------------
-function H.message(msg)
- vim.cmd('echomsg ' .. vim.inspect('(mini.indentscope) ' .. msg))
-end
+function H.message(msg) vim.cmd('echomsg ' .. vim.inspect('(mini.indentscope) ' .. msg)) end
@@ -1119,5 +1099,3 @@ function H.map(mode, key, rhs, opts)
-- Use mapping description only in Neovim>=0.7
- if vim.fn.has('nvim-0.7') == 0 then
- opts.desc = nil
- end
+ if vim.fn.has('nvim-0.7') == 0 then opts.desc = nil end
@@ -1129,5 +1107,3 @@ function H.exit_visual_mode()
local cur_mode = vim.fn.mode()
- if cur_mode == 'v' or cur_mode == 'V' or cur_mode == ctrl_v then
- vim.cmd('normal! ' .. cur_mode)
- end
+ if cur_mode == 'v' or cur_mode == 'V' or cur_mode == ctrl_v then vim.cmd('normal! ' .. cur_mode) end
end
diff --git a/lua/mini/jump.lua b/lua/mini/jump.lua
index 6dc4ac0..1d46e66 100644
--- a/lua/mini/jump.lua
+++ b/lua/mini/jump.lua
@@ -172,5 +172,3 @@ function MiniJump.jump(target, backward, till, n_times)
local hl_case = ''
- if vim.o.ignorecase and (not vim.o.smartcase or escaped_target == escaped_target:lower()) then
- hl_case = [[\c]]
- end
+ if vim.o.ignorecase and (not vim.o.smartcase or escaped_target == escaped_target:lower()) then hl_case = [[\c]] end
local pattern, hl_pattern = [[\V%s]], [[\V%s%s]]
@@ -193,5 +191,3 @@ function MiniJump.jump(target, backward, till, n_times)
0,
- vim.schedule_wrap(function()
- H.highlight(hl_pattern)
- end)
+ vim.schedule_wrap(function() H.highlight(hl_pattern) end)
)
@@ -203,5 +199,3 @@ function MiniJump.jump(target, backward, till, n_times)
0,
- vim.schedule_wrap(function()
- MiniJump.stop_jumping()
- end)
+ vim.schedule_wrap(function() MiniJump.stop_jumping() end)
)
@@ -233,5 +227,3 @@ function MiniJump.smart_jump(backward, till)
local cur_mode = vim.fn.mode(1)
- if MiniJump.state.mode ~= cur_mode then
- MiniJump.stop_jumping()
- end
+ if MiniJump.state.mode ~= cur_mode then MiniJump.stop_jumping() end
@@ -290,5 +282,3 @@ function MiniJump.on_cursormoved()
-- Stop jumping only if `CursorMoved` was not a result of smart jump
- if H.n_cursor_moved > 1 then
- MiniJump.stop_jumping()
- end
+ if H.n_cursor_moved > 1 then MiniJump.stop_jumping() end
end
@@ -409,5 +399,3 @@ end
-- Utilities ------------------------------------------------------------------
-function H.message(msg)
- vim.cmd('echomsg ' .. vim.inspect('(mini.jump) ' .. msg))
-end
+function H.message(msg) vim.cmd('echomsg ' .. vim.inspect('(mini.jump) ' .. msg)) end
@@ -417,14 +405,6 @@ function H.update_state(target, backward, till, n_times)
-- Don't use `? and <1> or <2>` because it doesn't work when `<1>` is `false`
- if target ~= nil then
- MiniJump.state.target = target
- end
- if backward ~= nil then
- MiniJump.state.backward = backward
- end
- if till ~= nil then
- MiniJump.state.till = till
- end
- if n_times ~= nil then
- MiniJump.state.n_times = n_times
- end
+ if target ~= nil then MiniJump.state.target = target end
+ if backward ~= nil then MiniJump.state.backward = backward end
+ if till ~= nil then MiniJump.state.till = till end
+ if n_times ~= nil then MiniJump.state.n_times = n_times end
end
@@ -443,5 +423,3 @@ function H.get_target()
- if type(char) == 'number' then
- char = vim.fn.nr2char(char)
- end
+ if type(char) == 'number' then char = vim.fn.nr2char(char) end
return char
@@ -456,5 +434,3 @@ function H.map(mode, key, rhs, opts)
-- Use mapping description only in Neovim>=0.7
- if vim.fn.has('nvim-0.7') == 0 then
- opts.desc = nil
- end
+ if vim.fn.has('nvim-0.7') == 0 then opts.desc = nil end
diff --git a/lua/mini/jump2d.lua b/lua/mini/jump2d.lua
index 465cc90..1e826a0 100644
--- a/lua/mini/jump2d.lua
+++ b/lua/mini/jump2d.lua
@@ -307,5 +307,3 @@ function MiniJump2d.start(opts)
local before_start = (opts.hooks or {}).before_start or MiniJump2d.config.hooks.before_start
- if before_start ~= nil then
- before_start()
- end
+ if before_start ~= nil then before_start() end
@@ -339,5 +337,3 @@ function MiniJump2d.stop()
- if H.cache.is_in_getchar then
- vim.api.nvim_input('<C-c>')
- end
+ if H.cache.is_in_getchar then vim.api.nvim_input('<C-c>') end
end
@@ -396,5 +392,3 @@ function MiniJump2d.gen_pattern_spotter(pattern, side)
-- Possibly correct spot to be index of last matched position
- if side == 'end' then
- spot = spot + math.max(whole:len() - 1, 0)
- end
+ if side == 'end' then spot = spot + math.max(whole:len() - 1, 0) end
@@ -408,5 +402,3 @@ function MiniJump2d.gen_pattern_spotter(pattern, side)
-- Add spot only if it referces new actually visible column
- if spot ~= res[#res] then
- table.insert(res, spot)
- end
+ if spot ~= res[#res] then table.insert(res, spot) end
end
@@ -522,5 +514,4 @@ end
--- `hooks.before_start`.
-MiniJump2d.builtin_opts.single_character = user_input_opts(
- function() return H.getcharstr('Enter single character to search') end
-)
+MiniJump2d.builtin_opts.single_character =
+ user_input_opts(function() return H.getcharstr('Enter single character to search') end)
@@ -675,5 +666,3 @@ function H.spots_show(spots, opts)
-- be shown and deferring disables this mode.
- if H.is_operator_pending() then
- vim.cmd('redraw')
- end
+ if H.is_operator_pending() then vim.cmd('redraw') end
end
@@ -803,5 +792,3 @@ end
-- Utilities ------------------------------------------------------------------
-function H.message(msg)
- vim.cmd('echomsg ' .. vim.inspect('(mini.jump2d) ' .. msg))
-end
+function H.message(msg) vim.cmd('echomsg ' .. vim.inspect('(mini.jump2d) ' .. msg)) end
@@ -828,5 +815,3 @@ function H.getcharstr(msg)
- if type(char) == 'number' then
- char = vim.fn.nr2char(char)
- end
+ if type(char) == 'number' then char = vim.fn.nr2char(char) end
return char
@@ -839,5 +824,3 @@ function H.input(prompt, text)
on_key(function(key)
- if key == H.keys.esc then
- was_cancelled = true
- end
+ if key == H.keys.esc then was_cancelled = true end
end, H.ns_id.input)
@@ -896,5 +879,3 @@ function H.map(mode, key, rhs, opts)
-- Use mapping description only in Neovim>=0.7
- if vim.fn.has('nvim-0.7') == 0 then
- opts.desc = nil
- end
+ if vim.fn.has('nvim-0.7') == 0 then opts.desc = nil end
@@ -917,5 +898,3 @@ function H.merge_unique(tbl_1, tbl_2)
end
- if res[#res] ~= to_add then
- table.insert(res, to_add)
- end
+ if res[#res] ~= to_add then table.insert(res, to_add) end
end
@@ -924,5 +903,3 @@ function H.merge_unique(tbl_1, tbl_2)
to_add = tbl_1[i]
- if res[#res] ~= to_add then
- table.insert(res, to_add)
- end
+ if res[#res] ~= to_add then table.insert(res, to_add) end
i = i + 1
@@ -931,5 +908,3 @@ function H.merge_unique(tbl_1, tbl_2)
to_add = tbl_2[j]
- if res[#res] ~= to_add then
- table.insert(res, to_add)
- end
+ if res[#res] ~= to_add then table.insert(res, to_add) end
j = j + 1
diff --git a/lua/mini/misc.lua b/lua/mini/misc.lua
index 76a0372..b0f22e7 100644
--- a/lua/mini/misc.lua
+++ b/lua/mini/misc.lua
@@ -258,5 +258,3 @@ function MiniMisc.tbl_tail(t, n)
i = i + 1
- if i >= start_i then
- res[k] = val
- end
+ if i >= start_i then res[k] = val end
end
@@ -372,5 +370,3 @@ end
-- Utilities ------------------------------------------------------------------
-function H.message(msg)
- vim.cmd('echomsg ' .. vim.inspect('(mini.misc) ' .. msg))
-end
+function H.message(msg) vim.cmd('echomsg ' .. vim.inspect('(mini.misc) ' .. msg)) end
diff --git a/lua/mini/pairs.lua b/lua/mini/pairs.lua
index 853808c..d3cab27 100644
--- a/lua/mini/pairs.lua
+++ b/lua/mini/pairs.lua
@@ -196,5 +196,3 @@ function MiniPairs.map_buf(buffer, mode, lhs, pair_info, opts)
opts = vim.tbl_deep_extend('force', opts or {}, { expr = true, noremap = true })
- if vim.fn.has('nvim-0.7') == 1 then
- opts.desc = H.infer_mapping_description(pair_info)
- end
+ if vim.fn.has('nvim-0.7') == 1 then opts.desc = H.infer_mapping_description(pair_info) end
@@ -417,5 +415,3 @@ function H.apply_config(config)
for name, to_set in pairs(config.modes) do
- if to_set then
- table.insert(mode_array, mode_ids[name])
- end
+ if to_set then table.insert(mode_array, mode_ids[name]) end
end
@@ -458,5 +454,3 @@ function H.unregister_pair(pair, mode, buffer)
for i, p in ipairs(buf_pairs[key]) do
- if p == pair then
- table.remove(buf_pairs[key], i)
- end
+ if p == pair then table.remove(buf_pairs[key], i) end
end
@@ -487,5 +481,3 @@ function H.ensure_cr_bs(mode)
-- `<BS>` and `<CR>` should work as normal even if no pairs are registered
- if has_any_bs_pair then
- H.map(mode, '<BS>', 'v:lua.MiniPairs.bs()', { expr = true, desc = 'MiniPairs <BS>' })
- end
+ if has_any_bs_pair then H.map(mode, '<BS>', 'v:lua.MiniPairs.bs()', { expr = true, desc = 'MiniPairs <BS>' }) end
if mode == 'i' and has_any_cr_pair then
@@ -567,5 +559,3 @@ function H.map(mode, key, rhs, opts)
-- Use mapping description only in Neovim>=0.7
- if vim.fn.has('nvim-0.7') == 0 then
- opts.desc = nil
- end
+ if vim.fn.has('nvim-0.7') == 0 then opts.desc = nil end
diff --git a/lua/mini/sessions.lua b/lua/mini/sessions.lua
index d5d72a4..cf527d5 100644
--- a/lua/mini/sessions.lua
+++ b/lua/mini/sessions.lua
@@ -193,5 +193,3 @@ function MiniSessions.read(session_name, opts)
-- Possibly notify
- if opts.verbose then
- H.message(('Read session %s'):format(session_path))
- end
+ if opts.verbose then H.message(('Read session %s'):format(session_path)) end
@@ -250,5 +248,3 @@ function MiniSessions.write(session_name, opts)
-- Possibly notify
- if opts.verbose then
- H.message(('Written session %s'):format(session_path))
- end
+ if opts.verbose then H.message(('Written session %s'):format(session_path)) end
@@ -303,10 +299,6 @@ function MiniSessions.delete(session_name, opts)
MiniSessions.detected[session_name] = nil
- if is_current_session then
- vim.v.this_session = ''
- end
+ if is_current_session then vim.v.this_session = '' end
-- Possibly notify
- if opts.verbose then
- H.message(('Deleted session %s'):format(session_path))
- end
+ if opts.verbose then H.message(('Deleted session %s'):format(session_path)) end
@@ -369,5 +361,3 @@ function MiniSessions.get_latest()
for name, data in pairs(MiniSessions.detected) do
- if data.modify_time > latest_time then
- latest_time, latest_name = data.modify_time, name
- end
+ if data.modify_time > latest_time then latest_time, latest_name = data.modify_time, name end
end
@@ -379,5 +369,3 @@ end
function MiniSessions.on_vimenter()
- if MiniSessions.config.autoread and not H.is_something_shown() then
- MiniSessions.read()
- end
+ if MiniSessions.config.autoread and not H.is_something_shown() then MiniSessions.read() end
end
@@ -516,5 +504,3 @@ function H.name_to_path(session_name)
if session_name == nil then
- if vim.v.this_session == '' then
- H.error('There is no active session. Supply non-nil session name.')
- end
+ if vim.v.this_session == '' then H.error('There is no active session. Supply non-nil session name.') end
return vim.v.this_session
@@ -523,5 +509,3 @@ function H.name_to_path(session_name)
session_name = tostring(session_name)
- if session_name == '' then
- H.error('Supply non-empty session name.')
- end
+ if session_name == '' then H.error('Supply non-empty session name.') end
@@ -542,9 +526,5 @@ end
-function H.message(msg)
- vim.cmd('echomsg ' .. vim.inspect('(mini.sessions) ' .. msg))
-end
+function H.message(msg) vim.cmd('echomsg ' .. vim.inspect('(mini.sessions) ' .. msg)) end
-function H.error(msg)
- error(('(mini.sessions) %s'):format(msg))
-end
+function H.error(msg) error(('(mini.sessions) %s'):format(msg)) end
@@ -569,6 +549,4 @@ function H.is_something_shown()
-- means unlisted buffers (like from `nvim-tree`) don't affect decision.
- local listed_buffers = vim.tbl_filter(
- function(buf_id) return vim.fn.buflisted(buf_id) == 1 end,
- vim.api.nvim_list_bufs()
- )
+ local listed_buffers =
+ vim.tbl_filter(function(buf_id) return vim.fn.buflisted(buf_id) == 1 end, vim.api.nvim_list_bufs())
if #listed_buffers > 1 then return true end
diff --git a/lua/mini/starter.lua b/lua/mini/starter.lua
index d060ff6..95c3adb 100644
--- a/lua/mini/starter.lua
+++ b/lua/mini/starter.lua
@@ -325,5 +325,3 @@ function MiniStarter.open(buf_id)
- if buf_id == nil or not vim.api.nvim_buf_is_valid(buf_id) then
- buf_id = vim.api.nvim_create_buf(false, true)
- end
+ if buf_id == nil or not vim.api.nvim_buf_is_valid(buf_id) then buf_id = vim.api.nvim_create_buf(false, true) end
@@ -511,5 +509,3 @@ function MiniStarter.sections.recent_files(n, current_dir, show_path)
- if current_dir then
- vim.cmd('au DirChanged * lua MiniStarter.refresh()')
- end
+ if current_dir then vim.cmd('au DirChanged * lua MiniStarter.refresh()') end
@@ -593,5 +589,3 @@ function MiniStarter.gen_hook.padding(left, top)
local is_empty_line = #line == 0 or (#line == 1 and line[1].string == '')
- if not is_empty_line then
- table.insert(line, 1, H.content_unit(left_pad, 'empty', nil))
- end
+ if not is_empty_line then table.insert(line, 1, H.content_unit(left_pad, 'empty', nil)) end
end
@@ -740,5 +734,3 @@ function MiniStarter.content_coords(content, predicate)
content = content or MiniStarter.content
- if predicate == nil then
- predicate = function(unit) return true end
- end
+ if predicate == nil then predicate = function(unit) return true end end
if type(predicate) == 'string' then
@@ -751,5 +743,3 @@ function MiniStarter.content_coords(content, predicate)
for u_num, unit in ipairs(line) do
- if predicate(unit) then
- table.insert(res, { line = l_num, unit = u_num })
- end
+ if predicate(unit) then table.insert(res, { line = l_num, unit = u_num }) end
end
@@ -842,5 +832,3 @@ end
--- Evaluate current item
-function MiniStarter.eval_current_item()
- H.eval_fun_or_string(H.items[H.current_item_id].action, true)
-end
+function MiniStarter.eval_current_item() H.eval_fun_or_string(H.items[H.current_item_id].action, true) end
@@ -893,5 +881,3 @@ function MiniStarter.set_query(query)
query = query or ''
- if type(query) ~= 'string' then
- error('`query` should be either `nil` or string.')
- end
+ if type(query) ~= 'string' then error('`query` should be either `nil` or string.') end
@@ -901,5 +887,3 @@ end
--- Act on |CursorMoved| by repositioning cursor in fixed place.
-function MiniStarter.on_cursormoved()
- H.position_cursor_on_current_item()
-end
+function MiniStarter.on_cursormoved() H.position_cursor_on_current_item() end
@@ -980,5 +964,3 @@ end
-function H.apply_config(config)
- MiniStarter.config = config
-end
+function H.apply_config(config) MiniStarter.config = config end
@@ -994,5 +976,3 @@ end
function H.normalize_header_footer(x)
- if type(x) == 'function' then
- x = x()
- end
+ if type(x) == 'function' then x = x() end
local res = tostring(x)
@@ -1026,5 +1006,3 @@ end
-function H.content_add_line(content_line)
- table.insert(MiniStarter.content, content_line)
-end
+function H.content_add_line(content_line) table.insert(MiniStarter.content, content_line) end
@@ -1072,5 +1050,3 @@ function H.items_flatten(items)
n_nested = n_nested + 1
- if n_nested > 100 then
- H.message('Too many nested functions in `config.items`.')
- end
+ if n_nested > 100 then H.message('Too many nested functions in `config.items`.') end
x = x()
@@ -1137,5 +1113,3 @@ end
-function H.position_cursor_on_current_item()
- vim.api.nvim_win_set_cursor(0, H.items[H.current_item_id]._cursorpos)
-end
+function H.position_cursor_on_current_item() vim.api.nvim_win_set_cursor(0, H.items[H.current_item_id]._cursorpos) end
@@ -1170,5 +1144,3 @@ function H.make_query(query)
-- Move to next active item if current is not active
- if not H.items[H.current_item_id]._active then
- MiniStarter.update_current_item('next')
- end
+ if not H.items[H.current_item_id]._active then MiniStarter.update_current_item('next') end
@@ -1292,5 +1264,3 @@ end
function H.is_fun_or_string(x, allow_nil)
- if allow_nil == nil then
- allow_nil = true
- end
+ if allow_nil == nil then allow_nil = true end
return (allow_nil and x == nil) or type(x) == 'function' or type(x) == 'string'
@@ -1318,6 +1288,4 @@ function H.is_something_shown()
-- means unlisted buffers (like from `nvim-tree`) don't affect decision.
- local listed_buffers = vim.tbl_filter(
- function(buf_id) return vim.fn.buflisted(buf_id) == 1 end,
- vim.api.nvim_list_bufs()
- )
+ local listed_buffers =
+ vim.tbl_filter(function(buf_id) return vim.fn.buflisted(buf_id) == 1 end, vim.api.nvim_list_bufs())
if #listed_buffers > 1 then return true end
@@ -1358,5 +1326,3 @@ end
-function H.message(msg)
- vim.cmd('echomsg ' .. vim.inspect('(mini.starter) ' .. msg))
-end
+function H.message(msg) vim.cmd('echomsg ' .. vim.inspect('(mini.starter) ' .. msg)) end
diff --git a/lua/mini/statusline.lua b/lua/mini/statusline.lua
index a904b54..15304fd 100644
--- a/lua/mini/statusline.lua
+++ b/lua/mini/statusline.lua
@@ -318,5 +318,3 @@ function MiniStatusline.section_diagnostics(args)
-- Add level info only if diagnostic is present
- if n > 0 then
- table.insert(t, string.format(' %s%s', level.sign, n))
- end
+ if n > 0 then table.insert(t, string.format(' %s%s', level.sign, n)) end
end
@@ -368,5 +366,3 @@ function MiniStatusline.section_fileinfo(args)
local icon = H.get_filetype_icon()
- if icon ~= '' then
- filetype = string.format('%s %s', icon, filetype)
- end
+ if icon ~= '' then filetype = string.format('%s %s', icon, filetype) end
diff --git a/lua/mini/surround.lua b/lua/mini/surround.lua
index 09b8022..51ca750 100644
--- a/lua/mini/surround.lua
+++ b/lua/mini/surround.lua
@@ -481,5 +481,3 @@ function MiniSurround.user_input(prompt, text)
on_key(function(key)
- if key == vim.api.nvim_replace_termcodes('<Esc>', true, true, true) then
- was_cancelled = true
- end
+ if key == vim.api.nvim_replace_termcodes('<Esc>', true, true, true) then was_cancelled = true end
end, H.ns_id.input)
@@ -787,5 +785,3 @@ end
-- Work with cursor -----------------------------------------------------------
-function H.set_cursor(line, col)
- vim.api.nvim_win_set_cursor(0, { line, col - 1 })
-end
+function H.set_cursor(line, col) vim.api.nvim_win_set_cursor(0, { line, col - 1 }) end
@@ -813,5 +809,3 @@ function H.cursor_cycle(pos_array, dir)
to_right = res_pos == nil and compare == '<' and dir == 'right'
- if to_left or to_right then
- res_pos = pos
- end
+ if to_left or to_right then res_pos = pos end
end
@@ -839,5 +833,3 @@ function H.user_surround_id(sur_type)
- if type(char) == 'number' then
- char = vim.fn.nr2char(char)
- end
+ if type(char) == 'number' then char = vim.fn.nr2char(char) end
if char:find('^[%w%p%s]$') == nil then
@@ -864,5 +856,3 @@ function H.linepart_to_pos_table(linepart)
local res = { { line = linepart.line, col = linepart.from } }
- if linepart.from ~= linepart.to then
- table.insert(res, { line = linepart.line, col = linepart.to })
- end
+ if linepart.from ~= linepart.to then table.insert(res, { line = linepart.line, col = linepart.to }) end
return res
@@ -923,5 +913,3 @@ function H.find_best_match(line, pattern, offset)
-- `".-"` and `line = '"a"aa"', offset = 3`.
- if (left == nil) or (match_right - match_left < right - left) then
- left, right = match_left, match_right
- end
+ if (left == nil) or (match_right - match_left < right - left) then left, right = match_left, match_right end
-- Try find smaller match
@@ -933,7 +921,4 @@ function H.find_best_match(line, pattern, offset)
if left == nil then
- left, right = H.infer_match(
- { left = left_prev, right = right_prev },
- { left = left_next, right = right_next },
- offset
- )
+ left, right =
+ H.infer_match({ left = left_prev, right = right_prev }, { left = left_next, right = right_next }, offset)
end
@@ -1105,7 +1090,4 @@ function H.make_surrounding_table()
-- Use data from `config` and extend with builtins
- local surroundings = vim.tbl_deep_extend(
- 'force',
- H.builtin_surroundings,
- MiniSurround.config.custom_surroundings or {}
- )
+ local surroundings =
+ vim.tbl_deep_extend('force', H.builtin_surroundings, MiniSurround.config.custom_surroundings or {})
@@ -1134,9 +1116,5 @@ end
-- Utilities ------------------------------------------------------------------
-function H.message(msg)
- vim.cmd('echomsg ' .. vim.inspect('(mini.surround) ' .. msg))
-end
+function H.message(msg) vim.cmd('echomsg ' .. vim.inspect('(mini.surround) ' .. msg)) end
-function H.error(msg)
- error(string.format('(mini.surround) %s', msg))
-end
+function H.error(msg) error(string.format('(mini.surround) %s', msg)) end
@@ -1149,5 +1127,3 @@ function H.map(mode, key, rhs, opts)
-- Use mapping description only in Neovim>=0.7
- if vim.fn.has('nvim-0.7') == 0 then
- opts.desc = nil
- end
+ if vim.fn.has('nvim-0.7') == 0 then opts.desc = nil end
diff --git a/lua/mini/tabline.lua b/lua/mini/tabline.lua
index f406060..4a0fcb1 100644
--- a/lua/mini/tabline.lua
+++ b/lua/mini/tabline.lua
@@ -234,5 +234,3 @@ function H.construct_highlight(buf_id)
end
- if vim.api.nvim_buf_get_option(buf_id, 'modified') then
- hl_type = 'Modified' .. hl_type
- end
+ if vim.api.nvim_buf_get_option(buf_id, 'modified') then hl_type = 'Modified' .. hl_type end
@@ -301,5 +299,3 @@ function H.make_unnamed_label(buf_id)
local unnamed_id = H.get_unnamed_id(buf_id)
- if unnamed_id > 1 then
- label = string.format('%s(%d)', label, unnamed_id)
- end
+ if unnamed_id > 1 then label = string.format('%s(%d)', label, unnamed_id) end
@@ -335,5 +331,3 @@ function H.finalize_labels()
tab.label = tab.label_extender(tab.label)
- if old_label ~= tab.label then
- nothing_changed = false
- end
+ if old_label ~= tab.label then nothing_changed = false end
end
@@ -350,5 +344,3 @@ function H.finalize_labels()
-- Have this `require()` here to not depend on plugin initialization order
- if show_icons then
- has_devicons, devicons = pcall(require, 'nvim-web-devicons')
- end
+ if show_icons then has_devicons, devicons = pcall(require, 'nvim-web-devicons') end
@@ -411,5 +403,3 @@ function H.update_center_buf_id()
local cur_buf = vim.api.nvim_get_current_buf()
- if H.is_buffer_in_minitabline(cur_buf) then
- H.center_buf_id = cur_buf
- end
+ if H.is_buffer_in_minitabline(cur_buf) then H.center_buf_id = cur_buf end
end
@@ -479,5 +469,3 @@ function H.concat_tabs()
end
- if position == 'left' then
- res = ('%%#MiniTablineTabpagesection#%s%s'):format(H.tabpage_section, res)
- end
+ if position == 'left' then res = ('%%#MiniTablineTabpagesection#%s%s'):format(H.tabpage_section, res) end
if position == 'right' then
@@ -492,5 +480,3 @@ end
-- Utilities ------------------------------------------------------------------
-function H.message(msg)
- vim.cmd('echomsg ' .. vim.inspect('(mini.tabline) ' .. msg))
-end
+function H.message(msg) vim.cmd('echomsg ' .. vim.inspect('(mini.tabline) ' .. msg)) end
diff --git a/lua/mini/test.lua b/lua/mini/test.lua
index 7ffa359..9452017 100644
--- a/lua/mini/test.lua
+++ b/lua/mini/test.lua
@@ -351,5 +351,3 @@ end
--- executing (regardless of whether it ended with error or not).
-function MiniTest.finally(f)
- H.cache.finally = f
-end
+function MiniTest.finally(f) H.cache.finally = f end
@@ -505,5 +503,3 @@ function MiniTest.collect(opts)
-- If output is test set, always use it (even if 'busted' tests were added)
- if H.is_instance(t, 'testset') then
- set[file] = t
- end
+ if H.is_instance(t, 'testset') then set[file] = t end
end
@@ -753,5 +749,3 @@ function MiniTest.expect.reference_screenshot(screenshot, path, opts)
-- Deal with multiple screenshots
- if H.cache.n_screenshots > 1 then
- path = path .. string.format('-%03d', H.cache.n_screenshots)
- end
+ if H.cache.n_screenshots > 1 then path = path .. string.format('-%03d', H.cache.n_screenshots) end
end
@@ -878,5 +872,4 @@ function MiniTest.gen_reporter.buffer(opts)
-- Helpers
- local set_cursor = function(line)
- vim.api.nvim_win_set_cursor(win_id, { line or vim.api.nvim_buf_line_count(buf_id), 0 })
- end
+ local set_cursor =
+ function(line) vim.api.nvim_win_set_cursor(win_id, { line or vim.api.nvim_buf_line_count(buf_id), 0 }) end
@@ -996,5 +989,3 @@ function MiniTest.gen_reporter.stdout(opts)
write(cur_group_name)
- if cur_group_name ~= '' then
- write(': ')
- end
+ if cur_group_name ~= '' then write(': ') end
end
@@ -1004,5 +995,3 @@ function MiniTest.gen_reporter.stdout(opts)
local cur_symbol = H.reporter_symbols[state]
- if cur_symbol ~= default_symbol then
- write(cur_symbol)
- end
+ if cur_symbol ~= default_symbol then write(cur_symbol) end
@@ -1276,5 +1265,3 @@ function MiniTest.new_child_neovim()
-- Possibly wait
- if has_wait and wait > 0 then
- vim.loop.sleep(wait)
- end
+ if has_wait and wait > 0 then vim.loop.sleep(wait) end
end
@@ -1329,5 +1316,3 @@ function MiniTest.new_child_neovim()
-- Error if Neovim version is "too old"
- if child.fn.has('nvim-0.6') == 0 then
- error('`child.get_screenshot()` needs Neovim>=0.6', 0)
- end
+ if child.fn.has('nvim-0.6') == 0 then error('`child.get_screenshot()` needs Neovim>=0.6', 0) end
@@ -1634,5 +1619,3 @@ end
-function H.apply_config(config)
- MiniTest.config = config
-end
+function H.apply_config(config) MiniTest.config = config end
@@ -1652,5 +1635,3 @@ function H.busted_emulate(set)
- _G.it = function(name, f)
- cur_set[name] = f
- end
+ _G.it = function(name, f) cur_set[name] = f end
@@ -1702,5 +1683,3 @@ end
function H.make_step_scheduler(case, case_num, opts)
- local report_update_case = function()
- H.exec_callable(opts.reporter.update, case_num)
- end
+ local report_update_case = function() H.exec_callable(opts.reporter.update, case_num) end
@@ -1772,6 +1751,4 @@ function H.set_to_testcases(set, template, hooks_once)
-- within corresponding test set.
- hooks_once = H.extend_hooks(
- hooks_once,
- { pre = H.wrap_callable(hooks.pre_once), post = H.wrap_callable(hooks.post_once) }
- )
+ hooks_once =
+ H.extend_hooks(hooks_once, { pre = H.wrap_callable(hooks.pre_once), post = H.wrap_callable(hooks.post_once) })
@@ -1782,5 +1759,3 @@ function H.set_to_testcases(set, template, hooks_once)
for _, args in ipairs(parametrize) do
- if type(args) ~= 'table' then
- H.error('`parametrize` should have only tables. Got ' .. vim.inspect(args))
- end
+ if type(args) ~= 'table' then H.error('`parametrize` should have only tables. Got ' .. vim.inspect(args)) end
@@ -1876,13 +1851,7 @@ function H.extend_hooks(hooks, layer, do_deepcopy)
local res = hooks
- if do_deepcopy == nil or do_deepcopy then
- res = vim.deepcopy(hooks)
- end
+ if do_deepcopy == nil or do_deepcopy then res = vim.deepcopy(hooks) end
-- Closer (in terms of nesting) hooks should be closer to test callable
- if vim.is_callable(layer.pre) then
- table.insert(res.pre, layer.pre)
- end
- if vim.is_callable(layer.post) then
- table.insert(res.post, 1, layer.post)
- end
+ if vim.is_callable(layer.pre) then table.insert(res.pre, layer.pre) end
+ if vim.is_callable(layer.post) then table.insert(res.post, 1, layer.post) end
@@ -2028,5 +1997,3 @@ function H.buffer_reporter.set_mappings(buf_id)
-- Use mapping description only in Neovim>=0.7
- if vim.fn.has('nvim-0.7') == 0 then
- opts.desc = nil
- end
+ if vim.fn.has('nvim-0.7') == 0 then opts.desc = nil end
@@ -2248,5 +2215,3 @@ end
-function H.screenshot_write(screenshot, path)
- vim.fn.writefile(vim.split(tostring(screenshot), '\n'), path)
-end
+function H.screenshot_write(screenshot, path) vim.fn.writefile(vim.split(tostring(screenshot), '\n'), path) end
@@ -2269,9 +2234,5 @@ end
-- Utilities ------------------------------------------------------------------
-function H.message(msg)
- vim.cmd('echomsg ' .. vim.inspect('(mini.test) ' .. msg))
-end
+function H.message(msg) vim.cmd('echomsg ' .. vim.inspect('(mini.test) ' .. msg)) end
-function H.error(msg)
- error(string.format('(mini.test) %s', msg))
-end
+function H.error(msg) error(string.format('(mini.test) %s', msg)) end
@@ -2293,5 +2254,3 @@ function H.add_prefix(tbl, prefix)
-- Do not create trailing whitespace
- if x:sub(1, 1) == '\n' then
- p = p:gsub('%s*$', '')
- end
+ if x:sub(1, 1) == '\n' then p = p:gsub('%s*$', '') end
return ('%s%s'):format(p, x)
diff --git a/lua/mini/trailspace.lua b/lua/mini/trailspace.lua
index a8e2d02..21c10c9 100644
--- a/lua/mini/trailspace.lua
+++ b/lua/mini/trailspace.lua
@@ -167,5 +167,3 @@ end
-function H.apply_config(config)
- MiniTrailspace.config = config
-end
+function H.apply_config(config) MiniTrailspace.config = config end
diff --git a/scripts/minidoc.lua b/scripts/minidoc.lua
index 01ca466..e5afb66 100644
--- a/scripts/minidoc.lua
+++ b/scripts/minidoc.lua
@@ -2,5 +2,3 @@ local minidoc = require('mini.doc')
-if _G.MiniDoc == nil then
- minidoc.setup()
-end
+if _G.MiniDoc == nil then minidoc.setup() end
minidoc.generate(nil, nil, { hooks = minidoc.default_hooks })
diff --git a/scripts/minitest.lua b/scripts/minitest.lua
index 92680ce..63b8f66 100644
--- a/scripts/minitest.lua
+++ b/scripts/minitest.lua
@@ -2,5 +2,3 @@ local minitest = require('mini.test')
-if _G.MiniDoc == nil then
- minitest.setup()
-end
+if _G.MiniDoc == nil then minitest.setup() end
minitest.run()
diff --git a/tests/dir-doc/helpers.lua b/tests/dir-doc/helpers.lua
index eb7546f..4c0e782 100644
--- a/tests/dir-doc/helpers.lua
+++ b/tests/dir-doc/helpers.lua
@@ -34,5 +34,3 @@ _G.validate_doc_structure = function(x)
for _, line in ipairs(section) do
- if type(line) ~= 'string' then
- error('Section element is not a line.')
- end
+ if type(line) ~= 'string' then error('Section element is not a line.') end
end
@@ -47,5 +45,3 @@ function H.validate_structure(x, struct_type, parent)
- if not H.is_structure(x, struct_type) then
- error(('Element is not %s structure.'):format(type_string))
- end
+ if not H.is_structure(x, struct_type) then error(('Element is not %s structure.'):format(type_string)) end
diff --git a/tests/dir-statusline/mock-diagnostics.lua b/tests/dir-statusline/mock-diagnostics.lua
index c5476a1..70fc55e 100644
--- a/tests/dir-statusline/mock-diagnostics.lua
+++ b/tests/dir-statusline/mock-diagnostics.lua
@@ -7,5 +7,3 @@ vim.lsp.diagnostic.get_count =
-- Neovim >= 0.6
-if vim.diagnostic == nil then
- vim.diagnostic = {}
-end
+if vim.diagnostic == nil then vim.diagnostic = {} end
diff --git a/tests/dir-test/init_stdout-reporter_works.lua b/tests/dir-test/init_stdout-reporter_works.lua
index 55bb405..4cc2dfc 100644
--- a/tests/dir-test/init_stdout-reporter_works.lua
+++ b/tests/dir-test/init_stdout-reporter_works.lua
@@ -7,5 +7,3 @@ local group_depth = tonumber(vim.env.TEST_GROUP_DEPTH)
local quit_on_finish
-if vim.env.TEST_QUIT_ON_FINISH ~= nil then
- quit_on_finish = vim.env.TEST_QUIT_ON_FINISH == 'true'
-end
+if vim.env.TEST_QUIT_ON_FINISH ~= nil then quit_on_finish = vim.env.TEST_QUIT_ON_FINISH == 'true' end
diff --git a/tests/dir-test/testref_case-helpers.lua b/tests/dir-test/testref_case-helpers.lua
index 18346ce..d1f8d3e 100644
--- a/tests/dir-test/testref_case-helpers.lua
+++ b/tests/dir-test/testref_case-helpers.lua
@@ -5,5 +5,3 @@ local finally_with_error, finally_no_error = false, false
T['finally() with error'] = function()
- MiniTest.finally(function()
- finally_with_error = true
- end)
+ MiniTest.finally(function() finally_with_error = true end)
error()
@@ -11,10 +9,6 @@ end
-T['finally() with error; check'] = function()
- MiniTest.expect.equality(finally_with_error, true)
-end
+T['finally() with error; check'] = function() MiniTest.expect.equality(finally_with_error, true) end
T['finally() no error'] = function()
- MiniTest.finally(function()
- finally_no_error = true
- end)
+ MiniTest.finally(function() finally_no_error = true end)
local res = true
@@ -23,5 +17,3 @@ end
-T['finally() no error; check'] = function()
- MiniTest.expect.equality(finally_no_error, true)
-end
+T['finally() no error; check'] = function() MiniTest.expect.equality(finally_no_error, true) end
@@ -37,5 +29,3 @@ end
-T['add_note()'] = function()
- MiniTest.add_note('This note should be appended')
-end
+T['add_note()'] = function() MiniTest.add_note('This note should be appended') end
diff --git a/tests/dir-test/testref_collect-busted.lua b/tests/dir-test/testref_collect-busted.lua
index f005770..457df9c 100644
--- a/tests/dir-test/testref_collect-busted.lua
+++ b/tests/dir-test/testref_collect-busted.lua
@@ -43,5 +43,3 @@ end)
describe('MiniTest.skip()', function()
- it('works', function()
- MiniTest.skip()
- end)
+ it('works', function() MiniTest.skip() end)
end)
diff --git a/tests/dir-test/testref_general.lua b/tests/dir-test/testref_general.lua
index 8b7f063..ef5735c 100644
--- a/tests/dir-test/testref_general.lua
+++ b/tests/dir-test/testref_general.lua
@@ -5,5 +5,3 @@ local T = new_set({ hooks = { pre_once = f, pre_case = f, post_case = f, post_on
-T['case 1'] = function()
- error('Some error')
-end
+T['case 1'] = function() error('Some error') end
T['case 2'] = function() end
diff --git a/tests/dir-test/testref_run-hooks.lua b/tests/dir-test/testref_run-hooks.lua
index 10da455..cd33773 100644
--- a/tests/dir-test/testref_run-hooks.lua
+++ b/tests/dir-test/testref_run-hooks.lua
@@ -5,5 +5,3 @@ local T = new_set()
local erroring = function(x)
- return function()
- error(x, 0)
- end
+ return function() error(x, 0) end
end
diff --git a/tests/helpers.lua b/tests/helpers.lua
index eac14bc..924feb8 100644
--- a/tests/helpers.lua
+++ b/tests/helpers.lua
@@ -40,5 +40,3 @@ Helpers.new_child_neovim = function()
- if type(arr) == 'string' then
- arr = vim.split(arr, '\n')
- end
+ if type(arr) == 'string' then arr = vim.split(arr, '\n') end
@@ -68,9 +66,5 @@ Helpers.new_child_neovim = function()
- if type(lines) == 'number' then
- child.o.lines = lines
- end
+ if type(lines) == 'number' then child.o.lines = lines end
- if type(columns) == 'number' then
- child.o.columns = columns
- end
+ if type(columns) == 'number' then child.o.columns = columns end
end
@@ -147,5 +141,3 @@ Helpers.new_child_neovim = function()
function child.expect_screenshot(opts, path, screenshot_opts)
- if child.fn.has('nvim-0.8') == 0 then
- MiniTest.skip('Screenshots are tested for Neovim>=0.8 (for simplicity).')
- end
+ if child.fn.has('nvim-0.8') == 0 then MiniTest.skip('Screenshots are tested for Neovim>=0.8 (for simplicity).') end
@@ -160,5 +152,3 @@ function Helpers.mark_flaky()
MiniTest.finally(function()
- if #MiniTest.current.case.exec.fails > 0 then
- MiniTest.add_note('This test is flaky.')
- end
+ if #MiniTest.current.case.exec.fails > 0 then MiniTest.add_note('This test is flaky.') end
end)
diff --git a/tests/test_base16.lua b/tests/test_base16.lua
index 7ecea4d..948fb07 100644
--- a/tests/test_base16.lua
+++ b/tests/test_base16.lua
@@ -13,5 +13,6 @@ local reload_module = function(config) unload_module(); load_module(config) end
-local validate_hl_group = function(group_name, target)
- eq(child.cmd_capture('highlight ' .. group_name):gsub(' +', ' '), group_name .. ' xxx ' .. target)
-end
+local validate_hl_group =
+ function(group_name, target)
+ eq(child.cmd_capture('highlight ' .. group_name):gsub(' +', ' '), group_name .. ' xxx ' .. target)
+ end
@@ -79,5 +80,3 @@ T['setup()']['creates `config` field'] = function()
-- Check default values
- local expect_config = function(field, value)
- eq(child.lua_get('MiniBase16.config.' .. field), value)
- end
+ local expect_config = function(field, value) eq(child.lua_get('MiniBase16.config.' .. field), value) end
@@ -96,5 +95,4 @@ T['setup()']['validates `config` argument'] = function()
- local expect_config_error = function(config, name, target_type)
- expect.error(load_module, vim.pesc(name) .. '.*' .. vim.pesc(target_type), config)
- end
+ local expect_config_error =
+ function(config, name, target_type) expect.error(load_module, vim.pesc(name) .. '.*' .. vim.pesc(target_type), config) end
@@ -175,5 +173,3 @@ T['mini_palette()']['validates arguments'] = function()
local validate = function(args, error_pattern)
- expect.error(function()
- child.lua_get('MiniBase16.mini_palette(...)', args)
- end, error_pattern)
+ expect.error(function() child.lua_get('MiniBase16.mini_palette(...)', args) end, error_pattern)
end
@@ -194,5 +190,4 @@ end
-T['mini_palette()']['works'] = function()
- eq(child.lua_get([[MiniBase16.mini_palette('#112641', '#e2e98f', 75)]]), minischeme_palette)
-end
+T['mini_palette()']['works'] =
+ function() eq(child.lua_get([[MiniBase16.mini_palette('#112641', '#e2e98f', 75)]]), minischeme_palette) end
@@ -202,5 +197,6 @@ T['rgb_palette_to_cterm_palette()']['validates arguments'] = function()
local validate = function(palette, error_pattern)
- expect.error(function()
- child.lua_get('MiniBase16.rgb_palette_to_cterm_palette(...)', { palette })
- end, error_pattern)
+ expect.error(
+ function() child.lua_get('MiniBase16.rgb_palette_to_cterm_palette(...)', { palette }) end,
+ error_pattern
+ )
end
@@ -215,5 +211,4 @@ end
-T['rgb_palette_to_cterm_palette()']['works'] = function()
- eq(child.lua_get('MiniBase16.rgb_palette_to_cterm_palette(...)', { minischeme_palette }), minischeme_use_cterm)
-end
+T['rgb_palette_to_cterm_palette()']['works'] =
+ function() eq(child.lua_get('MiniBase16.rgb_palette_to_cterm_palette(...)', { minischeme_palette }), minischeme_use_cterm) end
diff --git a/tests/test_bufremove.lua b/tests/test_bufremove.lua
index 7bf818e..b206886 100644
--- a/tests/test_bufremove.lua
+++ b/tests/test_bufremove.lua
@@ -178,5 +178,4 @@ T['setup()']['validates `config` argument'] = function()
- local expect_config_error = function(config, name, target_type)
- expect.error(load_module, vim.pesc(name) .. '.*' .. vim.pesc(target_type), config)
- end
+ local expect_config_error =
+ function(config, name, target_type) expect.error(load_module, vim.pesc(name) .. '.*' .. vim.pesc(target_type), config) end
@@ -203,5 +202,3 @@ end
-T['unshow()']['validates arguments'] = function()
- validate_args_validation('unshow', { 'buf_id' })
-end
+T['unshow()']['validates arguments'] = function() validate_args_validation('unshow', { 'buf_id' }) end
@@ -215,5 +212,3 @@ T['unshow()']['respects `vim.{g,b}.minibufremove_disable`'] = new_set({
}, {
- test = function(var_type)
- validate_disable(var_type, 'unshow', layout)
- end,
+ test = function(var_type) validate_disable(var_type, 'unshow', layout) end,
})
@@ -275,5 +270,3 @@ T['unshow_in_window()']['respects `vim.{g,b}.minibufremove_disable`'] = new_set(
}, {
- test = function(var_type)
- validate_disable(var_type, 'unshow_in_window', layout)
- end,
+ test = function(var_type) validate_disable(var_type, 'unshow_in_window', layout) end,
})
@@ -297,5 +290,3 @@ end
-T['delete()']['validates arguments'] = function()
- validate_args_validation('delete', { 'buf_id', 'force' })
-end
+T['delete()']['validates arguments'] = function() validate_args_validation('delete', { 'buf_id', 'force' }) end
@@ -306,5 +297,3 @@ end
-T['delete()']['respects `force` argument'] = function()
- validate_force_argument('delete', layout)
-end
+T['delete()']['respects `force` argument'] = function() validate_force_argument('delete', layout) end
@@ -313,5 +302,3 @@ T['delete()']['respects `vim.{g,b}.minibufremove_disable`'] = new_set({
}, {
- test = function(var_type)
- validate_disable(var_type, 'delete', layout)
- end,
+ test = function(var_type) validate_disable(var_type, 'delete', layout) end,
})
@@ -340,5 +327,3 @@ end
-T['wipeout()']['validates arguments'] = function()
- validate_args_validation('wipeout', { 'buf_id', 'force' })
-end
+T['wipeout()']['validates arguments'] = function() validate_args_validation('wipeout', { 'buf_id', 'force' }) end
@@ -349,5 +334,3 @@ end
-T['wipeout()']['respects `force` argument'] = function()
- validate_force_argument('wipeout', layout)
-end
+T['wipeout()']['respects `force` argument'] = function() validate_force_argument('wipeout', layout) end
@@ -356,5 +339,3 @@ T['wipeout()']['respects `vim.{g,b}.minibufremove_disable`'] = new_set({
}, {
- test = function(var_type)
- validate_disable(var_type, 'wipeout', layout)
- end,
+ test = function(var_type) validate_disable(var_type, 'wipeout', layout) end,
})
diff --git a/tests/test_comment.lua b/tests/test_comment.lua
index c6f70dd..873b09b 100644
--- a/tests/test_comment.lua
+++ b/tests/test_comment.lua
@@ -68,5 +68,3 @@ T['setup()']['creates `config` field'] = function()
-- Check default values
- local expect_config = function(field, value)
- eq(child.lua_get('MiniComment.config.' .. field), value)
- end
+ local expect_config = function(field, value) eq(child.lua_get('MiniComment.config.' .. field), value) end
@@ -86,5 +84,4 @@ T['setup()']['validates `config` argument'] = function()
- local expect_config_error = function(config, name, target_type)
- expect.error(load_module, vim.pesc(name) .. '.*' .. vim.pesc(target_type), config)
- end
+ local expect_config_error =
+ function(config, name, target_type) expect.error(load_module, vim.pesc(name) .. '.*' .. vim.pesc(target_type), config) end
diff --git a/tests/test_completion.lua b/tests/test_completion.lua
index b786fa1..b620bb9 100644
--- a/tests/test_completion.lua
+++ b/tests/test_completion.lua
@@ -98,5 +98,3 @@ T['setup()']['creates `config` field'] = function()
-- Check default values
- local expect_config = function(field, value)
- eq(child.lua_get('MiniCompletion.config.' .. field), value)
- end
+ local expect_config = function(field, value) eq(child.lua_get('MiniCompletion.config.' .. field), value) end
@@ -127,5 +125,4 @@ T['setup()']['validates `config` argument'] = function()
- local expect_config_error = function(config, name, target_type)
- expect.error(load_module, vim.pesc(name) .. '.*' .. vim.pesc(target_type), config)
- end
+ local expect_config_error =
+ function(config, name, target_type) expect.error(load_module, vim.pesc(name) .. '.*' .. vim.pesc(target_type), config) end
@@ -596,5 +593,4 @@ end
-T['Signature help']['respects `config.window_dimensions.signature`'] = function()
- validate_dimensions_signature({ 'l', 'o', 'n', 'g', '(' }, { height = 20, width = 40 })
-end
+T['Signature help']['respects `config.window_dimensions.signature`'] =
+ function() validate_dimensions_signature({ 'l', 'o', 'n', 'g', '(' }, { height = 20, width = 40 }) end
diff --git a/tests/test_cursorword.lua b/tests/test_cursorword.lua
index c60f865..3727d2f 100644
--- a/tests/test_cursorword.lua
+++ b/tests/test_cursorword.lua
@@ -63,5 +63,3 @@ T['setup()']['creates side effects'] = function()
-- Autocommand on `ModeChanged` event
- if child.fn.has('nvim-0.7.0') == 1 then
- eq(child.fn.exists('#MiniCursorword#ModeChanged'), 1)
- end
+ if child.fn.has('nvim-0.7.0') == 1 then eq(child.fn.exists('#MiniCursorword#ModeChanged'), 1) end
@@ -88,5 +86,4 @@ T['setup()']['validates `config` argument'] = function()
- local expect_config_error = function(config, name, target_type)
- expect.error(load_module, vim.pesc(name) .. '.*' .. vim.pesc(target_type), config)
- end
+ local expect_config_error =
+ function(config, name, target_type) expect.error(load_module, vim.pesc(name) .. '.*' .. vim.pesc(target_type), config) end
@@ -108,5 +105,3 @@ T['Highlighting'] = new_set({
-T['Highlighting']['works'] = function()
- child.expect_screenshot()
-end
+T['Highlighting']['works'] = function() child.expect_screenshot() end
@@ -131,5 +126,3 @@ T['Autohighlighting'] = new_set({
hooks = {
- pre_case = function()
- set_lines(example_lines)
- end,
+ pre_case = function() set_lines(example_lines) end,
},
@@ -146,5 +139,3 @@ end
-T['Autohighlighting']['works'] = function()
- validate_cursorword(test_times.delay)
-end
+T['Autohighlighting']['works'] = function() validate_cursorword(test_times.delay) end
@@ -177,9 +168,6 @@ end
-T['Autohighlighting']['highlights immediately inside current word'] = function()
- validate_immediate('normal! l')
-end
+T['Autohighlighting']['highlights immediately inside current word'] = function() validate_immediate('normal! l') end
-T['Autohighlighting']['highlights immediately same word in other place'] = function()
- validate_immediate('normal! k')
-end
+T['Autohighlighting']['highlights immediately same word in other place'] =
+ function() validate_immediate('normal! k') end
diff --git a/tests/test_doc.lua b/tests/test_doc.lua
index 7fd4e12..324a5a6 100644
--- a/tests/test_doc.lua
+++ b/tests/test_doc.lua
@@ -19,5 +19,3 @@ local remove_dir = function(path) child.lua('_G.remove_dir(...)', { path }) end
-- Make helpers
-local expect_equal_file_contents = function(file1, file2)
- eq(child.fn.readfile(file1), child.fn.readfile(file2))
-end
+local expect_equal_file_contents = function(file1, file2) eq(child.fn.readfile(file1), child.fn.readfile(file2)) end
@@ -57,5 +55,3 @@ T['setup()']['creates `config` field'] = function()
-- Check default values
- local expect_config = function(field, value)
- eq(child.lua_get('MiniDoc.config.' .. field), value)
- end
+ local expect_config = function(field, value) eq(child.lua_get('MiniDoc.config.' .. field), value) end
local expect_config_function = function(field)
@@ -98,5 +94,4 @@ T['setup()']['validates `config` argument'] = function()
- local expect_config_error = function(config, name, target_type)
- expect.error(load_module, vim.pesc(name) .. '.*' .. vim.pesc(target_type), config)
- end
+ local expect_config_error =
+ function(config, name, target_type) expect.error(load_module, vim.pesc(name) .. '.*' .. vim.pesc(target_type), config) end
@@ -177,13 +172,7 @@ end
-T['generate()']['uses correct default collation order'] = function()
- validate_test_scope('default-collation')
-end
+T['generate()']['uses correct default collation order'] = function() validate_test_scope('default-collation') end
-T['generate()']['makes correct afterlines inference'] = function()
- validate_test_scope('inference')
-end
+T['generate()']['makes correct afterlines inference'] = function() validate_test_scope('inference') end
-T['generate()']['handles sections correctly'] = function()
- validate_test_scope('sections')
-end
+T['generate()']['handles sections correctly'] = function() validate_test_scope('sections') end
@@ -223,5 +212,3 @@ T['generate()']['returns correct data structure'] = function()
- expect.no_error(function()
- child.lua('_G.validate_doc_structure(MiniDoc.generate())')
- end)
+ expect.no_error(function() child.lua('_G.validate_doc_structure(MiniDoc.generate())') end)
@@ -237,5 +224,3 @@ T['generate()']['uses custom script'] = function()
-- This should execute 'gendoc/gendoc-script.lua' and return what it returns
- expect.no_error(function()
- child.lua('_G.validate_doc_structure(MiniDoc.generate())')
- end)
+ expect.no_error(function() child.lua('_G.validate_doc_structure(MiniDoc.generate())') end)
expect_equal_file_contents('output.txt', 'output_reference.txt')
diff --git a/tests/test_fuzzy.lua b/tests/test_fuzzy.lua
index 1ab51d2..94d6622 100644
--- a/tests/test_fuzzy.lua
+++ b/tests/test_fuzzy.lua
@@ -48,5 +48,4 @@ T['setup()']['validates `config` argument'] = function()
- local expect_config_error = function(config, name, target_type)
- expect.error(load_module, vim.pesc(name) .. '.*' .. vim.pesc(target_type), config)
- end
+ local expect_config_error =
+ function(config, name, target_type) expect.error(load_module, vim.pesc(name) .. '.*' .. vim.pesc(target_type), config) end
@@ -90,9 +89,6 @@ end
-T['match()']['respects order of letters'] = function()
- validate_match('abc', 'bcacbac', { 3, 5, 7 })
-end
+T['match()']['respects order of letters'] = function() validate_match('abc', 'bcacbac', { 3, 5, 7 }) end
-T['match()']['handles special characters'] = function()
- validate_match('(.+*%-)', 'a(a.a+a*a%a-a)', { 2, 4, 6, 8, 10, 12, 14 })
-end
+T['match()']['handles special characters'] =
+ function() validate_match('(.+*%-)', 'a(a.a+a*a%a-a)', { 2, 4, 6, 8, 10, 12, 14 }) end
@@ -227,5 +223,4 @@ T['get_telescope_sorter()'] = new_set()
-T['get_telescope_sorter()']['is present'] = function()
- eq(child.lua_get('MiniFuzzy.get_telescope_sorter ~= nil'), true)
-end
+T['get_telescope_sorter()']['is present'] =
+ function() eq(child.lua_get('MiniFuzzy.get_telescope_sorter ~= nil'), true) end
diff --git a/tests/test_indentscope.lua b/tests/test_indentscope.lua
index 113ad51..df063fc 100644
--- a/tests/test_indentscope.lua
+++ b/tests/test_indentscope.lua
@@ -76,5 +76,3 @@ T['setup()']['creates side effects'] = function()
-- Autocommand on `ModeChanged` event
- if child.fn.has('nvim-0.7.0') == 1 then
- eq(child.fn.exists('#MiniIndentscope#ModeChanged'), 1)
- end
+ if child.fn.has('nvim-0.7.0') == 1 then eq(child.fn.exists('#MiniIndentscope#ModeChanged'), 1) end
@@ -89,5 +87,3 @@ T['setup()']['creates `config` field'] = function()
-- Check default values
- local expect_config = function(field, value)
- eq(child.lua_get('MiniIndentscope.config.' .. field), value)
- end
+ local expect_config = function(field, value) eq(child.lua_get('MiniIndentscope.config.' .. field), value) end
@@ -114,5 +110,4 @@ T['setup()']['validates `config` argument'] = function()
- local expect_config_error = function(config, name, target_type)
- expect.error(load_module, vim.pesc(name) .. '.*' .. vim.pesc(target_type), config)
- end
+ local expect_config_error =
+ function(config, name, target_type) expect.error(load_module, vim.pesc(name) .. '.*' .. vim.pesc(target_type), config) end
@@ -148,5 +143,3 @@ T['get_scope()'] = new_set({
hooks = {
- pre_case = function()
- set_lines(example_lines)
- end,
+ pre_case = function() set_lines(example_lines) end,
},
@@ -312,5 +305,3 @@ T['move_cursor()'] = new_set({
hooks = {
- pre_case = function()
- set_lines(example_lines_nested)
- end,
+ pre_case = function() set_lines(example_lines_nested) end,
},
@@ -318,5 +309,3 @@ T['move_cursor()'] = new_set({
-local move_cursor = function(...)
- child.lua('MiniIndentscope.move_cursor(...)', { ... })
-end
+local move_cursor = function(...) child.lua('MiniIndentscope.move_cursor(...)', { ... }) end
@@ -397,6 +386,4 @@ T['draw()']['respects `config.draw.animation`'] = function()
- local command = string.format(
- 'MiniIndentscope.config.draw.animation = function() return %d end',
- 2.5 * test_times.animation_step
- )
+ local command =
+ string.format('MiniIndentscope.config.draw.animation = function() return %d end', 2.5 * test_times.animation_step)
child.lua(command)
@@ -582,5 +569,3 @@ T['Motion'] = new_set({
hooks = {
- pre_case = function()
- set_lines(example_lines_nested)
- end,
+ pre_case = function() set_lines(example_lines_nested) end,
},
@@ -746,5 +731,3 @@ T['Textobject'] = new_set({
hooks = {
- pre_case = function()
- set_lines(example_lines_nested)
- end,
+ pre_case = function() set_lines(example_lines_nested) end,
},
diff --git a/tests/test_jump.lua b/tests/test_jump.lua
index b63b58a..9b78c00 100644
--- a/tests/test_jump.lua
+++ b/tests/test_jump.lua
@@ -59,5 +59,3 @@ T['setup()']['creates `config` field'] = function()
-- Check default values
- local expect_config = function(field, value)
- eq(child.lua_get('MiniJump.config.' .. field), value)
- end
+ local expect_config = function(field, value) eq(child.lua_get('MiniJump.config.' .. field), value) end
@@ -82,5 +80,4 @@ T['setup()']['validates `config` argument'] = function()
- local expect_config_error = function(config, name, target_type)
- expect.error(load_module, vim.pesc(name) .. '.*' .. vim.pesc(target_type), config)
- end
+ local expect_config_error =
+ function(config, name, target_type) expect.error(load_module, vim.pesc(name) .. '.*' .. vim.pesc(target_type), config) end
@@ -263,5 +260,3 @@ end
-T['jump()']['does not jump if there is no place to jump'] = function()
- validate_jump([['x']], { 1, 0 })
-end
+T['jump()']['does not jump if there is no place to jump'] = function() validate_jump([['x']], { 1, 0 }) end
@@ -288,5 +283,3 @@ T['smart_jump()'] = new_set({
hooks = {
- pre_case = function()
- set_lines(example_lines)
- end,
+ pre_case = function() set_lines(example_lines) end,
},
@@ -542,5 +535,3 @@ T['Jumping with f/t/F/T']['ignores current position if it is acceptable target']
local start_col, finish_col = 0, 1
- if key ~= key:lower() then
- start_col, finish_col = 3, 2
- end
+ if key ~= key:lower() then start_col, finish_col = 3, 2 end
set_cursor(1, start_col)
@@ -787,5 +778,4 @@ T['Delayed highlighting'] = new_set({
-- conflicting file names for reference screenshots in case-insensitive OS
-T['Delayed highlighting']['works'] = new_set(
- { parametrize = { { 'forward' }, { 'forward_till' }, { 'backward' }, { 'backward_till' } } },
- {
+T['Delayed highlighting']['works'] =
+ new_set({ parametrize = { { 'forward' }, { 'forward_till' }, { 'backward' }, { 'backward_till' } } }, {
test = function(direction)
@@ -804,8 +794,6 @@ T['Delayed highlighting']['works'] = new_set(
end,
- }
-)
+ })
-T['Delayed highlighting']['respects `config.delay.highlight`'] = new_set(
- { parametrize = { { 'forward' }, { 'forward_till' }, { 'backward' }, { 'backward_till' } } },
- {
+T['Delayed highlighting']['respects `config.delay.highlight`'] =
+ new_set({ parametrize = { { 'forward' }, { 'forward_till' }, { 'backward' }, { 'backward_till' } } }, {
test = function(direction)
@@ -826,4 +814,3 @@ T['Delayed highlighting']['respects `config.delay.highlight`'] = new_set(
end,
- }
-)
+ })
diff --git a/tests/test_jump2d.lua b/tests/test_jump2d.lua
index 7cb3f85..40aaab8 100644
--- a/tests/test_jump2d.lua
+++ b/tests/test_jump2d.lua
@@ -23,5 +23,3 @@ local get_latest_message = function() return child.cmd_capture('1messages') end
local setup_windows = function()
- if child.fn.has('nvim-0.6') == 0 then
- child.o.hidden = true
- end
+ if child.fn.has('nvim-0.6') == 0 then child.o.hidden = true end
@@ -67,5 +65,3 @@ end
local setup_two_windows = function()
- if child.fn.has('nvim-0.6') == 0 then
- child.o.hidden = true
- end
+ if child.fn.has('nvim-0.6') == 0 then child.o.hidden = true end
@@ -128,5 +124,3 @@ T['setup()']['creates `config` field'] = function()
-- Check default values
- local expect_config = function(field, value)
- eq(child.lua_get('MiniJump2d.config.' .. field), value)
- end
+ local expect_config = function(field, value) eq(child.lua_get('MiniJump2d.config.' .. field), value) end
@@ -152,5 +146,4 @@ T['setup()']['validates `config` argument'] = function()
- local expect_config_error = function(config, name, target_type)
- expect.error(load_module, vim.pesc(name) .. '.*' .. vim.pesc(target_type), config)
- end
+ local expect_config_error =
+ function(config, name, target_type) expect.error(load_module, vim.pesc(name) .. '.*' .. vim.pesc(target_type), config) end
@@ -551,15 +544,9 @@ T['start()']['does not call `hook.after_jump` on jump cancel'] = new_set({
{
- function()
- child.lua('MiniJump2d.stop()')
- end,
+ function() child.lua('MiniJump2d.stop()') end,
},
{
- function()
- type_keys('<Esc>')
- end,
+ function() type_keys('<Esc>') end,
},
{
- function()
- type_keys('<C-c>')
- end,
+ function() type_keys('<C-c>') end,
},
@@ -588,5 +575,3 @@ local validate_hl_group = function(hl_group)
for _, e_mark in ipairs(extmarks) do
- if e_mark[4].virt_text[1][2] ~= hl_group then
- all_correct_hl_group = false
- end
+ if e_mark[4].virt_text[1][2] ~= hl_group then all_correct_hl_group = false end
end
@@ -632,5 +617,3 @@ T['stop()']['works even if not jumping'] = function()
local init_cursor = get_cursor()
- expect.no_error(function()
- child.lua('MiniJump2d.stop()')
- end)
+ expect.no_error(function() child.lua('MiniJump2d.stop()') end)
eq(get_cursor(), init_cursor)
@@ -706,5 +689,3 @@ T['default_spotter()'] = new_set({
hooks = {
- pre_case = function()
- child.set_size(5, 25)
- end,
+ pre_case = function() child.set_size(5, 25) end,
},
@@ -712,5 +693,3 @@ T['default_spotter()'] = new_set({
-local start_default_spotter = function()
- child.lua('MiniJump2d.start({ spotter = MiniJump2d.default_spotter })')
-end
+local start_default_spotter = function() child.lua('MiniJump2d.start({ spotter = MiniJump2d.default_spotter })') end
@@ -786,5 +765,3 @@ T['builtin_opts.single_character'] = new_set()
-local start_single_char = function()
- child.lua_notify('MiniJump2d.start(MiniJump2d.builtin_opts.single_character)')
-end
+local start_single_char = function() child.lua_notify('MiniJump2d.start(MiniJump2d.builtin_opts.single_character)') end
@@ -861,5 +838,3 @@ T['builtin_opts.query'] = new_set({
-local start_query = function()
- child.lua_notify('MiniJump2d.start(MiniJump2d.builtin_opts.query)')
-end
+local start_query = function() child.lua_notify('MiniJump2d.start(MiniJump2d.builtin_opts.query)') end
diff --git a/tests/test_misc.lua b/tests/test_misc.lua
index 946a164..6073116 100644
--- a/tests/test_misc.lua
+++ b/tests/test_misc.lua
@@ -48,5 +48,4 @@ T['setup()']['validates `config` argument'] = function()
- local expect_config_error = function(config, name, target_type)
- expect.error(load_module, vim.pesc(name) .. '.*' .. vim.pesc(target_type), config)
- end
+ local expect_config_error =
+ function(config, name, target_type) expect.error(load_module, vim.pesc(name) .. '.*' .. vim.pesc(target_type), config) end
@@ -64,5 +63,3 @@ T['bench_time()'] = new_set({
hooks = {
- pre_case = function()
- child.lua('_G.f = function(ms) ms = ms or 10; vim.loop.sleep(ms); return ms end')
- end,
+ pre_case = function() child.lua('_G.f = function(ms) ms = ms or 10; vim.loop.sleep(ms); return ms end') end,
},
@@ -232,9 +229,9 @@ local stat_summary = function(...) return child.lua_get('MiniMisc.stat_summary({
-T['stat_summary()']['works'] = function()
- eq(stat_summary(10, 4, 3, 2, 1), { minimum = 1, mean = 4, median = 3, maximum = 10, n = 5, sd = math.sqrt(50 / 4) })
-end
+T['stat_summary()']['works'] =
+ function()
+ eq(stat_summary(10, 4, 3, 2, 1), { minimum = 1, mean = 4, median = 3, maximum = 10, n = 5, sd = math.sqrt(50 / 4) })
+ end
-T['stat_summary()']['works with one number'] = function()
- eq(stat_summary(10), { minimum = 10, mean = 10, median = 10, maximum = 10, n = 1, sd = 0 })
-end
+T['stat_summary()']['works with one number'] =
+ function() eq(stat_summary(10), { minimum = 10, mean = 10, median = 10, maximum = 10, n = 1, sd = 0 }) end
diff --git a/tests/test_pairs.lua b/tests/test_pairs.lua
index 23a4aac..ea1c165 100644
--- a/tests/test_pairs.lua
+++ b/tests/test_pairs.lua
@@ -208,5 +208,3 @@ end
-local validate_slash = function(key)
- validate_neigh_disable([[\]], key)
-end
+local validate_slash = function(key) validate_neigh_disable([[\]], key) end
@@ -285,5 +283,3 @@ T['setup()']['creates `config` field'] = function()
-- Check default values
- local expect_config = function(field, value)
- eq(child.lua_get('MiniPairs.config.' .. field), value)
- end
+ local expect_config = function(field, value) eq(child.lua_get('MiniPairs.config.' .. field), value) end
@@ -320,5 +316,4 @@ T['setup()']['validates `config` argument'] = function()
- local expect_config_error = function(config, name, target_type)
- expect.error(load_module, vim.pesc(name) .. '.*' .. vim.pesc(target_type), config)
- end
+ local expect_config_error =
+ function(config, name, target_type) expect.error(load_module, vim.pesc(name) .. '.*' .. vim.pesc(target_type), config) end
@@ -506,5 +501,3 @@ T['map()/map_buf()']['respect `opts` or `pair_info` argument'] = function(fun_na
-- Throws error because mapping `(` should already exist
- expect.error(function()
- apply_map(fun_name, [['i', '(', { action = 'open', pair = '()' }, { unique = true })]])
- end)
+ expect.error(function() apply_map(fun_name, [['i', '(', { action = 'open', pair = '()' }, { unique = true })]]) end)
end
@@ -532,5 +525,3 @@ end
-local make_test_map = function(fun_name)
- apply_map(fun_name, [['i', '<', { action = 'open', pair = '<>' }]])
-end
+local make_test_map = function(fun_name) apply_map(fun_name, [['i', '<', { action = 'open', pair = '<>' }]]) end
@@ -600,5 +591,3 @@ end
T['unmap()/unmap_buf()']['require explicit `pair` argument'] = function(fun_name)
- expect.error(function()
- apply_unmap(fun_name, [['i', '(']])
- end)
+ expect.error(function() apply_unmap(fun_name, [['i', '(']]) end)
end
@@ -616,5 +605,3 @@ end
T['unmap()/unmap_buf()']['work for already missing mapping'] = function(fun_name)
- expect.no_error(function()
- apply_unmap(fun_name, [['c', '%', '%%']])
- end)
+ expect.no_error(function() apply_unmap(fun_name, [['c', '%', '%%']]) end)
end
@@ -700,5 +687,3 @@ T['Close action']['is correctly initiated in `config.mappings`'] = function()
reload_module({ mappings = { [')'] = { action = 'close', pair = '()', neigh_pattern = '..' } } })
- expect.error(function()
- validate_slash_close(')', '()')
- end)
+ expect.error(function() validate_slash_close(')', '()') end)
end
diff --git a/tests/test_sessions.lua b/tests/test_sessions.lua
index 65d8eb6..3060326 100644
--- a/tests/test_sessions.lua
+++ b/tests/test_sessions.lua
@@ -89,9 +89,5 @@ end
-local validate_no_session_loaded = function()
- eq(child.lua_get('type(_G.session_file)'), 'nil')
-end
+local validate_no_session_loaded = function() eq(child.lua_get('type(_G.session_file)'), 'nil') end
-local reset_session_indicator = function()
- child.lua('_G.session_file = nil')
-end
+local reset_session_indicator = function() child.lua('_G.session_file = nil') end
@@ -164,5 +160,3 @@ T['setup()']['creates `config` field'] = function()
-- Check default values
- local expect_config = function(field, value)
- eq(child.lua_get('MiniSessions.config.' .. field), value)
- end
+ local expect_config = function(field, value) eq(child.lua_get('MiniSessions.config.' .. field), value) end
@@ -186,5 +180,4 @@ T['setup()']['validates `config` argument'] = function()
- local expect_config_error = function(config, name, target_type)
- expect.error(load_module, vim.pesc(name) .. '.*' .. vim.pesc(target_type), config)
- end
+ local expect_config_error =
+ function(config, name, target_type) expect.error(load_module, vim.pesc(name) .. '.*' .. vim.pesc(target_type), config) end
@@ -293,5 +286,4 @@ end
-T['detected']['is an empty table if no sessions are detected'] = function()
- eq(child.lua_get('MiniSessions.detected'), {})
-end
+T['detected']['is an empty table if no sessions are detected'] =
+ function() eq(child.lua_get('MiniSessions.detected'), {}) end
@@ -308,5 +300,3 @@ T['read()']['works with no detected sessions'] = function()
eq(child.lua_get('MiniSessions.detected'), {})
- expect.error(function()
- child.lua('MiniSessions.read()')
- end, '%(mini%.sessions%) There is no detected sessions')
+ expect.error(function() child.lua('MiniSessions.read()') end, '%(mini%.sessions%) There is no detected sessions')
end
@@ -315,5 +305,6 @@ T['read()']['accepts only name of detected session'] = function()
reload_module({ autowrite = false, directory = 'tests/dir-sessions/global' })
- expect.error(function()
- child.lua([[MiniSessions.read('session-absent')]])
- end, '%(mini%.sessions%) "session%-absent" is not a name for detected session')
+ expect.error(
+ function() child.lua([[MiniSessions.read('session-absent')]]) end,
+ '%(mini%.sessions%) "session%-absent" is not a name for detected session'
+ )
validate_no_session_loaded()
@@ -341,8 +332,5 @@ T['read()']['does not source if there are unsaved listed buffers'] = function()
-- Session should not be sourced
- local error_pattern = vim.pesc(
- '(mini.sessions) There are unsaved listed buffers: ' .. table.concat(unsaved_buffers, ', ') .. '.'
- )
- expect.error(function()
- child.lua([[MiniSessions.read('session1')]])
- end, error_pattern)
+ local error_pattern =
+ vim.pesc('(mini.sessions) There are unsaved listed buffers: ' .. table.concat(unsaved_buffers, ', ') .. '.')
+ expect.error(function() child.lua([[MiniSessions.read('session1')]]) end, error_pattern)
validate_no_session_loaded()
@@ -389,5 +377,6 @@ T['read()']['respects `force` from `config` and `opts` argument'] = function()
reset_session_indicator()
- expect.error(function()
- child.lua([[MiniSessions.read('session2.vim', { force = false })]])
- end, '%(mini%.sessions%) There are unsaved listed buffers')
+ expect.error(
+ function() child.lua([[MiniSessions.read('session2.vim', { force = false })]]) end,
+ '%(mini%.sessions%) There are unsaved listed buffers'
+ )
validate_no_session_loaded()
@@ -500,5 +489,6 @@ T['write()']['validates `session_name`'] = function()
reload_module({ autowrite = false, directory = 'tests/dir-sessions/global' })
- expect.error(function()
- child.lua([[MiniSessions.write('')]])
- end, '%(mini%.sessions%) Supply non%-empty session name')
+ expect.error(
+ function() child.lua([[MiniSessions.write('')]]) end,
+ '%(mini%.sessions%) Supply non%-empty session name'
+ )
end
@@ -554,5 +544,6 @@ T['write()']['respects `force` from `config` and `opts` argument'] = function()
- expect.error(function()
- child.lua([[MiniSessions.write('existing-file')]])
- end, [[%(mini%.sessions%) Can't write to existing]])
+ expect.error(
+ function() child.lua([[MiniSessions.write('existing-file')]]) end,
+ [[%(mini%.sessions%) Can't write to existing]]
+ )
eq(child.fn.readfile(path), {})
@@ -639,5 +630,6 @@ T['delete()']['validates presence of detected sessions'] = function()
- expect.error(function()
- child.lua([[MiniSessions.delete('aaa')]])
- end, '%(mini%.sessions%) There is no detected sessions')
+ expect.error(
+ function() child.lua([[MiniSessions.delete('aaa')]]) end,
+ '%(mini%.sessions%) There is no detected sessions'
+ )
end
@@ -646,5 +638,6 @@ T['delete()']['validates `session_name`'] = function()
reload_module({ directory = 'tests/dir-sessions/global' })
- expect.error(function()
- child.lua([[MiniSessions.delete('')]])
- end, '%(mini%.sessions%) Supply non%-empty session name')
+ expect.error(
+ function() child.lua([[MiniSessions.delete('')]]) end,
+ '%(mini%.sessions%) Supply non%-empty session name'
+ )
end
@@ -700,5 +693,6 @@ T['delete()']['deletes only detected session'] = function()
-- Shouldn't delete `Session.vim` because it is not detected
- expect.error(function()
- child.lua([[MiniSessions.delete('Session.vim')]])
- end, '%(mini%.sessions%) "Session%.vim" is not a name for detected session')
+ expect.error(
+ function() child.lua([[MiniSessions.delete('Session.vim')]]) end,
+ '%(mini%.sessions%) "Session%.vim" is not a name for detected session'
+ )
end
@@ -723,5 +717,6 @@ T['delete()']['respects `force` from `config` and `opts` argument'] = function()
- expect.error(function()
- child.lua([[MiniSessions.delete('session_b', { force = false })]])
- end, [[%(mini%.sessions%) Can't delete current session]])
+ expect.error(
+ function() child.lua([[MiniSessions.delete('session_b', { force = false })]]) end,
+ [[%(mini%.sessions%) Can't delete current session]]
+ )
eq(child.fn.filereadable(path), 1)
@@ -784,5 +779,3 @@ T['delete()']['respects `vim.{g,b}.minisessions_disable`'] = new_set({
- if child.fn.filereadable(path) == 0 then
- populate_sessions()
- end
+ if child.fn.filereadable(path) == 0 then populate_sessions() end
child.lua([[MiniSessions.delete('session_a')]])
@@ -834,10 +827,6 @@ T['select()']['verifies presense of `vim.ui` and `vim.ui.select`'] = function()
child.lua('vim.ui = 1')
- expect.error(function()
- child.lua('MiniSessions.select()')
- end, '%(mini%.sessions%).*vim%.ui')
+ expect.error(function() child.lua('MiniSessions.select()') end, '%(mini%.sessions%).*vim%.ui')
child.lua('vim.ui = {}')
- expect.error(function()
- child.lua('MiniSessions.select()')
- end, '%(mini%.sessions%).*vim%.ui%.select')
+ expect.error(function() child.lua('MiniSessions.select()') end, '%(mini%.sessions%).*vim%.ui%.select')
end
@@ -845,5 +834,6 @@ end
T['select()']['validates `action` argument'] = function()
- expect.error(function()
- child.lua([[MiniSessions.select('aaa')]])
- end, [[%(mini%.sessions%) `action` should be one of 'read', 'write', or 'delete'.]])
+ expect.error(
+ function() child.lua([[MiniSessions.select('aaa')]]) end,
+ [[%(mini%.sessions%) `action` should be one of 'read', 'write', or 'delete'.]]
+ )
end
diff --git a/tests/test_starter.lua b/tests/test_starter.lua
index b1fa166..589c9a9 100644
--- a/tests/test_starter.lua
+++ b/tests/test_starter.lua
@@ -23,9 +23,5 @@ local is_starter_shown = function() return child.api.nvim_buf_get_option(0, 'fil
-local validate_starter_shown = function()
- eq(is_starter_shown(), true)
-end
+local validate_starter_shown = function() eq(is_starter_shown(), true) end
-local validate_starter_not_shown = function()
- eq(is_starter_shown(), false)
-end
+local validate_starter_not_shown = function() eq(is_starter_shown(), false) end
@@ -61,3 +57,5 @@ end
local mock_item =
- function(name, section) return { name = name, action = ('lua _G.item_name = %s'):format(vim.inspect(name)), section = section } end
+ function(name, section)
+ return { name = name, action = ('lua _G.item_name = %s'):format(vim.inspect(name)), section = section }
+ end
@@ -102,5 +100,3 @@ T['setup()']['creates side effects'] = function()
-- Highlight groups
- local has_highlight = function(group, value)
- expect.match(child.cmd_capture('hi ' .. group), value)
- end
+ local has_highlight = function(group, value) expect.match(child.cmd_capture('hi ' .. group), value) end
@@ -121,5 +117,3 @@ T['setup()']['creates `config` field'] = function()
-- Check default values
- local expect_config = function(field, value)
- eq(child.lua_get('MiniStarter.config.' .. field), value)
- end
+ local expect_config = function(field, value) eq(child.lua_get('MiniStarter.config.' .. field), value) end
@@ -142,5 +136,4 @@ T['setup()']['validates `config` argument'] = function()
- local expect_config_error = function(config, name, target_type)
- expect.error(load_module, vim.pesc(name) .. '.*' .. vim.pesc(target_type), config)
- end
+ local expect_config_error =
+ function(config, name, target_type) expect.error(load_module, vim.pesc(name) .. '.*' .. vim.pesc(target_type), config) end
@@ -442,5 +435,3 @@ T['close()']['can be used when no Starter buffer is shown'] = function()
validate_starter_not_shown()
- expect.no_error(function()
- child.lua('MiniStarter.close()')
- end)
+ expect.no_error(function() child.lua('MiniStarter.close()') end)
end
@@ -563,5 +554,3 @@ T['content_to_lines()'] = new_set({
hooks = {
- pre_case = function()
- child.lua('MiniStarter.open()')
- end,
+ pre_case = function() child.lua('MiniStarter.open()') end,
},
@@ -569,5 +558,4 @@ T['content_to_lines()'] = new_set({
-T['content_to_lines()']['works'] = function()
- eq(child.lua_get('MiniStarter.content_to_lines(MiniStarter.content)'), get_lines())
-end
+T['content_to_lines()']['works'] =
+ function() eq(child.lua_get('MiniStarter.content_to_lines(MiniStarter.content)'), get_lines()) end
@@ -667,5 +655,3 @@ T['gen_hook']['aligning()']['respects arguments'] = new_set({
hooks = {
- pre_case = function()
- child.set_size(10, 40)
- end,
+ pre_case = function() child.set_size(10, 40) end,
},
@@ -723,5 +709,3 @@ end
T['gen_hook']['indexing()'] = new_set({ hooks = {
- pre_case = function()
- child.set_size(15, 40)
- end,
+ pre_case = function() child.set_size(15, 40) end,
} })
@@ -811,5 +795,3 @@ end
T['set_query()']['validates argument'] = function()
- expect.error(function()
- child.lua('MiniStarter.set_query(1)')
- end, '`query`.*`nil` or string')
+ expect.error(function() child.lua('MiniStarter.set_query(1)') end, '`query`.*`nil` or string')
end
@@ -1097,5 +1079,3 @@ T['Cursor positioning'] = new_set({
hooks = {
- pre_case = function()
- reload_module({ items = example_items, content_hooks = {}, header = '', footer = '' })
- end,
+ pre_case = function() reload_module({ items = example_items, content_hooks = {}, header = '', footer = '' }) end,
},
diff --git a/tests/test_statusline.lua b/tests/test_statusline.lua
index 6ca972d..faa1947 100644
--- a/tests/test_statusline.lua
+++ b/tests/test_statusline.lua
@@ -22,5 +22,3 @@ local setup_windows = function()
-- Ensure only two windows
- if #child.api.nvim_list_wins() > 1 then
- child.cmd('only')
- end
+ if #child.api.nvim_list_wins() > 1 then child.cmd('only') end
child.cmd('vsplit')
@@ -39,5 +37,3 @@ end
-- Mocks
-local mock_devicons = function()
- child.cmd('set rtp+=tests/dir-statusline')
-end
+local mock_devicons = function() child.cmd('set rtp+=tests/dir-statusline') end
@@ -59,5 +55,3 @@ end
-local mock_diagnostics = function()
- child.cmd('luafile tests/dir-statusline/mock-diagnostics.lua')
-end
+local mock_diagnostics = function() child.cmd('luafile tests/dir-statusline/mock-diagnostics.lua') end
@@ -71,5 +65,3 @@ end
-local unmock_file = function()
- pcall(vim.fn.delete, mocked_filepath)
-end
+local unmock_file = function() pcall(vim.fn.delete, mocked_filepath) end
@@ -101,5 +93,3 @@ T['setup()']['creates side effects'] = function()
-- Highlight groups
- local has_highlight = function(group, value)
- expect.match(child.cmd_capture('hi ' .. group), value)
- end
+ local has_highlight = function(group, value) expect.match(child.cmd_capture('hi ' .. group), value) end
@@ -121,5 +111,3 @@ T['setup()']['creates `config` field'] = function()
-- Check default values
- local expect_config = function(field, value)
- eq(child.lua_get('MiniStatusline.config.' .. field), value)
- end
+ local expect_config = function(field, value) eq(child.lua_get('MiniStatusline.config.' .. field), value) end
@@ -138,5 +126,4 @@ T['setup()']['validates `config` argument'] = function()
- local expect_config_error = function(config, name, target_type)
- expect.error(load_module, vim.pesc(name) .. '.*' .. vim.pesc(target_type), config)
- end
+ local expect_config_error =
+ function(config, name, target_type) expect.error(load_module, vim.pesc(name) .. '.*' .. vim.pesc(target_type), config) end
@@ -151,5 +138,4 @@ end
T['setup()']['sets proper autocommands'] = function()
- local validate = function(win_id, field)
- eq(child.api.nvim_win_get_option(win_id, 'statusline'), '%!v:lua.MiniStatusline.' .. field .. '()')
- end
+ local validate =
+ function(win_id, field) eq(child.api.nvim_win_get_option(win_id, 'statusline'), '%!v:lua.MiniStatusline.' .. field .. '()') end
@@ -181,5 +167,4 @@ local example_groups = {
-T['combine_groups()']['works'] = function()
- eq(combine_groups(example_groups), '%#AA# a1 a2 %#BB# b1 b2 %=%#CC# c1 ')
-end
+T['combine_groups()']['works'] =
+ function() eq(combine_groups(example_groups), '%#AA# a1 a2 %#BB# b1 b2 %=%#CC# c1 ') end
@@ -192,5 +177,4 @@ end
-T['combine_groups()']['uses only non-empty strings from `strings` field'] = function()
- eq(combine_groups({ { hl = 'AA', strings = { 'a', 1, {}, true, '', 'b' } } }), '%#AA# a b ')
-end
+T['combine_groups()']['uses only non-empty strings from `strings` field'] =
+ function() eq(combine_groups({ { hl = 'AA', strings = { 'a', 1, {}, true, '', 'b' } } }), '%#AA# a b ') end
@@ -215,6 +199,4 @@ T['active()/inactive()']['respects `config.content`'] = function(field)
unload_module()
- local command = string.format(
- [[require('mini.statusline').setup({ content = { %s = function() return 'aaa' end } })]],
- field
- )
+ local command =
+ string.format([[require('mini.statusline').setup({ content = { %s = function() return 'aaa' end } })]], field)
child.lua(command)
@@ -401,5 +383,4 @@ T['section_location()'] = new_set()
-T['section_location()']['works'] = function()
- eq(child.lua_get('MiniStatusline.section_location({})'), '%l|%L│%2v|%-2{virtcol("$") - 1}')
-end
+T['section_location()']['works'] =
+ function() eq(child.lua_get('MiniStatusline.section_location({})'), '%l|%L│%2v|%-2{virtcol("$") - 1}') end
@@ -416,5 +397,3 @@ local section_mode = function(args) return child.lua_get('{ MiniStatusline.secti
-T['section_mode()']['works'] = function()
- eq(section_mode(), { 'Normal', 'MiniStatuslineModeNormal' })
-end
+T['section_mode()']['works'] = function() eq(section_mode(), { 'Normal', 'MiniStatuslineModeNormal' }) end
diff --git a/tests/test_surround.lua b/tests/test_surround.lua
index d578ac2..52b0b75 100644
--- a/tests/test_surround.lua
+++ b/tests/test_surround.lua
@@ -21,5 +21,3 @@ local sleep = function(ms) vim.loop.sleep(ms); poke_eventloop() end
-- Make helpers
-local clear_messages = function()
- child.cmd('messages clear')
-end
+local clear_messages = function() child.cmd('messages clear') end
@@ -92,5 +90,3 @@ T['setup()']['creates `config` field'] = function()
-- Check default values
- local expect_config = function(field, value)
- eq(child.lua_get('MiniSurround.config.' .. field), value)
- end
+ local expect_config = function(field, value) eq(child.lua_get('MiniSurround.config.' .. field), value) end
@@ -119,5 +115,4 @@ T['setup()']['validates `config` argument'] = function()
- local expect_config_error = function(config, name, target_type)
- expect.error(load_module, vim.pesc(name) .. '.*' .. vim.pesc(target_type), config)
- end
+ local expect_config_error =
+ function(config, name, target_type) expect.error(load_module, vim.pesc(name) .. '.*' .. vim.pesc(target_type), config) end
@@ -1126,8 +1121,4 @@ T['Default single character surrounding']['has limited support of multibyte char
-- single character input. It would be great to fix this.
- expect.error(function()
- validate_edit({ 'ыaaaы' }, { 1, 3 }, { 'aaa' }, { 1, 0 }, type_keys, 'sd', 'ы')
- end)
- expect.error(function()
- validate_edit({ '(aaa)' }, { 1, 2 }, { 'ыaaaы' }, { 1, 2 }, type_keys, 'sr', ')', 'ы')
- end)
+ expect.error(function() validate_edit({ 'ыaaaы' }, { 1, 3 }, { 'aaa' }, { 1, 0 }, type_keys, 'sd', 'ы') end)
+ expect.error(function() validate_edit({ '(aaa)' }, { 1, 2 }, { 'ыaaaы' }, { 1, 2 }, type_keys, 'sr', ')', 'ы') end)
end
@@ -1202,5 +1193,3 @@ T['Function call surrounding']['has limited support of multibyte characters'] =
-- character in name. It would be great to fix this.
- expect.error(function()
- validate_edit({ 'ыыы(aaa)' }, { 1, 8 }, { 'aaa' }, { 1, 0 }, type_keys, 'sd', 'f')
- end)
+ expect.error(function() validate_edit({ 'ыыы(aaa)' }, { 1, 8 }, { 'aaa' }, { 1, 0 }, type_keys, 'sd', 'f') end)
@@ -1255,5 +1244,4 @@ end
-T['Tag surrounding']['detects tag with the same name'] = function()
- validate_edit({ '<x><y>a</x></y>' }, { 1, 1 }, { '_<y>a_</y>' }, { 1, 1 }, type_keys, 'sr', 't', '_')
-end
+T['Tag surrounding']['detects tag with the same name'] =
+ function() validate_edit({ '<x><y>a</x></y>' }, { 1, 1 }, { '_<y>a_</y>' }, { 1, 1 }, type_keys, 'sr', 't', '_') end
@@ -1309,5 +1297,3 @@ T['Tag surrounding']['has limited support of multibyte characters'] = function()
-- name. It would be great to fix this.
- expect.error(function()
- validate_edit({ '<ы>aaa</ы>' }, { 1, 5 }, { 'aaa' }, { 1, 0 }, type_keys, 'sd', 't')
- end)
+ expect.error(function() validate_edit({ '<ы>aaa</ы>' }, { 1, 5 }, { 'aaa' }, { 1, 0 }, type_keys, 'sd', 't') end)
@@ -1448,5 +1434,3 @@ T['Custom surrounding']['validates two captures in `input.extract`'] = function(
child.o.cmdheight = 40
- expect.error(function()
- validate_edit({ '#a#' }, { 1, 1 }, { 'a' }, { 1, 0 }, type_keys, 'sd', '#')
- end)
+ expect.error(function() validate_edit({ '#a#' }, { 1, 1 }, { 'a' }, { 1, 0 }, type_keys, 'sd', '#') end)
end
diff --git a/tests/test_tabline.lua b/tests/test_tabline.lua
index 05a054f..6238f82 100644
--- a/tests/test_tabline.lua
+++ b/tests/test_tabline.lua
@@ -15,13 +15,7 @@ local set_lines = function(...) return child.set_lines(...) end
-- Make helpers
-local mock_devicons = function()
- child.cmd('set rtp+=tests/dir-tabline')
-end
+local mock_devicons = function() child.cmd('set rtp+=tests/dir-tabline') end
-local edit = function(name)
- child.cmd('edit ' .. name)
-end
+local edit = function(name) child.cmd('edit ' .. name) end
-local edit_path = function(rel_path)
- child.cmd('edit tests/dir-tabline/' .. rel_path)
-end
+local edit_path = function(rel_path) child.cmd('edit tests/dir-tabline/' .. rel_path) end
@@ -30,5 +24,3 @@ local eval_tabline = function(show_hl, show_action)
- if not show_hl then
- res = res:gsub('%%#%w+#', '')
- end
+ if not show_hl then res = res:gsub('%%#%w+#', '') end
@@ -61,5 +53,3 @@ T['setup()']['creates side effects'] = function()
-- Highlight groups
- local has_highlight = function(group, value)
- expect.match(child.cmd_capture('hi ' .. group), value)
- end
+ local has_highlight = function(group, value) expect.match(child.cmd_capture('hi ' .. group), value) end
@@ -79,5 +69,3 @@ T['setup()']['creates `config` field'] = function()
-- Check default values
- local expect_config = function(field, value)
- eq(child.lua_get('MiniTabline.config.' .. field), value)
- end
+ local expect_config = function(field, value) eq(child.lua_get('MiniTabline.config.' .. field), value) end
@@ -96,5 +84,4 @@ T['setup()']['validates `config` argument'] = function()
- local expect_config_error = function(config, name, target_type)
- expect.error(load_module, vim.pesc(name) .. '.*' .. vim.pesc(target_type), config)
- end
+ local expect_config_error =
+ function(config, name, target_type) expect.error(load_module, vim.pesc(name) .. '.*' .. vim.pesc(target_type), config) end
@@ -557,5 +544,3 @@ T['Mouse click'] = new_set()
-local click = function(column)
- child.api.nvim_input_mouse('left', 'press', '', 0, 0, column)
-end
+local click = function(column) child.api.nvim_input_mouse('left', 'press', '', 0, 0, column) end
diff --git a/tests/test_test.lua b/tests/test_test.lua
index 99c7ba0..ac215a0 100644
--- a/tests/test_test.lua
+++ b/tests/test_test.lua
@@ -21,5 +21,3 @@ local get_ref_path = function(name) return string.format('tests/dir-test/%s', na
local skip_screenshot = function()
- if child.fn.has('nvim-0.6') == 0 then
- MiniTest.skip('Neovim version is not enough for `child.get_screenshot()`')
- end
+ if child.fn.has('nvim-0.6') == 0 then MiniTest.skip('Neovim version is not enough for `child.get_screenshot()`') end
end
@@ -67,5 +65,3 @@ local expect_all_state = function(cases, state)
for _, c in ipairs(cases) do
- if type(c.exec) ~= 'table' or c.exec.state ~= state then
- res = false
- end
+ if type(c.exec) ~= 'table' or c.exec.state ~= state then res = false end
end
@@ -102,5 +98,3 @@ T['setup()']['creates `config` field'] = function()
-- Check default values
- local expect_config = function(field, value)
- eq(child.lua_get('MiniTest.config.' .. field), value)
- end
+ local expect_config = function(field, value) eq(child.lua_get('MiniTest.config.' .. field), value) end
@@ -222,5 +216,6 @@ end
T['run()']['validates `parametrize`'] = function()
- expect.error(function()
- testrun_ref_file('testref_run-parametrize-error.lua')
- end, [[`parametrize` should have only tables. Got "a"]])
+ expect.error(
+ function() testrun_ref_file('testref_run-parametrize-error.lua') end,
+ [[`parametrize` should have only tables. Got "a"]]
+ )
end
@@ -285,5 +280,4 @@ T['run_file()']['works'] = function()
child.lua([[MiniTest.run_file(...)]], { get_ref_path('testref_run.lua') })
- local last_desc = child.lua_get(
- [[vim.tbl_map(function(case) return case.desc[#case.desc] end, MiniTest.current.all_cases)]]
- )
+ local last_desc =
+ child.lua_get([[vim.tbl_map(function(case) return case.desc[#case.desc] end, MiniTest.current.all_cases)]])
eq(last_desc, { 'run_at_location()', 'extra case' })
@@ -476,5 +470,3 @@ T['stop()']['respects `close_all_child_neovim` option'] = function()
-- Register cleanup
- finally(function()
- child.lua('_G.grandchild.stop()')
- end)
+ finally(function() child.lua('_G.grandchild.stop()') end)
child.lua([[MiniTest.execute(
@@ -507,5 +499,3 @@ T['is_executing()']['works'] = function()
for _, s in ipairs(child.lua_get('_G.executing_states')) do
- if s ~= true then
- all_true = false
- end
+ if s ~= true then all_true = false end
end
@@ -577,5 +567,6 @@ T['expect']['error()']['works'] = function()
- expect.error(function()
- MiniTest.expect.error(error, 'bb')
- end, 'error matching pattern "bb"%..*Observed error:.*Traceback:')
+ expect.error(
+ function() MiniTest.expect.error(error, 'bb') end,
+ 'error matching pattern "bb"%..*Observed error:.*Traceback:'
+ )
end
@@ -597,13 +588,7 @@ T['expect']['error()']['accepts function arguments'] = function()
- expect.no_error(function()
- MiniTest.expect.error(f, 'not equal', 1, 2)
- end)
- expect.error(function()
- MiniTest.expect.error(f, 'not equal', 1, 1)
- end)
+ expect.no_error(function() MiniTest.expect.error(f, 'not equal', 1, 2) end)
+ expect.error(function() MiniTest.expect.error(f, 'not equal', 1, 1) end)
end
-T['expect']['error()']['returns `true` on success'] = function()
- eq(MiniTest.expect.error(error), true)
-end
+T['expect']['error()']['returns `true` on success'] = function() eq(MiniTest.expect.error(error), true) end
@@ -612,5 +597,3 @@ T['expect']['no_error()'] = new_set()
T['expect']['no_error()']['works'] = function()
- expect.error(function()
- MiniTest.expect.no_error(error)
- end, '%*no%* error%..*Observed error:.*Traceback:')
+ expect.error(function() MiniTest.expect.no_error(error) end, '%*no%* error%..*Observed error:.*Traceback:')
@@ -627,8 +610,4 @@ T['expect']['no_error()']['accepts function arguments'] = function()
- expect.error(function()
- MiniTest.expect.no_error(f, 1, 2)
- end)
- expect.no_error(function()
- MiniTest.expect.no_error(f, 1, 1)
- end)
+ expect.error(function() MiniTest.expect.no_error(f, 1, 2) end)
+ expect.no_error(function() MiniTest.expect.no_error(f, 1, 1) end)
end
@@ -651,5 +630,6 @@ T['expect']['reference_screenshot()']['works'] = function()
set_lines({ 'bbb' })
- expect.error(function()
- MiniTest.expect.reference_screenshot(child.get_screenshot(), path)
- end, 'screenshot equality to reference at ' .. vim.pesc(vim.inspect(path)) .. '.*Reference:.*Observed:.*Traceback:')
+ expect.error(
+ function() MiniTest.expect.reference_screenshot(child.get_screenshot(), path) end,
+ 'screenshot equality to reference at ' .. vim.pesc(vim.inspect(path)) .. '.*Reference:.*Observed:.*Traceback:'
+ )
@@ -664,5 +644,3 @@ T['expect']['reference_screenshot()']['locates problem'] = function()
local validate = function(screen, pattern)
- expect.error(function()
- MiniTest.expect.reference_screenshot(screen, path)
- end, pattern)
+ expect.error(function() MiniTest.expect.reference_screenshot(screen, path) end, pattern)
end
@@ -732,6 +710,4 @@ local special_characters = string.char(0) .. string.char(1) .. string.char(31)
local suffix = useful_punctuation .. linux_forbidden .. windows_forbidden .. whitespace .. special_characters
-T['expect']['reference_screenshot()']['correctly sanitizes path ' .. suffix] = new_set(
- { parametrize = { { suffix } } },
- { test = validate_path_sanitize }
-)
+T['expect']['reference_screenshot()']['correctly sanitizes path ' .. suffix] =
+ new_set({ parametrize = { { suffix } } }, { test = validate_path_sanitize })
@@ -791,5 +767,3 @@ T['expect']['reference_screenshot()']['works with multibyte characters'] = funct
set_lines({ '  1  2' })
- expect.no_error(function()
- MiniTest.expect.reference_screenshot(child.get_screenshot())
- end)
+ expect.no_error(function() MiniTest.expect.reference_screenshot(child.get_screenshot()) end)
end
@@ -799,7 +773,4 @@ T['new_expectation()'] = new_set()
T['new_expectation()']['works'] = function()
- local expect_truthy = MiniTest.new_expectation(
- 'truthy',
- function(x) return x end,
- function(x) return 'Object: ' .. vim.inspect(x) end
- )
+ local expect_truthy =
+ MiniTest.new_expectation('truthy', function(x) return x end, function(x) return 'Object: ' .. vim.inspect(x) end)
@@ -810,7 +781,4 @@ end
T['new_expectation()']['allows string or function arguments'] = function()
- local expect_truthy = MiniTest.new_expectation(
- function() return 'func_truthy' end,
- function(x) return x end,
- 'Not truthy'
- )
+ local expect_truthy =
+ MiniTest.new_expectation(function() return 'func_truthy' end, function(x) return x end, 'Not truthy')
@@ -823,5 +791,3 @@ T['new_child_neovim()'] = new_set()
T['new_child_neovim()']['works'] = function()
- finally(function()
- child.lua('_G.grandchild.stop()')
- end)
+ finally(function() child.lua('_G.grandchild.stop()') end)
child.lua('_G.grandchild = MiniTest.new_child_neovim(); _G.grandchild.start()')
@@ -968,5 +934,3 @@ end
-T['child']['scoped variables']['field'] = function(scope)
- validate_child_field(scope, 'char', 'a')
-end
+T['child']['scoped variables']['field'] = function(scope) validate_child_field(scope, 'char', 'a') end
@@ -982,5 +946,4 @@ end
-T['child']['scoped options']['field'] = function(tbl_name, field_name, value)
- validate_child_field(tbl_name, field_name, value)
-end
+T['child']['scoped options']['field'] =
+ function(tbl_name, field_name, value) validate_child_field(tbl_name, field_name, value) end
@@ -1006,5 +969,4 @@ end
-T['child']['type_keys()']['throws error explicitly'] = function()
- expect.error(child.type_keys, 'E492: Not an editor command: aaa', ':aaa<CR>')
-end
+T['child']['type_keys()']['throws error explicitly'] =
+ function() expect.error(child.type_keys, 'E492: Not an editor command: aaa', ':aaa<CR>') end
@@ -1095,5 +1057,4 @@ T['child']['ensure_normal_mode()']['works'] = new_set({ parametrize = { { 'i' },
-T['child']['ensure_normal_mode()']['ensures running'] = function()
- validate_child_method(child.ensure_normal_mode, { prevent_hanging = false })
-end
+T['child']['ensure_normal_mode()']['ensures running'] =
+ function() validate_child_method(child.ensure_normal_mode, { prevent_hanging = false }) end
diff --git a/tests/test_trailspace.lua b/tests/test_trailspace.lua
index 83cd46f..c2b2bd5 100644
--- a/tests/test_trailspace.lua
+++ b/tests/test_trailspace.lua
@@ -18,5 +18,3 @@ local type_keys = function(...) return child.type_keys(...) end
-- Make helpers
-local ensure_no_highlighting = function()
- child.fn.clearmatches()
-end
+local ensure_no_highlighting = function() child.fn.clearmatches() end
@@ -70,5 +68,4 @@ T['setup()']['validates `config` argument'] = function()
- local expect_config_error = function(config, name, target_type)
- expect.error(load_module, vim.pesc(name) .. '.*' .. vim.pesc(target_type), config)
- end
+ local expect_config_error =
+ function(config, name, target_type) expect.error(load_module, vim.pesc(name) .. '.*' .. vim.pesc(target_type), config) end
@@ -148,5 +145,3 @@ T['unhighlight()'] = new_set({
hooks = {
- pre_case = function()
- child.lua('MiniTrailspace.highlight()')
- end,
+ pre_case = function() child.lua('MiniTrailspace.highlight()') end,
},
diff --git a/.stylua.toml b/.stylua.toml
index 6601564..b865102 100644
--- a/.stylua.toml
+++ b/.stylua.toml
@@ -4,3 +4,4 @@ indent_type = "Spaces"
indent_width = 2
quote_style = "AutoPreferSingle"
no_call_parentheses = false
+collapse_simple_statement = "ConditionalOnly"
diff --git a/lua/mini/base16.lua b/lua/mini/base16.lua
index ddc6e7d..64b6e05 100644
--- a/lua/mini/base16.lua
+++ b/lua/mini/base16.lua
@@ -308,9 +308,7 @@ function H.validate_base16_palette(x, x_name)
end
function H.validate_use_cterm(x, x_name)
- if not x or type(x) == 'boolean' then
- return true
- end
+ if not x or type(x) == 'boolean' then return true end
if type(x) ~= 'table' then
local msg = string.format('(mini.base16) `%s` should be boolean or table with cterm colors.', x_name)
@@ -752,9 +750,7 @@ H.cterm_first16 = {
H.cterm_basis = { 0, 95, 135, 175, 215, 255 }
function H.cterm2rgb(i)
- if i < 16 then
- return H.cterm_first16[i + 1]
- end
+ if i < 16 then return H.cterm_first16[i + 1] end
if 16 <= i and i <= 231 then
i = i - 16
local r = H.cterm_basis[math.floor(i / 36) % 6 + 1]
@@ -769,9 +765,7 @@ function H.cterm2rgb(i)
end
function H.ensure_cterm_palette()
- if H.cterm_palette then
- return
- end
+ if H.cterm_palette then return end
H.cterm_palette = {}
for i = 0, 255 do
H.cterm_palette[i] = H.cterm2rgb(i)
@@ -869,9 +863,7 @@ H.ref_v = (9 * 100) / (95.047 + (15 * 100) + (3 * 108.883))
function H.xyz2luv(xyz)
local x, y, z = xyz.x, xyz.y, xyz.z
- if x + y + z == 0 then
- return { l = 0, u = 0, v = 0 }
- end
+ if x + y + z == 0 then return { l = 0, u = 0, v = 0 } end
local var_u = 4 * x / (x + 15 * y + 3 * z)
local var_v = 9 * y / (x + 15 * y + 3 * z)
@@ -889,9 +881,7 @@ function H.xyz2luv(xyz)
end
function H.luv2xyz(luv)
- if luv.l == 0 then
- return { x = 0, y = 0, z = 0 }
- end
+ if luv.l == 0 then return { x = 0, y = 0, z = 0 } end
local var_y = (luv.l + 16) / 116
if var_y ^ 3 > 0.008856 then
diff --git a/lua/mini/bufremove.lua b/lua/mini/bufremove.lua
index 13a99a8..8c7b4b0 100644
--- a/lua/mini/bufremove.lua
+++ b/lua/mini/bufremove.lua
@@ -78,9 +78,7 @@ MiniBufremove.config = {
---
---@return boolean Whether operation was successful.
function MiniBufremove.delete(buf_id, force)
- if H.is_disabled() then
- return
- end
+ if H.is_disabled() then return end
return H.unshow_and_cmd(buf_id, force, 'bdelete')
end
@@ -94,9 +92,7 @@ end
---
---@return boolean Whether operation was successful.
function MiniBufremove.wipeout(buf_id, force)
- if H.is_disabled() then
- return
- end
+ if H.is_disabled() then return end
return H.unshow_and_cmd(buf_id, force, 'bwipeout')
end
@@ -108,15 +104,11 @@ end
---
---@return boolean Whether operation was successful.
function MiniBufremove.unshow(buf_id)
- if H.is_disabled() then
- return
- end
+ if H.is_disabled() then return end
buf_id = H.normalize_buf_id(buf_id)
- if not H.is_valid_id(buf_id, 'buffer') then
- return false
- end
+ if not H.is_valid_id(buf_id, 'buffer') then return false end
vim.tbl_map(MiniBufremove.unshow_in_window, vim.fn.win_findbuf(buf_id))
@@ -130,15 +122,11 @@ end
---
---@return boolean Whether operation was successful.
function MiniBufremove.unshow_in_window(win_id)
- if H.is_disabled() then
- return nil
- end
+ if H.is_disabled() then return nil end
win_id = (win_id == nil) and 0 or win_id
- if not H.is_valid_id(win_id, 'window') then
- return false
- end
+ if not H.is_valid_id(win_id, 'window') then return false end
local cur_buf = vim.api.nvim_win_get_buf(win_id)
@@ -153,9 +141,7 @@ function MiniBufremove.unshow_in_window(win_id)
-- Try using previous buffer
vim.cmd('bprevious')
- if cur_buf ~= vim.api.nvim_win_get_buf(win_id) then
- return
- end
+ if cur_buf ~= vim.api.nvim_win_get_buf(win_id) then return end
-- Create new listed scratch buffer
local new_buf = vim.api.nvim_create_buf(true, true)
@@ -211,9 +197,7 @@ function H.unshow_and_cmd(buf_id, force, cmd)
end
local fun_name = ({ ['bdelete'] = 'delete', ['bwipeout'] = 'wipeout' })[cmd]
- if not H.can_remove(buf_id, force, fun_name) then
- return false
- end
+ if not H.can_remove(buf_id, force, fun_name) then return false end
-- Unshow buffer from all windows
MiniBufremove.unshow(buf_id)
@@ -252,9 +236,7 @@ end
-- Check if buffer can be removed with `MiniBufremove.fun_name` function
function H.can_remove(buf_id, force, fun_name)
- if force then
- return true
- end
+ if force then return true end
if vim.api.nvim_buf_get_option(buf_id, 'modified') then
H.message(
@@ -273,9 +255,7 @@ end
-- Compute 'true' buffer id (strictly positive integer). Treat `nil` and 0 as
-- current buffer.
function H.normalize_buf_id(buf_id)
- if buf_id == nil or buf_id == 0 then
- return vim.api.nvim_get_current_buf()
- end
+ if buf_id == nil or buf_id == 0 then return vim.api.nvim_get_current_buf() end
return buf_id
end
diff --git a/lua/mini/comment.lua b/lua/mini/comment.lua
index f5fdc8c..29d4f1c 100644
--- a/lua/mini/comment.lua
+++ b/lua/mini/comment.lua
@@ -99,9 +99,7 @@ MiniComment.config = {
---@return string 'g@' if called without argument, '' otherwise (but after
--- performing action).
function MiniComment.operator(mode)
- if H.is_disabled() then
- return ''
- end
+ if H.is_disabled() then return '' end
-- If used without arguments inside expression mapping:
-- - Set itself as `operatorfunc` to be called later to perform action.
@@ -128,9 +126,7 @@ function MiniComment.operator(mode)
-- Do nothing if "left" mark is not on the left (earlier in text) of "right"
-- mark (indicating that there is nothing to do, like in comment textobject).
- if (line_left > line_right) or (line_left == line_right and col_left > col_right) then
- return
- end
+ if (line_left > line_right) or (line_left == line_right and col_left > col_right) then return end
-- Using `vim.cmd()` wrapper to allow usage of `lockmarks` command, because
-- raw execution will delete marks inside region (due to
@@ -157,9 +153,7 @@ end
---@param line_start number Start line number (inclusive from 1 to number of lines).
---@param line_end number End line number (inclusive from 1 to number of lines).
function MiniComment.toggle_lines(line_start, line_end)
- if H.is_disabled() then
- return
- end
+ if H.is_disabled() then return end
local n_lines = vim.api.nvim_buf_line_count(0)
if not (1 <= line_start and line_start <= n_lines and 1 <= line_end and line_end <= n_lines) then
@@ -204,9 +198,7 @@ end
--- Before successful textobject usage it executes `MiniComment.config.hooks.pre`.
--- After successful textobject usage it executes `MiniComment.config.hooks.post`.
function MiniComment.textobject()
- if H.is_disabled() then
- return
- end
+ if H.is_disabled() then return end
MiniComment.config.hooks.pre()
@@ -379,9 +371,7 @@ function H.make_uncomment_function(comment_parts)
return function(line)
local indent, new_line = string.match(line, uncomment_regex)
-- Return original if line is not commented
- if new_line == nil then
- return line
- end
+ if new_line == nil then return line end
-- Remove indent if line is a commented empty line
if new_line == '' then
indent = ''
diff --git a/lua/mini/completion.lua b/lua/mini/completion.lua
index 05008a3..041b0a8 100644
--- a/lua/mini/completion.lua
+++ b/lua/mini/completion.lua
@@ -298,9 +298,7 @@ MiniCompletion.config = {
--- Designed to be used with |autocmd|. No need to use it directly, everything
--- is setup in |MiniCompletion.setup|.
function MiniCompletion.auto_completion()
- if H.is_disabled() then
- return
- end
+ if H.is_disabled() then return end
H.completion.timer:stop()
@@ -352,9 +350,7 @@ end
---@param fallback boolean Whether to use fallback completion.
---@param force boolean Whether to force update of completion popup.
function MiniCompletion.complete_twostage(fallback, force)
- if H.is_disabled() then
- return
- end
+ if H.is_disabled() then return end
H.stop_completion()
H.completion.fallback, H.completion.force = fallback or true, force or true
@@ -363,9 +359,7 @@ end
--- Run fallback completion
function MiniCompletion.complete_fallback()
- if H.is_disabled() then
- return
- end
+ if H.is_disabled() then return end
H.stop_completion()
H.completion.fallback, H.completion.force = true, true
@@ -377,9 +371,7 @@ end
--- Designed to be used with |autocmd|. No need to use it directly, everything
--- is setup in |MiniCompletion.setup|.
function MiniCompletion.auto_info()
- if H.is_disabled() then
- return
- end
+ if H.is_disabled() then return end
H.info.timer:stop()
@@ -397,9 +389,7 @@ function MiniCompletion.auto_info()
H.info.id = H.info.id + 1
-- Don't even try to show info if nothing is selected in popup
- if vim.tbl_isempty(H.info.event.completed_item) then
- return
- end
+ if vim.tbl_isempty(H.info.event.completed_item) then return end
H.info.timer:start(MiniCompletion.config.delay.info, 0, vim.schedule_wrap(H.show_info_window))
end
@@ -409,20 +399,14 @@ end
--- Designed to be used with |autocmd|. No need to use it directly, everything
--- is setup in |MiniCompletion.setup|.
function MiniCompletion.auto_signature()
- if H.is_disabled() then
- return
- end
+ if H.is_disabled() then return end
H.signature.timer:stop()
- if not H.has_lsp_clients('signatureHelpProvider') then
- return
- end
+ if not H.has_lsp_clients('signatureHelpProvider') then return end
local left_char = H.get_left_char()
local char_is_trigger = left_char == ')' or H.is_lsp_trigger(left_char, 'signature')
- if not char_is_trigger then
- return
- end
+ if not char_is_trigger then return end
H.signature.timer:start(MiniCompletion.config.delay.signature, 0, vim.schedule_wrap(H.show_signature_window))
end
@@ -508,9 +492,7 @@ function MiniCompletion.completefunc_lsp(findstart, base)
-- filtered with one `base` in the other route of this function. Anyway,
-- the most common situation is with one attached LSP client.
local cancel_fun = vim.lsp.buf_request_all(bufnr, 'textDocument/completion', params, function(result)
- if not H.is_lsp_current(H.completion, current_id) then
- return
- end
+ if not H.is_lsp_current(H.completion, current_id) then return end
H.completion.lsp.status = 'received'
H.completion.lsp.result = result
@@ -529,16 +511,12 @@ function MiniCompletion.completefunc_lsp(findstart, base)
return {}
end
else
- if findstart == 1 then
- return H.get_completion_start()
- end
+ if findstart == 1 then return H.get_completion_start() end
local words = H.process_lsp_response(H.completion.lsp.result, function(response, client_id)
-- Response can be `CompletionList` with 'items' field or `CompletionItem[]`
local items = H.table_get(response, { 'items' }) or response
- if type(items) ~= 'table' then
- return {}
- end
+ if type(items) ~= 'table' then return {} end
items = MiniCompletion.config.lsp_completion.process_items(items, base)
return H.lsp_completion_response_items_to_complete_items(items, client_id)
end)
@@ -702,9 +680,7 @@ function H.trigger_twostep()
-- delay), these still match.
local allow_trigger = (vim.fn.mode() == 'i')
and (H.completion.force or (H.completion.text_changed_id == H.text_changed_id))
- if not allow_trigger then
- return
- end
+ if not allow_trigger then return end
if H.has_lsp_clients('completionProvider') and H.has_lsp_completion() then
H.trigger_lsp()
@@ -792,18 +768,12 @@ H.stop_actions = {
---@private
function H.has_lsp_clients(capability)
local clients = vim.lsp.buf_get_clients()
- if vim.tbl_isempty(clients) then
- return false
- end
- if not capability then
- return true
- end
+ if vim.tbl_isempty(clients) then return false end
+ if not capability then return true end
for _, c in pairs(clients) do
local has_capability = H.table_get(c.server_capabilities, capability)
- if has_capability then
- return true
- end
+ if has_capability then return true end
end
return false
end
@@ -822,9 +792,7 @@ function H.is_lsp_trigger(char, type)
for _, client in pairs(vim.lsp.buf_get_clients()) do
triggers = H.table_get(client, { 'server_capabilities', providers[type], 'triggerCharacters' })
- if vim.tbl_contains(triggers or {}, char) then
- return true
- end
+ if vim.tbl_contains(triggers or {}, char) then return true end
end
return false
end
@@ -845,9 +813,7 @@ function H.cancel_lsp(caches)
end
function H.process_lsp_response(request_result, processor)
- if not request_result then
- return {}
- end
+ if not request_result then return {} end
local res = {}
for client_id, item in pairs(request_result) do
@@ -870,9 +836,7 @@ end
-- For extra information see 'Response' section:
-- https://microsoft.github.io/language-server-protocol/specifications/specification-3-14/#textDocument_completion
function H.lsp_completion_response_items_to_complete_items(items, client_id)
- if vim.tbl_count(items) == 0 then
- return {}
- end
+ if vim.tbl_count(items) == 0 then return {} end
local res = {}
local docs, info
@@ -927,9 +891,7 @@ function H.apply_additional_text_edits()
client_id = lsp_data.client_id
end
- if edits == nil then
- return
- end
+ if edits == nil then return end
client_id = client_id or 0
-- Use extmark to track relevant cursor postion after text edits
@@ -947,17 +909,13 @@ end
-- Completion item info -------------------------------------------------------
function H.show_info_window()
local event = H.info.event
- if not event then
- return
- end
+ if not event then return end
-- Try first to take lines from LSP request result.
local lines
if H.info.lsp.status == 'received' then
lines = H.process_lsp_response(H.info.lsp.result, function(response)
- if not response.documentation then
- return {}
- end
+ if not response.documentation then return {} end
local res = vim.lsp.util.convert_input_to_markdown_lines(response.documentation)
return vim.lsp.util.trim_empty_lines(res)
end)
@@ -968,9 +926,7 @@ function H.show_info_window()
end
-- Don't show anything if there is nothing to show
- if not lines or H.is_whitespace(lines) then
- return
- end
+ if not lines or H.is_whitespace(lines) then return end
-- If not already, create a permanent buffer where info will be
-- displayed. For some reason, it is important to have it created not in
@@ -989,9 +945,7 @@ function H.show_info_window()
-- Defer execution because of textlock during `CompleteChanged` event
vim.defer_fn(function()
-- Ensure that window doesn't open when it shouldn't be
- if not (H.pumvisible() and vim.fn.mode() == 'i') then
- return
- end
+ if not (H.pumvisible() and vim.fn.mode() == 'i') then return end
H.open_action_window(H.info, opts)
end, 0)
end
@@ -1010,17 +964,13 @@ function H.info_window_lines(info_id)
end
-- If popup is not from LSP then there is nothing more to do
- if H.completion.source ~= 'lsp' then
- return nil
- end
+ if H.completion.source ~= 'lsp' then return nil end
-- Try to get documentation from LSP's initial completion result
local lsp_completion_item = H.table_get(completed_item, { 'user_data', 'nvim', 'lsp', 'completion_item' })
-- If there is no LSP's completion item, then there is no point to proceed as
-- it should serve as parameters to LSP request
- if not lsp_completion_item then
- return
- end
+ if not lsp_completion_item then return end
local doc = lsp_completion_item.documentation
if doc then
local lines = vim.lsp.util.convert_input_to_markdown_lines(doc)
@@ -1037,16 +987,12 @@ function H.info_window_lines(info_id)
local cancel_fun = vim.lsp.buf_request_all(bufnr, 'completionItem/resolve', params, function(result)
-- Don't do anything if there is other LSP request in action
- if not H.is_lsp_current(H.info, current_id) then
- return
- end
+ if not H.is_lsp_current(H.info, current_id) then return end
H.info.lsp.status = 'received'
-- Don't do anything if completion item was changed
- if H.info.id ~= info_id then
- return
- end
+ if H.info.id ~= info_id then return end
H.info.lsp.result = result
H.show_info_window()
@@ -1110,9 +1056,7 @@ function H.show_signature_window()
local params = vim.lsp.util.make_position_params()
local cancel_fun = vim.lsp.buf_request_all(bufnr, 'textDocument/signatureHelp', params, function(result)
- if not H.is_lsp_current(H.signature, current_id) then
- return
- end
+ if not H.is_lsp_current(H.signature, current_id) then return end
H.signature.lsp.status = 'received'
H.signature.lsp.result = result
@@ -1168,9 +1112,7 @@ function H.show_signature_window()
-- If window is already opened and displays the same text, don't reopen it
local cur_text = table.concat(lines, '\n')
- if H.signature.winnr and cur_text == H.signature.text then
- return
- end
+ if H.signature.winnr and cur_text == H.signature.text then return end
-- Cache lines for later checks if window should be reopened
H.signature.text = cur_text
@@ -1205,9 +1147,7 @@ function H.signature_window_lines()
end
function H.process_signature_response(response)
- if not response.signatures or vim.tbl_isempty(response.signatures) then
- return {}
- end
+ if not response.signatures or vim.tbl_isempty(response.signatures) then return {} end
-- Get active signature (based on textDocument/signatureHelp specification)
local signature_id = response.activeSignature or 0
@@ -1307,9 +1247,7 @@ end
-- Helpers for floating windows -----------------------------------------------
function H.ensure_buffer(cache, name)
- if cache.bufnr then
- return
- end
+ if cache.bufnr then return end
cache.bufnr = vim.api.nvim_create_buf(false, true)
vim.api.nvim_buf_set_name(cache.bufnr, name)
@@ -1389,14 +1327,10 @@ function H.get_completion_start()
end
function H.is_whitespace(s)
- if type(s) == 'string' then
- return s:find('^%s*$')
- end
+ if type(s) == 'string' then return s:find('^%s*$') end
if type(s) == 'table' then
for _, val in pairs(s) do
- if not H.is_whitespace(val) then
- return false
- end
+ if not H.is_whitespace(val) then return false end
end
return true
end
@@ -1430,9 +1364,7 @@ function H.wrap_line(l, width)
end
function H.table_get(t, id)
- if type(id) ~= 'table' then
- return H.table_get(t, { id })
- end
+ if type(id) ~= 'table' then return H.table_get(t, { id }) end
local success, res = true, t
for _, i in ipairs(id) do
--stylua: ignore start
diff --git a/lua/mini/cursorword.lua b/lua/mini/cursorword.lua
index 5740950..736eee6 100644
--- a/lua/mini/cursorword.lua
+++ b/lua/mini/cursorword.lua
@@ -222,9 +222,7 @@ function H.highlight(only_current)
-- 'current word' highlighting: with `:match` it is higher than for
-- `incsearch` which is not convenient.
local win_id = vim.api.nvim_get_current_win()
- if not vim.api.nvim_win_is_valid(win_id) then
- return
- end
+ if not vim.api.nvim_win_is_valid(win_id) then return end
H.window_matches[win_id] = H.window_matches[win_id] or {}
@@ -233,9 +231,7 @@ function H.highlight(only_current)
H.window_matches[win_id].id_current = match_id_current
-- Don't add main match id if not needed or if one is already present
- if only_current or H.window_matches[win_id].id ~= nil then
- return
- end
+ if only_current or H.window_matches[win_id].id ~= nil then return end
-- Make highlighting for cursor word with pattern being 'very nomagic' ('\V')
-- and matching whole word ('\<' and '\>')
@@ -257,9 +253,7 @@ function H.unhighlight(only_current)
-- Don't do anything if there is no valid information to act upon
local win_id = vim.api.nvim_get_current_win()
local win_match = H.window_matches[win_id]
- if not vim.api.nvim_win_is_valid(win_id) or win_match == nil then
- return
- end
+ if not vim.api.nvim_win_is_valid(win_id) or win_match == nil then return end
-- Use `pcall` because there is an error if match id is not present. It can
-- happen if something else called `clearmatches`.
diff --git a/lua/mini/doc.lua b/lua/mini/doc.lua
index 04a1f1e..ae07f41 100644
--- a/lua/mini/doc.lua
+++ b/lua/mini/doc.lua
@@ -246,9 +246,7 @@ MiniDoc.config = {
s:clear_lines()
- if output == nil then
- return
- end
+ if output == nil then return end
if type(output) == 'string' then
output = vim.split(output, '\n')
end
@@ -354,16 +352,12 @@ MiniDoc.config = {
-- Applied to block after all previous steps
--minidoc_replace_start block_post = --<function: does many things>,
block_post = function(b)
- if not b:has_lines() then
- return
- end
+ if not b:has_lines() then return end
local found_param, found_field = false, false
local n_tag_sections = 0
H.apply_recursively(function(x)
- if not (type(x) == 'table' and x.type == 'section') then
- return
- end
+ if not (type(x) == 'table' and x.type == 'section') then return end
-- Add headings before first occurence of a section which type usually
-- appear several times
@@ -391,9 +385,7 @@ MiniDoc.config = {
-- Applied to file after all previous steps
--minidoc_replace_start file = --<function: adds separator>,
file = function(f)
- if not f:has_lines() then
- return
- end
+ if not f:has_lines() then return end
f:insert(1, H.as_struct({ H.as_struct({ string.rep('=', 78) }, 'section') }, 'block'))
f:insert(H.as_struct({ H.as_struct({ '' }, 'section') }, 'block'))
@@ -405,9 +397,7 @@ MiniDoc.config = {
doc = function(d)
-- Render table of contents
H.apply_recursively(function(x)
- if not (type(x) == 'table' and x.type == 'section' and x.info.id == '@toc') then
- return
- end
+ if not (type(x) == 'table' and x.type == 'section' and x.info.id == '@toc') then return end
H.toc_insert(x)
end, d)
@@ -581,9 +571,7 @@ MiniDoc.default_hooks = MiniDoc.config.hooks
function MiniDoc.generate(input, output, config)
-- Try sourcing project specific script first
local success = H.execute_project_script(input, output, config)
- if success then
- return H.generate_recent_output
- end
+ if success then return H.generate_recent_output end
input = input or H.default_input()
output = output or H.default_output()
@@ -798,14 +786,10 @@ end
-- Work with project specific script ==========================================
function H.execute_project_script(input, output, config)
-- Don't process script if there are more than one active `generate` calls
- if H.generate_is_active then
- return
- end
+ if H.generate_is_active then return end
-- Don't process script if at least one argument is not default
- if not (input == nil and output == nil and config == nil) then
- return
- end
+ if not (input == nil and output == nil and config == nil) then return end
-- Store information
local config_cache = MiniDoc.config
@@ -840,12 +824,8 @@ function H.default_input()
-- Put 'init.lua' first among files from same directory
table.sort(files, function(a, b)
if vim.fn.fnamemodify(a, ':h') == vim.fn.fnamemodify(b, ':h') then
- if vim.fn.fnamemodify(a, ':t') == 'init.lua' then
- return true
- end
- if vim.fn.fnamemodify(b, ':t') == 'init.lua' then
- return false
- end
+ if vim.fn.fnamemodify(a, ':t') == 'init.lua' then return true end
+ if vim.fn.fnamemodify(b, ':t') == 'init.lua' then return false end
end
return a < b
@@ -906,9 +886,7 @@ end
-- captured as section id. Empty string of no section id was captured.
-- - Everything else is used as block info (like `afterlines`, etc.).
function H.raw_block_to_block(block_raw, config)
- if #block_raw.annotation == 0 and #block_raw.afterlines == 0 then
- return nil
- end
+ if #block_raw.annotation == 0 and #block_raw.afterlines == 0 then return nil end
local block = H.new_struct('block', {
afterlines = block_raw.afterlines,
@@ -972,9 +950,7 @@ function H.apply_structure_hooks(doc, hooks)
end
function H.alias_register(s)
- if #s == 0 then
- return
- end
+ if #s == 0 then return end
-- Remove first word (with bits of surrounding whitespace) while capturing it
local alias_name
@@ -982,18 +958,14 @@ function H.alias_register(s)
alias_name = x
return ''
end, 1)
- if alias_name == nil then
- return
- end
+ if alias_name == nil then return end
MiniDoc.current.aliases = MiniDoc.current.aliases or {}
MiniDoc.current.aliases[alias_name] = table.concat(s, '\n')
end
function H.alias_replace(s)
- if MiniDoc.current.aliases == nil then
- return
- end
+ if MiniDoc.current.aliases == nil then return end
for i, _ in ipairs(s) do
for alias_name, alias_desc in pairs(MiniDoc.current.aliases) do
@@ -1014,9 +986,7 @@ function H.toc_register(s)
end
function H.toc_insert(s)
- if MiniDoc.current.toc == nil then
- return
- end
+ if MiniDoc.current.toc == nil then return end
-- Render table of contents
local toc_lines = {}
@@ -1050,9 +1020,7 @@ function H.toc_insert(s)
end
function H.add_section_heading(s, heading)
- if #s == 0 or s.type ~= 'section' then
- return
- end
+ if #s == 0 or s.type ~= 'section' then return end
-- Add heading
s:insert(1, ('%s~'):format(heading))
@@ -1065,9 +1033,7 @@ function H.mark_optional(s)
end
function H.enclose_var_name(s)
- if #s == 0 or s.type ~= 'section' then
- return
- end
+ if #s == 0 or s.type ~= 'section' then return end
s[1] = s[1]:gsub('(%S+)', '{%1}', 1)
end
@@ -1076,16 +1042,12 @@ end
--- needed to not detect type early. Like in `@param a_function function`.
---@private
function H.enclose_type(s, enclosure, init)
- if #s == 0 or s.type ~= 'section' then
- return
- end
+ if #s == 0 or s.type ~= 'section' then return end
enclosure = enclosure or '`%(%1%)`'
init = init or 1
local cur_type = H.match_first_pattern(s[1], H.pattern_sets['types'], init)
- if #cur_type == 0 then
- return
- end
+ if #cur_type == 0 then return end
-- Add `%S*` to front and back of found pattern to support their combination
-- with `|`. Also allows using `[]` and `?` prefixes.
@@ -1106,9 +1068,7 @@ function H.infer_header(b)
return type(x) == 'table' and x.type == 'section' and x.info.id == '@tag'
end)
- if has_signature and has_tag then
- return
- end
+ if has_signature and has_tag then return end
local l_all = table.concat(b.info.afterlines, ' ')
local tag, signature
@@ -1146,9 +1106,7 @@ function H.format_signature(line)
-- Otherwise pick first word
name = name or line:match('(%S+)')
- if not name then
- return ''
- end
+ if not name then return '' end
-- Tidy arguments
if args and args ~= '()' then
@@ -1281,17 +1239,13 @@ function H.ensure_indent(text, n_indent_target)
end
function H.align_text(text, width, direction)
- if type(text) ~= 'string' then
- return
- end
+ if type(text) ~= 'string' then return end
text = vim.trim(text)
width = width or 78
direction = direction or 'left'
-- Don't do anything if aligning left or line is a whitespace
- if direction == 'left' or text:find('^%s*$') then
- return text
- end
+ if direction == 'left' or text:find('^%s*$') then return text end
local n_left = math.max(0, 78 - H.visual_text_width(text))
if direction == 'center' then
@@ -1325,9 +1279,7 @@ function H.match_first_pattern(text, pattern_set, init)
end
end
- if min_id == nil then
- return {}
- end
+ if min_id == nil then return {} end
return { text:match(pattern_set[min_id], init) }
end
diff --git a/lua/mini/fuzzy.lua b/lua/mini/fuzzy.lua
index 2d6a8d5..5fdb903 100644
--- a/lua/mini/fuzzy.lua
+++ b/lua/mini/fuzzy.lua
@@ -136,15 +136,9 @@ end
function MiniFuzzy.process_lsp_items(items, base)
-- Extract completion words from items
local words = vim.tbl_map(function(x)
- if type(x.textEdit) == 'table' and type(x.textEdit.newText) == 'string' then
- return x.textEdit.newText
- end
- if type(x.insertText) == 'string' then
- return x.insertText
- end
- if type(x.label) == 'string' then
- return x.label
- end
+ if type(x.textEdit) == 'table' and type(x.textEdit.newText) == 'string' then return x.textEdit.newText end
+ if type(x.insertText) == 'string' then return x.insertText end
+ if type(x.label) == 'string' then return x.label end
return ''
end, items)
@@ -185,9 +179,7 @@ function MiniFuzzy.get_telescope_sorter(opts)
-- @param line (entry.ordinal)
-- @param entry (the whole entry)
scoring_function = function(self, _, line, _)
- if #self.letters == 0 then
- return 1
- end
+ if #self.letters == 0 then return 1 end
line = self.case_sensitive and line or line:lower()
local positions = H.find_best_positions(self.letters, line)
return H.score_positions(positions)
@@ -198,9 +190,7 @@ function MiniFuzzy.get_telescope_sorter(opts)
-- `get_fzy_sorter`'s output). Besides, it seems that `display` and `line`
-- arguments might be different. So, extra calls to `match` are made.
highlighter = function(self, _, display)
- if #self.letters == 0 or #display == 0 then
- return {}
- end
+ if #self.letters == 0 or #display == 0 then return {} end
display = self.case_sensitive and display or display:lower()
return H.find_best_positions(self.letters, display)
end,
@@ -245,29 +235,21 @@ end
---@private
function H.find_best_positions(letters, candidate)
local n_candidate, n_letters = #candidate, #letters
- if n_letters == 0 or n_candidate < n_letters then
- return nil
- end
+ if n_letters == 0 or n_candidate < n_letters then return nil end
-- Search forward to find matching positions with left-most last letter match
local pos_last = 0
for let_i = 1, #letters do
pos_last = candidate:find(letters[let_i], pos_last + 1)
- if not pos_last then
- break
- end
+ if not pos_last then break end
end
-- Candidate is matched only if word's last letter is found
- if not pos_last then
- return nil
- end
+ if not pos_last then return nil end
-- If there is only one letter, it is already the best match (there will not
-- be better width and it has lowest first match)
- if n_letters == 1 then
- return { pos_last }
- end
+ if n_letters == 1 then return { pos_last } end
-- Compute best match positions by iteratively checking all possible last
-- letter matches (at and after initial one). At end of each iteration
@@ -328,9 +310,7 @@ end
--
-- Returns -1 if `positions` is `nil` or empty.
function H.score_positions(positions)
- if not positions or #positions == 0 then
- return -1
- end
+ if not positions or #positions == 0 then return -1 end
local first, last = positions[1], positions[#positions]
local cutoff = MiniFuzzy.config.cutoff
return cutoff * math.min(last - first + 1, cutoff) + math.min(first, cutoff)
@@ -352,9 +332,7 @@ function H.make_filter_indexes(word, candidate_array)
end
function H.compare_filter_indexes(a, b)
- if a.score < b.score then
- return true
- end
+ if a.score < b.score then return true end
if a.score == b.score then
-- Make sorting stable by preserving index order
diff --git a/lua/mini/indentscope.lua b/lua/mini/indentscope.lua
index fe285b6..6f3e69a 100644
--- a/lua/mini/indentscope.lua
+++ b/lua/mini/indentscope.lua
@@ -382,9 +382,7 @@ function MiniIndentscope.auto_draw(opts)
-- Make early return if nothing has to be done. Doing this before updating
-- event id allows to not interrupt ongoing animation.
- if opts.lazy and H.current.draw_status ~= 'none' and H.scope_is_equal(scope, H.current.scope) then
- return
- end
+ if opts.lazy and H.current.draw_status ~= 'none' and H.scope_is_equal(scope, H.current.scope) then return end
-- Account for current event
local local_event_id = H.current.event_id + 1
@@ -401,9 +399,7 @@ function MiniIndentscope.auto_draw(opts)
-- Use `defer_fn()` even if `delay` is 0 to draw indicator only after all
-- events are processed (stops flickering)
vim.defer_fn(function()
- if H.current.event_id ~= local_event_id then
- return
- end
+ if H.current.event_id ~= local_event_id then return end
H.undraw_scope(draw_opts)
@@ -557,9 +553,7 @@ function MiniIndentscope.operator(side, add_to_jumplist)
local scope = MiniIndentscope.get_scope()
-- Don't support scope that can't be shown
- if H.scope_get_draw_indent(scope) < 0 then
- return
- end
+ if H.scope_get_draw_indent(scope) < 0 then return end
-- Add movement to jump list. Needs remembering `count1` before that because
-- it seems to reset it to 1.
@@ -575,9 +569,7 @@ function MiniIndentscope.operator(side, add_to_jumplist)
scope = MiniIndentscope.get_scope(nil, nil, { try_as_border = false })
-- Don't support scope that can't be shown
- if H.scope_get_draw_indent(scope) < 0 then
- return
- end
+ if H.scope_get_draw_indent(scope) < 0 then return end
end
end
@@ -593,9 +585,7 @@ function MiniIndentscope.textobject(use_border)
local scope = MiniIndentscope.get_scope()
-- Don't support scope that can't be shown
- if H.scope_get_draw_indent(scope) < 0 then
- return
- end
+ if H.scope_get_draw_indent(scope) < 0 then return end
-- Allow chaining only if using border
local count = use_border and vim.v.count1 or 1
@@ -617,9 +607,7 @@ function MiniIndentscope.textobject(use_border)
scope = MiniIndentscope.get_scope(nil, nil, { try_as_border = false })
-- Don't support scope that can't be shown
- if H.scope_get_draw_indent(scope) < 0 then
- return
- end
+ if H.scope_get_draw_indent(scope) < 0 then return end
end
end
@@ -700,14 +688,10 @@ H.border_correctors = {
local prev_indent, cur_indent, next_indent =
H.get_line_indent(line - 1, opts), H.get_line_indent(line, opts), H.get_line_indent(line + 1, opts)
- if prev_indent <= cur_indent and next_indent <= cur_indent then
- return line
- end
+ if prev_indent <= cur_indent and next_indent <= cur_indent then return line end
-- If prev and next indents are equal and bigger than current, prefer next
- if prev_indent <= next_indent then
- return line + 1
- end
+ if prev_indent <= next_indent then return line + 1 end
return line - 1
end,
@@ -803,9 +787,7 @@ function H.cast_ray(line, indent, direction, opts)
local min_indent = math.huge
for l = line, final_line, increment do
local new_indent = H.get_line_indent(l + increment, opts)
- if new_indent < indent then
- return l, min_indent
- end
+ if new_indent < indent then return l, min_indent end
if new_indent < min_indent then
min_indent = new_indent
end
@@ -819,9 +801,7 @@ function H.scope_get_draw_indent(scope)
end
function H.scope_is_equal(scope_1, scope_2)
- if type(scope_1) ~= 'table' or type(scope_2) ~= 'table' then
- return false
- end
+ if type(scope_1) ~= 'table' or type(scope_2) ~= 'table' then return false end
return scope_1.buf_id == scope_2.buf_id
and H.scope_get_draw_indent(scope_1) == H.scope_get_draw_indent(scope_2)
@@ -830,9 +810,7 @@ function H.scope_is_equal(scope_1, scope_2)
end
function H.scope_has_intersect(scope_1, scope_2)
- if type(scope_1) ~= 'table' or type(scope_2) ~= 'table' then
- return false
- end
+ if type(scope_1) ~= 'table' or type(scope_2) ~= 'table' then return false end
if (scope_1.buf_id ~= scope_2.buf_id) or (H.scope_get_draw_indent(scope_1) ~= H.scope_get_draw_indent(scope_2)) then
return false
end
@@ -859,9 +837,7 @@ function H.indicator_compute(scope)
-- Don't draw indicator that should be outside of screen. This condition is
-- (perpusfully) "responsible" for not drawing indicator spanning whole file.
- if indent < 0 then
- return {}
- end
+ if indent < 0 then return {} end
-- Extmarks will be located at column zero but show indented text:
-- - This allows showing line even on empty lines.
@@ -870,9 +846,7 @@ function H.indicator_compute(scope)
-- - Neovim issue: https://github.com/neovim/neovim/issues/14050
-- - Used fix: https://github.com/lukas-reineke/indent-blankline.nvim/pull/155
local leftcol = vim.fn.winsaveview().leftcol
- if indent < leftcol then
- return {}
- end
+ if indent < leftcol then return {} end
-- Usage separate highlight groups for prefix and symbol allows cursor to be
-- "natural" when on the left of indicator line (like on empty lines)
@@ -971,9 +945,7 @@ function H.undraw_scope(opts)
opts = opts or {}
-- Don't operate outside of current event if able to verify
- if opts.event_id and opts.event_id ~= H.current.event_id then
- return
- end
+ if opts.event_id and opts.event_id ~= H.current.event_id then return end
pcall(vim.api.nvim_buf_clear_namespace, H.current.scope.buf_id or 0, H.ns_id, 0, -1)
@@ -989,9 +961,7 @@ function H.make_autodraw_opts(scope)
animation_fun = MiniIndentscope.config.draw.animation,
}
- if H.current.draw_status == 'none' then
- return res
- end
+ if H.current.draw_status == 'none' then return res end
-- Draw immediately scope which intersects (same indent, overlapping ranges)
-- currently drawn or finished. This is more natural when typing text.
@@ -1018,19 +988,13 @@ function H.make_draw_function(indicator, opts)
return function(l)
-- Don't draw if outdated
- if H.current.event_id ~= current_event_id and current_event_id ~= nil then
- return false
- end
+ if H.current.event_id ~= current_event_id and current_event_id ~= nil then return false end
-- Don't draw if disabled
- if H.is_disabled() then
- return false
- end
+ if H.is_disabled() then return false end
-- Don't put extmark outside of indicator range
- if not (indicator.top <= l and l <= indicator.bottom) then
- return true
- end
+ if not (indicator.top <= l and l <= indicator.bottom) then return true end
return pcall(vim.api.nvim_buf_set_extmark, indicator.buf_id, H.ns_id, l - 1, 0, extmark_opts)
end
@@ -1118,9 +1082,7 @@ function H.animation_geometrical_powers(type, opts)
local make_delta = function(n_steps, is_in_out)
local total_time = duration_unit == 'step' and (duration_value * n_steps) or duration_value
-- Exact solution to avoid possible (bad) approximation
- if n_steps == 1 then
- return total_time + 1
- end
+ if n_steps == 1 then return total_time + 1 end
if is_in_out then
local n_half = math.ceil(0.5 * n_steps)
-- Example for n_steps=6:
diff --git a/lua/mini/jump.lua b/lua/mini/jump.lua
index 2b3a08b..5a7656e 100644
--- a/lua/mini/jump.lua
+++ b/lua/mini/jump.lua
@@ -150,9 +150,7 @@ MiniJump.state = {
---@param till __till
---@param n_times __n_times
function MiniJump.jump(target, backward, till, n_times)
- if H.is_disabled() then
- return
- end
+ if H.is_disabled() then return end
-- Cache inputs for future use
H.update_state(target, backward, till, n_times)
@@ -167,9 +165,7 @@ function MiniJump.jump(target, backward, till, n_times)
local escaped_target = vim.fn.escape(MiniJump.state.target, [[\]])
local search_pattern = ([[\V%s]]):format(escaped_target)
local target_is_present = vim.fn.search(search_pattern, 'wn') ~= 0
- if not target_is_present then
- return
- end
+ if not target_is_present then return end
-- Construct search and highlight patterns
local flags = MiniJump.state.backward and 'Wb' or 'W'
@@ -231,9 +227,7 @@ end
---@param backward __backward
---@param till __till
function MiniJump.smart_jump(backward, till)
- if H.is_disabled() then
- return
- end
+ if H.is_disabled() then return end
-- Jumping should stop after mode change. Use `mode(1)` to track 'omap' case.
local cur_mode = vim.fn.mode(1)
@@ -246,9 +240,7 @@ function MiniJump.smart_jump(backward, till)
if not MiniJump.state.jumping or MiniJump.state.target == nil then
target = H.get_target()
-- Stop if user supplied invalid target
- if target == nil then
- return
- end
+ if target == nil then return end
end
H.update_state(target, backward, till, vim.v.count1)
@@ -267,17 +259,13 @@ end
---@param backward __backward
---@param till __till
function MiniJump.expr_jump(backward, till)
- if H.is_disabled() then
- return ''
- end
+ if H.is_disabled() then return '' end
-- Always ask for `target` as this will be used only in operator-pending
-- mode. Dot-repeat will be implemented via expression-mapping.
local target = H.get_target()
-- Stop if user supplied invalid target
- if target == nil then
- return
- end
+ if target == nil then return end
H.update_state(target, backward, till, vim.v.count1)
return vim.api.nvim_replace_termcodes('v<Cmd>lua MiniJump.jump()<CR>', true, true, true)
@@ -382,9 +370,7 @@ end
-- Highlighting ---------------------------------------------------------------
function H.highlight(pattern)
-- Don't do anything if already highlighting input pattern
- if H.is_highlighting(pattern) then
- return
- end
+ if H.is_highlighting(pattern) then return end
-- Stop highlighting possible previous pattern. Needed to adjust highlighting
-- when inside jumping but a different kind one. Example: first jump with
@@ -393,9 +379,7 @@ function H.highlight(pattern)
H.unhighlight()
-- Never highlight in Insert mode
- if vim.fn.mode() == 'i' then
- return
- end
+ if vim.fn.mode() == 'i' then return end
local match_id = vim.fn.matchadd('MiniJump', pattern)
H.window_matches[vim.api.nvim_get_current_win()] = { id = match_id, pattern = pattern }
@@ -420,9 +404,7 @@ end
function H.is_highlighting(pattern)
local win_id = vim.api.nvim_get_current_win()
local match_info = H.window_matches[win_id]
- if match_info == nil then
- return false
- end
+ if match_info == nil then return false end
return pattern == nil or match_info.pattern == pattern
end
@@ -452,18 +434,14 @@ end
function H.get_target()
local needs_help_msg = true
vim.defer_fn(function()
- if not needs_help_msg then
- return
- end
+ if not needs_help_msg then return end
H.message('Enter target single character ')
end, 1000)
local ok, char = pcall(vim.fn.getchar)
needs_help_msg = false
-- Terminate if couldn't get input (like with <C-c>) or it is `<Esc>`
- if not ok or char == 27 then
- return
- end
+ if not ok or char == 27 then return end
if type(char) == 'number' then
char = vim.fn.nr2char(char)
diff --git a/lua/mini/jump2d.lua b/lua/mini/jump2d.lua
index 2c8935f..858d1d3 100644
--- a/lua/mini/jump2d.lua
+++ b/lua/mini/jump2d.lua
@@ -298,9 +298,7 @@ MiniJump2d.config = {
---<
---@seealso |MiniJump2d.config|
function MiniJump2d.start(opts)
- if H.is_disabled() then
- return
- end
+ if H.is_disabled() then return end
opts = opts or {}
@@ -604,9 +602,7 @@ end
function H.spots_compute(opts)
local win_id_init = vim.api.nvim_get_current_win()
local win_id_arr = vim.tbl_filter(function(win_id)
- if win_id == win_id_init then
- return opts.allowed_windows.current
- end
+ if win_id == win_id_init then return opts.allowed_windows.current end
return opts.allowed_windows.not_current
end, H.tabpage_list_wins(0))
@@ -697,9 +693,7 @@ end
--- This considerably increases performance in case of many spots.
---@private
function H.spots_to_extmarks(spots)
- if #spots == 0 then
- return {}
- end
+ if #spots == 0 then return {} end
local res = {}
@@ -738,14 +732,10 @@ function H.spot_find_in_line(line_num, spotter_args, opts, cursor_pos)
-- Process folds
local fold_indicator = vim.fn.foldclosed(line_num)
- if fold_indicator ~= -1 then
- return (allowed.fold and fold_indicator == line_num) and { 1 } or {}
- end
+ if fold_indicator ~= -1 then return (allowed.fold and fold_indicator == line_num) and { 1 } or {} end
-- Process blank lines
- if vim.fn.prevnonblank(line_num) ~= line_num then
- return allowed.blank and { 1 } or {}
- end
+ if vim.fn.prevnonblank(line_num) ~= line_num then return allowed.blank and { 1 } or {} end
-- Finally apply spotter
return opts.spotter(line_num, spotter_args)
@@ -856,9 +846,7 @@ function H.input(prompt, text)
-- Stop key listening
on_key(nil, H.ns_id.input)
- if not ok or was_cancelled then
- return
- end
+ if not ok or was_cancelled then return end
return res
end
@@ -910,9 +898,7 @@ function H.map(mode, key, rhs, opts)
end
function H.merge_unique(tbl_1, tbl_2)
- if not (type(tbl_1) == 'table' and type(tbl_2) == 'table') then
- return
- end
+ if not (type(tbl_1) == 'table' and type(tbl_2) == 'table') then return end
local n_1, n_2 = #tbl_1, #tbl_2
local res, i, j = {}, 1, 1
diff --git a/lua/mini/misc.lua b/lua/mini/misc.lua
index f6565c5..725798c 100644
--- a/lua/mini/misc.lua
+++ b/lua/mini/misc.lua
@@ -204,9 +204,7 @@ end
function H.compute_median(t)
local n = #t
- if n == 0 then
- return 0
- end
+ if n == 0 then return 0 end
local t_sorted = vim.deepcopy(t)
table.sort(t_sorted)
@@ -225,9 +223,7 @@ function MiniMisc.tbl_head(t, n)
n = n or 5
local res, n_res = {}, 0
for k, val in pairs(t) do
- if n_res >= n then
- return res
- end
+ if n_res >= n then return res end
res[k] = val
n_res = n_res + 1
end
@@ -293,9 +289,7 @@ function MiniMisc.use_nested_comments(buf_id)
buf_id = buf_id or 0
local commentstring = vim.api.nvim_buf_get_option(buf_id, 'commentstring')
- if commentstring == '' then
- return
- end
+ if commentstring == '' then return end
-- Extract raw comment leader from 'commentstring' option
local comment_parts = vim.tbl_filter(function(x)
@@ -303,9 +297,7 @@ function MiniMisc.use_nested_comments(buf_id)
end, vim.split(commentstring, '%s', true))
-- Don't do anything if 'commentstring' is like '/*%s*/' (as in 'json')
- if #comment_parts > 1 then
- return
- end
+ if #comment_parts > 1 then return end
-- Get comment leader by removing whitespace
local leader = vim.trim(comment_parts[1])
@@ -357,14 +349,10 @@ function H.setup_config(config)
make_global = {
config.make_global,
function(x)
- if type(x) ~= 'table' then
- return false
- end
+ if type(x) ~= 'table' then return false end
local present_fields = vim.tbl_keys(MiniMisc)
for _, v in pairs(x) do
- if not vim.tbl_contains(present_fields, v) then
- return false
- end
+ if not vim.tbl_contains(present_fields, v) then return false end
end
return true
end,
diff --git a/lua/mini/pairs.lua b/lua/mini/pairs.lua
index b70e022..c9d2774 100644
--- a/lua/mini/pairs.lua
+++ b/lua/mini/pairs.lua
@@ -218,9 +218,7 @@ function MiniPairs.unmap(mode, lhs, pair)
-- Use `pcall` to allow 'deleting' already deleted mapping
pcall(vim.api.nvim_del_keymap, mode, lhs)
- if pair == '' then
- return
- end
+ if pair == '' then return end
H.unregister_pair(pair, mode, 'all')
end
@@ -243,9 +241,7 @@ function MiniPairs.unmap_buf(buffer, mode, lhs, pair)
-- Use `pcall` to allow 'deleting' already deleted mapping
pcall(vim.api.nvim_buf_del_keymap, buffer, mode, lhs)
- if pair == '' then
- return
- end
+ if pair == '' then return end
H.unregister_pair(pair, mode, buffer == 0 and vim.api.nvim_get_current_buf() or buffer)
end
@@ -261,9 +257,7 @@ end
---@param pair __pair
---@param neigh_pattern __neigh_pattern
function MiniPairs.open(pair, neigh_pattern)
- if H.is_disabled() or not H.neigh_match(neigh_pattern) then
- return pair:sub(1, 1)
- end
+ if H.is_disabled() or not H.neigh_match(neigh_pattern) then return pair:sub(1, 1) end
return ('%s%s'):format(pair, H.get_arrow_key('left'))
end
@@ -281,9 +275,7 @@ end
---@param pair __pair
---@param neigh_pattern __neigh_pattern
function MiniPairs.close(pair, neigh_pattern)
- if H.is_disabled() or not H.neigh_match(neigh_pattern) then
- return pair:sub(2, 2)
- end
+ if H.is_disabled() or not H.neigh_match(neigh_pattern) then return pair:sub(2, 2) end
local close = pair:sub(2, 2)
if H.get_cursor_neigh(1, 1) == close then
@@ -461,9 +453,7 @@ end
function H.unregister_pair(pair, mode, buffer)
local mode_pairs = H.registered_pairs[mode]
- if not (mode_pairs and mode_pairs[buffer]) then
- return
- end
+ if not (mode_pairs and mode_pairs[buffer]) then return end
local buf_pairs = mode_pairs[buffer]
for _, key in ipairs({ 'bs', 'cr' }) do
@@ -477,19 +467,13 @@ end
function H.is_pair_registered(pair, mode, buffer, key)
local mode_pairs = H.registered_pairs[mode]
- if not mode_pairs then
- return false
- end
+ if not mode_pairs then return false end
- if vim.tbl_contains(mode_pairs['all'][key], pair) then
- return true
- end
+ if vim.tbl_contains(mode_pairs['all'][key], pair) then return true end
buffer = buffer == 0 and vim.api.nvim_get_current_buf() or buffer
local buf_pairs = mode_pairs[buffer]
- if not buf_pairs then
- return false
- end
+ if not buf_pairs then return false end
return vim.tbl_contains(buf_pairs[key], pair)
end
diff --git a/lua/mini/sessions.lua b/lua/mini/sessions.lua
index bf718c4..d87754f 100644
--- a/lua/mini/sessions.lua
+++ b/lua/mini/sessions.lua
@@ -152,9 +152,7 @@ MiniSessions.detected = {}
--- `MiniSessions.config.hooks.pre.read` and
--- `MiniSessions.config.hooks.post.read`).
function MiniSessions.read(session_name, opts)
- if H.is_disabled() then
- return
- end
+ if H.is_disabled() then return end
if vim.tbl_count(MiniSessions.detected) == 0 then
H.error('There is no detected sessions. Change configuration and rerun `MiniSessions.setup()`.')
end
@@ -169,9 +167,7 @@ function MiniSessions.read(session_name, opts)
opts = vim.tbl_deep_extend('force', H.default_opts('read'), opts or {})
- if not H.validate_detected(session_name) then
- return
- end
+ if not H.validate_detected(session_name) then return end
-- Possibly check for unsaved listed buffers and do nothing if present
if not opts.force then
@@ -230,9 +226,7 @@ end
--- `MiniSessions.config.hooks.pre.write` and
--- `MiniSessions.config.hooks.post.write`).
function MiniSessions.write(session_name, opts)
- if H.is_disabled() then
- return
- end
+ if H.is_disabled() then return end
opts = vim.tbl_deep_extend('force', H.default_opts('write'), opts or {})
@@ -282,9 +276,7 @@ end
--- `MiniSessions.config.hooks.pre.delete` and
--- `MiniSessions.config.hooks.post.delete`).
function MiniSessions.delete(session_name, opts)
- if H.is_disabled() then
- return
- end
+ if H.is_disabled() then return end
if vim.tbl_count(MiniSessions.detected) == 0 then
H.error('There is no detected sessions. Change configuration and rerun `MiniSessions.setup()`.')
end
@@ -295,9 +287,7 @@ function MiniSessions.delete(session_name, opts)
-- Make sure to delete only detected session (matters for local session)
session_name = vim.fn.fnamemodify(session_path, ':t')
- if not H.validate_detected(session_name) then
- return
- end
+ if not H.validate_detected(session_name) then return end
session_path = MiniSessions.detected[session_name].path
local is_current_session = session_path == vim.v.this_session
@@ -365,9 +355,7 @@ function MiniSessions.select(action, opts)
return ('%s (%s)'):format(x, MiniSessions.detected[x].type)
end,
}, function(item, idx)
- if item == nil then
- return
- end
+ if item == nil then return end
MiniSessions[action](item, opts)
end)
end
@@ -379,9 +367,7 @@ end
---
---@return string|nil Name of latest session or `nil` if there is no sessions.
function MiniSessions.get_latest()
- if vim.tbl_count(MiniSessions.detected) == 0 then
- return
- end
+ if vim.tbl_count(MiniSessions.detected) == 0 then return end
local latest_time, latest_name = -1, nil
for name, data in pairs(MiniSessions.detected) do
@@ -476,9 +462,7 @@ function H.detect_sessions_global(global_dir)
end
local globs = vim.fn.globpath(global_dir, '*')
- if #globs == 0 then
- return {}
- end
+ if #globs == 0 then return {} end
local res = {}
for _, f in pairs(vim.split(globs, '\n')) do
@@ -493,9 +477,7 @@ end
function H.detect_sessions_local(local_file)
local f = H.joinpath(vim.fn.getcwd(), local_file)
- if not H.is_readable_file(f) then
- return {}
- end
+ if not H.is_readable_file(f) then return {} end
local res = {}
local s = H.new_session(f, 'local')
@@ -513,9 +495,7 @@ function H.new_session(session_path, session_type)
end
function H.get_session_type(session_path)
- if MiniSessions.config.directory == '' then
- return 'local'
- end
+ if MiniSessions.config.directory == '' then return 'local' end
local session_dir = H.full_path(session_path)
local global_dir = H.full_path(MiniSessions.config.directory)
@@ -524,9 +504,7 @@ end
function H.validate_detected(session_name)
local is_detected = vim.tbl_contains(vim.tbl_keys(MiniSessions.detected), session_name)
- if is_detected then
- return true
- end
+ if is_detected then return true end
H.error(('%s is not a name for detected session.'):format(vim.inspect(session_name)))
end
@@ -598,23 +576,17 @@ function H.is_something_shown()
-- empty (returns 2 instead of -1). This was also the reason of not being
-- able to test with child Neovim process from 'tests/helpers'.
local lines = vim.api.nvim_buf_get_lines(0, 0, -1, true)
- if #lines > 1 or (#lines == 1 and lines[1]:len() > 0) then
- return true
- end
+ if #lines > 1 or (#lines == 1 and lines[1]:len() > 0) then return true end
-- - Several buffers are listed (like session with placeholder buffers). That
-- means unlisted buffers (like from `nvim-tree`) don't affect decision.
local listed_buffers = vim.tbl_filter(function(buf_id)
return vim.fn.buflisted(buf_id) == 1
end, vim.api.nvim_list_bufs())
- if #listed_buffers > 1 then
- return true
- end
+ if #listed_buffers > 1 then return true end
-- - There are files in arguments (like `nvim foo.txt` with new file).
- if vim.fn.argc() > 0 then
- return true
- end
+ if vim.fn.argc() > 0 then return true end
return false
end
diff --git a/lua/mini/starter.lua b/lua/mini/starter.lua
index dec8f6d..0e4e799 100644
--- a/lua/mini/starter.lua
+++ b/lua/mini/starter.lua
@@ -310,9 +310,7 @@ end
---@param buf_id number Identifier of existing valid buffer (see |bufnr()|) to
--- open inside. Default: create a new one.
function MiniStarter.open(buf_id)
- if H.is_disabled() then
- return
- end
+ if H.is_disabled() then return end
-- Reset helper data
H.current_item_id = 1
@@ -379,9 +377,7 @@ end
--- Note: this function is executed on every |VimResized| to allow more
--- responsive behavior.
function MiniStarter.refresh()
- if H.is_disabled() or H.buf_id == nil or not vim.api.nvim_buf_is_valid(H.buf_id) then
- return
- end
+ if H.is_disabled() or H.buf_id == nil or not vim.api.nvim_buf_is_valid(H.buf_id) then return end
-- Normalize certain config values
H.header = H.normalize_header_footer(MiniStarter.config.header or H.default_header)
@@ -869,9 +865,7 @@ function MiniStarter.update_current_item(direction)
-- Advance current item
local prev_current = H.current_item_id
H.current_item_id = H.next_active_item_id(H.current_item_id, direction)
- if H.current_item_id == prev_current then
- return
- end
+ if H.current_item_id == prev_current then return end
-- Update cursor position
H.position_cursor_on_current_item()
@@ -928,9 +922,7 @@ H.default_config = MiniStarter.config
-- Default config values
H.default_items = {
function()
- if _G.MiniSessions == nil then
- return {}
- end
+ if _G.MiniSessions == nil then return {} end
return MiniStarter.sections.sessions(5, true)()
end,
MiniStarter.sections.recent_files(5, false, false),
@@ -1009,9 +1001,7 @@ end
-- Normalize config elements --------------------------------------------------
function H.normalize_items(items)
local res = H.items_flatten(items)
- if #res == 0 then
- return { { name = '`MiniStarter.config.items` is empty', action = '', section = '' } }
- end
+ if #res == 0 then return { { name = '`MiniStarter.config.items` is empty', action = '', section = '' } } end
return H.items_sort(res)
end
@@ -1020,9 +1010,7 @@ function H.normalize_header_footer(x)
x = x()
end
local res = tostring(x)
- if res == '' then
- return {}
- end
+ if res == '' then return {} end
return vim.split(res, '\n')
end
@@ -1108,9 +1096,7 @@ function H.items_flatten(items)
return
end
- if type(x) ~= 'table' then
- return
- end
+ if type(x) ~= 'table' then return end
return vim.tbl_map(f, x)
end
@@ -1340,32 +1326,24 @@ function H.is_something_shown()
-- empty (returns 2 instead of -1). This was also the reason of not being
-- able to test with child Neovim process from 'tests/helpers'.
local lines = vim.api.nvim_buf_get_lines(0, 0, -1, true)
- if #lines > 1 or (#lines == 1 and lines[1]:len() > 0) then
- return true
- end
+ if #lines > 1 or (#lines == 1 and lines[1]:len() > 0) then return true end
-- - Several buffers are listed (like session with placeholder buffers). That
-- means unlisted buffers (like from `nvim-tree`) don't affect decision.
local listed_buffers = vim.tbl_filter(function(buf_id)
return vim.fn.buflisted(buf_id) == 1
end, vim.api.nvim_list_bufs())
- if #listed_buffers > 1 then
- return true
- end
+ if #listed_buffers > 1 then return true end
-- - There are files in arguments (like `nvim foo.txt` with new file).
- if vim.fn.argc() > 0 then
- return true
- end
+ if vim.fn.argc() > 0 then return true end
return false
end
-- Utilities ------------------------------------------------------------------
function H.eval_fun_or_string(x, string_as_cmd)
- if type(x) == 'function' then
- return x()
- end
+ if type(x) == 'function' then return x() end
if type(x) == 'string' then
if string_as_cmd then
vim.cmd(x)
diff --git a/lua/mini/statusline.lua b/lua/mini/statusline.lua
index b0c827b..0bf298f 100644
--- a/lua/mini/statusline.lua
+++ b/lua/mini/statusline.lua
@@ -180,18 +180,14 @@ MiniStatusline.config = {
-- Module functionality =======================================================
--- Compute content for active window
function MiniStatusline.active()
- if H.is_disabled() then
- return ''
- end
+ if H.is_disabled() then return '' end
return (MiniStatusline.config.content.active or H.default_content_active)()
end
--- Compute content for inactive window
function MiniStatusline.inactive()
- if H.is_disabled() then
- return ''
- end
+ if H.is_disabled() then return '' end
return (MiniStatusline.config.content.inactive or H.default_content_inactive)()
end
@@ -284,18 +280,14 @@ end
---
---@return __section
function MiniStatusline.section_git(args)
- if H.isnt_normal_buffer() then
- return ''
- end
+ if H.isnt_normal_buffer() then return '' end
local head = vim.b.gitsigns_head or '-'
local signs = MiniStatusline.is_truncated(args.trunc_width) and '' or (vim.b.gitsigns_status or '')
local icon = args.icon or (MiniStatusline.config.use_icons and '' or 'Git')
if signs == '' then
- if head == '-' or head == '' then
- return ''
- end
+ if head == '-' or head == '' then return '' end
return string.format('%s %s', icon, head)
end
return string.format('%s %s %s', icon, head, signs)
@@ -317,9 +309,7 @@ function MiniStatusline.section_diagnostics(args)
-- `vim.lsp.buf_get_clients()` is empty
local hasnt_attached_client = next(vim.lsp.buf_get_clients()) == nil
local dont_show_lsp = MiniStatusline.is_truncated(args.trunc_width) or H.isnt_normal_buffer() or hasnt_attached_client
- if dont_show_lsp then
- return ''
- end
+ if dont_show_lsp then return '' end
-- Construct diagnostic info using predefined order
local t = {}
@@ -332,9 +322,7 @@ function MiniStatusline.section_diagnostics(args)
end
local icon = args.icon or (MiniStatusline.config.use_icons and '' or 'LSP')
- if vim.tbl_count(t) == 0 then
- return ('%s -'):format(icon)
- end
+ if vim.tbl_count(t) == 0 then return ('%s -'):format(icon) end
return string.format('%s%s', icon, table.concat(t, ''))
end
@@ -374,9 +362,7 @@ function MiniStatusline.section_fileinfo(args)
-- Don't show anything if can't detect file type or not inside a "normal
-- buffer"
- if (filetype == '') or H.isnt_normal_buffer() then
- return ''
- end
+ if (filetype == '') or H.isnt_normal_buffer() then return '' end
-- Add filetype icon
local icon = H.get_filetype_icon()
@@ -385,9 +371,7 @@ function MiniStatusline.section_fileinfo(args)
end
-- Construct output string if truncated
- if MiniStatusline.is_truncated(args.trunc_width) then
- return filetype
- end
+ if MiniStatusline.is_truncated(args.trunc_width) then return filetype end
-- Construct output string with extra file info
local encoding = vim.bo.fileencoding or vim.bo.encoding
@@ -410,9 +394,7 @@ end
---@return __section
function MiniStatusline.section_location(args)
-- Use virtual column number to allow update when past last column
- if MiniStatusline.is_truncated(args.trunc_width) then
- return '%l│%2v'
- end
+ if MiniStatusline.is_truncated(args.trunc_width) then return '%l│%2v' end
-- Use `virtcol()` to correctly handle multi-byte characters
return '%l|%L│%2v|%-2{virtcol("$") - 1}'
@@ -433,19 +415,13 @@ end
---
---@return __section
function MiniStatusline.section_searchcount(args)
- if vim.v.hlsearch == 0 or MiniStatusline.is_truncated(args.trunc_width) then
- return ''
- end
+ if vim.v.hlsearch == 0 or MiniStatusline.is_truncated(args.trunc_width) then return '' end
-- `searchcount()` can return errors because it is evaluated very often in
-- statusline. For example, when typing `/` followed by `\(`, it gives E54.
local ok, s_count = pcall(vim.fn.searchcount, (args or {}).options or { recompute = true })
- if not ok or s_count.current == nil or s_count.total == 0 then
- return ''
- end
+ if not ok or s_count.current == nil or s_count.total == 0 then return '' end
- if s_count.incomplete == 1 then
- return '?/?'
- end
+ if s_count.incomplete == 1 then return '?/?' end
local too_many = ('>%d'):format(s_count.maxcount)
local current = s_count.current > s_count.maxcount and too_many or s_count.current
@@ -587,14 +563,10 @@ end
function H.get_filetype_icon()
-- Skip if NerdFonts is disabled
- if not MiniStatusline.config.use_icons then
- return ''
- end
+ if not MiniStatusline.config.use_icons then return '' end
-- Have this `require()` here to not depend on plugin initialization order
local has_devicons, devicons = pcall(require, 'nvim-web-devicons')
- if not has_devicons then
- return ''
- end
+ if not has_devicons then return '' end
local file_name, file_ext = vim.fn.expand('%:t'), vim.fn.expand('%:e')
return devicons.get_icon(file_name, file_ext, { default = true })
diff --git a/lua/mini/surround.lua b/lua/mini/surround.lua
index 10bf2a8..06b96d8 100644
--- a/lua/mini/surround.lua
+++ b/lua/mini/surround.lua
@@ -353,9 +353,7 @@ end
---@param mode string Mapping mode (normal by default).
function MiniSurround.add(mode)
-- Needed to disable in visual mode
- if H.is_disabled() then
- return '<Esc>'
- end
+ if H.is_disabled() then return '<Esc>' end
-- Get marks' positions based on current mode
local marks = H.get_marks_pos(mode)
@@ -368,9 +366,7 @@ function MiniSurround.add(mode)
else
surr_info = H.get_surround_info('output', true)
end
- if surr_info == nil then
- return '<Esc>'
- end
+ if surr_info == nil then return '<Esc>' end
-- Add surrounding. Begin insert from right to not break column numbers
-- Insert after the right mark (`+ 1` is for that)
@@ -387,9 +383,7 @@ end
function MiniSurround.delete()
-- Find input surrounding
local surr = H.find_surrounding(H.get_surround_info('input', true))
- if surr == nil then
- return '<Esc>'
- end
+ if surr == nil then return '<Esc>' end
-- Delete surrounding. Begin with right to not break column numbers.
H.delete_linepart(surr.right)
@@ -405,15 +399,11 @@ end
function MiniSurround.replace()
-- Find input surrounding
local surr = H.find_surrounding(H.get_surround_info('input', true))
- if surr == nil then
- return '<Esc>'
- end
+ if surr == nil then return '<Esc>' end
-- Get output surround info
local new_surr_info = H.get_surround_info('output', true)
- if new_surr_info == nil then
- return '<Esc>'
- end
+ if new_surr_info == nil then return '<Esc>' end
-- Replace by parts starting from right to not break column numbers
H.delete_linepart(surr.right)
@@ -432,9 +422,7 @@ end
function MiniSurround.find()
-- Find surrounding
local surr = H.find_surrounding(H.get_surround_info('input', true))
- if surr == nil then
- return '<Esc>'
- end
+ if surr == nil then return '<Esc>' end
-- Make array of positions to cycle through
local pos_array = H.linepart_to_pos_table(surr.left)
@@ -454,9 +442,7 @@ end
function MiniSurround.highlight()
-- Find surrounding
local surr = H.find_surrounding(H.get_surround_info('input', true))
- if surr == nil then
- return '<Esc>'
- end
+ if surr == nil then return '<Esc>' end
-- Highlight surrounding
local buf_id = vim.api.nvim_get_current_buf()
@@ -470,9 +456,7 @@ end
--- Convenient wrapper for updating `MiniSurround.config.n_lines` in case the
--- default one is not appropriate.
function MiniSurround.update_n_lines()
- if H.is_disabled() then
- return '<Esc>'
- end
+ if H.is_disabled() then return '<Esc>' end
local n_lines = MiniSurround.user_input('New number of neighbor lines', MiniSurround.config.n_lines)
n_lines = math.floor(tonumber(n_lines) or MiniSurround.config.n_lines)
@@ -518,9 +502,7 @@ function MiniSurround.user_input(prompt, text)
-- Stop key listening
on_key(nil, H.ns_id.input)
- if not ok or was_cancelled then
- return
- end
+ if not ok or was_cancelled then return end
return res
end
@@ -664,9 +646,7 @@ function H.is_search_method(x, x_name)
x = x or MiniSurround.config.search_method
x_name = x_name or '`config.search_method`'
- if vim.tbl_contains({ 'cover', 'cover_or_prev', 'cover_or_next', 'cover_or_nearest' }, x) then
- return true
- end
+ if vim.tbl_contains({ 'cover', 'cover_or_prev', 'cover_or_next', 'cover_or_nearest' }, x) then return true end
local msg = ([[%s should be one of 'cover', 'cover_or_prev', 'cover_or_next', 'cover_or_nearest'.]]):format(x_name)
return false, msg
end
@@ -704,9 +684,7 @@ function H.find_surrounding(surround_info)
-- `surround_info` should have `find` field with surrounding pattern. If
-- needed, it should also have a `extract` field with extract pattern for two
-- parts of surrounding assuming they are at the start and end of string.
- if surround_info == nil then
- return nil
- end
+ if surround_info == nil then return nil end
local n_lines = MiniSurround.config.n_lines
-- First try only current line as it is the most common use case
@@ -732,9 +710,7 @@ function H.find_surrounding_in_neighborhood(surround_info, n_neighbors)
-- Find span of surrounding
local span = H.find_best_match(neigh['1d'], surround_info.find, cur_offset)
- if span == nil then
- return nil
- end
+ if span == nil then return nil end
-- Compute lineparts for left and right surroundings
local l, r = span.left, span.right
@@ -750,13 +726,9 @@ function H.find_surrounding_in_neighborhood(surround_info, n_neighbors)
local right_from, right_to = neigh.offset_to_pos(r - right:len() + 1), neigh.offset_to_pos(r)
local left_linepart = H.new_linepart(left_from, left_to)
- if left_linepart == nil then
- return nil
- end
+ if left_linepart == nil then return nil end
local right_linepart = H.new_linepart(right_from, right_to)
- if right_linepart == nil then
- return nil
- end
+ if right_linepart == nil then return nil end
return { left = left_linepart, right = right_linepart }
end
@@ -820,18 +792,10 @@ function H.set_cursor(line, col)
end
function H.compare_pos(pos1, pos2)
- if pos1.line < pos2.line then
- return '<'
- end
- if pos1.line > pos2.line then
- return '>'
- end
- if pos1.col < pos2.col then
- return '<'
- end
- if pos1.col > pos2.col then
- return '>'
- end
+ if pos1.line < pos2.line then return '<' end
+ if pos1.line > pos2.line then return '>' end
+ if pos1.col < pos2.col then return '<' end
+ if pos1.col > pos2.col then return '>' end
return '='
end
@@ -873,9 +837,7 @@ function H.user_surround_id(sur_type)
needs_help_msg = false
-- Terminate if couldn't get input (like with <C-c>) or it is `<Esc>`
- if not ok or char == 27 then
- return nil
- end
+ if not ok or char == 27 then return nil end
if type(char) == 'number' then
char = vim.fn.nr2char(char)
@@ -979,9 +941,7 @@ function H.find_best_match(line, pattern, offset)
end
-- If still didn't find anything, return nothing
- if left == nil then
- return
- end
+ if left == nil then return end
-- Try make covering match even smaller. Can happen if there are greedy
-- quantifiers. For example:
diff --git a/lua/mini/tabline.lua b/lua/mini/tabline.lua
index c172120..3fd92f5 100644
--- a/lua/mini/tabline.lua
+++ b/lua/mini/tabline.lua
@@ -126,9 +126,7 @@ MiniTabline.config = {
-- Module functionality =======================================================
--- Make string for |tabline|
function MiniTabline.make_tabline_string()
- if H.is_disabled() then
- return ''
- end
+ if H.is_disabled() then return '' end
H.make_tabpage_section()
H.list_tabs()
@@ -320,9 +318,7 @@ end
function H.get_unnamed_id(buf_id)
-- Use existing sequential id if possible
local seq_id = H.unnamed_buffers_seq_ids[buf_id]
- if seq_id ~= nil then
- return seq_id
- end
+ if seq_id ~= nil then return seq_id end
-- Cache sequential id for currently unnamed buffer `buf_id`
H.unnamed_buffers_seq_ids[buf_id] = vim.tbl_count(H.unnamed_buffers_seq_ids) + 1
@@ -346,9 +342,7 @@ function H.finalize_labels()
end
end
- if nothing_changed then
- break
- end
+ if nothing_changed then break end
nonunique_tab_ids = H.get_nonunique_tab_ids()
end
diff --git a/lua/mini/test.lua b/lua/mini/test.lua
index f68bf7b..777c2a0 100644
--- a/lua/mini/test.lua
+++ b/lua/mini/test.lua
@@ -345,15 +345,11 @@ end
---@param opts table|nil Options with structure similar to |MiniTest.config|.
--- Absent values are inferred from there.
function MiniTest.run(opts)
- if H.is_disabled() then
- return
- end
+ if H.is_disabled() then return end
-- Try sourcing project specific script first
local success = H.execute_project_script(opts)
- if success then
- return
- end
+ if success then return end
-- Collect and execute
opts = vim.tbl_deep_extend('force', MiniTest.config, opts or {})
@@ -770,9 +766,7 @@ end
--- )
function MiniTest.new_expectation(subject, predicate, fail_context)
return function(...)
- if predicate(...) then
- return true
- end
+ if predicate(...) then return true end
local cur_subject = vim.is_callable(subject) and subject(...) or subject
local cur_context = vim.is_callable(fail_context) and fail_context(...) or fail_context
@@ -1652,14 +1646,10 @@ end
-- Work with execution --------------------------------------------------------
function H.execute_project_script(...)
-- Don't process script if there are more than one active `run` calls
- if H.is_inside_script then
- return false
- end
+ if H.is_inside_script then return false end
-- Don't process script if at least one argument is not default (`nil`)
- if #{ ... } > 0 then
- return
- end
+ if #{ ... } > 0 then return end
-- Store information
local config_cache = MiniTest.config
@@ -1740,9 +1730,7 @@ function H.set_to_testcases(set, template, hooks_once)
return vim.is_callable(node) or H.is_instance(node, 'testset')
end, key_order)
- if #node_keys == 0 then
- return {}, {}
- end
+ if #node_keys == 0 then return {}, {} end
-- Ensure that newly added hooks are represented by new functions.
-- This is needed to count them later only within current set. Example: use
@@ -1866,9 +1854,7 @@ end
function H.case_to_stringid(case)
local desc = table.concat(case.desc, ' | ')
- if #case.args == 0 then
- return desc
- end
+ if #case.args == 0 then return desc end
local args = vim.inspect(case.args, { newline = '', indent = '' })
return ('%s + args %s'):format(desc, args)
end
diff --git a/lua/mini/trailspace.lua b/lua/mini/trailspace.lua
index 7509187..6029e45 100644
--- a/lua/mini/trailspace.lua
+++ b/lua/mini/trailspace.lua
@@ -108,9 +108,7 @@ function MiniTrailspace.highlight()
end
-- Possibly work only in normal buffers
- if MiniTrailspace.config.only_in_normal_buffers and not H.is_buffer_normal() then
- return
- end
+ if MiniTrailspace.config.only_in_normal_buffers and not H.is_buffer_normal() then return end
-- Don't add match id on top of existing one
--stylua: ignore
@@ -139,9 +137,7 @@ end
---
--- Designed to be used with |autocmd|. No need to use it directly.
function MiniTrailspace.track_normal_buffer()
- if not MiniTrailspace.config.only_in_normal_buffers then
- return
- end
+ if not MiniTrailspace.config.only_in_normal_buffers then return end
-- This should be used with 'OptionSet' event for 'buftype' option
-- Empty 'buftype' means "normal buffer"
@@ -186,9 +182,7 @@ function H.get_match_id()
-- window but it will have more edge cases (like won't update on manual
-- `clearmatches()`)
for _, match in ipairs(vim.fn.getmatches()) do
- if match.group == 'MiniTrailspace' then
- return match.id
- end
+ if match.group == 'MiniTrailspace' then return match.id end
end
end
diff --git a/tests/completion-tests/mock-months-lsp.lua b/tests/completion-tests/mock-months-lsp.lua
index e4733e2..114acf7 100644
--- a/tests/completion-tests/mock-months-lsp.lua
+++ b/tests/completion-tests/mock-months-lsp.lua
@@ -77,9 +77,7 @@ Months.requests = {
local after_close_paren = line:match('%).*$') or line
-- Stop showing signature help after closing bracket
- if after_close_paren:len() < after_open_paren:len() then
- return { {} }
- end
+ if after_close_paren:len() < after_open_paren:len() then return { {} } end
-- Compute active parameter id by counting number of ',' from latest '('
local _, active_param_id = after_open_paren:gsub('%,', '%,')
@@ -108,9 +106,7 @@ Months.requests = {
-- Replace builtin functions with custom testable ones ========================
vim.lsp.buf_request_all = function(bufnr, method, params, callback)
local requests = Months.requests[method]
- if requests == nil then
- return
- end
+ if requests == nil then return end
callback(requests(params))
end
diff --git a/tests/doc-tests/helpers.lua b/tests/doc-tests/helpers.lua
index c8b08b2..eb7546f 100644
--- a/tests/doc-tests/helpers.lua
+++ b/tests/doc-tests/helpers.lua
@@ -11,9 +11,7 @@ _G.remove_dir = function(path)
local path_sep = package.config:sub(1, 1)
while true do
local f_name, _ = vim.loop.fs_scandir_next(fs)
- if f_name == nil then
- break
- end
+ if f_name == nil then break end
local p = ('%s%s%s'):format(path, path_sep, f_name)
vim.loop.fs_unlink(p)
end
@@ -51,9 +49,7 @@ function H.validate_structure(x, struct_type, parent)
error(('Element is not %s structure.'):format(type_string))
end
- if parent == nil then
- return
- end
+ if parent == nil then return end
if tostring(x.parent) ~= tostring(parent) then
error(('%s structure has not correct `info.parent`.'):format(type_string))
@@ -72,17 +68,11 @@ H.info_fields = {
}
function H.is_structure(x, struct_type)
- if not H.struct_has_elements(x) then
- return false
- end
- if not x.type == struct_type then
- return false
- end
+ if not H.struct_has_elements(x) then return false end
+ if not x.type == struct_type then return false end
for info_name, info_type in pairs(H.info_fields[struct_type]) do
- if type(x.info[info_name]) ~= info_type then
- return false
- end
+ if type(x.info[info_name]) ~= info_type then return false end
end
return true
@@ -90,19 +80,13 @@ end
function H.struct_has_elements(x)
-- Fields
- if not (type(x.info) == 'table' and type(x.type) == 'string') then
- return false
- end
+ if not (type(x.info) == 'table' and type(x.type) == 'string') then return false end
- if x.parent ~= nil and not (type(x.parent) == 'table' and type(x.parent_index) == 'number') then
- return false
- end
+ if x.parent ~= nil and not (type(x.parent) == 'table' and type(x.parent_index) == 'number') then return false end
-- Methods
for _, name in ipairs({ 'insert', 'remove', 'has_descendant', 'has_lines', 'clear_lines' }) do
- if type(x[name]) ~= 'function' then
- return false
- end
+ if type(x[name]) ~= 'function' then return false end
end
return true
diff --git a/tests/statusline-tests/lua/nvim-web-devicons.lua b/tests/statusline-tests/lua/nvim-web-devicons.lua
index edd6fe8..c076f0a 100644
--- a/tests/statusline-tests/lua/nvim-web-devicons.lua
+++ b/tests/statusline-tests/lua/nvim-web-devicons.lua
@@ -2,17 +2,9 @@ return {
get_icon = function(filename, extension, options)
_G.devicons_args = { filename = filename, extension = extension, options = options }
- if filename == 'LICENSE' then
- return '', 'DevIconLicense'
- end
- if extension == 'lua' then
- return '', 'DevIconLua'
- end
- if extension == 'txt' then
- return '', 'DevIconTxt'
- end
- if (options or {}).default then
- return '', 'DevIconDefault'
- end
+ if filename == 'LICENSE' then return '', 'DevIconLicense' end
+ if extension == 'lua' then return '', 'DevIconLua' end
+ if extension == 'txt' then return '', 'DevIconTxt' end
+ if (options or {}).default then return '', 'DevIconDefault' end
end,
}
diff --git a/tests/tabline-tests/lua/nvim-web-devicons.lua b/tests/tabline-tests/lua/nvim-web-devicons.lua
index edd6fe8..c076f0a 100644
--- a/tests/tabline-tests/lua/nvim-web-devicons.lua
+++ b/tests/tabline-tests/lua/nvim-web-devicons.lua
@@ -2,17 +2,9 @@ return {
get_icon = function(filename, extension, options)
_G.devicons_args = { filename = filename, extension = extension, options = options }
- if filename == 'LICENSE' then
- return '', 'DevIconLicense'
- end
- if extension == 'lua' then
- return '', 'DevIconLua'
- end
- if extension == 'txt' then
- return '', 'DevIconTxt'
- end
- if (options or {}).default then
- return '', 'DevIconDefault'
- end
+ if filename == 'LICENSE' then return '', 'DevIconLicense' end
+ if extension == 'lua' then return '', 'DevIconLua' end
+ if extension == 'txt' then return '', 'DevIconTxt' end
+ if (options or {}).default then return '', 'DevIconDefault' end
end,
}
diff --git a/tests/test_base16.lua b/tests/test_base16.lua
index e3ce885..7ecea4d 100644
--- a/tests/test_base16.lua
+++ b/tests/test_base16.lua
@@ -118,9 +118,7 @@ T['setup()']['defines builtin highlight groups'] = function()
validate_hl_group('SpellBad', ('ctermbg=9 gui=%s guisp=%s'):format('undercurl', p.base08))
-- Don't test exact values on Neovim<=0.5.1 due to CI difficulties
- if vim.fn.has('nvim-0.6.0') == 0 then
- return
- end
+ if vim.fn.has('nvim-0.6.0') == 0 then return end
validate_hl_group('Comment', ('ctermfg=14 guifg=%s'):format(p.base03))
validate_hl_group('Error', ('ctermfg=15 ctermbg=9 guifg=%s guibg=%s'):format(p.base00, p.base08))
diff --git a/tests/test_completion.lua b/tests/test_completion.lua
index 1984997..684efd0 100644
--- a/tests/test_completion.lua
+++ b/tests/test_completion.lua
@@ -46,9 +46,7 @@ local get_shown_completion_data = function(what)
local complete_info = vim.fn.complete_info()
-- No words is shown if no popup is shown or there is no items
- if complete_info.pum_visible ~= 1 or #complete_info.items == 0 then
- return {}
- end
+ if complete_info.pum_visible ~= 1 or #complete_info.items == 0 then return {} end
local res = {}
local i, n_items = 0, #complete_info.items
diff --git a/tests/test_cursorword.lua b/tests/test_cursorword.lua
index 72a4766..3b7f6c6 100644
--- a/tests/test_cursorword.lua
+++ b/tests/test_cursorword.lua
@@ -195,9 +195,7 @@ T['Cursorword autohighlighting']['stops in Terminal mode'] = function()
end
T['Cursorword autohighlighting']['respects ModeChanged'] = function()
- if child.fn.exists('##ModeChanged') ~= 1 then
- return
- end
+ if child.fn.exists('##ModeChanged') ~= 1 then return end
-- Add disabling in Visual mode
unload_module()
diff --git a/tests/test_indentscope.lua b/tests/test_indentscope.lua
index ee2c74e..ed731b3 100644
--- a/tests/test_indentscope.lua
+++ b/tests/test_indentscope.lua
@@ -534,9 +534,7 @@ T['Auto drawing']['respects TextChangedP'] = function()
end
T['Auto drawing']['respects ModeChanged'] = function()
- if child.fn.exists('##ModeChanged') ~= 1 then
- return
- end
+ if child.fn.exists('##ModeChanged') ~= 1 then return end
-- Add disabling in Insert mode
unload_module()
diff --git a/tests/test_starter.lua b/tests/test_starter.lua
index 4b7449a..3992fc3 100644
--- a/tests/test_starter.lua
+++ b/tests/test_starter.lua
@@ -1093,15 +1093,11 @@ local get_hl_history = function(filter)
return vim.tbl_filter(function(x)
for key, val in pairs(filter) do
- if not (x[key] == nil or x[key] == val) then
- return false
- end
+ if not (x[key] == nil or x[key] == val) then return false end
end
-- Use special `line` key to filter by line
- if not (filter.line == nil or filter.line == x.start[1]) then
- return false
- end
+ if not (filter.line == nil or filter.line == x.start[1]) then return false end
return true
end, history)
diff --git a/tests/test_statusline.lua b/tests/test_statusline.lua
index 58e9936..7b009de 100644
--- a/tests/test_statusline.lua
+++ b/tests/test_statusline.lua
@@ -26,9 +26,7 @@ local setup_windows = function()
child.cmd('vsplit')
local win_list = child.api.nvim_list_wins()
- if win_list[1] == child.api.nvim_get_current_win() then
- return { active = win_list[1], inactive = win_list[2] }
- end
+ if win_list[1] == child.api.nvim_get_current_win() then return { active = win_list[1], inactive = win_list[2] } end
return { active = win_list[2], inactive = win_list[1] }
end
diff --git a/tests/test_test.lua b/tests/test_test.lua
index fdb97b8..e008a95 100644
--- a/tests/test_test.lua
+++ b/tests/test_test.lua
@@ -901,9 +901,7 @@ T['child']['redirected method tables'] = new_set({
T['child']['redirected method tables']['method'] = function(tbl_name, field_name, args)
-- Test only on Neovim>=0.7 (not everything is present in earlier versions)
- if child.fn.has('nvim-0.7.0') == 0 then
- return
- end
+ if child.fn.has('nvim-0.7.0') == 0 then return end
--stylua: ignore
local method = function() return child[tbl_name][field_name](unpack(args)) end
@@ -912,9 +910,7 @@ end
T['child']['redirected method tables']['field'] = function(tbl_name, field_name, _, _)
-- Test only on Neovim>=0.7 (not everything is present in earlier versions)
- if child.fn.has('nvim-0.7.0') == 0 then
- return
- end
+ if child.fn.has('nvim-0.7.0') == 0 then return end
-- Although being tables, they should be overridable to allow test doubles
validate_child_field(tbl_name, field_name, true)
@@ -1175,9 +1171,7 @@ end
T['child']['get_screenshot()']['throws error with floating windows in Neovim<=0.7'] = function()
skip_screenshot()
- if child.fn.has('nvim-0.8') == 1 then
- return
- end
+ if child.fn.has('nvim-0.8') == 1 then return end
local buf_id = child.api.nvim_create_buf(true, true)
child.api.nvim_buf_set_lines(buf_id, 0, -1, true, { ' ' })
@@ -1187,9 +1181,7 @@ T['child']['get_screenshot()']['throws error with floating windows in Neovim<=0.
end
T['child']['get_screenshot()']['works with floating windows in Neovim>=0.8'] = function()
- if child.fn.has('nvim-0.8') == 0 then
- return
- end
+ if child.fn.has('nvim-0.8') == 0 then return end
-- This setup should result into displayed text 'bb a': 'bb ' from floating
-- window, 'aa' - from underneath text
@@ -1224,9 +1216,7 @@ T['gen_reporter']['buffer'] = new_set({
})
T['gen_reporter']['buffer']['test'] = function(opts_element)
- if child.fn.has('nvim-0.8') == 0 then
- return
- end
+ if child.fn.has('nvim-0.8') == 0 then return end
mark_flaky()
diff --git a/.stylua.toml b/.stylua.toml
index 6601564..b5f9cee 100644
--- a/.stylua.toml
+++ b/.stylua.toml
@@ -4,3 +4,4 @@ indent_type = "Spaces"
indent_width = 2
quote_style = "AutoPreferSingle"
no_call_parentheses = false
+collapse_simple_statement = "FunctionOnly"
diff --git a/lua/mini/base16.lua b/lua/mini/base16.lua
index ddc6e7d..c9111ea 100644
--- a/lua/mini/base16.lua
+++ b/lua/mini/base16.lua
@@ -240,9 +240,7 @@ function MiniBase16.rgb_palette_to_cterm_palette(palette)
-- Create cterm palette only when it is needed to decrease load time
H.ensure_cterm_palette()
- return vim.tbl_map(function(hex)
- return H.nearest_rgb_id(H.hex2rgb(hex), H.cterm_palette)
- end, palette)
+ return vim.tbl_map(function(hex) return H.nearest_rgb_id(H.hex2rgb(hex), H.cterm_palette) end, palette)
end
-- Helper data ================================================================
diff --git a/lua/mini/bufremove.lua b/lua/mini/bufremove.lua
index 13a99a8..10cb53b 100644
--- a/lua/mini/bufremove.lua
+++ b/lua/mini/bufremove.lua
@@ -190,9 +190,7 @@ function H.apply_config(config)
end
end
-function H.is_disabled()
- return vim.g.minibufremove_disable == true or vim.b.minibufremove_disable == true
-end
+function H.is_disabled() return vim.g.minibufremove_disable == true or vim.b.minibufremove_disable == true end
-- Removing implementation ----------------------------------------------------
function H.unshow_and_cmd(buf_id, force, cmd)
diff --git a/lua/mini/comment.lua b/lua/mini/comment.lua
index f5fdc8c..0aed4cb 100644
--- a/lua/mini/comment.lua
+++ b/lua/mini/comment.lua
@@ -280,9 +280,7 @@ function H.apply_config(config)
H.map('o', config.mappings.textobject, '<cmd>lua MiniComment.textobject()<cr>', { desc = 'Comment textobject' })
end
-function H.is_disabled()
- return vim.g.minicomment_disable == true or vim.b.minicomment_disable == true
-end
+function H.is_disabled() return vim.g.minicomment_disable == true or vim.b.minicomment_disable == true end
-- Core implementations -------------------------------------------------------
function H.make_comment_parts()
@@ -306,9 +304,7 @@ function H.make_comment_check(comment_parts)
-- <space> <left> <anything> <right> <space>
local regex = string.format('^%%s-%s.*%s%%s-$', vim.pesc(l), vim.pesc(r))
- return function(line)
- return line:find(regex) ~= nil
- end
+ return function(line) return line:find(regex) ~= nil end
end
function H.get_lines_info(lines, comment_parts)
diff --git a/lua/mini/completion.lua b/lua/mini/completion.lua
index 05008a3..baed287 100644
--- a/lua/mini/completion.lua
+++ b/lua/mini/completion.lua
@@ -261,9 +261,7 @@ MiniCompletion.config = {
return vim.startswith(H.get_completion_word(item), base) and item.kind ~= 15
end, items)
- table.sort(res, function(a, b)
- return (a.sortText or a.label) < (b.sortText or b.label)
- end)
+ table.sort(res, function(a, b) return (a.sortText or a.label) < (b.sortText or b.label) end)
return res
end,
@@ -631,9 +629,7 @@ function H.setup_config(config)
lsp_completion = { config.lsp_completion, 'table' },
fallback_action = {
config.fallback_action,
- function(x)
- return type(x) == 'function' or type(x) == 'string'
- end,
+ function(x) return type(x) == 'function' or type(x) == 'string' end,
'function or string',
},
mappings = { config.mappings, 'table' },
@@ -650,9 +646,7 @@ function H.setup_config(config)
['lsp_completion.source_func'] = {
config.lsp_completion.source_func,
- function(x)
- return x == 'completefunc' or x == 'omnifunc'
- end,
+ function(x) return x == 'completefunc' or x == 'omnifunc' end,
'one of strings: "completefunc" or "omnifunc"',
},
['lsp_completion.auto_setup'] = { config.lsp_completion.auto_setup, 'boolean' },
@@ -688,9 +682,7 @@ function H.apply_config(config)
end
end
-function H.is_disabled()
- return vim.g.minicompletion_disable == true or vim.b.minicompletion_disable == true
-end
+function H.is_disabled() return vim.g.minicompletion_disable == true or vim.b.minicompletion_disable == true end
-- Completion triggers --------------------------------------------------------
function H.trigger_twostep()
@@ -859,9 +851,7 @@ function H.process_lsp_response(request_result, processor)
return res
end
-function H.is_lsp_current(cache, id)
- return cache.lsp.id == id and cache.lsp.status == 'sent'
-end
+function H.is_lsp_current(cache, id) return cache.lsp.id == id and cache.lsp.status == 'sent' end
-- Completion -----------------------------------------------------------------
-- This is a truncated version of
@@ -1376,9 +1366,7 @@ function H.is_char_keyword(char)
return vim.fn.match(char, '[[:keyword:]]') >= 0
end
-function H.pumvisible()
- return vim.fn.pumvisible() > 0
-end
+function H.pumvisible() return vim.fn.pumvisible() > 0 end
function H.get_completion_start()
-- Compute start position of latest keyword (as in `vim.lsp.omnifunc`)
diff --git a/lua/mini/cursorword.lua b/lua/mini/cursorword.lua
index 5740950..95b8002 100644
--- a/lua/mini/cursorword.lua
+++ b/lua/mini/cursorword.lua
@@ -208,9 +208,7 @@ function H.apply_config(config)
MiniCursorword.config = config
end
-function H.is_disabled()
- return vim.g.minicursorword_disable == true or vim.b.minicursorword_disable == true
-end
+function H.is_disabled() return vim.g.minicursorword_disable == true or vim.b.minicursorword_disable == true end
-- Highlighting ---------------------------------------------------------------
---@param only_current boolean Whether to forcefuly highlight only current word
@@ -279,8 +277,6 @@ function H.is_cursor_on_keyword()
return vim.fn.match(curchar, '[[:keyword:]]') >= 0
end
-function H.get_cursor_word()
- return vim.fn.escape(vim.fn.expand('<cword>'), [[\/]])
-end
+function H.get_cursor_word() return vim.fn.escape(vim.fn.expand('<cword>'), [[\/]]) end
return MiniCursorword
diff --git a/lua/mini/doc.lua b/lua/mini/doc.lua
index 04a1f1e..c5e9681 100644
--- a/lua/mini/doc.lua
+++ b/lua/mini/doc.lua
@@ -179,9 +179,7 @@ end
MiniDoc.config = {
-- Function which extracts part of line used to denote annotation.
-- For more information see 'Notes' in |MiniDoc.config|.
- annotation_extractor = function(l)
- return string.find(l, '^%-%-%-(%S*) ?')
- end,
+ annotation_extractor = function(l) return string.find(l, '^%-%-%-(%S*) ?') end,
-- Identifier of block annotation lines until first captured identifier
default_section_id = '@text',
@@ -232,9 +230,7 @@ MiniDoc.config = {
--minidoc_replace_start ['@eval'] = --<function: evaluates lines; replaces with their return>,
['@eval'] = function(s)
local src = table.concat(s, '\n')
- local is_loaded, code = pcall(function()
- return assert(loadstring(src))
- end)
+ local is_loaded, code = pcall(function() return assert(loadstring(src)) end)
local output
if is_loaded then
MiniDoc.current.eval_section = s
@@ -791,9 +787,7 @@ function H.apply_config(config)
MiniDoc.config = config
end
-function H.is_disabled()
- return vim.g.minidoc_disable == true or vim.b.minidoc_disable == true
-end
+function H.is_disabled() return vim.g.minidoc_disable == true or vim.b.minidoc_disable == true end
-- Work with project specific script ==========================================
function H.execute_project_script(input, output, config)
@@ -833,9 +827,7 @@ function H.default_input()
local files = vim.fn.globpath(dir_glob, '*.lua', false, true)
-- Use full paths
- files = vim.tbl_map(function(x)
- return vim.fn.fnamemodify(x, ':p')
- end, files)
+ files = vim.tbl_map(function(x) return vim.fn.fnamemodify(x, ':p') end, files)
-- Put 'init.lua' first among files from same directory
table.sort(files, function(a, b)
@@ -1021,9 +1013,9 @@ function H.toc_insert(s)
-- Render table of contents
local toc_lines = {}
for _, toc_entry in ipairs(MiniDoc.current.toc) do
- local _, tag_section = toc_entry.parent:has_descendant(function(x)
- return type(x) == 'table' and x.type == 'section' and x.info.id == '@tag'
- end)
+ local _, tag_section = toc_entry.parent:has_descendant(
+ function(x) return type(x) == 'table' and x.type == 'section' and x.info.id == '@tag' end
+ )
tag_section = tag_section or {}
local lines = {}
@@ -1099,12 +1091,12 @@ end
-- Infer data from afterlines -------------------------------------------------
function H.infer_header(b)
- local has_signature = b:has_descendant(function(x)
- return type(x) == 'table' and x.type == 'section' and x.info.id == '@signature'
- end)
- local has_tag = b:has_descendant(function(x)
- return type(x) == 'table' and x.type == 'section' and x.info.id == '@tag'
- end)
+ local has_signature = b:has_descendant(
+ function(x) return type(x) == 'table' and x.type == 'section' and x.info.id == '@signature' end
+ )
+ local has_tag = b:has_descendant(
+ function(x) return type(x) == 'table' and x.type == 'section' and x.info.id == '@tag' end
+ )
if has_signature and has_tag then
return
@@ -1207,9 +1199,7 @@ function H.new_struct(struct_type, info)
end
output.has_lines = function(self)
- return self:has_descendant(function(x)
- return type(x) == 'string'
- end)
+ return self:has_descendant(function(x) return type(x) == 'string' end)
end
output.clear_lines = function(self)
@@ -1314,9 +1304,7 @@ end
---
---@private
function H.match_first_pattern(text, pattern_set, init)
- local start_tbl = vim.tbl_map(function(pattern)
- return text:find(pattern, init) or math.huge
- end, pattern_set)
+ local start_tbl = vim.tbl_map(function(pattern) return text:find(pattern, init) or math.huge end, pattern_set)
local min_start, min_id = math.huge, nil
for id, st in ipairs(start_tbl) do
@@ -1371,9 +1359,7 @@ function H.file_write(path, lines)
vim.fn.writefile(lines, path, 'b')
end
-function H.full_path(path)
- return vim.fn.resolve(vim.fn.fnamemodify(path, ':p'))
-end
+function H.full_path(path) return vim.fn.resolve(vim.fn.fnamemodify(path, ':p')) end
function H.message(msg)
vim.cmd('echomsg ' .. vim.inspect('(mini.doc) ' .. msg))
diff --git a/lua/mini/fuzzy.lua b/lua/mini/fuzzy.lua
index 2d6a8d5..af7c323 100644
--- a/lua/mini/fuzzy.lua
+++ b/lua/mini/fuzzy.lua
@@ -150,9 +150,7 @@ function MiniFuzzy.process_lsp_items(items, base)
-- Fuzzy match
local _, match_inds = MiniFuzzy.filtersort(base, words)
- return vim.tbl_map(function(i)
- return items[i]
- end, match_inds)
+ return vim.tbl_map(function(i) return items[i] end, match_inds)
end
--- Custom getter for `telescope.nvim` sorter
@@ -222,9 +220,7 @@ function H.setup_config(config)
vim.validate({
cutoff = {
config.cutoff,
- function(x)
- return type(x) == 'number' and x >= 1
- end,
+ function(x) return type(x) == 'number' and x >= 1 end,
'number not less than 1',
},
})
@@ -375,8 +371,6 @@ function H.filter_by_indexes(candidate_array, ids)
end
-- Utilities ------------------------------------------------------------------
-function H.string_to_letters(s)
- return vim.tbl_map(vim.pesc, vim.split(s, ''))
-end
+function H.string_to_letters(s) return vim.tbl_map(vim.pesc, vim.split(s, '')) end
return MiniFuzzy
diff --git a/lua/mini/indentscope.lua b/lua/mini/indentscope.lua
index fe285b6..91989d4 100644
--- a/lua/mini/indentscope.lua
+++ b/lua/mini/indentscope.lua
@@ -223,9 +223,7 @@ MiniIndentscope.config = {
-- |MiniIndentscope.gen_animation()| for builtin options. To not use
-- animation, supply `require('mini.indentscope').gen_animation('none')`.
--minidoc_replace_start animation = --<function: implements constant 20ms between steps>,
- animation = function(s, n)
- return 20
- end,
+ animation = function(s, n) return 20 end,
--minidoc_replace_end
},
@@ -641,18 +639,10 @@ H.current = { event_id = 0, scope = {}, draw_status = 'none' }
-- Functions to compute indent in ambiguous cases
H.indent_funs = {
- ['min'] = function(top_indent, bottom_indent)
- return math.min(top_indent, bottom_indent)
- end,
- ['max'] = function(top_indent, bottom_indent)
- return math.max(top_indent, bottom_indent)
- end,
- ['top'] = function(top_indent, bottom_indent)
- return top_indent
- end,
- ['bottom'] = function(top_indent, bottom_indent)
- return bottom_indent
- end,
+ ['min'] = function(top_indent, bottom_indent) return math.min(top_indent, bottom_indent) end,
+ ['max'] = function(top_indent, bottom_indent) return math.max(top_indent, bottom_indent) end,
+ ['top'] = function(top_indent, bottom_indent) return top_indent end,
+ ['bottom'] = function(top_indent, bottom_indent) return bottom_indent end,
}
-- Functions to compute indent of blank line to satisfy `config.options.border`
@@ -665,15 +655,9 @@ H.blank_indent_funs = {
-- Functions to compute border from body
H.border_from_body = {
- ['none'] = function(body, opts)
- return {}
- end,
- ['top'] = function(body, opts)
- return { top = body.top - 1, indent = H.get_line_indent(body.top - 1, opts) }
- end,
- ['bottom'] = function(body, opts)
- return { bottom = body.bottom + 1, indent = H.get_line_indent(body.bottom + 1, opts) }
- end,
+ ['none'] = function(body, opts) return {} end,
+ ['top'] = function(body, opts) return { top = body.top - 1, indent = H.get_line_indent(body.top - 1, opts) } end,
+ ['bottom'] = function(body, opts) return { bottom = body.bottom + 1, indent = H.get_line_indent(body.bottom + 1, opts) } end,
['both'] = function(body, opts)
return {
top = body.top - 1,
@@ -685,9 +669,7 @@ H.border_from_body = {
-- Functions to correct line in case it is a border
H.border_correctors = {
- ['none'] = function(line, opts)
- return line
- end,
+ ['none'] = function(line, opts) return line end,
['top'] = function(line, opts)
local cur_indent, next_indent = H.get_line_indent(line, opts), H.get_line_indent(line + 1, opts)
return (cur_indent < next_indent) and (line + 1) or line
@@ -765,9 +747,7 @@ function H.apply_config(config)
--stylua: ignore start
end
-function H.is_disabled()
- return vim.g.miniindentscope_disable == true or vim.b.miniindentscope_disable == true
-end
+function H.is_disabled() return vim.g.miniindentscope_disable == true or vim.b.miniindentscope_disable == true end
function H.get_opts(opts)
local opts_local = vim.b.miniindentscope_options
@@ -814,9 +794,7 @@ function H.cast_ray(line, indent, direction, opts)
return final_line, min_indent
end
-function H.scope_get_draw_indent(scope)
- return scope.border.indent or (scope.body.indent - 1)
-end
+function H.scope_get_draw_indent(scope) return scope.border.indent or (scope.body.indent - 1) end
function H.scope_is_equal(scope_1, scope_2)
if type(scope_1) ~= 'table' or type(scope_2) ~= 'table' then
@@ -1081,12 +1059,8 @@ function H.animation_arithmetic_powers(power, type, opts)
end
return ({
- ['in'] = function(s, n)
- return make_delta(n) * (n - s + 1) ^ power
- end,
- ['out'] = function(s, n)
- return make_delta(n) * s ^ power
- end,
+ ['in'] = function(s, n) return make_delta(n) * (n - s + 1) ^ power end,
+ ['out'] = function(s, n) return make_delta(n) * s ^ power end,
['in-out'] = function(s, n)
local n_half = math.ceil(0.5 * n)
local s_halved
diff --git a/lua/mini/jump.lua b/lua/mini/jump.lua
index 2b3a08b..32d0798 100644
--- a/lua/mini/jump.lua
+++ b/lua/mini/jump.lua
@@ -375,9 +375,7 @@ function H.apply_config(config)
--stylua: ignore end
end
-function H.is_disabled()
- return vim.g.minijump_disable == true or vim.b.minijump_disable == true
-end
+function H.is_disabled() return vim.g.minijump_disable == true or vim.b.minijump_disable == true end
-- Highlighting ---------------------------------------------------------------
function H.highlight(pattern)
diff --git a/lua/mini/jump2d.lua b/lua/mini/jump2d.lua
index 2c8935f..04ffda5 100644
--- a/lua/mini/jump2d.lua
+++ b/lua/mini/jump2d.lua
@@ -475,9 +475,7 @@ MiniJump2d.builtin_opts.default = { spotter = MiniJump2d.default_spotter }
---
--- Defines `spotter` and `hooks.after_jump`.
MiniJump2d.builtin_opts.line_start = {
- spotter = function(line_num, args)
- return { 1 }
- end,
+ spotter = function(line_num, args) return { 1 } end,
hooks = {
after_jump = function()
-- Move to first non-blank character
@@ -519,17 +517,15 @@ end
---
--- Defines `spotter`, `allowed_lines.blank`, `allowed_lines.fold`, and
--- `hooks.before_start`.
-MiniJump2d.builtin_opts.single_character = user_input_opts(function()
- return H.getcharstr('Enter single character to search')
-end)
+MiniJump2d.builtin_opts.single_character = user_input_opts(
+ function() return H.getcharstr('Enter single character to search') end
+)
--- Jump to query taken from user input
---
--- Defines `spotter`, `allowed_lines.blank`, `allowed_lines.fold`, and
--- `hooks.before_start`.
-MiniJump2d.builtin_opts.query = user_input_opts(function()
- return H.input('Enter query to search')
-end)
+MiniJump2d.builtin_opts.query = user_input_opts(function() return H.input('Enter query to search') end)
-- Helper data ================================================================
-- Module default config
@@ -596,9 +592,7 @@ function H.apply_config(config)
H.map('o', keymap, '<Cmd>lua MiniJump2d.start()<CR>', { desc = 'Start 2d jumping' })
end
-function H.is_disabled()
- return vim.g.minijump2d_disable == true or vim.b.minijump2d_disable == true
-end
+function H.is_disabled() return vim.g.minijump2d_disable == true or vim.b.minijump2d_disable == true end
-- Jump spots -----------------------------------------------------------------
function H.spots_compute(opts)
@@ -811,9 +805,7 @@ function H.message(msg)
vim.cmd('echomsg ' .. vim.inspect('(mini.jump2d) ' .. msg))
end
-function H.is_operator_pending()
- return vim.tbl_contains({ 'no', 'noV', H.keys.block_operator_pending }, vim.fn.mode(1))
-end
+function H.is_operator_pending() return vim.tbl_contains({ 'no', 'noV', H.keys.block_operator_pending }, vim.fn.mode(1)) end
function H.getcharstr(msg)
local needs_help_msg = true
diff --git a/lua/mini/misc.lua b/lua/mini/misc.lua
index f6565c5..05085dc 100644
--- a/lua/mini/misc.lua
+++ b/lua/mini/misc.lua
@@ -298,9 +298,7 @@ function MiniMisc.use_nested_comments(buf_id)
end
-- Extract raw comment leader from 'commentstring' option
- local comment_parts = vim.tbl_filter(function(x)
- return x ~= ''
- end, vim.split(commentstring, '%s', true))
+ local comment_parts = vim.tbl_filter(function(x) return x ~= '' end, vim.split(commentstring, '%s', true))
-- Don't do anything if 'commentstring' is like '/*%s*/' (as in 'json')
if #comment_parts > 1 then
diff --git a/lua/mini/pairs.lua b/lua/mini/pairs.lua
index b70e022..1b81db9 100644
--- a/lua/mini/pairs.lua
+++ b/lua/mini/pairs.lua
@@ -436,9 +436,7 @@ function H.apply_config(config)
end
end
-function H.is_disabled()
- return vim.g.minipairs_disable == true or vim.b.minipairs_disable == true
-end
+function H.is_disabled() return vim.g.minipairs_disable == true or vim.b.minipairs_disable == true end
-- Pair registration ----------------------------------------------------------
function H.register_pair(pair_info, mode, buffer)
@@ -564,9 +562,7 @@ function H.get_cursor_neigh(start, finish)
return string.sub(('%s%s%s'):format('\r', line, '\n'), col + 1 + start, col + 1 + finish)
end
-function H.neigh_match(pattern)
- return (pattern == nil) or (H.get_cursor_neigh(0, 1):find(pattern) ~= nil)
-end
+function H.neigh_match(pattern) return (pattern == nil) or (H.get_cursor_neigh(0, 1):find(pattern) ~= nil) end
function H.get_arrow_key(key)
if vim.fn.mode() == 'i' then
diff --git a/lua/mini/sessions.lua b/lua/mini/sessions.lua
index bf718c4..62a120a 100644
--- a/lua/mini/sessions.lua
+++ b/lua/mini/sessions.lua
@@ -355,15 +355,11 @@ function MiniSessions.select(action, opts)
return a_name < b_name
end
table.sort(detected, sort_fun)
- local detected_names = vim.tbl_map(function(x)
- return x.name
- end, detected)
+ local detected_names = vim.tbl_map(function(x) return x.name end, detected)
vim.ui.select(detected_names, {
prompt = 'Select session to ' .. action,
- format_item = function(x)
- return ('%s (%s)'):format(x, MiniSessions.detected[x].type)
- end,
+ format_item = function(x) return ('%s (%s)'):format(x, MiniSessions.detected[x].type) end,
}, function(item, idx)
if item == nil then
return
@@ -455,9 +451,7 @@ function H.apply_config(config)
MiniSessions.detected = H.detect_sessions(config)
end
-function H.is_disabled()
- return vim.g.minisessions_disable == true or vim.b.minisessions_disable == true
-end
+function H.is_disabled() return vim.g.minisessions_disable == true or vim.b.minisessions_disable == true end
-- Work with sessions ---------------------------------------------------------
function H.detect_sessions(config)
@@ -532,14 +526,13 @@ function H.validate_detected(session_name)
end
function H.get_unsaved_listed_buffers()
- return vim.tbl_filter(function(buf_id)
- return vim.api.nvim_buf_get_option(buf_id, 'modified') and vim.api.nvim_buf_get_option(buf_id, 'buflisted')
- end, vim.api.nvim_list_bufs())
+ return vim.tbl_filter(
+ function(buf_id) return vim.api.nvim_buf_get_option(buf_id, 'modified') and vim.api.nvim_buf_get_option(buf_id, 'buflisted') end,
+ vim.api.nvim_list_bufs()
+ )
end
-function H.get_current_session_name()
- return vim.fn.fnamemodify(vim.v.this_session, ':t')
-end
+function H.get_current_session_name() return vim.fn.fnamemodify(vim.v.this_session, ':t') end
function H.name_to_path(session_name)
if session_name == nil then
@@ -577,17 +570,11 @@ function H.error(msg)
error(('(mini.sessions) %s'):format(msg))
end
-function H.is_readable_file(path)
- return vim.fn.isdirectory(path) ~= 1 and vim.fn.getfperm(path):sub(1, 1) == 'r'
-end
+function H.is_readable_file(path) return vim.fn.isdirectory(path) ~= 1 and vim.fn.getfperm(path):sub(1, 1) == 'r' end
-function H.joinpath(directory, filename)
- return ('%s%s%s'):format(directory, H.path_sep, tostring(filename))
-end
+function H.joinpath(directory, filename) return ('%s%s%s'):format(directory, H.path_sep, tostring(filename)) end
-function H.full_path(path)
- return vim.fn.resolve(vim.fn.fnamemodify(path, ':p'))
-end
+function H.full_path(path) return vim.fn.resolve(vim.fn.fnamemodify(path, ':p')) end
function H.is_something_shown()
-- Don't autoread session if Neovim is opened to show something. That is
@@ -604,9 +591,10 @@ function H.is_something_shown()
-- - Several buffers are listed (like session with placeholder buffers). That
-- means unlisted buffers (like from `nvim-tree`) don't affect decision.
- local listed_buffers = vim.tbl_filter(function(buf_id)
- return vim.fn.buflisted(buf_id) == 1
- end, vim.api.nvim_list_bufs())
+ local listed_buffers = vim.tbl_filter(
+ function(buf_id) return vim.fn.buflisted(buf_id) == 1 end,
+ vim.api.nvim_list_bufs()
+ )
if #listed_buffers > 1 then
return true
end
diff --git a/lua/mini/starter.lua b/lua/mini/starter.lua
index dec8f6d..640c172 100644
--- a/lua/mini/starter.lua
+++ b/lua/mini/starter.lua
@@ -521,9 +521,7 @@ function MiniStarter.sections.recent_files(n, current_dir, show_path)
local section = ('Recent files%s'):format(current_dir and ' (current directory)' or '')
-- Use only actual readable files
- local files = vim.tbl_filter(function(f)
- return vim.fn.filereadable(f) == 1
- end, vim.v.oldfiles or {})
+ local files = vim.tbl_filter(function(f) return vim.fn.filereadable(f) == 1 end, vim.v.oldfiles or {})
if #files == 0 then
return { { name = 'There are no recent files (`v:oldfiles` is empty)', action = '', section = section } }
@@ -533,9 +531,7 @@ function MiniStarter.sections.recent_files(n, current_dir, show_path)
if current_dir then
local cwd = vim.loop.cwd()
local n_cwd = cwd:len()
- files = vim.tbl_filter(function(f)
- return f:sub(1, n_cwd) == cwd
- end, files)
+ files = vim.tbl_filter(function(f) return f:sub(1, n_cwd) == cwd end, files)
end
if #files == 0 then
@@ -715,9 +711,7 @@ function MiniStarter.gen_hook.aligning(horizontal, vertical)
-- Align horizontally
-- Don't use `string.len()` to account for multibyte characters
- local lines_width = vim.tbl_map(function(l)
- return vim.fn.strdisplaywidth(l)
- end, line_strings)
+ local lines_width = vim.tbl_map(function(l) return vim.fn.strdisplaywidth(l) end, line_strings)
local min_right_space = vim.api.nvim_win_get_width(0) - math.max(unpack(lines_width))
local left_pad = math.max(math.floor(horiz_coef * min_right_space), 0)
@@ -749,15 +743,11 @@ end
function MiniStarter.content_coords(content, predicate)
content = content or MiniStarter.content
if predicate == nil then
- predicate = function(unit)
- return true
- end
+ predicate = function(unit) return true end
end
if type(predicate) == 'string' then
local pred_type = predicate
- predicate = function(unit)
- return unit.type == pred_type
- end
+ predicate = function(unit) return unit.type == pred_type end
end
local res = {}
@@ -843,9 +833,7 @@ function MiniStarter.content_to_items(content)
end
-- Compute length of unique prefix for every item's name (ignoring case)
- local strings = vim.tbl_map(function(x)
- return x.name:lower()
- end, items)
+ local strings = vim.tbl_map(function(x) return x.name:lower() end, items)
local nprefix = H.unique_nprefix(strings)
for i, n in ipairs(nprefix) do
items[i]._nprefix = n
@@ -1002,9 +990,7 @@ function H.apply_config(config)
MiniStarter.config = config
end
-function H.is_disabled()
- return vim.g.ministarter_disable == true or vim.b.ministarter_disable == true
-end
+function H.is_disabled() return vim.g.ministarter_disable == true or vim.b.ministarter_disable == true end
-- Normalize config elements --------------------------------------------------
function H.normalize_items(items)
@@ -1346,9 +1332,10 @@ function H.is_something_shown()
-- - Several buffers are listed (like session with placeholder buffers). That
-- means unlisted buffers (like from `nvim-tree`) don't affect decision.
- local listed_buffers = vim.tbl_filter(function(buf_id)
- return vim.fn.buflisted(buf_id) == 1
- end, vim.api.nvim_list_bufs())
+ local listed_buffers = vim.tbl_filter(
+ function(buf_id) return vim.fn.buflisted(buf_id) == 1 end,
+ vim.api.nvim_list_bufs()
+ )
if #listed_buffers > 1 then
return true
end
diff --git a/lua/mini/statusline.lua b/lua/mini/statusline.lua
index b0c827b..d6f061a 100644
--- a/lua/mini/statusline.lua
+++ b/lua/mini/statusline.lua
@@ -506,9 +506,7 @@ function H.apply_config(config)
end
end
-function H.is_disabled()
- return vim.g.ministatusline_disable == true or vim.b.ministatusline_disable == true
-end
+function H.is_disabled() return vim.g.ministatusline_disable == true or vim.b.ministatusline_disable == true end
-- Mode -----------------------------------------------------------------------
-- Custom `^V` and `^S` symbols to make this file appropriate for copy-paste
@@ -564,9 +562,7 @@ function H.default_content_active()
-- stylua: ignore end
end
-function H.default_content_inactive()
- return '%#MiniStatuslineInactive#%F%='
-end
+function H.default_content_inactive() return '%#MiniStatuslineInactive#%F%=' end
-- Utilities ------------------------------------------------------------------
function H.isnt_normal_buffer()
@@ -601,13 +597,9 @@ function H.get_filetype_icon()
end
if vim.fn.has('nvim-0.6') == 1 then
- H.get_diagnostic_count = function(id)
- return #vim.diagnostic.get(0, { severity = id })
- end
+ H.get_diagnostic_count = function(id) return #vim.diagnostic.get(0, { severity = id }) end
else
- H.get_diagnostic_count = function(id)
- return vim.lsp.diagnostic.get_count(0, id)
- end
+ H.get_diagnostic_count = function(id) return vim.lsp.diagnostic.get_count(0, id) end
end
return MiniStatusline
diff --git a/lua/mini/surround.lua b/lua/mini/surround.lua
index 10bf2a8..624cbdc 100644
--- a/lua/mini/surround.lua
+++ b/lua/mini/surround.lua
@@ -656,9 +656,7 @@ function H.apply_config(config)
--stylua: ignore end
end
-function H.is_disabled()
- return vim.g.minisurround_disable == true or vim.b.minisurround_disable == true
-end
+function H.is_disabled() return vim.g.minisurround_disable == true or vim.b.minisurround_disable == true end
function H.is_search_method(x, x_name)
x = x or MiniSurround.config.search_method
diff --git a/lua/mini/tabline.lua b/lua/mini/tabline.lua
index c172120..6d26e83 100644
--- a/lua/mini/tabline.lua
+++ b/lua/mini/tabline.lua
@@ -190,9 +190,7 @@ function H.apply_config(config)
vim.o.tabline = '%!v:lua.MiniTabline.make_tabline_string()'
end
-function H.is_disabled()
- return vim.g.minitabline_disable == true or vim.b.minitabline_disable == true
-end
+function H.is_disabled() return vim.g.minitabline_disable == true or vim.b.minitabline_disable == true end
-- Work with tabpages ---------------------------------------------------------
function H.make_tabpage_section()
@@ -224,9 +222,7 @@ function H.list_tabs()
H.tabs = tabs
end
-function H.is_buffer_in_minitabline(buf_id)
- return vim.api.nvim_buf_get_option(buf_id, 'buflisted')
-end
+function H.is_buffer_in_minitabline(buf_id) return vim.api.nvim_buf_get_option(buf_id, 'buflisted') end
-- Tab's highlight group
function H.construct_highlight(buf_id)
@@ -388,9 +384,7 @@ function H.get_nonunique_tab_ids()
end
-- Collect tab-array-ids with non-unique labels
- return vim.tbl_flatten(vim.tbl_filter(function(x)
- return #x > 1
- end, label_tab_ids))
+ return vim.tbl_flatten(vim.tbl_filter(function(x) return #x > 1 end, label_tab_ids))
end
-- Fit tabline to maximum displayed width -------------------------------------
diff --git a/lua/mini/test.lua b/lua/mini/test.lua
index f68bf7b..0398d79 100644
--- a/lua/mini/test.lua
+++ b/lua/mini/test.lua
@@ -398,9 +398,7 @@ function MiniTest.run_at_location(location, opts)
local stronger_opts = {
collect = {
- find_files = function()
- return { location.file }
- end,
+ find_files = function() return { location.file } end,
filter_cases = function(case)
local info = debug.getinfo(case.test)
@@ -624,9 +622,7 @@ end
--- Check if tests are being executed
---
---@return boolean
-function MiniTest.is_executing()
- return H.cache.is_executing == true
-end
+function MiniTest.is_executing() return H.cache.is_executing == true end
-- Expectations ---------------------------------------------------------------
--- Table with expectation functions
@@ -844,9 +840,7 @@ function MiniTest.gen_reporter.buffer(opts)
)
local buf_id, win_id
- local is_valid_buf_win = function()
- return vim.api.nvim_buf_is_valid(buf_id) and vim.api.nvim_win_is_valid(win_id)
- end
+ local is_valid_buf_win = function() return vim.api.nvim_buf_is_valid(buf_id) and vim.api.nvim_win_is_valid(win_id) end
-- Helpers
local set_cursor = function(line)
@@ -1131,9 +1125,7 @@ function MiniTest.new_child_neovim()
child.api = setmetatable({}, {
__index = function(_, key)
ensure_running()
- return function(...)
- return vim.rpcrequest(child.job.channel, key, ...)
- end
+ return function(...) return vim.rpcrequest(child.job.channel, key, ...) end
end,
})
@@ -1142,9 +1134,7 @@ function MiniTest.new_child_neovim()
child.api_notify = setmetatable({}, {
__index = function(_, key)
ensure_running()
- return function(...)
- return vim.rpcnotify(child.job.channel, key, ...)
- end
+ return function(...) return vim.rpcnotify(child.job.channel, key, ...) end
end,
})
@@ -1286,9 +1276,7 @@ function MiniTest.new_child_neovim()
return child.api.nvim_get_mode()['blocking']
end
- function child.is_running()
- return child.job ~= nil
- end
+ function child.is_running() return child.job ~= nil end
-- Various wrappers
function child.ensure_normal_mode()
@@ -1608,9 +1596,7 @@ function H.apply_config(config)
MiniTest.config = config
end
-function H.is_disabled()
- return vim.g.minitest_disable == true or vim.b.minitest_disable == true
-end
+function H.is_disabled() return vim.g.minitest_disable == true or vim.b.minitest_disable == true end
-- Work with collection -------------------------------------------------------
function H.busted_emulate(set)
@@ -2158,9 +2144,7 @@ function H.screenshot_new(t)
end
return setmetatable(t, {
- __tostring = function(x)
- return string.format('%s\n\n%s', process_screen(x.text), process_screen(x.attr))
- end,
+ __tostring = function(x) return string.format('%s\n\n%s', process_screen(x.text), process_screen(x.attr)) end,
})
end
@@ -2273,9 +2257,7 @@ function H.add_prefix(tbl, prefix)
end, tbl)
end
-function H.add_style(x, ansi_code)
- return string.format('%s%s%s', H.ansi_codes[ansi_code], x, H.ansi_codes.reset)
-end
+function H.add_style(x, ansi_code) return string.format('%s%s%s', H.ansi_codes[ansi_code], x, H.ansi_codes.reset) end
function H.string_to_chars(s)
-- Can't use `vim.split(s, '')` because of multibyte characters
diff --git a/lua/mini/trailspace.lua b/lua/mini/trailspace.lua
index 7509187..da63e52 100644
--- a/lua/mini/trailspace.lua
+++ b/lua/mini/trailspace.lua
@@ -173,13 +173,9 @@ function H.apply_config(config)
MiniTrailspace.config = config
end
-function H.is_disabled()
- return vim.g.minitrailspace_disable == true or vim.b.minitrailspace_disable == true
-end
+function H.is_disabled() return vim.g.minitrailspace_disable == true or vim.b.minitrailspace_disable == true end
-function H.is_buffer_normal(buf_id)
- return vim.api.nvim_buf_get_option(buf_id or 0, 'buftype') == ''
-end
+function H.is_buffer_normal(buf_id) return vim.api.nvim_buf_get_option(buf_id or 0, 'buftype') == '' end
function H.get_match_id()
-- NOTE: this can be replaced with more efficient custom tracking of id per
diff --git a/tests/completion-tests/mock-months-lsp.lua b/tests/completion-tests/mock-months-lsp.lua
index e4733e2..62e3f2f 100644
--- a/tests/completion-tests/mock-months-lsp.lua
+++ b/tests/completion-tests/mock-months-lsp.lua
@@ -127,6 +127,4 @@ vim.lsp.buf_get_clients = function(bufnr)
}
end
-vim.lsp.get_client_by_id = function(client_id)
- return vim.lsp.buf_get_clients(0)[client_id]
-end
+vim.lsp.get_client_by_id = function(client_id) return vim.lsp.buf_get_clients(0)[client_id] end
diff --git a/tests/dir-test/testref_custom-script.lua b/tests/dir-test/testref_custom-script.lua
index b216e71..9a01662 100644
--- a/tests/dir-test/testref_custom-script.lua
+++ b/tests/dir-test/testref_custom-script.lua
@@ -3,8 +3,6 @@ _G.custom_script_result = 'This actually ran'
-- Dummy call to `run()` to ensure there is no infinite loop
MiniTest.run({
collect = {
- find_files = function()
- return {}
- end,
+ find_files = function() return {} end,
},
})
diff --git a/tests/doc-tests/sections/eval.lua b/tests/doc-tests/sections/eval.lua
index 22b9e90..0ce5c2e 100644
--- a/tests/doc-tests/sections/eval.lua
+++ b/tests/doc-tests/sections/eval.lua
@@ -13,9 +13,7 @@ local M = {}
M.tab = {
-- Some functional setting
--minidoc_replace_start a = <function; should be padded>,
- a = function()
- return 1 + 1
- end,
+ a = function() return 1 + 1 end,
--minidoc_replace_end
-- A very important setting
b = 2,
diff --git a/tests/doc-tests/sections/init.lua b/tests/doc-tests/sections/init.lua
index c863a1d..9b2183f 100644
--- a/tests/doc-tests/sections/init.lua
+++ b/tests/doc-tests/sections/init.lua
@@ -17,9 +17,7 @@ M.User = {}
---
---@overload fun(x: string)
---@diagnostic disable
-local f = function(x, y)
- return x + 1
-end
+local f = function(x, y) return x + 1 end
---@diagnostic enable
--- Test for `@private`
@@ -33,9 +31,7 @@ M._private_user = {}
---@usage `M.fun(1, 2)`
---
---@seealso |test-f| |f-test-different-line|
-function M.fun(a, b)
- return true
-end
+function M.fun(a, b) return true end
--- Test for `@signature` and `@tag`
---
diff --git a/tests/helpers.lua b/tests/helpers.lua
index 03923f7..c25d71e 100644
--- a/tests/helpers.lua
+++ b/tests/helpers.lua
@@ -3,17 +3,17 @@ local Helpers = {}
-- Add extra expectations
Helpers.expect = vim.deepcopy(MiniTest.expect)
-Helpers.expect.match = MiniTest.new_expectation('string matching', function(str, pattern)
- return str:find(pattern) ~= nil
-end, function(str, pattern)
- return string.format('Pattern: %s\nObserved string: %s', vim.inspect(pattern), str)
-end)
-
-Helpers.expect.no_match = MiniTest.new_expectation('no string matching', function(str, pattern)
- return str:find(pattern) == nil
-end, function(str, pattern)
- return string.format('Pattern: %s\nObserved string: %s', vim.inspect(pattern), str)
-end)
+Helpers.expect.match = MiniTest.new_expectation(
+ 'string matching',
+ function(str, pattern) return str:find(pattern) ~= nil end,
+ function(str, pattern) return string.format('Pattern: %s\nObserved string: %s', vim.inspect(pattern), str) end
+)
+
+Helpers.expect.no_match = MiniTest.new_expectation(
+ 'no string matching',
+ function(str, pattern) return str:find(pattern) == nil end,
+ function(str, pattern) return string.format('Pattern: %s\nObserved string: %s', vim.inspect(pattern), str) end
+)
-- Monkey-patch `MiniTest.new_child_neovim` with helpful wrappers
Helpers.new_child_neovim = function()
@@ -35,17 +35,13 @@ Helpers.new_child_neovim = function()
child.api.nvim_buf_set_lines(0, start or 0, finish or -1, false, arr)
end
- function child.get_lines(start, finish)
- return child.api.nvim_buf_get_lines(0, start or 0, finish or -1, false)
- end
+ function child.get_lines(start, finish) return child.api.nvim_buf_get_lines(0, start or 0, finish or -1, false) end
function child.set_cursor(line, column, win_id)
child.api.nvim_win_set_cursor(win_id or 0, { line, column })
end
- function child.get_cursor(win_id)
- return child.api.nvim_win_get_cursor(win_id or 0)
- end
+ function child.get_cursor(win_id) return child.api.nvim_win_get_cursor(win_id or 0) end
function child.set_size(lines, columns)
if type(lines) == 'number' then
@@ -75,9 +71,7 @@ Helpers.new_child_neovim = function()
actions = actions or {}
local before = actions.before or function() end
local effect = actions.effect
- or function()
- return { cursor = child.get_cursor(), text = child.api.nvim_buf_get_lines(0, 0, -1, true) }
- end
+ or function() return { cursor = child.get_cursor(), text = child.api.nvim_buf_get_lines(0, 0, -1, true) } end
local after = actions.after or function() end
before()
diff --git a/tests/statusline-tests/mock-diagnostics.lua b/tests/statusline-tests/mock-diagnostics.lua
index c202ef4..c5476a1 100644
--- a/tests/statusline-tests/mock-diagnostics.lua
+++ b/tests/statusline-tests/mock-diagnostics.lua
@@ -1,11 +1,8 @@
-vim.lsp.buf_get_clients = function()
- return { 'mock client' }
-end
+vim.lsp.buf_get_clients = function() return { 'mock client' } end
-- Neovim <= 0.5.1
-vim.lsp.diagnostic.get_count = function(buf_id, id)
- return ({ Error = 4, Warning = 3, Information = 2, Hint = 1 })[id]
-end
+vim.lsp.diagnostic.get_count =
+ function(buf_id, id) return ({ Error = 4, Warning = 3, Information = 2, Hint = 1 })[id] end
-- Neovim >= 0.6
if vim.diagnostic == nil then
diff --git a/tests/test_comment.lua b/tests/test_comment.lua
index 7643af4..9a40c85 100644
--- a/tests/test_comment.lua
+++ b/tests/test_comment.lua
@@ -99,9 +99,7 @@ T['setup()']['validates `config` argument'] = function()
end
T['setup()']['properly handles `config.mappings`'] = function()
- local has_map = function(lhs)
- return child.cmd_capture('omap ' .. lhs):find('MiniComment') ~= nil
- end
+ local has_map = function(lhs) return child.cmd_capture('omap ' .. lhs):find('MiniComment') ~= nil end
eq(has_map('gc'), true)
unload_module()
diff --git a/tests/test_completion.lua b/tests/test_completion.lua
index 1984997..90777d9 100644
--- a/tests/test_completion.lua
+++ b/tests/test_completion.lua
@@ -68,15 +68,14 @@ end
local get_completion = function(what)
what = what or 'word'
- return vim.tbl_map(function(x)
- return x[what]
- end, child.fn.complete_info().items)
+ return vim.tbl_map(function(x) return x[what] end, child.fn.complete_info().items)
end
local get_floating_windows = function()
- return vim.tbl_filter(function(x)
- return child.api.nvim_win_get_config(x).relative ~= ''
- end, child.api.nvim_list_wins())
+ return vim.tbl_filter(
+ function(x) return child.api.nvim_win_get_config(x).relative ~= '' end,
+ child.api.nvim_list_wins()
+ )
end
local validate_single_floating_win = function(opts)
@@ -201,9 +200,7 @@ T['setup()']['validates `config` argument'] = function()
end
T['setup()']['properly handles `config.mappings`'] = function()
- local has_map = function(lhs)
- return child.cmd_capture('imap ' .. lhs):find('MiniCompletion') ~= nil
- end
+ local has_map = function(lhs) return child.cmd_capture('imap ' .. lhs):find('MiniCompletion') ~= nil end
eq(has_map('<C-Space>'), true)
unload_module()
@@ -277,9 +274,7 @@ end
T['Autocompletion']['works without LSP clients'] = function()
-- Mock absence of LSP
- child.lsp.buf_get_clients = function()
- return {}
- end
+ child.lsp.buf_get_clients = function() return {} end
type_keys('i', 'aa ab a')
eq(get_completion(), {})
diff --git a/tests/test_cursorword.lua b/tests/test_cursorword.lua
index 72a4766..11514d1 100644
--- a/tests/test_cursorword.lua
+++ b/tests/test_cursorword.lua
@@ -31,9 +31,7 @@ local word_is_highlighted = function(word)
end
local get_match = function(hl_group)
- return vim.tbl_filter(function(x)
- return x.group == hl_group
- end, child.fn.getmatches())
+ return vim.tbl_filter(function(x) return x.group == hl_group end, child.fn.getmatches())
end
-- Data =======================================================================
diff --git a/tests/test_fuzzy.lua b/tests/test_fuzzy.lua
index 215b7dc..1ab51d2 100644
--- a/tests/test_fuzzy.lua
+++ b/tests/test_fuzzy.lua
@@ -159,9 +159,7 @@ end
T['filtersort()'] = new_set()
-local filtersort = function(...)
- return child.lua_get('{ MiniFuzzy.filtersort(...) }', { ... })
-end
+local filtersort = function(...) return child.lua_get('{ MiniFuzzy.filtersort(...) }', { ... }) end
local validate_filtersort = function(word, candidate_array, matched_candidates)
local output = filtersort(word, candidate_array)
@@ -193,13 +191,10 @@ end
T['process_lsp_items()'] = new_set()
-local new_item = function(newText, insertText, label)
- return { textEdit = { newText = newText }, insertText = insertText, label = label }
-end
+local new_item =
+ function(newText, insertText, label) return { textEdit = { newText = newText }, insertText = insertText, label = label } end
-local process_lsp_items = function(...)
- return child.lua_get('MiniFuzzy.process_lsp_items(...)', { ... })
-end
+local process_lsp_items = function(...) return child.lua_get('MiniFuzzy.process_lsp_items(...)', { ... }) end
T['process_lsp_items()']['works'] = function()
local items
diff --git a/tests/test_indentscope.lua b/tests/test_indentscope.lua
index ee2c74e..c1d6bd6 100644
--- a/tests/test_indentscope.lua
+++ b/tests/test_indentscope.lua
@@ -36,9 +36,7 @@ local get_visual_marks = function()
end, extmarks)
-- Ensure increasing order of lines
- table.sort(res, function(a, b)
- return a.line < b.line
- end)
+ table.sort(res, function(a, b) return a.line < b.line end)
return res
end
@@ -156,9 +154,7 @@ T['setup()']['validates `config` argument'] = function()
end
T['setup()']['properly handles `config.mappings`'] = function()
- local has_map = function(lhs)
- return child.cmd_capture('nmap ' .. lhs):find('MiniIndentscope') ~= nil
- end
+ local has_map = function(lhs) return child.cmd_capture('nmap ' .. lhs):find('MiniIndentscope') ~= nil end
eq(has_map('[i'), true)
unload_module()
@@ -177,12 +173,8 @@ T['get_scope()'] = new_set({
},
})
-local get_scope = function(...)
- return child.lua_get('MiniIndentscope.get_scope(...)', { ... })
-end
-local get_cursor_scope = function(opts)
- return child.lua_get('MiniIndentscope.get_scope(nil, nil, ...)', { opts })
-end
+local get_scope = function(...) return child.lua_get('MiniIndentscope.get_scope(...)', { ... }) end
+local get_cursor_scope = function(opts) return child.lua_get('MiniIndentscope.get_scope(nil, nil, ...)', { opts }) end
T['get_scope()']['returns correct structure'] = function()
set_cursor(3, 4)
@@ -282,9 +274,7 @@ local expect_easing = function(easing, target, opts, tolerance)
opts = opts or {}
tolerance = tolerance or 0.1
child.lua('_G._f = MiniIndentscope.gen_animation(...)', { easing, opts })
- local f = function(...)
- return child.lua_get('_G._f(...)', { ... })
- end
+ local f = function(...) return child.lua_get('_G._f(...)', { ... }) end
for i, _ in ipairs(target) do
-- Expect approximate equality
eq(math.abs(f(i, #target) - target[i]) <= tolerance, true)
diff --git a/tests/test_jump.lua b/tests/test_jump.lua
index 852332d..53692b7 100644
--- a/tests/test_jump.lua
+++ b/tests/test_jump.lua
@@ -114,9 +114,7 @@ T['setup()']['validates `config` argument'] = function()
end
T['setup()']['properly handles `config.mappings`'] = function()
- local has_map = function(lhs)
- return child.cmd_capture('nmap ' .. lhs):find('MiniJump') ~= nil
- end
+ local has_map = function(lhs) return child.cmd_capture('nmap ' .. lhs):find('MiniJump') ~= nil end
eq(has_map('f'), true)
unload_module()
@@ -137,9 +135,7 @@ T['state'] = new_set({
},
})
-local get_state = function()
- return child.lua_get('MiniJump.state')
-end
+local get_state = function() return child.lua_get('MiniJump.state') end
T['state']['has correct initial values'] = function()
eq(get_state(), {
@@ -593,9 +589,7 @@ T['Jumping with f/t/F/T']['for t/T ignores matches with nothing before/after the
end
T['Jumping with f/t/F/T']['asks for target letter after one idle second'] = function()
- local get_latest_message = function()
- return child.cmd_capture('1messages')
- end
+ local get_latest_message = function() return child.cmd_capture('1messages') end
child.cmd('messages clear')
-- Execute one time to test if 'needs help message' flag is set per call
diff --git a/tests/test_jump2d.lua b/tests/test_jump2d.lua
index 3384d69..27f8847 100644
--- a/tests/test_jump2d.lua
+++ b/tests/test_jump2d.lua
@@ -66,9 +66,7 @@ local get_extmarks = function()
end
local get_extmarks_short = function()
- return vim.tbl_map(function(x)
- return { x.col, x.text }
- end, get_extmarks())
+ return vim.tbl_map(function(x) return { x.col, x.text } end, get_extmarks())
end
--- Convert {{col = 1, text = 'aa'}, {col = 5, text = 'bbb'}} to ' aa bbb'
@@ -136,9 +134,7 @@ local get_extmark_lines = function()
return raw_lines
end
-local get_extmark_lines_curwin = function()
- return get_extmark_lines()[child.api.nvim_get_current_win()]
-end
+local get_extmark_lines_curwin = function() return get_extmark_lines()[child.api.nvim_get_current_win()] end
-- Window setups
local setup_windows = function()
@@ -299,9 +295,7 @@ T['setup()']['applies `config.mappings`'] = function()
end
T['setup()']['properly handles `config.mappings`'] = function()
- local has_map = function(lhs)
- return child.cmd_capture('nmap ' .. lhs):find('MiniJump2d') ~= nil
- end
+ local has_map = function(lhs) return child.cmd_capture('nmap ' .. lhs):find('MiniJump2d') ~= nil end
eq(has_map('<CR>'), true)
unload_module()
diff --git a/tests/test_misc.lua b/tests/test_misc.lua
index a2a1337..160dbe8 100644
--- a/tests/test_misc.lua
+++ b/tests/test_misc.lua
@@ -68,9 +68,7 @@ T['bench_time()'] = new_set({
},
})
-local bench_time = function(...)
- return unpack(child.lua_get('{ MiniMisc.bench_time(_G.f, ...) }', { ... }))
-end
+local bench_time = function(...) return unpack(child.lua_get('{ MiniMisc.bench_time(_G.f, ...) }', { ... })) end
-- Validate that benchmark is within tolerable error from target. This is
-- needed due to random nature of benchmarks.
@@ -230,9 +228,7 @@ end
T['stat_summary()'] = new_set()
-local stat_summary = function(...)
- return child.lua_get('MiniMisc.stat_summary({ ... })', { ... })
-end
+local stat_summary = function(...) return child.lua_get('MiniMisc.stat_summary({ ... })', { ... }) end
T['stat_summary()']['works'] = function()
eq(stat_summary(10, 4, 3, 2, 1), { minimum = 1, mean = 4, median = 3, maximum = 10, n = 5, sd = math.sqrt(50 / 4) })
@@ -301,9 +297,10 @@ end
T['zoom()'] = new_set()
local get_floating_windows = function()
- return vim.tbl_filter(function(x)
- return child.api.nvim_win_get_config(x).relative ~= ''
- end, child.api.nvim_list_wins())
+ return vim.tbl_filter(
+ function(x) return child.api.nvim_win_get_config(x).relative ~= '' end,
+ child.api.nvim_list_wins()
+ )
end
T['zoom()']['works'] = function()
diff --git a/tests/test_pairs.lua b/tests/test_pairs.lua
index 833b8b1..1c2b79c 100644
--- a/tests/test_pairs.lua
+++ b/tests/test_pairs.lua
@@ -20,9 +20,7 @@ local sleep = function(ms) vim.loop.sleep(ms); poke_eventloop() end
-- Make helpers
local get_term_channel = function()
- local term_chans = vim.tbl_filter(function(x)
- return x.mode == 'terminal'
- end, child.api.nvim_list_chans())[1]['id']
+ local term_chans = vim.tbl_filter(function(x) return x.mode == 'terminal' end, child.api.nvim_list_chans())[1]['id']
return term_chans[1]['id']
end
diff --git a/tests/test_sessions.lua b/tests/test_sessions.lua
index b11c1f0..b6c26d6 100644
--- a/tests/test_sessions.lua
+++ b/tests/test_sessions.lua
@@ -42,13 +42,10 @@ local cleanup_directories = function()
end
end
-local get_latest_message = function()
- return child.cmd_capture('1messages')
-end
+local get_latest_message = function() return child.cmd_capture('1messages') end
-local get_buf_names = function()
- return child.lua_get('vim.tbl_map(function(x) return vim.fn.bufname(x) end, vim.api.nvim_list_bufs())')
-end
+local get_buf_names =
+ function() return child.lua_get('vim.tbl_map(function(x) return vim.fn.bufname(x) end, vim.api.nvim_list_bufs())') end
local compare_buffer_names = function(x, y)
-- Don't test exact equality because different Neovim versions create
diff --git a/tests/test_starter.lua b/tests/test_starter.lua
index 4b7449a..2b0b614 100644
--- a/tests/test_starter.lua
+++ b/tests/test_starter.lua
@@ -19,9 +19,7 @@ local type_keys = function(...) return child.type_keys(...) end
--stylua: ignore end
-- Make helpers
-local is_starter_shown = function()
- return child.bo.filetype == 'starter'
-end
+local is_starter_shown = function() return child.bo.filetype == 'starter' end
local validate_starter_shown = function()
eq(is_starter_shown(), true)
@@ -47,23 +45,16 @@ local validate_equal_starter = function(strconfig_1, strconfig_2)
reload_module()
end
-local get_latest_message = function()
- return child.cmd_capture('1messages')
-end
+local get_latest_message = function() return child.cmd_capture('1messages') end
local get_active_items_names = function()
local items = child.lua_get('MiniStarter.content_to_items(MiniStarter.content)')
- local active_items = vim.tbl_filter(function(x)
- return x._active == true
- end, items)
- return vim.tbl_map(function(x)
- return x.name
- end, active_items)
+ local active_items = vim.tbl_filter(function(x) return x._active == true end, items)
+ return vim.tbl_map(function(x) return x.name end, active_items)
end
-local mock_item = function(name, section)
- return { name = name, action = ('lua _G.item_name = %s'):format(vim.inspect(name)), section = section }
-end
+local mock_item =
+ function(name, section) return { name = name, action = ('lua _G.item_name = %s'):format(vim.inspect(name)), section = section } end
local mock_itemstring = function(name, section)
return ([[{ name = '%s', action = 'lua _G.item_name = "%s"', section = '%s' }]]):format(name, name, section)
@@ -1087,9 +1078,10 @@ T['Highlighting'] = new_set({
local get_hl_history = function(filter)
filter = filter or {}
- local history = vim.tbl_map(function(x)
- return { hl = x[3], start = x[4], finish = x[5], priority = (x[6] or {}).priority }
- end, child.lua_get('_G.hl_history'))
+ local history = vim.tbl_map(
+ function(x) return { hl = x[3], start = x[4], finish = x[5], priority = (x[6] or {}).priority } end,
+ child.lua_get('_G.hl_history')
+ )
return vim.tbl_filter(function(x)
for key, val in pairs(filter) do
diff --git a/tests/test_statusline.lua b/tests/test_statusline.lua
index 58e9936..cdee37d 100644
--- a/tests/test_statusline.lua
+++ b/tests/test_statusline.lua
@@ -169,9 +169,7 @@ end
T['combine_groups()'] = new_set()
-local combine_groups = function(...)
- return child.lua_get('MiniStatusline.combine_groups(...)', { ... })
-end
+local combine_groups = function(...) return child.lua_get('MiniStatusline.combine_groups(...)', { ... }) end
local example_groups = {
{ hl = 'AA', strings = { 'a1', 'a2' } },
@@ -206,9 +204,7 @@ T['combine_groups()']['allows empty `strings` to start new highlight'] = functio
eq(combine_groups({ { strings = { 'a1', 'a2' } }, { hl = 'BB' }, { strings = { 'c1' } } }), ' a1 a2 %#BB# c1 ')
end
-local eval_content = function(field)
- return child.lua_get(('MiniStatusline.%s()'):format(field))
-end
+local eval_content = function(field) return child.lua_get(('MiniStatusline.%s()'):format(field)) end
T['active()/inactive()'] = new_set({
parametrize = { { 'active' }, { 'inactive' } },
@@ -418,9 +414,7 @@ end
T['section_mode()'] = new_set()
-local section_mode = function(args)
- return child.lua_get('{ MiniStatusline.section_mode(...) }', { args or {} })
-end
+local section_mode = function(args) return child.lua_get('{ MiniStatusline.section_mode(...) }', { args or {} }) end
T['section_mode()']['works'] = function()
eq(section_mode(), { 'Normal', 'MiniStatuslineModeNormal' })
@@ -472,9 +466,8 @@ T['section_searchcount()'] = new_set({
},
})
-local section_searchcount = function(args)
- return child.lua_get('MiniStatusline.section_searchcount(...)', { args or {} })
-end
+local section_searchcount =
+ function(args) return child.lua_get('MiniStatusline.section_searchcount(...)', { args or {} }) end
T['section_searchcount()']['works'] = function()
set_lines({ '', 'a a a ' })
diff --git a/tests/test_surround.lua b/tests/test_surround.lua
index 2dabea7..c839d3d 100644
--- a/tests/test_surround.lua
+++ b/tests/test_surround.lua
@@ -23,9 +23,7 @@ local clear_messages = function()
child.cmd('messages clear')
end
-local get_latest_message = function()
- return child.cmd_capture('1messages')
-end
+local get_latest_message = function() return child.cmd_capture('1messages') end
local has_message_about_not_found = function(char, n_lines, search_method)
n_lines = n_lines or 20
diff --git a/tests/test_test.lua b/tests/test_test.lua
index fdb97b8..c915a9d 100644
--- a/tests/test_test.lua
+++ b/tests/test_test.lua
@@ -16,9 +16,7 @@ local set_lines = function(...) return child.set_lines(...) end
local get_lines = function(...) return child.get_lines(...) end
--stylua: ignore end
-local get_ref_path = function(name)
- return string.format('tests/dir-test/%s', name)
-end
+local get_ref_path = function(name) return string.format('tests/dir-test/%s', name) end
local skip_screenshot = function()
if child.fn.has('nvim-0.6') == 0 then
@@ -61,9 +59,7 @@ local testrun_ref_file = function(name)
end
local filter_by_desc = function(cases, id, value)
- return vim.tbl_filter(function(c)
- return c.desc[id] == value
- end, cases)
+ return vim.tbl_filter(function(c) return c.desc[id] == value end, cases)
end
local expect_all_state = function(cases, state)
@@ -225,9 +221,7 @@ end
T['run()']['handles `data`'] = function()
local res = testrun_ref_file('testref_run-data.lua')
- local short_res = vim.tbl_map(function(c)
- return { data = c.data, desc = vim.list_slice(c.desc, 2) }
- end, res)
+ local short_res = vim.tbl_map(function(c) return { data = c.data, desc = vim.list_slice(c.desc, 2) } end, res)
eq(#short_res, 2)
eq(short_res[1], {
@@ -242,13 +236,16 @@ end
T['run()']['handles `hooks`'] = function()
local res = testrun_ref_file('testref_run-hooks.lua')
- local order_cases = vim.tbl_map(function(c)
- return {
- desc = vim.list_slice(c.desc, 2),
- fails = c.exec.fails,
- n_hooks = { pre = #c.hooks.pre, post = #c.hooks.post },
- }
- end, filter_by_desc(res, 2, 'order'))
+ local order_cases = vim.tbl_map(
+ function(c)
+ return {
+ desc = vim.list_slice(c.desc, 2),
+ fails = c.exec.fails,
+ n_hooks = { pre = #c.hooks.pre, post = #c.hooks.post },
+ }
+ end,
+ filter_by_desc(res, 2, 'order')
+ )
eq(order_cases[1], {
desc = { 'order', 'first level' },
@@ -760,22 +757,22 @@ end
T['new_expectation()'] = new_set()
T['new_expectation()']['works'] = function()
- local expect_truthy = MiniTest.new_expectation('truthy', function(x)
- return x
- end, function(x)
- return 'Object: ' .. vim.inspect(x)
- end)
+ local expect_truthy = MiniTest.new_expectation(
+ 'truthy',
+ function(x) return x end,
+ function(x) return 'Object: ' .. vim.inspect(x) end
+ )
expect.error(expect_truthy, 'truthy%..*Object:.*Traceback:', false)
expect.no_error(expect_truthy, 1)
end
T['new_expectation()']['allows string or function arguments'] = function()
- local expect_truthy = MiniTest.new_expectation(function()
- return 'func_truthy'
- end, function(x)
- return x
- end, 'Not truthy')
+ local expect_truthy = MiniTest.new_expectation(
+ function() return 'func_truthy' end,
+ function(x) return x end,
+ 'Not truthy'
+ )
expect.error(expect_truthy, 'func_truthy%..*Not truthy.*Traceback:', false)
expect.no_error(expect_truthy, 1)
diff --git a/tests/test_trailspace.lua b/tests/test_trailspace.lua
index 8e90d0c..bf2daab 100644
--- a/tests/test_trailspace.lua
+++ b/tests/test_trailspace.lua
@@ -18,14 +18,10 @@ local type_keys = function(...) return child.type_keys(...) end
-- Make helpers
local get_match = function(win_id)
win_id = win_id or child.api.nvim_get_current_win()
- return vim.tbl_filter(function(x)
- return x.group == 'MiniTrailspace'
- end, child.fn.getmatches(win_id))
+ return vim.tbl_filter(function(x) return x.group == 'MiniTrailspace' end, child.fn.getmatches(win_id))
end
-local is_trailspace_highlighted = function(win_id)
- return #get_match(win_id) > 0
-end
+local is_trailspace_highlighted = function(win_id) return #get_match(win_id) > 0 end
local validate_highlighted = function(win_id)
eq(is_trailspace_highlighted(win_id), true)
@@ -41,9 +37,7 @@ end
-- Data =======================================================================
local example_lines = { 'aa ', 'aa ', 'aa\t', 'aa\t\t', 'aa \t', 'aa\t ', ' aa', '\taa' }
-local example_trimmed_lines = vim.tbl_map(function(x)
- return x:gsub('%s*$', '')
-end, example_lines)
+local example_trimmed_lines = vim.tbl_map(function(x) return x:gsub('%s*$', '') end, example_lines)
-- Output test set ============================================================
T = new_set({
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment