onivim / oni

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

Linux support #13

Closed darkwater closed 7 years ago

darkwater commented 7 years ago

Looks like ONI only supports Windows and macOS right now? Judging by some of the source files it checks whether the OS is "Darwin", and assumes Windows otherwise.

What needs to be done for this to run on Linux?

bryphe commented 7 years ago

Yes, unfortunately I do not have a Linux box to test support at the moment, but in theory it should be straightforward to support.

Electron itself is fortunately compatible with Linux, so there shouldn't be much work to make it compatible. It might be sufficient to reverse those checks to check for Windows instead.

I'll flip those checks for now, since there is no harm in that, and potentially it could at least get the Linux build running to test further.

darkwater commented 7 years ago

Cool, but you forgot the check in cli/oni. After #15 I can successfully build and run on Linux.

No issues running, though the default font seems unavailable. Not sure how to go about this correctly since available fonts vary wildly between distributions.

On another note, how do I configure the Neovim part? It doesn't seem to use my existing Neovim configuration.

bryphe commented 7 years ago

Sweet, thanks for the fix! That's great that it is launching now.

Regarding the font - there's this code in Config.ts:

const MacConfig: any = {
    "editor.fontFamily": "Monaco"
}

const WindowsConfig: any = {
    "editor.fontFamily": "Consolas"
}

That picks some defaults for Mac & Windows. We might need to come up with a set of defaults for Linux - but I'm not sure what a good default font on Linux is. An alternative would be to bundle a default font with the app (like fontawesome is bundled right now).

I opened another issue for sourcing the init.vim - #16

darkwater commented 7 years ago

Bundling a default font would probably the most robust method. Alternatively, is a list of fonts possible? ONI could try a couple of common fonts which should cover pretty much every user.

bryphe commented 7 years ago

Makes sense. I don't think there is a great way to list the fonts, and then identify which ones are monospace.

We could potentially bundle this font: https://fonts.google.com/specimen/Inconsolata

It has an open license and is monospace. I'll take a look at bundling it in the next couple days. In the meantime, you might want to manually change the font family to your preferred font.

define-private-public commented 7 years ago

I was trying to install this on Linux and I got this error at the "npm install..." level:


sh: 1: node: not found
/usr/local/lib
└── (empty)

npm ERR! Linux 4.4.0-51-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "-g" "oni-vim"
npm ERR! node v4.2.6
npm ERR! npm  v3.5.2
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn

npm ERR! electron@1.4.10 postinstall: `node install.js`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the electron@1.4.10 postinstall script 'node install.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the electron package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node install.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs electron
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls electron
npm ERR! There is likely additional logging output above.

I'm not familiar at all with node or npm. Is is trying to look for a fil in /usr/local/lib that doesn't exist?

bryphe commented 7 years ago

@define-private-public - hmm, seems like npm failed to install electron - maybe related to one of these issues? https://github.com/electron/electron/issues/7007 https://github.com/electron-userland/electron-prebuilt/issues/186

define-private-public commented 7 years ago

Okay, I got a little farther by install Node from a different repo, now I'm getting this error:

I find those permission errors odd as I'm running the npm install as sudo.

npm ERR! addLocal Could not install /usr/local/lib/node_modules/oni-vim/vim/vimfiles/bundle/oni-plugin-typescript
npm ERR! Linux 4.4.0-51-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install"
npm ERR! node v4.2.6
npm ERR! npm  v3.5.2
npm ERR! path /home/ben/.npm/oni-plugin-typescript/0.0.1/package
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall mkdir

npm ERR! Error: EACCES: permission denied, mkdir '/home/ben/.npm/oni-plugin-typescript/0.0.1/package'
npm ERR!     at Error (native)
npm ERR!  { [Error: EACCES: permission denied, mkdir '/home/ben/.npm/oni-plugin-typescript/0.0.1/package']
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'mkdir',
npm ERR!   path: '/home/ben/.npm/oni-plugin-typescript/0.0.1/package' }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.

npm ERR! Please include the following file with any support request:
npm ERR!     /usr/local/lib/node_modules/oni-vim/vim/vimfiles/bundle/oni-plugin-typescript/npm-debug.log

