Skip to content

Commit

Permalink
Set tab_width=indent_size if tab_width undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
treyhunner committed Nov 9, 2011
1 parent 1e653b8 commit 2df0e97
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions editorconfig.vim
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ endfunction
" Set the indentation style according to the config values
function! s:ApplyConfig(config)
if has_key(a:config, "indent_style")
if has_key(a:config, "indent_size") && !has_key(a:config, "tab_width")
let a:config["tab_width"] = a:config["indent_size"]
endif
if a:config["indent_style"] == "tab"
setl noexpandtab
if has_key(a:config, "tab_width")
Expand All @@ -137,6 +140,7 @@ function! s:ApplyConfig(config)
endif
if has_key(a:config, "tab_width")
let &l:softtabstop = str2nr(a:config["tab_width"])
let &l:tabstop = str2nr(a:config["tab_width"])
endif
endif
endif
Expand Down

6 comments on commit 2df0e97

@xuhdev
Copy link
Member

@xuhdev xuhdev commented on 2df0e97 Nov 9, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering whether we should implement this feature in EditorConfig Core or here. Which one do you think is better?

@treyhunner
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good point. Maybe we should put this feature in the EditorConfig core instead.

If we ever decide there is a use case for checking whether tab_width is specified in a plugin (or another program that uses EditorConfig) we could work with plugin developers to phase out that functionality in the core or add a switch to turn it off.

@xuhdev
Copy link
Member

@xuhdev xuhdev commented on 2df0e97 Nov 9, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could add a switch to turn this functionality on or off. Let's call it "value preprocessing feature"?

@treyhunner
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could. Maybe that switch should turn off all value pre-processing (e.g. lowercasing property names or values) as well.

@xuhdev
Copy link
Member

@xuhdev xuhdev commented on 2df0e97 Nov 10, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why we need to add a switch to turn it off. I can't think of any meaning.

@treyhunner
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually can't think of a use case for either of these right now. Maybe we should implement this feature without a switch first until a use case appears. If you can think of a case for which this would be useful to have short term, we should probably continue the discussion though.

I've added an issue to EditorConfig core for defaulting tab_width to indent_size.

I think in general it might be a good idea to plan out what switches EditorConfig core can accept so we can more easily maintain backwards compatibility after adding them. I've created an issue for this topic as well.

Please sign in to comment.