mixer.vim - (Classic) Vim plugin providing text objects and niceties for working with Mix projects

I’ve heard that if you’re not embarrassed by v1 of your product Vim plugin then you’ve released too late.

I’ve been sitting on this the past couple of months and while there is plenty I still have planned (a good amount of stuff is in the works just not in this version), I decided I should cut a release so the few people who will be interested can start using what’s available.

So, I’m happy to announce mixer.vim. Mixer is somewhat similar to elixir-tools.nvim only it’s written in vim9script so that Vim users can have nice Elixir things too. It assumes you have elixir.vim installed.

Here is the features section of the README for posterity:

Features

  • Text objects

    • ad/id - Any macro with a do block. Works on user-defined macros as well as keyword syntax (though the latter needs a little improvement).
    • aD - Like ad but include any assignment and/or attached comments (iD exists for convenience but is identical to id).
    • af/if - A function/macro definition
    • aF - Like af but include all heads, docs, annotations, attr and slot declarations, and even do_ prefixed versions (iF exists for convenience but is identical to if).
    • iS/aS- A sigil
    • im/am- A map or struct
    • iM/aM- A module
    • ic/ac- A comment or documentation
  • Conveniences

    • 'commentstring' is dynamically set in embedded HEEx/Surface.
    • matchit works in embedded HEEx/Surface templates.
    • Automatically sets :compiler if the appropriate plugin is found.
    • [experimental] Remaps ctrl-] in templates that will jump to a phx-hook definition (it’s pretty smart about it) or event handlers on other phx- attributes. Unfortunately this has a dependency on git-grep atm.
  • Commands

    • :Mix runs a mix command with autocomplete. Uses dispatch, neomake, asyncrun, or asyncdo if available.
    • :Deps doesn’t just wrap Mix deps but adds functionality like dynamically adding packages under your cursor (:Deps add floki, for example) or jumping to your deps
      function no matter what you’ve called it (:Deps with no args).
    • :Gen is a unified command for running gen tasks (with autocomplete!), eg:
      • :Gen migration add_name_to_users
      • :Gen live Accounts User users name:string age:integer
    • :IEx starts a :term window running iex. Within a mix project it will assume -S mix. Use :IEx! to get a plain session within a mix project.

:help mixer has more!

8 Likes

(replying here not to avoid fully necroing the old thread)

Lol, ya I hear ya. I’m annoyed at how long I put this off for myself. For me the text objects are the star of the show here even though they need some tweaking for keyword syntax. I find :Gen very useful as well since I seem to always type mix phx.gen.migration. Mix can be a bit finicky depending on if you use an async runner or not. I’m happy to discuss defaults and adding options and for any feedback/contributions in general of course!

There is quite a bit more coming than I’ve documented. I always get nervous before I make a repo public so I scrambled to ready it and missed some things. A lot of it is near ready just not quite polished enough for release.

Thank you for the effort! It’s very appreciated

1 Like

Just a lil’ update…

Once this plugin reaches beta I don’t plan on updating here anymore but for now you’re likely gonna be getting some semi-regular updates (whatever that means).

Here’s what’s different:

  • :Gen now does what you probably expected it should do from the start which is load all generated files into the quickfix list and auto-jump to the first entry. And of course :Gen! is available just in case you want don’t want to do any jumping and stay right where you are.

That’s it, really… unless, of course, you tried this plugin as soon as I posted it and learned that my cherry-picking fu was way off and I had neglected to include several features I claimed were there… anyway, that all that works now (probably).

The :IEx command now includes a hacky “connected REPL” or “Discount Connected REPL” as I like to call it. You could also say it’s a “We have connected REPLs at home” if you’re into that meme. I wouldn’t go so far as to say it’s the GoBots of connected REPLs because GoBots were cooler than this.

In short, you can start an iex session in a Vim :term and every time you save the buffer it will load the changes into the terminal. It even works with parts of a buffer via ranges/counts/visual selection.

In any event, it’s hard to describe so I made a short-ish screencast. It’s my first one ever so be nice if you choose to watch it… or don’t be nice, either is cool.

1 Like