sodapopcan

sodapopcan

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!

Most Liked

ca1989

ca1989

Thank you for the effort! It’s very appreciated

sodapopcan

sodapopcan

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.

sodapopcan

sodapopcan

I haven’t given an update on this project in a while so figured I’d share a newer thing. I’ve only been using it a week so it’s not super polished yet.

I’ve been playing around with htmx lately which means I’ve been using classic controllers for the first time in a while which finally gave me the push to implement the :R command. If you are unfamiliar, this is similar to rails.vim’s :R here for hopping to “related” files (and almost entirely different than projectionist’s idea of “related”).

In a nutshell:

  • Jump from controller to heex/template (context aware based cursor position) - this works whether you use dedicated heex files or components in the HTML module. Outside of a controller action it will jump to the HTML/view module
  • Jump to and from HEEx in a LiveView/Component/Hologram/Surface (this is implemented with the jumplist)
  • Jump from schema to context.
  • Jump from context to schema (context aware based on function name)—YMMV on this one as it uses some pretty hilarious brute forcing to find a file. Still tweaking it.
  • Jump between Router and Endpoint.
  • Go back one migration.
  • There are a few more places it works and more coming.

This is currently non-configurable since for all I know I’m the only one who uses this plugin.

I’ve also added some experimental (and so far undocumented) general Projectionist support (to try it out add let g:mixer_enable_projections = v:true to your vimrc). I’m still tweaking it but the big idea here is that it uses its own heuristics (not to be confused with projectionist’s codified heuristics) to determine your project’s layout and defines projections based on this. There is a lot of detail here so I won’t go into it but briefly:

  • Edomain - Edit a file in lib/my_app or lib/core.
  • Eweb - Edit a file in lib/my_app_web or lib/web.
  • Emigration - With no arguments will jump to the latest migration.
  • a whole host of others

I’m still working on this and I may end up implementing my own version as Projectionist isn’t too well suited for typical Phoenix project layouts (if there is indeed such a thing).

Where Next?

Popular in Announcing Top

zachdaniel
Ash Framework 3.0: Official Release! I’m here with the fine folks at Gig City Elixir, pushing the button live on stage :sunglasses: T...
New
MRdotB
Greetings Elixir community! Today, I’m thrilled to present you with resvg_nif, an open-source project that provides Elixir bindings for ...
New
sonic182
Hi everyone, at Doofinder we have been building llm_composer for some new apps, and we thought it could be useful to share it with the co...
New
kzemek
I’ve recently released v0.2.0 of my Python interop library, Snex. This version rolls up all work-in-progress improvements that have been...
New
munksgaard
flakify is an igniter installer that allows you to quickly get a Nix flake-based development shell up and running for your Elixir/Phoenix...
New
rms.mrcs
Hi there :waving_hand: Just dropping by to share PhonixLiveState, a lib I’ve just published. It’s still VERY RAW, but already in a reas...
New
LostKobrakai
I’ve recently created a small library phoenix_vite integrating the vite build tooling with phoenix. It provides an igniter.installer t...
New
anuaralfetahe
Hello Published a new library - ProcessHub! ProcessHub is a library designed to manage process distribution within the Elixir cluster. ...
New
Mati365
Phoenix has great tooling overall, but one thing that’s still lacking is a solid, plug-and-play integration with a modern WYSIWYG editor....
New
waseigo
I saw this LinkedIn post: *Can your programming language do this? This is a macro in Clojure called `dotrace`. When you surround a pie...
New

Other popular topics Top

chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 30048 115
New
yurko
Here are few pieces of (common) Linux knowledge that we use for reasonably small one server apps. We use Ubuntu but this should work for ...
New
_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
vac
Hi, I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New

We're in Beta

About us Mission Statement