Skip to content

Commit

Permalink
Allow EditorConfig not touching softtabstop via [] config
Browse files Browse the repository at this point in the history
Picking up the argument from @chreekat in #137, it can be argued that
'softtabstop' purely is a user experience feature and the EditorConfig plugin
should not modify it at all. (This argument can be made since Vim 7.3.693, where
a negative value makes 'softtabstop' automatically assume the value of
'shiftwidth'; a value of 0 disables the feature altogether. However, I think
most users would rather see 'softtabstop' as one of the indent options,
especially when positive values are assigned to it.)

A special (empty) List configuration value can make the EditorConfig plugin skip
the update of 'softtabstop'.
  • Loading branch information
inkarkat committed Oct 31, 2022
1 parent ecaff9e commit fc190c9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
4 changes: 3 additions & 1 deletion doc/editorconfig.txt
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,16 @@ backspace key delete one indent level. If you turn off that feature (by
setting the option to 0), only a single space will be deleted.
This option defaults to 1, which enables 'softtabstop' and uses the
'shiftwidth' value for it. You can also set this to -1 to automatically follow
the current 'shiftwidth' value (since Vim 7.3.693).
the current 'shiftwidth' value (since Vim 7.3.693). Or set this to [] if
EditorConfig should not touch 'softtabstop' at all.

*g:EditorConfig_softtabstop_tab*
When tabs are used for indent, Vim's 'softtabstop' feature only applies to
backspacing over existing runs of spaces.
This option defaults to 1, so backspace will delete one indent level worth of
spaces; -1 does the same but automatically follows the current 'shiftwidth'
value. Set this to 0 to have backspace delete just a single space character.
Or set this to [] if EditorConfig should not touch 'softtabstop' at all.

*g:EditorConfig_verbose*
Set this to 1 if you want debug info printed:
Expand Down
12 changes: 8 additions & 4 deletions plugin/editorconfig.vim
Original file line number Diff line number Diff line change
Expand Up @@ -402,14 +402,18 @@ function! s:ApplyConfig(config) abort " Set the buffer options {{{1
" value
if a:config["indent_size"] == "tab"
let &l:shiftwidth = &l:tabstop
let &l:softtabstop = g:EditorConfig_softtabstop_tab > 0 ?
\ &l:shiftwidth : g:EditorConfig_softtabstop_tab
if type(g:EditorConfig_softtabstop_tab) != type([])
let &l:softtabstop = g:EditorConfig_softtabstop_tab > 0 ?
\ &l:shiftwidth : g:EditorConfig_softtabstop_tab
endif
else
let l:indent_size = str2nr(a:config["indent_size"])
if l:indent_size > 0
let &l:shiftwidth = l:indent_size
let &l:softtabstop = g:EditorConfig_softtabstop_space > 0 ?
\ &l:shiftwidth : g:EditorConfig_softtabstop_space
if type(g:EditorConfig_softtabstop_space) != type([])
let &l:softtabstop = g:EditorConfig_softtabstop_space > 0 ?
\ &l:shiftwidth : g:EditorConfig_softtabstop_space
endif
endif
endif

Expand Down

0 comments on commit fc190c9

Please sign in to comment.