sodapopcan

sodapopcan

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!

https://github.com/sodapopcan/vim-mixer

Showing Posts 1 to 5

sodapopcan

sodapopcan OP

(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.

ca1989

ca1989

Thank you for the effort! It’s very appreciated

sodapopcan

sodapopcan OP

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).

sodapopcan

sodapopcan OP

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 OP

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).

— All posts loaded —

Where Next? Top

Trending in Announcing Top

woylie
Flop is an Elixir library that applies filtering, ordering and pagination parameters to your Ecto queries. offset-based pagination with...
New
MRdotB
I needed to reuse React components from my Chrome extension in my Phoenix/LiveView backend. I noticed that for Svelte/Vue, there are live...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
fuelen
Hi all! I want to present a small library which provides a mix task for generating an Entity-Relationship Diagram for Ecto schemas. You...
New
anuaralfetahe
Hello Published a new library - ProcessHub! ProcessHub is a library designed to manage process distribution within the Elixir cluster. ...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New

Other Trending Topics Top

ancatrusca
New episode with Louis Pilfold - the most detailed conversation about Gleam’s design I’ve come across. Worth knowing for the Elixir comm...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New
sergio
It’s not that it’s vocabulary is too advanced. It’s something worse. I get lost trying to follow even a paragraph written by Claude. It’...
New
AstonJ
This showed up on my feed.. anyone heard of it? Just hype? Ox Alpha is a reasoning model designed for coding, sustained ag...
New
sorenone
Today we’re releasing Oban for Python. Not an Oban client in Python. Not a pythonx wrapper embedded in Elixir. Nope, it’s a fully operati...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews