Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

py-yapf does not use local style settings #12

Open
JorisE opened this issue Apr 13, 2016 · 10 comments
Open

py-yapf does not use local style settings #12

JorisE opened this issue Apr 13, 2016 · 10 comments

Comments

@JorisE
Copy link

JorisE commented Apr 13, 2016

yapf will normally look in directories upwards to see if it can find information in the [yapf] section in setup.cfg or the [yapf] section in .yapf.style. Because py-yapf operates on a file in /tmp, this settings are not respected.

It would be convenient if py-yapf would operate as if it were changing the file that a buffer represents.

@roopeshvaddepally
Copy link

I'm looking at the same issue. My .style.yapf in my home directory is not recognized

@ntcong
Copy link

ntcong commented May 12, 2016

you can edit py-yapf-options and add "--style .style.yapf" I think. Is this enough?

@roopeshvaddepally
Copy link

that doesn't work, because the formatting is happening in /tmp folder, and the file is not available without adding it as "--style ~/.style.yapf".

Even if we add it like that, the next version install is going to wipe the custom settings.

Having it as a option that can be set inside emacs init.el will solve the problem of version upgrades. Or failing that do the yapf formatting inside the same folder as the file for that buffer (of course having a temp name that doesn't conflict with another file in the same folder)

@ntcong
Copy link

ntcong commented May 17, 2016

Your custom settings will not be changed by the plugin. py-yapf-options is already the option you're asking for.

@roopeshvaddepally
Copy link

Now I get what you meant, I was thinking of editing the extension file itself, when you mentioned editing.

I've added this to my emacs init file:
(add-to-list 'py-yapf-options "--style .style.yapf") and yapf just finishes with "Buffer is already yapfed" without formatting anything.

But once I set it back to nil (setq py-yapf-options nil), the formatting works again. So, at least for now it's not helping me solve the issue

@roopeshvaddepally
Copy link

roopeshvaddepally commented May 18, 2016

Tried multiple ways to customize, everytime after setting this option it fails saying "Buffer is already yapfed"

I tried following

  • (add-to-list 'py-yapf-options '("--style ~/.style.yapf"))
  • (setq py-yapf-options '("--style ~/.style.yapf"))
  • (customize-set-variables '(py-yapf-options '("--style ~/.style.yapf")))

But once I reset it to nil, everything works as usual

@ntcong
Copy link

ntcong commented May 18, 2016

You need to use (quote ("--style" "~/.style.yapf")) instead of straight "--style ~/.style.yapf"

@roopeshvaddepally
Copy link

I added quote to all of it, notice the single quote before the style list. (I added the quote to add-to-list after your comment, but it was there in my code though).

@JorisE
Copy link
Author

JorisE commented Jun 5, 2016

Yapf will use the file ~/.config/yapf/style by default @roopeshvaddepally. Using that file will work with py-yapf.

If anyone wants to pick up project settings, you can try https://github.com/JorisE/yapfify.el/blob/master/yapfify.el. Unlike py-yapf, it operates on the original file, so that YAPF will use the settings applicable to that file.

@nevsan
Copy link
Contributor

nevsan commented Sep 16, 2016

I think #13 is a very important update to this project that makes this really useable in any situation. Is this project still maintained?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants