Tips for debugging a plugin?

I’m new to Kakoune and trying to reproduce some of the features I rely on in vim by pulling in some plugins with plug.kak. There are some settings that I want to configure with fzf.kak, but not all of them seem to be taking effect.

I’m digging through the source code and finding how my config gets turned into the tmux window commands, but how do I see the commands that it ends up running? Is there a way to print out values to figure out if I’m messing up config or if somewhere along the line it’s sending the wrong commands?

What are some general troubleshooting tips for figuring out how a plugin works?

The single most useful tip is: check the *debug* buffer. If anything goes wrong, there should be a message in there.

The second most useful tip is: anything a shell block writes to stderr gets logged to the *debug* buffer. For example, if I run a command like:

evaluate-commands %sh{
    cmd="info hello"
    echo about to excute "$cmd" 1>&2
    echo "$cmd"

…then the evaluate-commands will run :info hello, but the *debug* buffer will contain:

shell stderr: <<<
about to excute info hello

The third most useful tip is decoding “stack traces”. Any plugin of reasonable complexity is likely to wind up with deeply nested evaluations - commands calling shell blocks that wind up invoking other commands, etc. and you’ll wind up with an error that looks like:

Error: 1:1: 'eval' 1:2: 'eval' no such command: 'blort'

The “1:2” bits mean line 1 column 2… of the block that they’re in. So the above message says that there was some evaluation that began (line 1 column 1) with an eval command. That first command starts a nested evaluation, and there was a second eval command at line 1 column 2 of the nested evaluation. That second eval command hit tried to call the non-existent “blort” command, but there’s no clue where that command occurred within the second eval command’s argument.