sindresorhus / editorconfig-sublime

Sublime Text plugin for EditorConfig - Helps developers maintain consistent coding styles between different editors
MIT License
1.77k stars 108 forks source link

override for specific directory/files not working #41

Closed isimmons closed 9 years ago

isimmons commented 9 years ago

Maybe I'm missing something here so sorry if it's me and not an issue.

My .editorconfig (only one in root of laravel project

# editorconfig.org
root = true

[*.php]
indent_style = tab
indent_size = 1
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[resources/views/**.php]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.js, *.css, *.html]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false

Console output:

D:\projects\larabook4\resources\views\pages\home.blade.php
OrderedDict([(u'indent_style', u'tab'), (u'indent_size', u'1'), (u'end_of_line', u'lf'), (u'charset', u'utf-8'), (u'trim_trailing_whitespace', u'true'), (u'insert_final_newline', u'true'), ('tab_width', u'1')])

I want views (blade.php) to use the same style as html files.

I've tried

[*.blade.php]
[resources/views/**.php]
[resources/views/**.blade.php]

But the settings for .php are applied to them instead of the override.

sindresorhus commented 9 years ago

You're using multiple globs incorrectly. Please look at the example: http://editorconfig.org/

isimmons commented 9 years ago

@sindresorhus are you referring to the js/css/html block? I got that from someone else' example somewhere but removing it completely and the blade.php override still doesn't work.

I'm going by the example you linked to where it overrides .js files

# Tab indentation (no size specified)
[*.js]
indent_style = tab

# Indentation override for all JS under lib directory
[lib/**.js]
indent_style = space
indent_size = 2

Thinking that would mean this would work

[*.php]
indent_style = tab
indent_size = 1
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[resources/views/**.php]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
isimmons commented 9 years ago

Ok thought I had also tried simply *.blade.php but apparently I didn't or the incorrect globing below it was causing issue, because that works. Also removed redundant configs from overrides and fixed incorrect glob.

New working config:

# editorconfig.org
root = true
[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true

[*.php]
indent_style = tab
indent_size = 1
insert_final_newline = true

[*.blade.php]
indent_style = space
indent_size = 2

[*.{css,js,html}]
indent_style = space
indent_size = 2

[*.md]
trim_trailing_whitespace = false
sindresorhus commented 9 years ago

Glad you worked it out :)