WinSetOption filetype=... doesn't seem to work for me

I’m trying to write something like:

hook global WinSetOption filetype=nix %{
  set-option buffer formatcmd nixfmt
  set-option buffer tabstop 2
  set-option buffer softtabstop 2
  echo "IT'S NIX!"
}

but this code never seems to be called. From the information I get in plugin READMEs and wiki pages, this seems unusual… is filetype not being set for me? Anybody have any idea what could be going on?

(By the way I’m not sure if it’s that the hook isn’t being called or filetype isn’t being set… I’m not sure how to tell that yet! I’d appreciate a hint there as well!)

You can check the filetype for a buffer with :echo %opt{filetype} - that should let you figure out whether the option is being set, and what it’s being set to.

1 Like

wow, that helped a lot, thanks. With this knowledge I went down this path until I found that there was an error early in my kakrc so this code was never being run. :man_facepalming: That explains everything!

1 Like

Just in case you haven’t already found it, lots of helpful error messages wind up in the *debug* buffer - try :buffer *debug* to switch to it and look around.

Glad to hear you got things sorted!