[vim/vim] Swift: Change tabstop and shiftwidth to 4 (#5801)

45 views
Skip to first unread message

Emir Sarı

unread,
Mar 17, 2020, 12:36:37 PM3/17/20
to vim/vim, Subscribed

Due to Swift project's code indentation settings, Swift filetype plugin uses 2 spaces for ts and sw. This conflicts with Xcode, which uses 4 by default (and generally Swift projects use 4), and if same file is opened via Vim or vice versa, it's always extra steps to fix indentation. This PR sets ts and sw to 4, for a more unified environment.

I've brought this up to Swift team, but they prefer to keep it 2.


You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/5801

Commit Summary

  • Swift: Change tabstop and shiftwidth to 4

File Changes

Patch Links:


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.

Gary Johnson

unread,
Mar 17, 2020, 1:22:10 PM3/17/20
to reply+ACY5DGCLWR7NPUHWAJ...@reply.github.com, vim...@googlegroups.com
On 2020-03-17, Emir Sarı wrote:
> Due to Swift project's code indentation settings, Swift filetype plugin uses 2
> spaces for ts and sw. This conflicts with Xcode, which uses 4 by default (and
> generally Swift projects use 4), and if same file is opened via Vim or vice
> versa, it's always extra steps to fix indentation. This PR sets ts and sw to 4,
> for a more unified environment.
>
> I've brought this up to Swift team, but they prefer to keep it 2.

If this plugin is part of the Swift project and the Swift project
team prefers 2, wouldn't it be more appropriate to put your
preferences for 4 into ~/.vim/after/ftplugin/swift.vim?

Regards,
Gary

vim-dev ML

unread,
Mar 17, 2020, 1:22:33 PM3/17/20
to vim/vim, vim-dev ML, Your activity

On 2020-03-17, Emir Sarı wrote:
> Due to Swift project's code indentation settings, Swift filetype plugin uses 2
> spaces for ts and sw. This conflicts with Xcode, which uses 4 by default (and
> generally Swift projects use 4), and if same file is opened via Vim or vice
> versa, it's always extra steps to fix indentation. This PR sets ts and sw to 4,
> for a more unified environment.
>
> I've brought this up to Swift team, but they prefer to keep it 2.

If this plugin is part of the Swift project and the Swift project
team prefers 2, wouldn't it be more appropriate to put your
preferences for 4 into ~/.vim/after/ftplugin/swift.vim?

Regards,
Gary

Emir Sarı

unread,
Mar 17, 2020, 1:35:34 PM3/17/20
to vim/vim, vim-dev ML, Comment

If this plugin is part of the Swift project and the Swift project team prefers 2, wouldn't it be more appropriate to put your preferences for 4 into ~/.vim/after/ftplugin/swift.vim? Regards, Gary

I certainly do; this is about providing more sensible defaults. They only use two, because Swift project code uses 2, however most Swift projects do not. Regarding ownership issues, I am using this conversation as basis; if it's not appropriate to modify it on Vim side, feel free to close this PR.


You are receiving this because you commented.

Gary Johnson

unread,
Mar 17, 2020, 2:56:51 PM3/17/20
to reply+ACY5DGDZ4MYVN2C7AU...@reply.github.com, vim...@googlegroups.com
On 2020-03-17, Emir Sarı wrote:
> If this plugin is part of the Swift project and the Swift project team
> prefers 2, wouldn't it be more appropriate to put your preferences for 4
> into ~/.vim/after/ftplugin/swift.vim? Regards, Gary
>
> I certainly do; this is about providing more sensible defaults. They only use
> two, because Swift project code uses 2, however most Swift projects do not.
> Regarding ownership issues, I am using this conversation as basis; if it's not
> appropriate to modify it on Vim side, feel free to close this PR.

Got it. I expressed my concern and you answered it. It's really
your call.

Regards,
Gary


vim-dev ML

unread,
Mar 17, 2020, 2:57:13 PM3/17/20
to vim/vim, vim-dev ML, Your activity

Bram Moolenaar

unread,
Mar 17, 2020, 3:58:54 PM3/17/20
to vim/vim, vim-dev ML, Comment


Emir Sari wrote:

> Due to Swift project's code indentation settings, Swift filetype
> plugin uses 2 spaces for `ts` and `sw`. This conflicts with Xcode,

> which uses 4 by default (and generally Swift projects use 4), and if
> same file is opened via Vim or vice versa, it's always extra steps to
> fix indentation. This PR sets `ts` and `sw` to 4, for a more unified
> environment.
>
> I've brought this up to Swift team, but they prefer to keep it 2.

Why is 'tabstop' set here? It is strongly recommended to keep it at 8,
since that's what is used nearly everywhere. Instead 'softtabstop' can
be set:

setlocal sw=4 sts=4

Since 'expandtab' is set that will work the same, without any side
effects.


--
He was not in the least bit scared to be mashed into a pulp
Or to have his eyes gouged out and his elbows broken;
To have his kneecaps split and his body burned away
And his limbs all hacked and mangled, brave Sir Robin.
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///


You are receiving this because you commented.

Emir Sarı

unread,
Mar 17, 2020, 4:27:02 PM3/17/20
to vim/vim, vim-dev ML, Push

@bitigchi pushed 1 commit.


You are receiving this because you are subscribed to this thread.

View it on GitHub or unsubscribe.

Emir Sarı

unread,
Mar 17, 2020, 4:27:55 PM3/17/20
to vim/vim, vim-dev ML, Comment

Why is 'tabstop' set here? It is strongly recommended to keep it at 8, since that's what is used nearly everywhere. Instead 'softtabstop' can be set: setlocal sw=4 sts=4 Since 'expandtab' is set that will work the same, without any side effects.

You're right. Edited as such.


You are receiving this because you commented.

Bram Moolenaar

unread,
Mar 17, 2020, 5:49:02 PM3/17/20
to vim/vim, vim-dev ML, Comment

I'll include it like this, thanks.


You are receiving this because you commented.

Bram Moolenaar

unread,
Mar 17, 2020, 5:49:03 PM3/17/20
to vim/vim, vim-dev ML, Comment

Closed #5801.


You are receiving this because you commented.

Reply all
Reply to author
Forward
0 new messages