venantius / vim-cljfmt

A Vim plugin for cljfmt, the Clojure formatting tool.
152 stars 22 forks source link

ranges? #9

Open bhurlow opened 9 years ago

bhurlow commented 9 years ago

possible to add support to only format a selected range?

venantius commented 9 years ago

Hmm, interesting request. It's definitely possible but it's not a use case I had particularly considered before. How do you see the interface for this looking?

bhurlow commented 9 years ago

I would want to map Cljfmt to = to be able to format only a specific closure. Just a thought!

bhurlow commented 9 years ago

seems like this is more per file which is fine

rbxbx commented 9 years ago

@venantius in agreement here – most plugins of this nature will allow you to select a range and then apply the transformation ie: :'<,'>Cljfmt

I think you'd be able to do this in terms of :[range]substitute

CurrentBufferContents would have to grab this range, and then line 69 where the actual substitution changes would have to run over that range as well.

You can also make it default to the whole file pretty easily as well, so it wouldn't break current behavior.

see http://stackoverflow.com/a/16164585 for more info. I might try to cook up a PR, but VimL isn't exactly my forte.

Cheers!

venantius commented 9 years ago

I'm fairly new to vimL myself, so if you wanted to take a stab at a PR I'd certainly welcome it ;D

Otherwise I do think this'd be a neat feature, but it's going to be a secondary consideration until I get rid of all of the bugs first :bear:

rbxbx commented 9 years ago

@venantius fair enough. I suspected a similar response :p

May take a stab at it one of these days. Until then, my code shall remain ugly // to my personal preferences.

Thanks for getting back!

venantius commented 9 years ago

It's starting to percolate up to the shortlist; I've been doing a lot of bug fixing over the last few weeks. Don't write it off yet ;)

Deraen commented 9 years ago

Sorry to advertise my own project, but I just created alternative plugin which implements this: https://github.com/Deraen/vim-cider Edit: It doesn't support ranges but it supports motions

rbxbx commented 9 years ago

@Deraen neat – I'll take a look at this :)

Realize movements/selections aren't huge for everyone, but they're pretty integral to my workflow.

Cheers!

ps: don't worry @venantius, still lots of love for ultra :)

venantius commented 9 years ago

Haha, thanks @rbxbx !

If either you or @Deraen felt like submitting a PR here to add motions (which I'm sad to say I'm not familiar with), I'd love it :smile:

sushovannits commented 4 years ago

Is there gonna be a release with ranges support

venantius commented 4 years ago

Is all we're waiting for a formal release? I haven't been writing a lot of code lately :(