Sunday, October 30, 2022

pb with nnoremap an imported vim9 defnot loaded

Hi,


Using this def func to blink searched word I mapped it in $MYVIMRC as this but it seems that at vim startup, the nnoremap is not defined, no call occurs.

Thankyou for help
Nicolas

$MYVIMRC
import autoload './vimfiles/plugged/foobar.vim'
as thatHelp

nnoremap n   n<ScriptCmd> thatHelp.HLNext(80)<CR>
nnoremap N   N<ScriptCmd> thatHelp.HLNext(80)<CR>



foobar.vim
export def HLNext(blinktime: number): number
    # https://www.youtube.com/watch?v=aHm36-na4-4#t6m36s

  echomsg 'export def HLNext has been called.'

  highlight BlackOnBlack guibg=black guifg=#3c4c55 ctermbg=black ctermfg=black

  var [bufnum: number, lnum: number, col: number, off: number] = getpos('.')
  var target_pat: string = '\k*\%#\k*'
  target_pat = '\%#' .. @/
  target_pat = '\k*\%#\k*'
  var blinks: number = 3

  var sleep_duration: number = ( blinktime / (2 * blinks) )->float2nr()
  var sleep_cmd: string = 'sleep ' .. sleep_duration .. 'm'


  for n in range(1, blinks)

    # echomsg n
    var hide: number = matchadd('BlackOnBlack', target_pat, 101)
    redraw
    exec sleep_cmd
    matchdelete(hide)
    redraw
    exec sleep_cmd

  endfor

  return 0

enddef



--
--
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/f6861e1f-9783-49b6-b151-b6f1625e6ce5n%40googlegroups.com.

No comments: