python-lsp / python-lsp-server

Fork of the python-language-server project, maintained by the Spyder IDE team and the community
MIT License
1.75k stars 187 forks source link

How can I prevent autopep8 from changing tabsize to 4? #521

Open taiwbi opened 5 months ago

taiwbi commented 5 months ago

This is my pylsp neovim configuration, It doesn't show E111 indentation is not a multiple of 4 anymore but when I format my document, it changes all the tabs from 2 spaces to 4 spaces

pylsp = {
  configurationSources = { "pycodestyle" },
  plugins = {
    autopep8 = {
      enabled = true,
      ignore = { "E121" },
      indentSize = 2,
    },
    pycodestyle = {
      enabled = true,
      maxLineLength = 121,
      indentSize = 2,
    },
  },
},
taiwbi commented 5 months ago

I just disabled autopep8 and started using yapf

pylsp = {
  configurationSources = { "pycodestyle" },
  plugins = {
    autopep8 = { enabled = false },
    yapf = {
      enabled = true,
      style = {
        based_on_style = "pep8",
        indent_width = 2,
      },
    },
    pycodestyle = {
      enabled = true,
      maxLineLength = 121,
      indentSize = 2,
    },
  },
},

I don't know if it's an issue or my configuration mistake so I keep this issue open but my problem is solved