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

Plugin seems to ignore language-specific indent settings for makefile, auto-converting tabs to spaces #58

Closed xml closed 5 years ago

xml commented 7 years ago

Hi. First, the plugin is super-helpful. Thank you very much for it.

For the first time ever, I seem to be encountering a defect, however. Either that, or I'm totally misreading my docs and config format.

I've got a makefile, where the tabs are significant. But, editorconfig seems to be the culprit in converting all my tabs back to spaces every time I save. So, i use the "Convert Indentation to Tabs" command to put it back. Which works. Then I save... and it's spaces again.

(Is auto-converting indents on save a feature of editorconfig, or some other plugin that's interacting with it?)

Notably, when I go into .editorconfig and convert the default indent_style to tab, then try to save my makefile again, it's fine.

Here's my project's .editorconfig, with make-specific overrides at bottom:

# http://editorconfig.org

# A special property that should be specified at the top of the file outside of
# any sections. Set to true to stop .editor config file search on current file
root = true

[*]
# Indentation style
# Possible values - tab, space
indent_style = space

# Indentation size in single-spaced characters
# Possible values - an integer, tab
indent_size = 2

# Line ending file format
# Possible values - lf, crlf, cr
end_of_line = lf

# File character encoding
# Possible values - latin1, utf-8, utf-16be, utf-16le
charset = utf-8

# Denotes whether to trim whitespace at the end of lines
# Possible values - true, false
trim_trailing_whitespace = true

# Denotes whether file should end with a newline
# Possible values - true, false
insert_final_newline = true

[Makefile]
# Indentation style
# Possible values - tab, space
indent_style = tab

And here are the Sublime syntax-specific settings:

{
  "translate_tabs_to_spaces": false,
}

Am I reading this right, or just overlooking a configuration detail? Thanks!

sindresorhus commented 7 years ago

I tried your .editorconfig with a Makefile and it did not convert tabs to spaces.

clenemt commented 7 years ago

Hello, same problem here, less file get changed to space when I save.

config:

root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.js]
indent_size = 4
indent_style = space

[*.less]
indent_size = 4
indent_style = tab

[src/**]
indent_size = 4
indent_style = space

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

Try disabling all other plugins to ensure it's not something else that interferes.

clenemt commented 7 years ago

"detect_indentation": false fixed it for me