AndreaCrotti / yasnippet-snippets

a collection of yasnippet snippets for many languages
GNU General Public License v3.0
1.15k stars 461 forks source link

Merge elpy snippets (again) #465

Closed JulienPalard closed 6 months ago

JulienPalard commented 1 year ago

A follow up of #278.

I tried to keep it simple, not much elisp, only simple additions.

I did not tested it yet, I'd like to test it a bit before merging.

It's my very first contribution to this repo so beware :D

JulienPalard commented 1 year ago

OK this looks almost OK to me.

Few things are not OK though:

The try / tryelse don't expand correctly, they "indent", is it due to my setup?

The files contains:

# -*- mode: snippet -*-
# name: try
# key: try
# --
try:
    $0
except ${1:Exception}:
    $2

and

# -*- mode: snippet -*-
# name: tryelse
# key: tryelse
# --
try:
    $0
except $1:
    $2
else:
    $3

It gives:

try:

    except Exception:

and:

try:

    except :

        else:

also for the "newlines at end of file" is that common to add them or not add them? I spotted that when there's a newline at end of file it also get inputed in the file, so the behavior is different, I hope there's an existing concensus on this?

JulienPalard commented 1 year ago

@AndreaCrotti gentle ping

JulienPalard commented 1 year ago

Oh my indentation issue has to do with the last lines of .yas-setup.yml:

(add-hook 'python-mode-hook #'yasnippet-snippets--fixed-indent)

and the way I test my snippets. I was testing them by just symlinking ~/.emacs.d/snippets/ to my clone, haha.

What is the proper way to run yasnippet-snippets from my clone instead of elpa?

JulienPalard commented 1 year ago

I was able to test it properly using:

(use-package yasnippet-snippets
  :load-path "~/clones/yasnippet-snippets"
)

I checked ans yes, yasnippet-snippets--fixed-indent do runs. but in my Python buffer the yas-indent-line is still auto.

JulienPalard commented 1 year ago

Using # expand-env: ((yas-indent-line 'fixed)) in the individual snippet that need it works though.

JulienPalard commented 1 year ago

OK for me everything now works as expected.

JulienPalard commented 7 months ago

Is there something I can do here?