npm ERR! Linux 4.4.0-51-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "run" "install:oni-plugin-typescript"
npm ERR! node v4.2.6
npm ERR! npm  v3.5.2
npm ERR! code ELIFECYCLE
npm ERR! oni-vim@0.1.1 install:oni-plugin-typescript: `cd vim/vimfiles/bundle/oni-plugin-typescript && npm install`
npm ERR! Exit status 243
npm ERR! 
npm ERR! Failed at the oni-vim@0.1.1 install:oni-plugin-typescript script 'cd vim/vimfiles/bundle/oni-plugin-typescript && npm install'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the oni-vim package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     cd vim/vimfiles/bundle/oni-plugin-typescript && npm install
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs oni-vim
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls oni-vim
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /usr/local/lib/node_modules/oni-vim/npm-debug.log
npm ERR! Linux 4.4.0-51-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "-g" "oni-vim"
npm ERR! node v4.2.6
npm ERR! npm  v3.5.2
npm ERR! code ELIFECYCLE

npm ERR! oni-vim@0.1.1 postinstall: `npm run install:oni-plugin-typescript`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the oni-vim@0.1.1 postinstall script 'npm run install:oni-plugin-typescript'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the oni-vim package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     npm run install:oni-plugin-typescript
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs oni-vim
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls oni-vim
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/ben/Desktop/npm-debug.log
keforbes commented 7 years ago

FWIW, I just installed on Arch Linux with no problems. Using the latest version of node and npm and running the Build directions on the project page.

node v7.2.0 npm v4.0.3

It looks like you're using:

node v4.2.6 npm v3.5.2

Is there a reason why you're using older versions?

define-private-public commented 7 years ago

@keforbes It must have been from the repo that I pulled it from (I guess they weren't keeping things up to day). I'll try it again and see what happens.

keforbes commented 7 years ago

Please excuse my ignorance (I don't know anything about Electron development) but isn't that fontFamily property used like a CSS property? Can't you define multiple fonts as fallbacks? For example, in CSS you could do:

font-family: "Menlo, DejaVu Sans Mono, Lucida Console, monospace"

This would be the order of preferred fonts, where the default monospace font is the final fallback if none of the other fonts are installed.

I just tried changing MacConfig to:

const MacConfig: any = {
    "editor.fontFamily": "Menlo, DejaVu Sans Mono, Lucida Console, monospace",
}

and it seemed to have an effect on Linux (since it's checking for isWindows). Anyway, just a thought.

Edit: My list of fonts was pretty much arbitrary. I found a more comprehensive list of monospace fonts (both Windows and Mac) which is probably better if you take this route:

font-family:"Consolas,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New, monospace";
bryphe commented 7 years ago

@keforbes - not ignorant at all, thanks for the suggestion :)

We use the font family to set the font in the canvas. For some reason I thought that you couldn't have font fallbacks in the canvas font, but I could very well be mistaken.

If you're up for it, feel free to send out a pull request with the fallback fonts! Would be helpful to have. DejaVu Sans Mon was just added for Linux by @JakubJecminek , but having additional fallbacks for all the platforms wouldn't hurt.

darkwater commented 7 years ago

For some reason I thought that you couldn't have font fallbacks in the canvas font, but I could very well be mistaken.

Yeah, you can set ctx.font to a comma-separated list of fonts of which the first available will be used, just like in CSS. (demo)

bryphe commented 7 years ago

@darkwater thanks for the jsfiddle, you're right, good call.

It seems like it would be helpful to have a set of fallback fonts that we append when drawing our text (in ctx.font) regardless of what that value is, so we can at least be guaranteed a monospace font even if the font doesn't exist. I believe this is similiar to how gvim behaves.

Potentially we could add the fallback here, I'm thinking, when we set the font https://github.com/extr0py/oni/blob/master/browser/src/Renderer/RenderCache.ts

bryphe commented 7 years ago

Closed this out since most of the conversation was specific to fonts... I'm sure there are lots of other Linux-specific issues, though. Feel free to log additional issues as they come up (I don't use Linux for development at the moment, so these are the last issues for me to find)