andreyorst / smarttab.kak

Automatic handling different styles of indentation and alignment.
MIT License
62 stars 4 forks source link

Indentation is always 8 spaces wide. #7

Closed fungalcofe closed 5 years ago

fungalcofe commented 5 years ago

Hi,

I installed the plugin with kak following your example:

plug "andreyorst/smarttab.kak" %{
    set-option global softtabstop 4 # or other preferred value
}

then: :plug-install

Installation done, I close kakoune and open a new one. When I start to write and press tab is always 8 spaces wide.

The only other addon installed is fzf.

--

Not really related but where should I declare the option expandtab? I'm new to kakoune and don't find the correct place or way to declare it (excepting doing it manually).

andreyorst commented 5 years ago

Ok, so I suspect that you haven't configured actual tabstop and indentwidth options.

softtabstop represents amount of spaces that is being deleted when you hit Backspace in insert mode. It doesn't affect your Kakoune settings.

You need to set tabstop and indentwidth options to your preferred value like so:

set-option global tabstop 4
set-option global indentwidth 4

This will set global values for these options. If you want different settings between filetypes you can either use hook like so:

hook global WinSetOption filetype=gas %{
    set-option buffer tabstop 8
    set-option buffer indentwidth 8
}

Or you can set up .editorconfig file. Kakoune supports editorconfig out of the box.

Not really related but where should I declare the option expandtab? I'm new to kakoune and don't find the correct place or way to declare it (excepting doing it manually).

Sure. You should define hooks, like the one above for various filetypes. You can check my configuration, but in general this will looks like so:

plug "andreyorst/smarttab.kak" %{
    hook global WinSetOption filetype=gas %{ noexpandtab }
    hook global WinSetOption filetype=c %{ smarttabtab }
    hook global WinSetOption filetype=rust %{ expandtab }
}

Also, smarttab, expandtab, and noexpandtab are commands, which means that you can execute those with :: :smarttab

fungalcofe commented 5 years ago

Thank you very much! Everything works now. You gave handy tips.