rhysd / NyaoVim

Web-enhanced Extensible Neovim Frontend
Other
2.22k stars 57 forks source link

NyaoVim always starts with two open buffers #140

Open unode opened 6 years ago

unode commented 6 years ago

When I start NyaoVim, even if I don't specify a file/folder, the first buffer to be opened is always the path <prefix>/lib/node_modules/nyaovim, where <prefix> is the location where I installed NyaoVim.

The problem is caused by the code: https://github.com/rhysd/NyaoVim/blob/99db8fa62125106d7182d7c8e09aca5b04f7f76e/renderer/nyaovim-app.ts#L237

which only works if the binary is called electron. This is fragile and can break easily.

When running on NixOS by the time the code above runs the binary is actually .electron-wrapped, resulting in electron_argc = 1 which in turn causes <prefix>/lib/node_modules/nyaovim to be kept as 2nd argument.

On my system, since the folder where the binary lives is called electron I worked around the problem by using:

    if ('electron' === basename(remote.process.argv[0]).toLowerCase()) {
        electron_argc = 2;
    }
    else if ('electron' === basename(dirname(remote.process.argv[0])).toLowerCase()) {
        electron_argc = 2;
    }

however this is equally fragile...

As I understand, the goal here is to distinguish between the two execution modes, NyaoVim.app and electron. Can this be fixed by some other means instead of matching the name of the binary?