onivim / oni

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

Document adding language support #2123

Open PatrickMassot opened 6 years ago

PatrickMassot commented 6 years ago

I just discovered Oni and I would like to give it a try because I've been using vim for 15 years but I've recently been forced to use VScode because of its Lean prover support. Of course I would much prefer using vim than VScode. Oni seems to make it much easier to port something from VScode to vim than using regular vim. Here Lean support means (syntax highlighting and) Language Server Protocol: https://github.com/leanprover/vscode-lean. It seems Oni has all it takes, except maybe documentation.

Here is what I tried, mostly mimicking stuff I saw in existing codebase:

Side note: finishing the sentence "You can access the Oni object directly, ie:" at the end of https://github.com/onivim/oni/wiki/Plugins#api would probably already help.

Thank you very much for your work on Oni!

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.

parkerault commented 6 years ago

The Oni object in the dev tools is available as Oni, i.e. Oni.language.isLanguageServerAvailable('lean'). I think someone more knowledgeable will have to help you with the language server issues though. I agree that the plugin API has a low documentation area, but there are some good examples here: https://github.com/onivim/oni/tree/master/vim/core

PatrickMassot commented 6 years ago

Thanks @parkerault, but I'm closing this for now. There is no point discussing such fancy features as long as Oni is not yet usable as a basic text editor (see #2140 ).

parkerault commented 6 years ago

Well, it is an alpha, but I've been using Oni for all of my professional work for the last two months without any major hiccups.

PatrickMassot commented 6 years ago

Ok, there is a workaround to #2140, so let's say fancy features could make sense, and reopen that issue.

bryphe commented 6 years ago

Hi @PatrickMassot ,

Glad @CrossR got you unblocked with #2140 😄

Your configuration looks solid - a good next step would be to open the developer tools:

And then open up a lean file - it'd be interesting to see if there are any errors / warnings there.

Trying the command @parkerault mentioned is a good starting point:

Oni.language.isLanguageServerAvailable('lean')

Running this command is a good sanity check too:

Oni.editors.activeEditor.activeBuffer.language

That should return lean - if it isn't, then the syntax highlighting / language server definitely won't work.

Let me know if you see any errors in the console when you try those steps. I hope that we can implement some better error handling around here to make it easier / more user friendly to hook this.

And long-term, I'd like to be able to grab the grammars+language service from VSCode plugins, so you could just use the vscode-lean plugin directly with Oni, w/o needing to manually configure.

PatrickMassot commented 6 years ago

Thanks for your comments. Oni.language.isLanguageServerAvailable('lean') and Oni.editors.activeEditor.activeBuffer.language are both ok, I do see in the lower left corner of Oni the word lean next to some "turning almost circle" suggesting something is running (by the way I noticed this indicator earlier when using vimtex and I find it somewhat misleading, to me it sounds like something is not loaded yet and I should wait). More importantly, there is indeed some lean --server process running.

I understood my "After a rather long time, some syntax highlighting appears". When I launch Oni and then open a .lean file, Oni needs some cursor movement to start syntax highlighting. I guess this will be pretty easy to fix on your side.

But I still have very partial syntax highlighting. And option editor.textMateHighlighting.debugScopes seems to have no effect whatsoever. This is really my main question so far: what is this option meant to do?

And also, knowing that the syntax file is https://github.com/leanprover/vscode-lean/blob/master/syntaxes/lean.json should I see something or should I provide some sort of theme color file somewhere? What confuses me is I see no such thing in the vscode-lean repo, I have no idea how VScode decides which color to use.

And about LSP, I also have no idea what is meant to work out of the box and what is meant to require some specific coding.

SolarLiner commented 6 years ago

I'm trying to get language support for Vala in Oni, through the Vala Language Server. However, when I open vala files, the language is set to image and not vala as it should (checking through Oni.editors.activeEditor.activeBuffer.language). Oni does recognize that Vala is available though (Oni.language.isLanguageServerAvailable('vala') == true).

Here's my configuration:

export const configuration = {
    "editor.textMateHighlighting.enabled": true,
    "ui.colorscheme": "nord",
    "language.vala.languageServer.command": "/home/solarliner/.local/bin/vala-language-server",
    "language.vala.textMateGrammar": "/home/solarliner/.config/oni/plugins/vala/syntaxes/vala.tmLanguage",
    // UI customizations
    "ui.animations.enabled": true,
    "ui.fontSmoothing": "auto",
}
CrossR commented 6 years ago

Hey @SolarLiner, there was a similar issue to yours over in #2038.

Oni has an image buffer (for showing images) and it looks like there is some form of bug where if vim doesn't know what the filetype is, Oni somehow defaults to swapping to setting it to image instead.

There is a workaround outlined in the linked issue, but I've seen it on some common filetypes too like CSVs. I'm going to try and have a look into it over these next few days again and see if I can work out where its being set.