Code view:

A painting is a person's account of this edit as text, recorded independently of the node mapping - a rendering often has several equally defensible answers where the mapping has one. Deletions and insertions carry no position on the opposite side in a painting, so that panel draws no caret for them.

Before

…lines 1–301 unchanged (301 lines)
302 end)
303 )
304 end
305
306 return urls
307end
308
309return M
310

After

…lines 1–302 unchanged (302 lines)
303 )
304 end
305
306 return urls
307end
308
309do
310 ---@class ProgressMessage
311 ---@field id? number|string ID of the progress message
312 ---@field title? string Title of the progress message
313 ---@field status string Status: "running" | "success" | "failed" | "cancel"
314 ---@field percent? integer Percent complete (0–100)
315 ---@private
316
317 --- Cache of active progress messages, keyed by msg_id
318 --- TODO(justinmk): visibility of "stale" (never-finished) Progress. https://github.com/neovim/neovim/pull/35428#discussion_r2942696157
319 ---@type table<integer, ProgressMessage>
320 local progress = {}
321
322 -- store progress events
323 local progress_group, progress_autocmd = nil, nil
324
325 ---Initialize progress event listeners
326 local function progress_init()
327 progress_group = vim.api.nvim_create_augroup('nvim.ui.progress_status', { clear = true })
328 progress_autocmd = vim.api.nvim_create_autocmd('Progress', {
329 group = progress_group,
330 desc = 'Tracks progress messages for vim.ui.progress_status()',
331 ---@param ev {data: {id: integer, title: string, status: string, percent: integer}}
332 callback = function(ev)
333 if not ev.data or not ev.data.id then
334 return
335 end
336 progress[ev.data.id] = {
337 id = ev.data.id,
338 title = ev.data.title,
339 status = ev.data.status,
340 percent = ev.data.percent or 0,
341 }
342
343 -- Clear finished items
344 if
345 ev.data.status == 'success'
346 or ev.data.percent == 100
347 or ev.data.status == 'failed'
348 or ev.data.status == 'cancel'
349 then
350 progress[ev.data.id] = nil
351 end
352 end,
353 })
354 end
355
356 ---Return statusline text summarizing progress messages.
357 --- - If none: returns empty string
358 --- - If one running item: "title: 42%"
359 --- - If multiple running items: "Progress: N items AVG%"
360 ---@param running ProgressMessage[]
361 ---@return string
362 local function progress_status_fmt(running)
363 local count = #running
364 if count == 0 then
365 return '' -- nothing to show
366 elseif count == 1 then
367 local progress_item = running[1]
368 if progress_item.title == nil then
369 return string.format('%d%%%% ', progress_item.percent or 0)
370 end
371 return string.format('%s: %d%%%% ', progress_item.title, progress_item.percent or 0)
372 else
373 local sum = 0 ---@type integer
374 for _, progress_item in ipairs(running) do
375 sum = sum + (progress_item.percent or 0)
376 end
377 local avg = math.floor(sum / count)
378 return string.format('Progress: %d items %d%%%% ', count, avg)
379 end
380 end
381
382 --- Gets the status of currently running progress messages, in a format
383 --- convenient for inclusion in 'statusline'.
384 ---@return string formatted text of progress status for statusline
385 function M.progress_status()
386 -- Create progress event listener on first call
387 if progress_autocmd == nil then
388 progress_init()
389 end
390
391 local running = vim.tbl_values(progress)
392 return progress_status_fmt(running) or ''
393 end
394end
395
396return M
397

Before

