Indent is not working properly

Automatic indent doesn’t seem to work in all cases when using treesitter. I have autoindent off, smartindent off, and indent=true in treesitter. Most things work. This case is does not. Sample python code:

def foo():
    """ Comment """
    return

When on the comment line and press o cursor ends up indents 4 more spaces (ends up under the C. Similarly when I press O cursor ends up in the same spot.

My expectation is that the cursor is not indented the additional 4 spaces and would end up in line with the rest of the block.

Bug? Config error? Runing latest plugin as of this writing and using nvim 0.5.1.

With autoindent on and treesitter indent=false opening a new line works as expected.

1 Like

I believe this issue is related: Invalid indents for python · Issue #1136 · nvim-treesitter/nvim-treesitter · GitHub