Jump to content

Open files and folders in Neovim


Recommended Posts

Posted (edited)

Open the selected file or folder in Finder with Neovim.

 

Available on GitHub: https://github.com/alexchantastic/alfred-open-with-neovim-workflow

 

Screenshot2024-06-05at9_40_46AM.png.b4a51b0cd1174f231668981e40422161.png

🎥 Check out a video of the workflow in action

 

Currently only supports opening Neovim in iTerm2, but feel free to open an issue on GitHub or leave a message here with a terminal emulator or Neovim GUI that you're interested in using and I can try to add it in!

 

Keywords available:

  • nvim which opens the currently selected file or folder (or whatever folder you have focused) in Finder. You can also type a path to a file or folder.
  • nvimf which initiates Alfred's file search and allows you to use that interface to select a file or folder to open

Edited by alexchantastic
Link to comment

A few suggestions:


You should always prefer with input as argv over with input as {query}.


But better yet, you should be able to do this entirely without code or being specific to iTerm. There is an Automation Task to get the Selection in Finder and another to Shell Escape Text. With both of those in sequence connected to a Terminal Command Action set up to nvim {query} (with all escaping turned off, because it was done by the Automation Task), you should have the same behaviour plus support for whatever Terminal the user has set up in Alfred Preferences. I wrote some code years ago (and still working fine) to open Terminal commands with iTerm via Alfred.

 

By adding a Text Field configuration, you can even make this generic to any CLI text editor.

 

Thank you for the idea, I use Helix and just built a quick workflow to do this. For reference, I also made the File Action support only +public.plain-text and public.folder.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...