py-yapf.el
py-yapf.el copied to clipboard
py-yapf does not use local style settings
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.
I'm looking at the same issue. My .style.yapf in my home directory is not recognized
you can edit py-yapf-options and add "--style .style.yapf" I think. Is this enough?
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)
Your custom settings will not be changed by the plugin. py-yapf-options is already the option you're asking for.
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
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
You need to use (quote ("--style" "~/.style.yapf")) instead of straight "--style ~/.style.yapf"
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).
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.
I think https://github.com/paetzke/py-yapf.el/pull/13 is a very important update to this project that makes this really useable in any situation. Is this project still maintained?