onivim / oni

Oni: Modern Modal Editing - powered by Neovim
https://www.onivim.io
MIT License
11.34k stars 298 forks source link

Register Oni as an editor for all file types, so it shows up in “Open with…” on macOS #1932

Open mikl opened 6 years ago

mikl commented 6 years ago

I know very little of macOS app development, so this is a suggestion for now…

A nice “Quality of Life” improvement for users on macOS would be for Oni to register itself as an editor for everything, so it always shows up in “Open with…” like I have a bunch of other apps doing in this screenshot:

screen shot 2018-03-26 at 17 13 02

I don’t know the mechanism for this, but it appears to be something any app can do (even if it makes very little sense, as is the case with “Day One” or “Notes.app” in this example), and it would be a huge help for Oni users on the Mac, since otherwise you have to select “Other” and find the app manually for every new file type.

oni-bot[bot] commented 6 years ago

Hello and welcome to the Oni repository! Thanks for opening your first issue here. To help us out, please make sure to include as much detail as possible - including screenshots and logs, if possible.

CrossR commented 6 years ago

Seems reasonable! I think we have it setup for certain app types (as listed in the package.json) but not generally to appear in that "Open With" context menu.

I know the same functionality was added to the Windows binary so I expect we'd want feature parity when possible. (Only reason I didn't add it to Mac was since I'm unable to test it there and on Windows its done with registy keys which isn't applicable outside Windows).

akinsho commented 6 years ago

@mikl thanks for the opening this so we can track this 👍. We actually use electron-builder 's config settings to register oni as a default filetype on macOS but we have to manually specify the filetypes and I think at present that list is just

"fileAssociations": [
            {
                "ext": "js",
                "name": "javascript",
                "role": "Editor",
                "isPackage": true
            },
            {
                "ext": "json",
                "name": "JSON",
                "role": "Editor",
                "isPackage": true
            },
            {
                "ext": "jsx",
                "name": "JSX",
                "role": "Editor",
                "isPackage": true
            },
            {
                "ext": "py",
                "name": "Python",
                "role": "Editor",
                "isPackage": true
            },
            {
                "ext": "go",
                "name": "Go Lang",
                "role": "Editor",
                "isPackage": true
            },
            {
                "ext": "re",
                "name": "Reason",
                "role": "Editor",
                "isPackage": true
            },
            {
                "ext": "vim",
                "name": "VimL",
                "role": "Editor",
                "isPackage": true
            },
            {
                "ext": "ts",
                "name": "Typescript",
                "role": "Editor",
                "isPackage": true
            },
            {
                "ext": "tsx",
                "name": "Typescript",
                "role": "Editor",
                "isPackage": true
            },
            {
                "ext": "css",
                "name": "CSS",
                "role": "Editor",
                "isPackage": true
            },
            {
                "ext": "txt",
                "name": "Text",
                "role": "Editor",
                "isPackage": true
            },
            {
                "ext": "md",
                "name": "Markdown",
                "role": "Editor",
                "isPackage": true
            }
        ]

Very open to adding more it'd be great to have oni show up with more filetypes, which ones did you have in mind? (unfortunately I dont think theres a catch all)

mikl commented 6 years ago

I was looking at what Atom does (it also being an Electron app), and they simply have a (much) longer list of file extensions, and they also have a wildcard in there: https://github.com/atom/atom/blob/master/resources/mac/atom-Info.plist#L1521

This part might also be significant

            <key>CFBundleTypeRole</key>
            <string>Editor</string>
mikl commented 6 years ago

Ok, I’ll take a stab at extending the electron-builder settings to have more supported file extensions and also some of the special keys I’ve seen in other apps.

bryphe commented 6 years ago

That'd be great! Thanks for the help, @mikl 👍

mikl commented 6 years ago

First PR is up.

badosu commented 6 years ago

@mikl Did your PR address this issue?