mix of vim9 and legacy vimscript

29 views
Skip to first unread message

Ni Va

unread,
Jan 14, 2022, 4:00:21 AM1/14/22
to vim_use
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

Ni Va

unread,
Jan 14, 2022, 5:11:26 AM1/14/22
to vim_use
It seems this kind of joke in red bold caused issue.

....
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

Christian Brabandt

unread,
Jan 14, 2022, 1:30:09 PM1/14/22
to vim_use
Hi,
I haven't yet played much with Vim9 Script, but are you aware, that you
do not need my plugin just to be able to use Patient Diff mode? This is
all configurable by Vim using the 'diffopt' setting switch nowadays.

Thanks,
Chris

On Fr, 14 Jan 2022, Ni Va wrote:

> 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
Mit freundlichen Grüßen
Christian
> 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

Ni Va

unread,
Jan 15, 2022, 4:56:28 AM1/15/22
to vim_use
Thank you Christian, i was not aware of this diffopt.

I was happy to use your plugin maybe thinking it was doing more than set diffopt=algorithm:patience.
Reply all
Reply to author
Forward
0 new messages