I have a few language-specific tools that I have enabled for their associated filetype using the WinSetOption hook.
Example:
hook global WinSetOption filetype=(clojure) %{
parinfer-enable-window -smart
}
But there are specific config files (in this example, project.clj
) that I’d like to disable the tool for. Is there a recommended way to do this?
I started typing this as a question, but think I figured it out while typing…
hook global WinSetOption filetype=(clojure|lisp|scheme|racket) %{
evaluate-commands %sh{
special_files_regex='.*\(project\.clj\|profiles\.clj\)$'
if ! expr $kak_buffile : $special_files_regex 1>/dev/null; then
printf %s 'parinfer-enable-window -smart'
fi
}
}
The key pieces here are:
- A shell block for the conditional (if) expression
- The
$kak_buffile
variable that gives us the file name (with the full path) - The
expr
command to match the filename(s) I want to ignore via regex- This took me quite a bit of digging to figure out (how to check if a string matches a regex in a posix shell), and would likely be useful for other cases