emacs-vs/ts-docstr

Python: inserted docstring's indentation off

d-miketa opened this issue ยท 5 comments

Hi, thanks for making this package available. I've been looking for something that supports Google-style docstrings for Python and this seems like the most promising choice going forward. I especially like the use of Treesitter underneath. It shows a lot of potential.

Unfortunately I can't quite get the package to work out of the box. I have set it up with 'google style Python docstrings and to trigger on typing """. The result ends up indented twice as much as it should be.

Starting from
image

And after writing """:
image

PS: I noticed you use the word "triggeration" in the README to refer to the activation of a trigger. The usual word for this is simply "triggering". Hope you don't mind the correction.

I am not able to reproduce this bug. Can you try it in emacs -q?

PS: I noticed you use the word "triggeration" in the README to refer to the activation of a trigger. The usual word for this is simply "triggering". Hope you don't mind the correction.

No, I don't mind. ๐Ÿ‘ Thank you for the correction!

Sorry for the long delay in responding.

I had trouble setting up ts-docstr within emacs -q; I use Doom Emacs and feel a bit useless without all the nice extras!

However, you may be able to reproduce the bug (in Python) by first indenting a little bit (try 4 spaces) and then writing the three quotes. One of my minor modes seems to be indenting me automatically while writing a function. So, if | represents my cursor:

class MyClass:
    def my_method(a:int) -> int:|

then hitting enter drops me to

class MyClass:
    def my_method(a:int) -> int:|
        |

and writing """ causes the issue described above:

class MyClass:
    def my_method(a:int) -> int:|
            """[summary]
            ...

Disabling dtrt-indent-mode increases the indentation to 8 spaces.

Sorry for the late reply. I was very busy with other things. ๐Ÿ˜“

I don't have a clear idea to reproduce this, and not sure the relation regarding the package dtrt-indent-mode. I will investigate more once I have better idea. And feel free to report anything you found might causes this bug! Thank you!

I've opened a PR in #6. I hope this will fix the issue for you, can you try pull the latest version? Thanks!

My turn to apologise for taking so long to test and reply. The issue seems to be resolved on the current version of main, thank you!! :)