Friday, January 14, 2022

Re: mix of vim9 and legacy vimscript

It seems this kind of joke in red bold caused issue.

in https://github.com/niva-xx/vim9-diff-enhanced/blob/master/autoload/EnhancedDiff.vim
....
def s:SysList(cmd: string): string
  if exists('*systemlist')
    return systemlist(cmd)
  endif
  return split(system(cmd), '\n')
enddef
function EnhancedDiff#Diff(...) #{{{2
  let cmd = (exists("a:1") ? a:1 : '')
  let arg = (exists("a:2") ? a:2 : '')

  " no-op
  " error occured, reset diffexpr
  try
    call s:DiffInit(cmd, arg)
  catch
    set diffexpr=
    " call s:Warn( cmd . ' not found in path, aborting!' )
    call s:Warn( ' not found in path, aborting ' )
    return
  endtry
....



Meanwhile this fix, script still 
often gives an error E97 cannot create diffs when 
I launch :EnhancedDiff patience


Capture.PNGCapture1.PNG


Le vendredi 14 janvier 2022 à 10:00:21 UTC+1, Ni Va a écrit :
Hi Bram, Christian, Hi All,


I wish to use and port some part of plugin made by Christian few years ago in order to improve dirdiff with patience algorithm. https://github.com/chrisbra/vim-diff-enhanced


In vim9 help §2 it is written;

Vim9 script and legacy Vim script can be mixed.  There is no requirement to
rewrite old scripts, they keep working as before.  You may want to use a few
`:def` functions for code that needs to be fast.


So try to port the plugin, let some functions that need (...) or (A,L,P) args for commands that I don't know how to deal with in vim9script. https://github.com/niva-xx/vim9-diff-enhanced

And then test it,

:EnhancedDiff patience
Capture.PNG



I don't understant why I got this error in argue of s:Warn( which waiting for string arg.

function EnhancedDiff#Diff(...) #{{{2
  let cmd = (exists("a:1") ? a:1 : '')
  let arg = (exists("a:2") ? a:2 : '')

  " no-op
  " error occured, reset diffexpr
  try
    call s:DiffInit(cmd, arg)
  catch
    set diffexpr=
    call s:Warn( cmd . ' not found in path, aborting!' )


Thank you for your help
NiVa

--
--
You received this message from the "vim_use" 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_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/700c3f98-a763-42d6-b40c-424aaf16abaan%40googlegroups.com.

No comments: