honza / vim-snippets

vim-snipmate default snippets (Previously snipmate-snippets)
MIT License
4.8k stars 2.03k forks source link

Google-style python docstrings? #1091

Open bradwood opened 5 years ago

bradwood commented 5 years ago

Hi,

I'm trying to figure out how to get my Python snippets to use Google-Style docstrings, rather than RST-style... or pandas/numpy style...

I'm using ncm2 and UltiSnips -- completion works well with this setup.

Here is what I'm getting after a class expansion:

 class Test(object):

    """Testing"""

    def __init__(self, one, two, three):
        """TODO: to be defined1.

        :one: TODO
        :two: TODO
        :three: TODO

        """
        self._one = one
        self._two = two
        self._three = three

I want it to look like this though:

class Test(object):

    """Testing"""

    def __init__(self, one, two, three):
        """TODO: to be defined1.

        Args:
            one: TODO
            two: TODO
            three: TODO

        """
        self._one = one
        self._two = two
        self._three = three

Is there an easy way to switch this, or do I need to hack the snippets to be Google-style?

Thanks!

lpil commented 5 years ago

I don't believe there is a way to do this currently.

We would accept a pull request that added a new snippet using this format, or one that made the existing snippet use that format if a variable is set in the user's vim config.

Guzzii commented 5 years ago

@lpil @bradwood The docstring format has already been defined here: https://github.com/honza/vim-snippets/blob/master/UltiSnips/python.snippets#L166-L184

I am curious how to set the style parameter, so that UltiSnips knows the correct style to use

Guzzii commented 5 years ago

Actually, just found out that one can use g:ultisnips_python_style for styling, https://github.com/honza/vim-snippets/blob/master/UltiSnips/python.snippets#L35 @bradwood

bradwood commented 5 years ago

Hrm -- interesting, but doesnt' appear in the docs that I can see, nor does it appear to set to anything when I try to read it... will play a bit more...

InnovativeInventor commented 5 years ago

@bradwood Did you find out anything interesting/understand how to use g:ultisnips_python_style?