How to set filetype based on the file extension?

I work with two types of files that, I guess, is not defined internally in Kakoune: asymptote and glsl shader files. Asymptote is a vector graphics language, that is used to draw graphics and is mostly embedded in LaTeX/TeX and GLSL is OpenGL Shading Language. Both of these look very very similar to C source code file. So, for syntax highlighting and code highlighting, every time I open a new file, I have to the following,

:set buffer filetype c

How can I do this automatically, i.e, as soon as open a .asy or .frag file, kakoune executes the above command?

hook global BufCreate .*\.(asy|frag) %{ set buffer filetype c }

read about hooks

1 Like