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 all commits
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
16 changes: 16 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,19 @@ def apply_config(self, view, config):
elif insert_final_newline == 'false':
settings.set('ensure_newline_at_eof_on_save', False)

try:
max_line_length = int(max_line_length)
except ValueError:
pass

if isinstance(max_line_length, int) and max_line_length > 0:
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