Hi, folks. I’m using Kakoune to write Purescript code. This language does not want TAB characters at all. How should I configure the smarttab plugin to give me spaces instead of the TAB character when I use the TAB key to indent?
Please note: the indent commands work fine; the indent width is correct. I merely want to know whether I can use the smarttab plugin to insert spaces when I type TAB or if I have to get used to indenting using only the indent command and when auto-indenting happens.
I’m very new to plugins—I installed the plugins manager for the first time yesterday. Please feel free to assume that I know nothing and might have made some rookie mistakes.
Hi there, smarttab README mentions the expandtab command which is what you should use: https://github.com/andreyorst/smarttab.kak#usage. In order to set it automatically according to file type you can use hooks. The README also has examples of hooks you can adapt, for vanilla or plug.kak installs.
Thank you! I’ve added this to my kakrc and when I press TAB inside a Purescript file, I still get a TAB character instead of spaces. I have confirmed by debugging the options in my Purescript buffer that filetype is indeed purescript. I have this in my kakrc:
plug "andreyorst/smarttab.kak" defer smarttab %{
# when `backspace' is pressed, 4 spaces are deleted at once
set-option global softtabstop 4
} config %{
# these languages will use `expandtab' behavior
hook global WinSetOption filetype=(rust|markdown|kak|lisp|scheme|sh|perl|purescript|elm) expandtab
# these languages will use `noexpandtab' behavior
hook global WinSetOption filetype=(makefile|gas) noexpandtab
# these languages will use `smarttab' behavior
hook global WinSetOption filetype=(c|cpp) smarttab
}
How can I confirm that the expandtab option is set for this buffer? When I debug all the options, I don’t see any option called expandtab among the options set. Should I look for something else or does this mean that I’ve made a mistake somewhere?
I suppose that this is how I will learn how the plugins work.
That’s interesting, if the filetype is purescript I would expect your config to work.
How can I confirm that the expandtab option is set for this buffer?
You can check with :echo %opt{smarttab_expandtab_mode_name}, it should echo expandtab if it is set correctly. Maybe the plugin isn’t actually loaded for whatever reason, in which case no such option should exist for that window.