From 760447b215595231b06be0d2ed489366e8884a8c Mon Sep 17 00:00:00 2001 From: Mark Nauwelaerts Date: Tue, 28 Dec 2021 18:47:45 +0100 Subject: [PATCH] Support pycodestyle indent-size option --- CONFIGURATION.md | 2 ++ pylsp/config/flake8_conf.py | 2 ++ pylsp/config/pycodestyle_conf.py | 1 + pylsp/config/schema.json | 10 ++++++++++ pylsp/plugins/flake8_lint.py | 1 + pylsp/plugins/pycodestyle_lint.py | 1 + 6 files changed, 17 insertions(+) diff --git a/CONFIGURATION.md b/CONFIGURATION.md index 5f32f78b..7ba70cf9 100644 --- a/CONFIGURATION.md +++ b/CONFIGURATION.md @@ -12,6 +12,7 @@ This server can be configured using `workspace/didChangeConfiguration` method. E | `pylsp.plugins.flake8.hangClosing` | `boolean` | Hang closing bracket instead of matching indentation of opening bracket's line. | `null` | | `pylsp.plugins.flake8.ignore` | `array` | List of errors and warnings to ignore (or skip). | `null` | | `pylsp.plugins.flake8.maxLineLength` | `integer` | Maximum allowed line length for the entirety of this run. | `null` | +| `pylsp.plugins.flake8.indentSize` | `integer` | Set indentation spaces. | `null` | | `pylsp.plugins.flake8.perFileIgnores` | `array` | A pairing of filenames and violation codes that defines which violations to ignore in a particular file, for example: `["file_path.py:W305,W304"]`). | `null` | | `pylsp.plugins.flake8.select` | `array` | List of errors and warnings to enable. | `null` | | `pylsp.plugins.jedi.extra_paths` | `array` | Define extra paths for jedi.Script. | `[]` | @@ -44,6 +45,7 @@ This server can be configured using `workspace/didChangeConfiguration` method. E | `pylsp.plugins.pycodestyle.ignore` | `array` of unique `string` items | Ignore errors and warnings | `null` | | `pylsp.plugins.pycodestyle.hangClosing` | `boolean` | Hang closing bracket instead of matching indentation of opening bracket's line. | `null` | | `pylsp.plugins.pycodestyle.maxLineLength` | `number` | Set maximum allowed line length. | `null` | +| `pylsp.plugins.pycodestyle.indentSize` | `integer` | Set indentation spaces. | `null` | | `pylsp.plugins.pydocstyle.enabled` | `boolean` | Enable or disable the plugin. | `false` | | `pylsp.plugins.pydocstyle.convention` | `string` | Choose the basic list of checked errors by specifying an existing convention. | `null` | | `pylsp.plugins.pydocstyle.addIgnore` | `array` of unique `string` items | Ignore errors and warnings in addition to the specified convention. | `null` | diff --git a/pylsp/config/flake8_conf.py b/pylsp/config/flake8_conf.py index eed9a31c..bdc34767 100644 --- a/pylsp/config/flake8_conf.py +++ b/pylsp/config/flake8_conf.py @@ -20,6 +20,7 @@ ('hang-closing', 'plugins.pycodestyle.hangClosing', bool), ('ignore', 'plugins.pycodestyle.ignore', list), ('max-line-length', 'plugins.pycodestyle.maxLineLength', int), + ('indent-size', 'plugins.pycodestyle.indentSize', int), ('select', 'plugins.pycodestyle.select', list), # flake8 ('exclude', 'plugins.flake8.exclude', list), @@ -27,6 +28,7 @@ ('hang-closing', 'plugins.flake8.hangClosing', bool), ('ignore', 'plugins.flake8.ignore', list), ('max-line-length', 'plugins.flake8.maxLineLength', int), + ('indent-size', 'plugins.flake8.indentSize', int), ('select', 'plugins.flake8.select', list), ('per-file-ignores', 'plugins.flake8.perFileIgnores', list), ] diff --git a/pylsp/config/pycodestyle_conf.py b/pylsp/config/pycodestyle_conf.py index a5f2fbe9..6ac5941e 100644 --- a/pylsp/config/pycodestyle_conf.py +++ b/pylsp/config/pycodestyle_conf.py @@ -16,6 +16,7 @@ ('hang-closing', 'plugins.pycodestyle.hangClosing', bool), ('ignore', 'plugins.pycodestyle.ignore', list), ('max-line-length', 'plugins.pycodestyle.maxLineLength', int), + ('indent-size', 'plugins.pycodestyle.indentSize', int), ('select', 'plugins.pycodestyle.select', list), ('aggressive', 'plugins.pycodestyle.aggressive', int), ] diff --git a/pylsp/config/schema.json b/pylsp/config/schema.json index b2d369a9..c29d78bd 100644 --- a/pylsp/config/schema.json +++ b/pylsp/config/schema.json @@ -54,6 +54,11 @@ "default": null, "description": "Maximum allowed line length for the entirety of this run." }, + "pylsp.plugins.flake8.indentSize": { + "type": "integer", + "default": null, + "description": "Set indentation spaces." + }, "pylsp.plugins.flake8.perFileIgnores": { "type": "array", "default": null, @@ -237,6 +242,11 @@ "default": null, "description": "Set maximum allowed line length." }, + "pylsp.plugins.pycodestyle.indentSize": { + "type": "integer", + "default": null, + "description": "Set indentation spaces." + }, "pylsp.plugins.pydocstyle.enabled": { "type": "boolean", "default": false, diff --git a/pylsp/plugins/flake8_lint.py b/pylsp/plugins/flake8_lint.py index 0ffc48f7..3707222f 100644 --- a/pylsp/plugins/flake8_lint.py +++ b/pylsp/plugins/flake8_lint.py @@ -43,6 +43,7 @@ def pylsp_lint(workspace, document): 'hang-closing': settings.get('hangClosing'), 'ignore': ignores or None, 'max-line-length': settings.get('maxLineLength'), + 'indent-size': settings.get('indentSize'), 'select': settings.get('select'), } diff --git a/pylsp/plugins/pycodestyle_lint.py b/pylsp/plugins/pycodestyle_lint.py index c8d7dae8..99a6f074 100644 --- a/pylsp/plugins/pycodestyle_lint.py +++ b/pylsp/plugins/pycodestyle_lint.py @@ -32,6 +32,7 @@ def pylsp_lint(workspace, document): 'hang_closing': settings.get('hangClosing'), 'ignore': settings.get('ignore'), 'max_line_length': settings.get('maxLineLength'), + 'indent_size': settings.get('indentSize'), 'select': settings.get('select'), } kwargs = {k: v for k, v in opts.items() if v}