{
"$type": "site.standard.document",
"description": "I have been using Neovim in a dedicated Alacritty for exactly a year. Took me a long time to come to it, but I recently sought to fix one issue — I",
"path": "/double-click-file-in-macos-to-open-in-neovim/",
"publishedAt": "2024-02-17T14:07:00.000Z",
"site": "at://did:plc:bryys25pc2fnagnyxqgsglhd/site.standard.publication/3mn26bjkkmh23",
"tags": [
"Scripts",
"vim",
"macOS"
],
"textContent": "I have been using Neovim in a dedicated Alacritty for exactly a year.\n\nTook me a long time to come to it, but I recently sought to fix one issue — I can't double click on a file to open it in Neovim.\n\nThere are 3 components to getting this to work:\n\n * Neovim can start a server that listens on a named pipe\n * Automator can be used to make an app, which can then be configured as the file handler.\n * I use Alacritty as a dedicated app for using Neovim\n\nThere are a few steps to do it:\n\n 1. Always start Neovim with server listening on a named pipe:\n\nnvim --listen ~/nvim-server.pipe\n\n 2. Write a script (I use ruby, and call it open-in-nvim) that opens a given filename:\n\n#!/usr/bin/env ruby\n\narg = ARGV[0]\nif arg.nil?\n arg = STDIN.read.lines[0]&.chomp\nend\n\n`/opt/homebrew/bin/nvim --server ~/nvim-server.pipe --remote-send \"<ESC>:tabe #{arg}<CR>\"`\n`open -a Alacritty`\n\n 3. In Automator, create a new Application, add Run Shell Script, and make Pass input as to stdin and paste the absolute path to the open-in-nvim script. Save the application as open-in-nvim.app\n\n 4. Click on a file with the file types you want (.md and .swift for me) and press Cmd+i (Get Info) and change Open with: to be open-in-nvim.app. Remember to click Change All….\n\nNow double clicking files with that extension will open the file in Neovim and switch to it/Alacritty.",
"title": "Double Click File in macOS to Open in Neovim"
}