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

Proposal: Minify Code #43

Open
1 task done
l-zeuch opened this issue May 29, 2022 · 3 comments
Open
1 task done

Proposal: Minify Code #43

l-zeuch opened this issue May 29, 2022 · 3 comments
Labels
status/triage default label before it is marked as bug or something else type/enhancement New feature or request
Milestone

Comments

@l-zeuch
Copy link
Owner

l-zeuch commented May 29, 2022

Description

In a similar fashion to jo3-l/cc-minifier, add a command (and/or binding) to generate a minified version of the current buffer contents.

Solution

To begin with, I'm not entirely sure if this feature is even possible in pure Vim script, or if we have to resort to the Lua API, and thus make this a Neovim-only feature.
I'll do some research in those regards and see if I can come up with results that bring this forward.

However, before I further go into the discussion of a potential solution, we first have to consider the dreaded feature creep — is such a feature really necessary and needed?
To me it sure seems convenient to just enter a command and have a minimal version of my code.

Finally, we have to consider multiple things:

  • Sane defaults that are not too aggressive but still show some decent results
  • A way to conveniently and easily manipulate the result

Regarding my first point, this definitely needs some discussion. Perhaps we can take inspiration at jo3-l/cc-minifier?
With respect to the second point however, we'll have to decide a way.

Comments feel rather clunky and unnecessarily complicated to me — their format and what argument does what would have to be documented well.

If we can pass arguments to our command, then I suggest we go with that, in a very similar fashion to command line programs that already do text manipulation. We would then also be able to bundle multiple effects into one single argument, say --aggressive.

The format, whether we use the flag syntax or pass arguments surely is up to debate. Personally, I like the flags style more, they feel to me more appropriate.

Code of Conduct

  • I agree to follow this project's Code of Conduct.
@l-zeuch l-zeuch added type/enhancement New feature or request status/triage default label before it is marked as bug or something else labels May 29, 2022
@l-zeuch l-zeuch added this to the Backlog milestone May 29, 2022
@LRitzdorf
Copy link
Collaborator

This does indeed seem useful. Although it might constitute just a bit of feature creep, I think it makes sense, along with #40 (as both implement enhanced functionality that wouldn't otherwise be available).

As for the issues you mentioned, I also like the flags approach. Since most options would likely be binary, flags do seem to be the most logical option.

Joe's code could definitely be useful as a basis for this, but (obviously) it's JS, so we'd have to port it to something more suitable for Vim. To that end, I like Python more than Lua here, since that will ensure we aren't limited to Neovim.

Lastly, in addition to the transforms in Joe's existing code, we might want to add one-lining (perhaps as part of an extra-aggressive mode?), since newlines in the CC itself count as two characters each.

@l-zeuch
Copy link
Owner Author

l-zeuch commented May 30, 2022

Personally I prefer this feature over #40 — adding features to a programming interface is not the task of a simple plugin, in my eyes.

[...] but (obviously) it's JS, so we'd have to port it to something more suitable for Vim. To that end, I like Python more than Lua here, since that will ensure we aren't limited to Neovim.

I honestly don't know if that would make any difference. When you try to run :checkhealth in your Neovim, you'll see a multitude of language providers, namely: Ruby via neovim-ruby-host gem; Node.js via neovim npm/yarn package; Perl via Neovim::Ext; Python3 via pynvim. Lua just so happens to be inbuilt and shipped everywhere, these modules and packages are obviously all optional.

However, if there is a way — any way — to also interface Vim with this backend, we'll use that way and thus that language.

`:checkhealth` image

image

Lastly, in addition to the transforms in Joe's existing code, we might want to add one-lining (perhaps as part of an extra-aggressive mode?), since newlines in the CC itself count as two characters each.

Definitely needed, the character count being off on the web interface has been fixed recently as well.

@LRitzdorf
Copy link
Collaborator

Hm, good point about language support. But also, I think Python is something of a standard for more advanced Vim plugins (even for vanilla Vim), so it might be more reasonable to expect users to have Python already installed and set up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/triage default label before it is marked as bug or something else type/enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants