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

Add support for max_line_length #57

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions EditorConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ def apply_config(self, view, config):
indent_size = config.get('indent_size')
trim_trailing_whitespace = config.get('trim_trailing_whitespace')
insert_final_newline = config.get('insert_final_newline')
max_line_length = config.get('max_line_length')
if indent_style == 'space':
settings.set('translate_tabs_to_spaces', True)
elif indent_style == 'tab':
Expand All @@ -103,4 +104,14 @@ def apply_config(self, view, config):
elif insert_final_newline == 'false':
settings.set('ensure_newline_at_eof_on_save', False)

if isinstance(max_line_length, int) and max_line_length:
Copy link
Owner

Choose a reason for hiding this comment

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

I think max_line_length is always a string, so you'll need to coerce it into an int.

Copy link
Author

@joaoe joaoe Nov 5, 2016

Choose a reason for hiding this comment

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

Wouldn't it be an int if typed as max_line_length = 123 instead of max_line_length = "123" ?

But I agree it can be made more flexible by parsing a string, if that's the case.

Copy link
Author

Choose a reason for hiding this comment

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

Ok, just tested it again. Indeed it's true. I think I tested it first by having a max length in my user preferences.

Thanks for the heads up.

Copy link
Owner

Choose a reason for hiding this comment

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

Ideally yes, but .editorconfig is based on .ini, which is untyped and unspec'd, so everything are just strings.

settings.set('auto_wrap', True)
settings.set('auto_wrap_width', max_line_length)
else:
if max_line_length == "off":
settings.set('auto_wrap', False)
else:
settings.erase('auto_wrap')
settings.erase('auto_wrap_width')

view.settings().set(self.MARKER, True)
2 changes: 2 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ See the [EditorConfig site][] for documentation.
- charset
- trim_trailing_whitespace
- insert_final_newline
- max_line_length*

Explanation of the properties can be found on the [EditorConfig site][].

\* support for `max_line_length` requires the [AutoWrap](https://github.com/randy3k/AutoWrap) plugin to be installed.

## Example file

Expand Down