chunk
variable_declaration
local "local"
assignment_statement
variable_list
identifier "M"
= "="
expression_list
table_constructor
{ "{"
} "}"
comment
-- "--"
comment_content "-@class vim.ui.select.Opts"
comment
-- "--"
comment_content "-@inlinedoc"
comment
-- "--"
comment_content "-"
comment
-- "--"
comment_content "- Text of the prompt. Defaults to `Select one of:`"
comment
-- "--"
comment_content "-@field prompt? string"
comment
-- "--"
comment_content "-"
comment
-- "--"
comment_content "- Function to format an"
comment
-- "--"
comment_content "- individual item from `items`. Defaults to `tostring`."
comment
-- "--"
comment_content "-@field format_item? fun(item: any):string"
comment
-- "--"
comment_content "-"
comment
-- "--"
comment_content "- Arbitrary hint string indicating the item shape."
comment
-- "--"
comment_content "- Plugins reimplementing `vim.ui.select` may wish to"
comment
-- "--"
comment_content "- use this to infer the structure or semantics of"
comment
-- "--"
comment_content "- `items`, or the context in which select() was called."
comment
-- "--"
comment_content "-@field kind? string"
comment
-- "--"
comment_content "- Prompts the user to pick from a list of items, allowing ar"...
comment
-- "--"
comment_content "- work until `on_choice`."
comment
-- "--"
comment_content "-"
comment
-- "--"
comment_content "- Example:"
comment
-- "--"
comment_content "-"
comment
-- "--"
comment_content "- ```lua"
comment
-- "--"
comment_content "- vim.ui.select({ 'tabs', 'spaces' }, {"
comment
-- "--"
comment_content "- prompt = 'Select tabs or spaces:',"
comment
-- "--"
comment_content "- format_item = function(item)"
comment
-- "--"
comment_content "- return \"I'd like to choose \" .. item"
comment
-- "--"
comment_content "- end,"
comment
-- "--"
comment_content "- }, function(choice)"
comment
-- "--"
comment_content "- if choice == 'spaces' then"
comment
-- "--"
comment_content "- vim.o.expandtab = true"
comment
-- "--"
comment_content "- else"
comment
-- "--"
comment_content "- vim.o.expandtab = false"
comment
-- "--"
comment_content "- end"
comment
-- "--"
comment_content "- end)"
comment
-- "--"
comment_content "- ```"
comment
-- "--"
comment_content "-"
comment
-- "--"
comment_content "-@generic T"
comment
-- "--"
comment_content "-@param items T[] Arbitrary items"
comment
-- "--"
comment_content "-@param opts vim.ui.select.Opts Additional options"
comment
-- "--"
comment_content "-@param on_choice fun(item: T|nil, idx: integer|nil)"
comment
-- "--"
comment_content "- Called once the user made a choice."
comment
-- "--"
comment_content "- `idx` is the 1-based index of `item` within "...
comment
-- "--"
comment_content "- `nil` if the user aborted the dialog."
function_declaration (+212 nodes collapsed)
comment
-- "--"
comment_content "-@class vim.ui.input.Opts"
comment
-- "--"
comment_content "-@inlinedoc"
comment
-- "--"
comment_content "-"
comment
-- "--"
comment_content "-Text of the prompt"
comment
-- "--"
comment_content "-@field prompt? string"
comment
-- "--"
comment_content "-"
comment
-- "--"
comment_content "-Default reply to the input"
comment
-- "--"
comment_content "-@field default? string"
comment
-- "--"
comment_content "-"
comment
-- "--"
comment_content "-Specifies type of completion supported"
comment
-- "--"
comment_content "-for input. Supported types are the same"
comment
-- "--"
comment_content "-that can be supplied to a user-defined"
comment
-- "--"
comment_content "-command using the \"-complete=\" argument."
comment
-- "--"
comment_content "-See |:command-completion|"
comment
-- "--"
comment_content "-@field completion? string"
comment
-- "--"
comment_content "-"
comment
-- "--"
comment_content "-Function that will be used for highlighting"
comment
-- "--"
comment_content "-user inputs."
comment
-- "--"
comment_content "-@field highlight? function"
comment
-- "--"
comment_content "- Prompts the user for input, allowing arbitrary (potentiall"...
comment
-- "--"
comment_content "- `on_confirm`."
comment
-- "--"
comment_content "-"
comment
-- "--"
comment_content "- Example:"
comment
-- "--"
comment_content "-"
comment
-- "--"
comment_content "- ```lua"
comment
-- "--"
comment_content "- vim.ui.input({ prompt = 'Enter value for shiftwidth: ' }, "...
comment
-- "--"
comment_content "- vim.o.shiftwidth = tonumber(input)"
comment
-- "--"
comment_content "- end)"
comment
-- "--"
comment_content "- ```"
comment
-- "--"
comment_content "-"
comment
-- "--"
comment_content "-@param opts? vim.ui.input.Opts Additional options. See |inp"...
comment
-- "--"
comment_content "-@param on_confirm fun(input?: string)"
comment
-- "--"
comment_content "- Called once the user confirms or abort the i"...
comment
-- "--"
comment_content "- `input` is what the user typed (it might be"
comment
-- "--"
comment_content "- an empty string if nothing was entered), or"
comment
-- "--"
comment_content "- `nil` if the user aborted the dialog."
function_declaration (+185 nodes collapsed)
comment
-- "--"
comment_content "-@class vim.ui.open.Opts"
comment
-- "--"
comment_content "-@inlinedoc"
comment
-- "--"
comment_content "-"
comment
-- "--"
comment_content "- Command used to open the path or URL."
comment
-- "--"
comment_content "-@field cmd? string[]"
comment
-- "--"
comment_content "- Opens `path` with the system default handler (macOS `open`"...
comment
-- "--"
comment_content "- `xdg-open`, …), or returns (but does not show) an error me"...
comment
-- "--"
comment_content "-"
comment
-- "--"
comment_content "- Can also be invoked with `:Open`. [:Open]()"
comment
-- "--"
comment_content "-"
comment
-- "--"
comment_content "- Expands \"~/\" and environment variables in filesystem paths"...
comment
-- "--"
comment_content "-"
comment
-- "--"
comment_content "- Examples:"
comment
-- "--"
comment_content "-"
comment
-- "--"
comment_content "- ```lua"
comment
-- "--"
comment_content "- -- Asynchronous."
comment
-- "--"
comment_content "- vim.ui.open(\"https://neovim.io/\")"
comment
-- "--"
comment_content "- vim.ui.open(\"~/path/to/file\")"
comment
-- "--"
comment_content "- -- Use the \"osurl\" command to handle the path or URL."
comment
-- "--"
comment_content "- vim.ui.open(\"gh#neovim/neovim!29490\", { cmd = { 'osurl' } "...
comment
-- "--"
comment_content "- -- Synchronous (wait until the process exits)."
comment
-- "--"
comment_content "- local cmd, err = vim.ui.open(\"$VIMRUNTIME\")"
comment
-- "--"
comment_content "- if cmd then"
comment
-- "--"
comment_content "- cmd:wait()"
comment
-- "--"
comment_content "- end"
comment
-- "--"
comment_content "- ```"
comment
-- "--"
comment_content "-"
comment
-- "--"
comment_content "-@param path string Path or URL to open"
comment
-- "--"
comment_content "-@param opt? vim.ui.open.Opts Options"
comment
-- "--"
comment_content "-"
comment
-- "--"
comment_content "-@return vim.SystemObj|nil # Command object, or nil if not f"...
comment
-- "--"
comment_content "-@return nil|string # Error message on failure, or nil on su"...
comment
-- "--"
comment_content "-"
comment
-- "--"
comment_content "-@see |vim.system()|"
function_declaration (+258 nodes collapsed)
comment
-- "--"
comment_content "- Get an available command used to open the path or URL."
comment
-- "--"
comment_content "-"
comment
-- "--"
comment_content "- @return string[]|nil # Command, or nil if not found."
comment
-- "--"
comment_content "- @return nil|string # Error message on failure, or nil on s"...
function_declaration (+257 nodes collapsed)
comment
-- "--"
comment_content "- @param bufnr integer"
variable_declaration (+439 nodes collapsed)
comment
-- "--"
comment_content "- Returns all URLs at cursor, if any."
comment
-- "--"
comment_content "- @return string[]"
function_declaration (+650 nodes collapsed)
return_statement
return "return"
expression_list
identifier "M"

