Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set tabbing to match Elm style guide and examples (2 spaces) #185

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Set tabbing to match Elm style guide and examples (2 spaces) #185

wants to merge 1 commit into from

Conversation

niksilver
Copy link

Problem: When I use elm-vim out of the box it defaults to tab stops of 8 spaces, but the Elm standard is 2 spaces.

Workaround: As a workaround I added the following line to my ~/.vimrc file:

autocmd FileType elm setlocal shiftwidth=2 tabstop=2

But that's a manual change.

Fix: The change submitted seems to fix this problem, and sets tab stops in .elm files to 2 spaces, regardless of the user's global settings.

@dtaskoff
Copy link

dtaskoff commented Aug 13, 2019

Where is this "vim standard" defined?
Anyway, such "user-preference" settings should be kept in ~/.vimrc, and elm-format enforces 4 spaces, so elm-vim setting tabstop=2 would be quite inconsistent.

@niksilver niksilver changed the title Set tabbing to the vim standard (2 spaces) Set tabbing to match Elm style guide and examples (2 spaces) Aug 13, 2019
@niksilver
Copy link
Author

Regards "standard vim": Yes, "vim standard" is the wrong phrase - the title of the request is an error. I've corrected that now. Apologies for the confusion.

My personal experience suggests that the default tab spacing on most terminals is 8 spaces, and Wikipedia says tab has been "de facto standardized at every multiple of 8 characters horizontally". Therefore as it stands if the elm-vim plugin is installed with no other settings or preferences (user preferences or otherwise) the user can expect to find it defaults to 8-space tabs. This is what I found.

Regards elm-format: I did not suggest tabstop=2 based on elm-format. I suggested it based on looking at the Elm style guide and the code examples on the Elm website. In those examples new indents are 2 spaces, or 4 spaces. Thus I interpret 2 space indents as the base case - the lowest common denominator - and 4 spaces being "2 spaces twice".

Regards user preferences: Yes, user preference settings should indeed be put in ~/.vimrc. However, as the Elm style guide and the examples clearly show a preference, I thought it would be beneficial to users for the Elm plugin to use the "Elm preference" by default. The user can override that if they have a different user preference.

I offer this patch simply as a benefit to the community. The maintainers of ElmCast, of course, are free to accept or reject as they wish.

@dtaskoff
Copy link

dtaskoff commented Aug 13, 2019

AFAIK, Evan used two spaces indentation in the examples, since four spaces indentation would make them too wide to fit in the website, and elm-format is supposed to be following (or enforcing) the community preference (since the tool is maintained by members of elm).

I find it confusing, as well, that even the style guide, and the standard packages, are not consistent with regard to indentation (using both two and four spaces).

@andys8
Copy link

andys8 commented Oct 5, 2019

The majority of projects use elm-format with a non configurable tab width of 4

https://github.com/avh4/elm-format/blob/c14cfb9546144da3b87350944b88849a7dc65dd2/src/Box.hs#L247-L249

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants