kakoune icon indicating copy to clipboard operation
kakoune copied to clipboard

Proposal for indentation settings

Open alexherbo2 opened this issue 3 years ago • 8 comments

Options

indent_style

Specifies the indentation style, whether to use tabs or spaces for indenting.

Possible values are tab and space.

Default is space.

indent_size

Specifies the number of columns used for each indentation level and the width of soft tabs.

When indenting with tabs, the value of tab_width (if specified) will be used.

Default is 4.

tab_width

Specifies the number of columns used to represent a tab character.

This defaults to the value of indent_size and doesn’t usually need to be specified.

Reference

alexherbo2 avatar Feb 11 '22 17:02 alexherbo2

What's wrong with the current system, where indentwidth=0 means "indents are 1 tab"?

Screwtapello avatar Feb 12 '22 00:02 Screwtapello

Have you tried the editorconfig-load command? That's generally the best way to set up these settings in kakoune.

clarfonthey avatar Feb 12 '22 18:02 clarfonthey

An editor should not need to be hacked to support a basic feature. The lack of this feature makes collaboration difficult.

JKAnderson409 avatar Apr 11 '22 18:04 JKAnderson409

What's wrong with the current system, where indentwidth=0 means "indents are 1 tab"?

This does not satisfy the feature as described:

Specifies the indentation style, whether to use tabs or spaces for indenting.

JKAnderson409 avatar Apr 11 '22 18:04 JKAnderson409

indentwidth=0 means "use tabs", any other number means "use spaces". Is that not specifying the indentation style?

Screwtapello avatar Apr 12 '22 00:04 Screwtapello

Again, I redirect you to my comment about editorconfig-load. The most common way to set these settings is to include an editorconfig file in your project and have kakoune parse it.

clarfonthey avatar Apr 12 '22 00:04 clarfonthey

https://github.com/mawww/kakoune/blob/f3cb2e434004a718d1225cb0d74c694e66a7248b/rc/detection/editorconfig.kak#L38-L40

@Screwtapello it seems tab stop will always be set to indent_size, so if I want to space, this is my editor config:

end_of_line=lf
charset=utf-8
indent_style=space
indent_size=2
tab_width=0
insert_final_newline=true
trim_trailing_whitespace=true

tab_stop will be 2, I still can not use tab to instead 2 spaces.

I just don't know how to configure my editor config to force the tab to space, I'm new to kak, try learning it.

theowenyoung avatar Jul 14 '22 06:07 theowenyoung

I figured it out by using smarttab plugin:

with the following editorconfig:

end_of_line=lf
charset=utf-8
indent_style=space
indent_size=2
insert_final_newline=true
trim_trailing_whitespace=true
tab_width=2

and this in kakrc:

hook global BufCreate .* %{
  editorconfig-load
  autoconfigtab
}
plug "andreyorst/smarttab.kak" defer smarttab %{
    set-option global softtabstop 2
}

You also need to install editorconfig in your system.

theowenyoung avatar Jul 14 '22 06:07 theowenyoung