After

chunk
variable_declaration
local "local"
assignment_statement
variable_list
identifier "M"
= "="
expression_list
table_constructor
{ "{"
} "}"
comment
-- "--"
comment_content "-@class vim.ui.select.Opts"
comment
-- "--"
comment_content "-@inlinedoc"
comment
-- "--"
comment_content "-"
comment
-- "--"
comment_content "- Text of the prompt. Defaults to `Select one of:`"
comment
-- "--"
comment_content "-@field prompt? string"
comment
-- "--"
comment_content "-"
comment
-- "--"
comment_content "- Function to format an"
comment
-- "--"
comment_content "- individual item from `items`. Defaults to `tostring`."
comment
-- "--"
comment_content "-@field format_item? fun(item: any):string"
comment
-- "--"
comment_content "-"
comment
-- "--"
comment_content "- Arbitrary hint string indicating the item shape."
comment
-- "--"
comment_content "- Plugins reimplementing `vim.ui.select` may wish to"
comment
-- "--"
comment_content "- use this to infer the structure or semantics of"
comment
-- "--"
comment_content "- `items`, or the context in which select() was called."
comment
-- "--"
comment_content "-@field kind? string"
comment
-- "--"
comment_content "- Prompts the user to pick from a list of items, allowing ar"...
comment
-- "--"
comment_content "- work until `on_choice`."
comment
-- "--"
comment_content "-"
comment
-- "--"
comment_content "- Example:"
comment
-- "--"
comment_content "-"
comment
-- "--"
comment_content "- ```lua"
comment
-- "--"
comment_content "- vim.ui.select({ 'tabs', 'spaces' }, {"
comment
-- "--"
comment_content "- prompt = 'Select tabs or spaces:',"
comment
-- "--"
comment_content "- format_item = function(item)"
comment
-- "--"
comment_content "- return \"I'd like to choose \" .. item"
comment
-- "--"
comment_content "- end,"
comment
-- "--"
comment_content "- }, function(choice)"
comment
-- "--"
comment_content "- if choice == 'spaces' then"
comment
-- "--"
comment_content "- vim.o.expandtab = true"
comment
-- "--"
comment_content "- else"
comment
-- "--"
comment_content "- vim.o.expandtab = false"
comment
-- "--"
comment_content "- end"
comment
-- "--"
comment_content "- end)"
comment
-- "--"
comment_content "- ```"
comment
-- "--"
comment_content "-"
comment
-- "--"
comment_content "-@generic T"
comment
-- "--"
comment_content "-@param items T[] Arbitrary items"
comment
-- "--"
comment_content "-@param opts vim.ui.select.Opts Additional options"
comment
-- "--"
comment_content "-@param on_choice fun(item: T|nil, idx: integer|nil)"
comment
-- "--"
comment_content "- Called once the user made a choice."
comment
-- "--"
comment_content "- `idx` is the 1-based index of `item` within "...
comment
-- "--"
comment_content "- `nil` if the user aborted the dialog."
function_declaration (+212 nodes collapsed)
comment
-- "--"
comment_content "-@class vim.ui.input.Opts"
comment
-- "--"
comment_content "-@inlinedoc"
comment
-- "--"
comment_content "-"
comment
-- "--"
comment_content "-Text of the prompt"
comment
-- "--"
comment_content "-@field prompt? string"
comment
-- "--"
comment_content "-"
comment
-- "--"
comment_content "-Default reply to the input"
comment
-- "--"
comment_content "-@field default? string"
comment
-- "--"
comment_content "-"
comment
-- "--"
comment_content "-Specifies type of completion supported"
comment
-- "--"
comment_content "-for input. Supported types are the same"
comment
-- "--"
comment_content "-that can be supplied to a user-defined"
comment
-- "--"
comment_content "-command using the \"-complete=\" argument."
comment
-- "--"
comment_content "-See |:command-completion|"
comment
-- "--"
comment_content "-@field completion? string"
comment
-- "--"
comment_content "-"
comment
-- "--"
comment_content "-Function that will be used for highlighting"
comment
-- "--"
comment_content "-user inputs."
comment
-- "--"
comment_content "-@field highlight? function"
comment
-- "--"
comment_content "- Prompts the user for input, allowing arbitrary (potentiall"...
comment
-- "--"
comment_content "- `on_confirm`."
comment
-- "--"
comment_content "-"
comment
-- "--"
comment_content "- Example:"
comment
-- "--"
comment_content "-"
comment
-- "--"
comment_content "- ```lua"
comment
-- "--"
comment_content "- vim.ui.input({ prompt = 'Enter value for shiftwidth: ' }, "...
comment
-- "--"
comment_content "- vim.o.shiftwidth = tonumber(input)"
comment
-- "--"
comment_content "- end)"
comment
-- "--"
comment_content "- ```"
comment
-- "--"
comment_content "-"
comment
-- "--"
comment_content "-@param opts? vim.ui.input.Opts Additional options. See |inp"...
comment
-- "--"
comment_content "-@param on_confirm fun(input?: string)"
comment
-- "--"
comment_content "- Called once the user confirms or abort the i"...
comment
-- "--"
comment_content "- `input` is what the user typed (it might be"
comment
-- "--"
comment_content "- an empty string if nothing was entered), or"
comment
-- "--"
comment_content "- `nil` if the user aborted the dialog."
function_declaration (+185 nodes collapsed)
comment
-- "--"
comment_content "-@class vim.ui.open.Opts"
comment
-- "--"
comment_content "-@inlinedoc"
comment
-- "--"
comment_content "-"
comment
-- "--"
comment_content "- Command used to open the path or URL."
comment
-- "--"
comment_content "-@field cmd? string[]"
comment
-- "--"
comment_content "- Opens `path` with the system default handler (macOS `open`"...
comment
-- "--"
comment_content "- `xdg-open`, …), or returns (but does not show) an error me"...
comment
-- "--"
comment_content "-"
comment
-- "--"
comment_content "- Can also be invoked with `:Open`. [:Open]()"
comment
-- "--"
comment_content "-"
comment
-- "--"
comment_content "- Expands \"~/\" and environment variables in filesystem paths"...
comment
-- "--"
comment_content "-"
comment
-- "--"
comment_content "- Examples:"
comment
-- "--"
comment_content "-"
comment
-- "--"
comment_content "- ```lua"
comment
-- "--"
comment_content "- -- Asynchronous."
comment
-- "--"
comment_content "- vim.ui.open(\"https://neovim.io/\")"
comment
-- "--"
comment_content "- vim.ui.open(\"~/path/to/file\")"
comment
-- "--"
comment_content "- -- Use the \"osurl\" command to handle the path or URL."
comment
-- "--"
comment_content "- vim.ui.open(\"gh#neovim/neovim!29490\", { cmd = { 'osurl' } "...
comment
-- "--"
comment_content "- -- Synchronous (wait until the process exits)."
comment
-- "--"
comment_content "- local cmd, err = vim.ui.open(\"$VIMRUNTIME\")"
comment
-- "--"
comment_content "- if cmd then"
comment
-- "--"
comment_content "- cmd:wait()"
comment
-- "--"
comment_content "- end"
comment
-- "--"
comment_content "- ```"
comment
-- "--"
comment_content "-"
comment
-- "--"
comment_content "-@param path string Path or URL to open"
comment
-- "--"
comment_content "-@param opt? vim.ui.open.Opts Options"
comment
-- "--"
comment_content "-"
comment
-- "--"
comment_content "-@return vim.SystemObj|nil # Command object, or nil if not f"...
comment
-- "--"
comment_content "-@return nil|string # Error message on failure, or nil on su"...
comment
-- "--"
comment_content "-"
comment
-- "--"
comment_content "-@see |vim.system()|"
function_declaration (+258 nodes collapsed)
comment
-- "--"
comment_content "- Get an available command used to open the path or URL."
comment
-- "--"
comment_content "-"
comment
-- "--"
comment_content "- @return string[]|nil # Command, or nil if not found."
comment
-- "--"
comment_content "- @return nil|string # Error message on failure, or nil on s"...
function_declaration (+257 nodes collapsed)
comment
-- "--"
comment_content "- @param bufnr integer"
variable_declaration (+439 nodes collapsed)
comment
-- "--"
comment_content "- Returns all URLs at cursor, if any."
comment
-- "--"
comment_content "- @return string[]"
function_declaration (+650 nodes collapsed)
do_statement
do "do"
comment
-- "--"
comment_content "-@class ProgressMessage"
comment
-- "--"
comment_content "-@field id? number|string ID of the progress message"
comment
-- "--"
comment_content "-@field title? string Title of the progress message"
comment
-- "--"
comment_content "-@field status string Status: \"running\" | \"success\" | \"fail"...
comment
-- "--"
comment_content "-@field percent? integer Percent complete (0–100)"
comment
-- "--"
comment_content "-@private"
comment
-- "--"
comment_content "- Cache of active progress messages, keyed by msg_id"
comment
-- "--"
comment_content "- TODO(justinmk): visibility of \"stale\" (never-finished) Pro"...
comment
-- "--"
comment_content "-@type table<integer, ProgressMessage>"
block
variable_declaration
local "local"
assignment_statement
variable_list
identifier "progress"
= "="
expression_list
table_constructor
{ "{"
} "}"
comment
-- "--"
comment_content " store progress events"
variable_declaration
local "local"
assignment_statement
variable_list
identifier "progress_group"
, ","
identifier "progress_autocmd"
= "="
expression_list
nil "nil"
, ","
nil "nil"
comment
-- "--"
comment_content "-Initialize progress event listeners"
function_declaration
local "local"
function "function"
identifier "progress_init"
parameters
( "("
) ")"
block
assignment_statement
variable_list
identifier "progress_group"
= "="
expression_list
function_call
dot_index_expression
dot_index_expression
identifier "vim"
. "."
identifier "api"
. "."
identifier "nvim_create_augroup"
arguments
( "("
string
' "'"
string_content "nvim.ui.progress_status"
' "'"
, ","
table_constructor
{ "{"
field
identifier "clear"
= "="
true "true"
} "}"
) ")"
assignment_statement
variable_list
identifier "progress_autocmd"
= "="
expression_list
function_call
dot_index_expression
dot_index_expression
identifier "vim"
. "."
identifier "api"
. "."
identifier "nvim_create_autocmd"
arguments
( "("
string
' "'"
string_content "Progress"
' "'"
, ","
table_constructor
{ "{"
field
identifier "group"
= "="
identifier "progress_group"
, ","
field
identifier "desc"
= "="
string
' "'"
string_content "Tracks progress messages for vim.ui.progress_status()"
' "'"
, ","
comment
-- "--"
comment_content "-@param ev {data: {id: integer, title: string, status: strin"...
field
identifier "callback"
= "="
function_definition
function "function"
parameters
( "("
identifier "ev"
) ")"
block
if_statement
if "if"
binary_expression
unary_expression
not "not"
dot_index_expression
identifier "ev"
. "."
identifier "data"
or "or"
unary_expression
not "not"
dot_index_expression
dot_index_expression
identifier "ev"
. "."
identifier "data"
. "."
identifier "id"
then "then"
block
return_statement
return "return"
end "end"
assignment_statement
variable_list
bracket_index_expression
identifier "progress"
[ "["
dot_index_expression
dot_index_expression
identifier "ev"
. "."
identifier "data"
. "."
identifier "id"
] "]"
= "="
expression_list
table_constructor
{ "{"
field
identifier "id"
= "="
dot_index_expression
dot_index_expression
identifier "ev"
. "."
identifier "data"
. "."
identifier "id"
, ","
field
identifier "title"
= "="
dot_index_expression
dot_index_expression
identifier "ev"
. "."
identifier "data"
. "."
identifier "title"
, ","
field
identifier "status"
= "="
dot_index_expression
dot_index_expression
identifier "ev"
. "."
identifier "data"
. "."
identifier "status"
, ","
field
identifier "percent"
= "="
binary_expression
dot_index_expression
dot_index_expression
identifier "ev"
. "."
identifier "data"
. "."
identifier "percent"
or "or"
number "0"
, ","
} "}"
comment
-- "--"
comment_content " Clear finished items"
if_statement
if "if"
binary_expression
binary_expression
binary_expression
binary_expression
dot_index_expression
dot_index_expression
identifier "ev"
. "."
identifier "data"
. "."
identifier "status"
== "=="
string
' "'"
string_content "success"
' "'"
or "or"
binary_expression
dot_index_expression
dot_index_expression
identifier "ev"
. "."
identifier "data"
. "."
identifier "percent"
== "=="
number "100"
or "or"
binary_expression
dot_index_expression
dot_index_expression
identifier "ev"
. "."
identifier "data"
. "."
identifier "status"
== "=="
string
' "'"
string_content "failed"
' "'"
or "or"
binary_expression
dot_index_expression
dot_index_expression
identifier "ev"
. "."
identifier "data"
. "."
identifier "status"
== "=="
string
' "'"
string_content "cancel"
' "'"
then "then"
block
assignment_statement
variable_list
bracket_index_expression
identifier "progress"
[ "["
dot_index_expression
dot_index_expression
identifier "ev"
. "."
identifier "data"
. "."
identifier "id"
] "]"
= "="
expression_list
nil "nil"
end "end"
end "end"
, ","
} "}"
) ")"
end "end"
comment
-- "--"
comment_content "-Return statusline text summarizing progress messages."
comment
-- "--"
comment_content "- - If none: returns empty string"
comment
-- "--"
comment_content "- - If one running item: \"title: 42%\""
comment
-- "--"
comment_content "- - If multiple running items: \"Progress: N items AVG%\""
comment
-- "--"
comment_content "-@param running ProgressMessage[]"
comment
-- "--"
comment_content "-@return string"
function_declaration
local "local"
function "function"
identifier "progress_status_fmt"
parameters
( "("
identifier "running"
) ")"
block
variable_declaration
local "local"
assignment_statement
variable_list
identifier "count"
= "="
expression_list
unary_expression
# "#"
identifier "running"
if_statement
if "if"
binary_expression
identifier "count"
== "=="
number "0"
then "then"
block
return_statement
return "return"
expression_list
string
' "'"
' "'"
comment
-- "--"
comment_content " nothing to show"
elseif_statement
elseif "elseif"
binary_expression
identifier "count"
== "=="
number "1"
then "then"
block
variable_declaration
local "local"
assignment_statement
variable_list
identifier "progress_item"
= "="
expression_list
bracket_index_expression
identifier "running"
[ "["
number "1"
] "]"
if_statement
if "if"
binary_expression
dot_index_expression
identifier "progress_item"
. "."
identifier "title"
== "=="
nil "nil"
then "then"
block
return_statement
return "return"
expression_list
function_call
dot_index_expression
identifier "string"
. "."
identifier "format"
arguments
( "("
string
' "'"
string_content "%d%%%% "
' "'"
, ","
binary_expression
dot_index_expression
identifier "progress_item"
. "."
identifier "percent"
or "or"
number "0"
) ")"
end "end"
return_statement
return "return"
expression_list
function_call
dot_index_expression
identifier "string"
. "."
identifier "format"
arguments
( "("
string
' "'"
string_content "%s: %d%%%% "
' "'"
, ","
dot_index_expression
identifier "progress_item"
. "."
identifier "title"
, ","
binary_expression
dot_index_expression
identifier "progress_item"
. "."
identifier "percent"
or "or"
number "0"
) ")"
else_statement
else "else"
block
variable_declaration
local "local"
assignment_statement
variable_list
identifier "sum"
= "="
expression_list
number "0"
comment
-- "--"
comment_content "-@type integer"
for_statement
for "for"
for_generic_clause
variable_list
identifier "_"
, ","
identifier "progress_item"
in "in"
expression_list
function_call
identifier "ipairs"
arguments
( "("
identifier "running"
) ")"
do "do"
block
assignment_statement
variable_list
identifier "sum"
= "="
expression_list
binary_expression
identifier "sum"
+ "+"
parenthesized_expression
( "("
binary_expression
dot_index_expression
identifier "progress_item"
. "."
identifier "percent"
or "or"
number "0"
) ")"
end "end"
variable_declaration
local "local"
assignment_statement
variable_list
identifier "avg"
= "="
expression_list
function_call
dot_index_expression
identifier "math"
. "."
identifier "floor"
arguments
( "("
binary_expression
identifier "sum"
/ "/"
identifier "count"
) ")"
return_statement
return "return"
expression_list
function_call
dot_index_expression
identifier "string"
. "."
identifier "format"
arguments
( "("
string
' "'"
string_content "Progress: %d items %d%%%% "
' "'"
, ","
identifier "count"
, ","
identifier "avg"
) ")"
end "end"
end "end"
comment
-- "--"
comment_content "- Gets the status of currently running progress messages, in"...
comment
-- "--"
comment_content "- convenient for inclusion in 'statusline'."
comment
-- "--"
comment_content "-@return string formatted text of progress status for status"...
function_declaration
function "function"
dot_index_expression
identifier "M"
. "."
identifier "progress_status"
parameters
( "("
) ")"
comment
-- "--"
comment_content " Create progress event listener on first call"
block
if_statement
if "if"
binary_expression
identifier "progress_autocmd"
== "=="
nil "nil"
then "then"
block
function_call
identifier "progress_init"
arguments
( "("
) ")"
end "end"
variable_declaration
local "local"
assignment_statement
variable_list
identifier "running"
= "="
expression_list
function_call
dot_index_expression
identifier "vim"
. "."
identifier "tbl_values"
arguments
( "("
identifier "progress"
) ")"
return_statement
return "return"
expression_list
binary_expression
function_call
identifier "progress_status_fmt"
arguments
( "("
identifier "running"
) ")"
or "or"
string
' "'"
' "'"
end "end"
end "end"
return_statement
return "return"
expression_list
identifier "M"