Home Explore Blog CI



neovim

10th chunk of `runtime/doc/lua.txt`
37046ea07f5a5d406e9ff2f7d96232e27d2c420f093d44d50000000100000fe0
       • {inclusive}? (`boolean`, default: `false`) Indicates
                     whether the range is end-inclusive
                   • {priority}? (`integer`, default:
                     `vim.hl.priorities.user`) Highlight priority
                   • {timeout}? (`integer`, default: -1 no timeout) Time in ms
                     before highlight is cleared

    Return (multiple): ~
        (`uv.uv_timer_t?`) range_timer A timer which manages how much time the
        highlight has left
        (`fun()?`) range_clear A function which allows clearing the highlight
        manually. nil is returned if timeout is not specified


==============================================================================
VIM.DIFF                                                            *vim.diff*

vim.diff({a}, {b}, {opts})                                        *vim.diff()*
    Run diff on strings {a} and {b}. Any indices returned by this function,
    either directly or via callback arguments, are 1-based.

    Examples: >lua
        vim.diff('a\n', 'b\nc\n')
        -- =>
        -- @@ -1 +1,2 @@
        -- -a
        -- +b
        -- +c

        vim.diff('a\n', 'b\nc\n', {result_type = 'indices'})
        -- =>
        -- {
        --   {1, 1, 1, 2}
        -- }
<

    Parameters: ~
      • {a}     (`string`) First string to compare
      • {b}     (`string`) Second string to compare
      • {opts}  (`table?`) Optional parameters:
                • {on_hunk}?
                  (`fun(start_a: integer, count_a: integer, start_b: integer, count_b: integer): integer?`)
                  Invoked for each hunk in the diff. Return a negative number
                  to cancel the callback for any remaining hunks. Arguments:
                  • `start_a` (`integer`): Start line of hunk in {a}.
                  • `count_a` (`integer`): Hunk size in {a}.
                  • `start_b` (`integer`): Start line of hunk in {b}.
                  • `count_b` (`integer`): Hunk size in {b}.
                • {result_type}? (`'unified'|'indices'`, default: `'unified'`)
                  Form of the returned diff:
                  • `unified`: String in unified format.
                  • `indices`: Array of hunk locations. Note: This option is
                    ignored if `on_hunk` is used.
                • {linematch}? (`boolean|integer`) Run linematch on the
                  resulting hunks from xdiff. When integer, only hunks upto
                  this size in lines are run through linematch. Requires
                  `result_type = indices`, ignored otherwise.
                • {algorithm}? (`'myers'|'minimal'|'patience'|'histogram'`,
                  default: `'myers'`) Diff algorithm to use. Values:
                  • `myers`: the default algorithm
                  • `minimal`: spend extra time to generate the smallest
                    possible diff
                  • `patience`: patience diff algorithm
                  • `histogram`: histogram diff algorithm
                • {ctxlen}? (`integer`) Context length
                • {interhunkctxlen}? (`integer`) Inter hunk context length
                • {ignore_whitespace}? (`boolean`) Ignore whitespace
                • {ignore_whitespace_change}? (`boolean`) Ignore whitespace
                  change
                • {ignore_whitespace_change_at_eol}? (`boolean`) Ignore
                  whitespace change at end-of-line.
                • {ignore_cr_at_eol}? (`boolean`) Ignore carriage return at
                  end-of-line
                • {ignore_blank_lines}? (`boolean`) Ignore blank lines
                • {indent_heuristic}? (`boolean`) Use the indent heuristic for
                  the internal diff library.

    Return: ~
        (`string|integer[][]?`) See {opts.result_type}. `nil` if
        {opts.on_hunk} is given.


==============================================================================
VIM.MPACK                                                          *vim.mpack*

Title: vim.diff: String Comparison with Options
Summary
This section describes the `vim.diff()` function, which compares two strings and returns the diff. It provides examples demonstrating its usage and the different output formats. The section also details the various parameters available via the `opts` table, including callbacks for processing each hunk, result type options ('unified' or 'indices'), and configurations for the diff algorithm, context length, whitespace handling, and indent heuristics. The return value depends on the chosen `result_type` or the presence of the `on_hunk` callback.