tpope / vim-sleuth

sleuth.vim: Heuristically set buffer options
https://www.vim.org/scripts/script.php?script_id=4375
1.92k stars 86 forks source link

Disable for specific filetype #77

Closed kovasap closed 2 years ago

kovasap commented 2 years ago

I'm having some issues with this plugin properly identifying python files as 2-space indented (perhaps because continuation lines are indented with 4 spaces? I haven't dug into the algorithm). I'd like to disable the plugin for all python files for now. I don't see an option for this, is it possible?

tpope commented 2 years ago

What's possible is documented. I'd be interested to see the problematic file to inform future changes to the algorithm.

kovasap commented 2 years ago

I can't share directly the file in question, but this minimal file gets its shiftwidth set to 4:

from typing import List

def test(
    arg: str,
) -> List[str]:
  return [
      'hi',
      'yo',
  ]

def test2(
    arg: List[str]
) -> str:
  var = []
  var2 = set()
  for i in sorted(arg,
                  key=lambda a: str(a)):
    print(i)

When python sees it as 2-space-indented with continuation lines given an extra 2 spaces.

tpope commented 2 years ago

I guess Python line continuations are common enough that we could try special casing them. Hopefully I'm not opening Pandora's box.

tpope commented 2 years ago

For posterity, and in case this gets rolled back, I think the right workaround here is probably .editorconfig. Forcing shiftwidth=2 in all Python files is a great example of why file type based configuration is so limiting.

kovasap commented 2 years ago

That looks like it works for me. Thank you!!