0

I'm working on a vim 'logging' plugin. I'm attempting to hook any calls to 'source', 'echo', 'echom', 'echoerr'. AFAIK, the way that you typically execute arbitrary code on 'events' is through the use of an autocmd(grp) with an autocmd-event - however it doesn't appear to be possible to hook any of the those commands through this method.

Any suggestions how else this might be possible?

Edit:

I'm currently playing around with this a little and shoved what I'm working on into a gist here:

nfarrar
  • 2,291
  • 4
  • 25
  • 33

1 Answers1

0

There is the SourcePre event that allows you to hook into scripts.

You can access past messages via

:redir => var
:silent messages
:redir END

maybe periodically on the CursorHold event.

But please carefully reconsider the need for a "logging plugin". I think this is best done in core Vim, not Vimscript, and Vim already provides quite good logging infrastructure (cp. 'verbose' and 'verbosefile'). And there are plugins like DrChip's Decho for instrumenting your Vimscript code.

Ingo Karkat
  • 167,457
  • 16
  • 250
  • 324
  • Thank you - I am taking your advice and currently exploring some builtin or already built options. – nfarrar Nov 06 '15 at 21:32