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

respect custom indent rules #24

Open
blinsay opened this issue Nov 22, 2015 · 4 comments
Open

respect custom indent rules #24

blinsay opened this issue Nov 22, 2015 · 4 comments

Comments

@blinsay
Copy link

blinsay commented Nov 22, 2015

it'd be rad to have formatting from inside vim respect custom indent rules!

right now I have this set up in my project.clj:

:cljfmt {:indents {my-fancy-macro [[:inner 0]]}}

and when I run :Cljfmt it gets ignored.

@venantius
Copy link
Owner

I'll look into this. Whether or not it's reasonably feasible depends largely on whether or not lein-cljfmt injects your preferences into a namespace var that's accessible at REPL / runtime; having to parse your project.clj from vim-cljfmt directly is possible but it's a vastly less preferable approach.

@raycheung
Copy link

I'm facing the same issue, is there any solution? I have a few custom rules for cljfmt and I can't really use this plugin.

@venantius
Copy link
Owner

@raycheung unfortunately there is no solution at present. I spent a few hours today trying to get a viable PR put together but wasn't able to get all the way there and don't have the time to keep working on it.

If you're interested, I've pushed up my work in a commit here -- this is really close to being able to give you a runtime-accessible var with your project's cljfmt options, but unfortunately it tries to eval the symbols loaded in from the respective resource files ("cljfmt/indents/clojure.clj", etc.) and fails when it can't lookup defroutes, for instance. If you were able to get this over the line and merged into Cljfmt upstream it would be pretty trivial to patch vim-cljfmt to do the same.

MichaelBlume added a commit to MichaelBlume/cljfmt that referenced this issue Jun 30, 2017
vim-cljfmt uses a REPL connection to call reformat-string and reformat vim
buffers on command. Unfortunately, it doesn't respect indent options specified
in project.clj/profiles.clj. As mentioned in venantius/vim-cljfmt#24 the author
is reluctant to parse these files manually.

By injecting indent settings into cljfmt.core at REPL startup, we can enable
vim-cljfmt to easily respect these settings.
MichaelBlume added a commit to MichaelBlume/cljfmt that referenced this issue Jun 30, 2017
vim-cljfmt uses a REPL connection to call reformat-string and reformat vim
buffers on command. Unfortunately, it doesn't respect indent options specified
in project.clj/profiles.clj. As mentioned in venantius/vim-cljfmt#24 the author
is reluctant to parse these files manually.

By injecting indent settings into cljfmt.core at REPL startup, we can enable
vim-cljfmt to easily respect these settings.
MichaelBlume added a commit to MichaelBlume/cljfmt that referenced this issue Jun 30, 2017
vim-cljfmt uses a REPL connection to call reformat-string and reformat vim
buffers on command. Unfortunately, it doesn't respect indent options specified
in project.clj/profiles.clj. As mentioned in venantius/vim-cljfmt#24 the author
is reluctant to parse these files manually.

By injecting indent settings into cljfmt.core at REPL startup, we can enable
vim-cljfmt to easily respect these settings.
MichaelBlume added a commit to MichaelBlume/vim-cljfmt that referenced this issue Jun 30, 2017
@MichaelBlume
Copy link

I no longer have this problem in my workflow since I have vim pointing to https://github.com/michaelblume/vim-cljfmt and my profiles.clj pointing to https://github.com/MichaelBlume/lein-cljfmt-editor. So far I've had no luck getting this code merged, but it's quite usable where it is.

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