On Sat, May 6, 2023 at 4:44 AM rickhowe <[email protected]> wrote:
> I am interested in this builtin function as I have developed some plugins > to support word/character level diff in lines (this > <https://github.com/rickhowe/diffchar.vim>) and range/area selectable > diff in buffers (this <https://github.com/rickhowe/spotdiff.vim>). I > implemented the O(NP) comparison algorithm in vim script, but I have been > looking for a builtin function like yours. Several month ago, I noticed > that neovim has vim.diff() function so I switched to use it for neovim in > my script. > > Honestly, I am confused about a return value of your function. vim.diff() > actually returns diff in a unified format as default, from which is very > easy to generate a shortest edit script (SES). > > > The Neovim vim.diff() function ( https://neovim.io/doc/user/lua.html#lua-diff) returns the diff between two strings. It returns either a String or a List depending on the "result_type" option value. If "result_type" is set to "unified" (which is the default), then this function returns a String which is the unified diff output between the two string arguments. If the "result_type" option is set to "indices", then vim.diff() returns a List with 4 numbers (starting line number in the first string, line count, starting line number in the second string, line count). The return value of vim.diff() is not fully suitable for getting the change information needed for the LSP DidChangeTextDocument notification ( https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocumentContentChangeEvent ). For this notification, we need the range of characters in the old text (starting and ending text position) and the new text that replaces the old text. I can modify the new diff() function to return a value similar to that returned by the Neovim vim.diff() function. i.e. either a string with the unified diff or a List with the indices. We can then add an additional option ("range" or "extended" or "position") to return the starting and ending position of the change in the old and the new text. Bram: What do you think about this approach? Regards, Yegappan -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/vim_dev/CAAW7x7%3Df2mhL6LbVQQRQEJnTaSU4bBhHFqvvkT-Bwztsc5%2Bg2A%40mail.gmail.com.
