Monday, December 10, 2018

Re: How to debug a vim plugin?

Peng Yu wrote:

> I am wondering how to debug a vim plugin (for example, the following
> one) in an efficient way.
>
> https://github.com/Clavelito/indent-sh.vim/blob/master/indent/sh.vim
>
> The main difficulty that I see is that a vim plugin is different from
> a typical program is that in a typical programming language one can
> easily isolate a piece of code and insert print statements. But in a
> vim plugin, since it causes some effects in the code shown in vim, I
> am not sure how a print statement can help much.
>
> Also, in a regular programming language, one can run a function with
> different parameters, then check its behavior. But a vim plugin is
> just a whole piece of code, it is not clear how to run a piece of code
> in an isolated environment to inspect its behavior.
>
> Does anybody have any tips on how to debugging vim plugins? Thanks.

Besides what's already said, if you just want a simple way to log some
text, you can use the mechanism for channels:

ch_logfile('SomeFileName', 'w')
ch_log('This happened')

Messages are written to a log, thus this also works for things like
autocomplete. It will include time stamps, which are often useful.

--
An easy way to determine if you have enough teamwork to be doomed is simply to
measure how long it takes from the time you decide to go to lunch together
until the time you actually eat.
(Scott Adams - The Dilbert principle)

/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

--
--
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.
For more options, visit https://groups.google.com/d/optout.

No comments: