Vimjas / vim-python-pep8-indent

A nicer Python indentation style for vim.
Creative Commons Zero v1.0 Universal
790 stars 69 forks source link

Indention not working after using escaped { #132

Open clouddistortion opened 4 years ago

clouddistortion commented 4 years ago

Hi, I am escaping a curly bracket in a string and after that line of code the indention breaks and runs mad. id=1 d="somestring" LINEBREAK="\n" rendered_result = 'System_Boundary({id},"{descr}") {{'.format(id=id,descr=d) + LINE_BREAK

The following line indention is 62 characters long

blueyed commented 4 years ago

Please provide a full example that (does not) work(s) by itself. The above is not valid Python code, and the next line's indent is 1 as expected.. ;)

clouddistortion commented 4 years ago

For sure :)

Here a working example code.

def some_function():
    id=1
    d="somestring"
    LINE_BREAK="\n"
    rendered_result = 'System_Boundary({id},"{descr}") {{'.format(id=id,descr=d) + LINE_BREAK
    return rendered_result

print(some_function())

If text is being added after the some_function method it will be indented approx. 58-60 spaces to right

blueyed commented 4 years ago

Works for me. Is the "{{" recognized as "pythonString" with your syntax highlighting? This should take care of skipping it: https://github.com/Vimjas/vim-python-pep8-indent/blob/b3a7395ce49b13145bbb54b1cdbfe6a33585bfe9/indent/python.vim#L369

clouddistortion commented 4 years ago

I think it s interpreted as a variable

screenshot
clouddistortion commented 4 years ago

even a simple S="{{" provokes a file indent on the next line

blueyed commented 4 years ago

Appears to be an issue with your syntax file then.

blueyed commented 4 years ago

Looks like it delegates to some other syntax maybe? What does :echo reverse(map(synstack(line("."), col(".")), 'synIDattr(v:val,"name")')) display? (or zS with vim-scriptease)

clouddistortion commented 4 years ago

if the cursors location is in the string with the two curly brackets it displays: ['pythonStrFormat', 'pythonString']

blueyed commented 4 years ago

So that should be ok. But there's another method used to check/skip this after all. Can you try https://github.com/Vimjas/vim-python-pep8-indent/pull/133, please? What syntax plugin/file are you using?

clouddistortion commented 4 years ago

I am using the configuration of https://vim.fisadev.com/ at https://raw.githubusercontent.com/fisadev/fisa-vim-config/master/config.vim

clouddistortion commented 4 years ago

works great!

blueyed commented 4 years ago

Cool! Will have to check this with regard to slower performance now maybe (and adding a test), but good to know already that it works.