THM-MoTE / mope-server

Server process for Modelica | Editor
https://thm-mote.github.io//projects/mope
GNU General Public License v3.0
9 stars 0 forks source link

Language Server Protocol #3

Open thorade opened 7 years ago

thorade commented 7 years ago

This whole Modelica-Tool-Ensemble looks interesting, but I do not really understand what it does or how it works... Do you have an introductory text? Conference paper? Maybe a YouTube video of the components in action or similar? Is this something similar (or even related to) the "Language Server Protocol"? http://langserver.org/

thorade commented 7 years ago

OK, I just saw that there will be two presentations in Prague at the Modelica Conference 2017: http://dx.doi.org/10.3384/ecp17132809 http://dx.doi.org/10.3384/ecp17132815

And, I found your webpage: https://thm-mote.github.io/

njustus commented 7 years ago

Hey

  1. there is our website. The website contains instructions to install MoVE and Mo|E.
  2. there are two papers submitted to the 17th International Modelica Conference
    • Paper about Mo|E: “Mo|E – A Communication Service Between Modelica Compilers and Text Editors“
    • Paper about MoVE: "MoVE – A Standalone Modelica Vector Graphics Editor"

I’m going to talk about this papers on Wednesday (May 17th) at the conference. Meet me there if you like.

In short: MoVE is a graphical editor for the icon annotation of Modelica models. Mo|E is an integrated development environment for Modelica. It enhances the text editor Atom to a Modelica IDE. In order to use it you need OpenModelica, Atom, the Atom plugin and the server release.

We don't have a YouTube video at the moment.

Mo|E wasn't intended to be like the language server protocol but it is really similar. You could say we built our own language server protocol.

thorade commented 7 years ago

Thanks, I will try to attend your presentations! How similar is "really similar"? Similar enough to make it compatible? Maybe you could profit from some previous work? Closing for now, as there is no action required.

thorade commented 7 years ago

I attended your talks in Prague and I really liked how the editor looked like and the support it gives to the user, BUT:

The more I think about it, the more I am sure that using the language server protocol (LSP) would make a lot of sense here. Their homepage has a list of supported languages and clients: http://langserver.org/ Atom is already in the list of supported LSP clients. Here is the repository (seems to be official, as it is from the atom organization): https://github.com/atom/atom-languageclient

So by implementing a Modelica server (or, Dymola-server, OpenModelica-server and JModelica-server?) you would get Modelica support in quite a bunch of editors right away, including Atom: https://github.com/Microsoft/language-server-protocol/wiki/Tools-supporting-the-Language-Server-Protocol

njustus commented 7 years ago

I had a deeper look into the LSP and it has its benefits. We get support in more editors but the whole communication is getting more complex because the LSP is much more complex than our HTTP protocol. As long as we don't have to implement the client side, that doesn't matter.

I'm not sure if the atom plugin is working right away. For me it looks like we would have to rewrite our plugin and using this (npm?) package. In any case we are going to consider this approach in the future. LSP looks really promising. Because we are in the middle of the semester I don't have the time to do it know. May be in fall.

But first I would like to make the whole installation process more easy. Unfortunately I don't know how, because the most complex part is setting up OpenModelica..

I'm glad that you liked the system and thanks for the informations about the LSP.

thorade commented 7 years ago

Thanks for considering. The Atom LSP client seems to be under development, but as it seems to be "official" and given the Atom development speed in the past, it might be ready to use in the near future. Until then and for testing, one could use VS Code.

What exactly do you consider too complicated in the OpenModelica installation? Windows or Linux?

njustus commented 7 years ago

There are a few things I consider complicated in OpenModelica. The installation itself is a little bit tricky on Linux (except for Ubuntu) and especially hard on OSX. I had to built from source and that was quite a pain and took me over an hour. Sadly I don't even know the problems anymore.. (Another problem is, that there is uninstaller for OSX.) Installation on Windows doesn't seem to be a problem, except finding the installed omc executable.

It would be ideal if we could automate the whole installation process by downloading 1 executable. My big vision is that the user installs the Atom plugin and the whole system is set up automatically while setting up the Atom plugin. But that doesn't seem possible.

The current installation procedure is like this:

  1. Install OpenModelica
  2. Install the Atom plugin
  3. Let the plugin fetch the MoPE server
  4. configure server
  5. configure plugin

I would like to reduce the whole process..

thorade commented 7 years ago

There are rpm packages for Fedora/RHEL/CentOS: https://openmodelica.org/download/download-linux These can be installed easily using yum. Maybe install alien also. yum is also available for other distros, and should work e.g. on Suse, but I have never tried that. What distro are your users using?

Maybe you could run OpenModelica in a Docker container? Then users need to install Docker and just pull your image?

After some editing, the users would probably want to simulate, so they need a regular OpenModelica anyway, I would say. Or are you planning to also run simulations from Atom? If so, you could have a look at the hydrogen package, it connects to Jupyter kernels from Atom: https://atom.io/packages/hydrogen

CSchoel commented 7 years ago

You are right, currently MoPE is mainly targeted at users who already have OpenModelica installed, but want to use a more comfortable editor for their code.

In the future, we would like to tailor it a little more towards teaching Modelica to students. This is where a simpler installation process would really help. In some courses we will probably only use Modelica for one or two exercises, so a full installation of OpenModelica may be a little bit of an overkill for students.

We are currently playing around with the idea of hosting Modelica sessions on a web server. With MoPE it should be fairly easy to communicate with an OMC on a different machine, but we would probably need to spawn a new instance of OMC for each user, which could provide some challenges. It would also make sense to have a similar tool for simulating models in a web browser.

The main problem is that the MoPE-Team consists of a bright student, who created this project for his thesis and will now move on to other tasks (Nico) and a chronically overworked PhD student (myself). :wink: We may be able to include a few bugfixes and small features, but for any larger improvements or changes we would first have to find another Student who is willing to work with Modelica - wich is hard precisely because of the reasons why we started our effort for MoTE in the first place.

I think I will hold on to the idea of using the LSP for MoPE as well as running the MoPE server on a different machine than the client. Both seem to be nice topics for a thesis that are worth investigating.

thorade commented 7 years ago

Note: I just suggested the same to the OpenModelica developers: https://trac.openmodelica.org/OpenModelica/ticket/4458

thorade commented 7 years ago

github seems to be supporting LSP more and more: http://blog.atom.io/2017/09/12/announcing-atom-ide.html https://github.com/blog/2430-introducing-atom-ide http://blog.atom.io/2017/09/12/atom-1-20.html

njustus commented 6 years ago

So I had the time to implement parts of the LSP inside the server (see branch lsp). The LSP itself is working correctly and compilation, code completion, go to definition, and hover for documentation is working. Compilation is triggered automatically through a didSave event.

I tested this using Atom and at least in Atom the html documentation is not rendered correctly. It seems like the Atom lsp package does not support html at the moment.

There are still some features missing:

thorade commented 6 years ago

Nice! I hope LSP documentation is good and it was not too much work to implement this. I'll try to find some time soon to test it. Maybe VSCode is also good a good chocie on the client side for testing, their LSP implementation might be more mature that that in Atom: https://langserver.org/#implementations-client

thorade commented 5 years ago

@atrosinenko This might be interesting as well! https://github.com/modelica/ModelicaStandardLibrary/pull/2837#issuecomment-467381998 Did you share your code on github?

atrosinenko commented 5 years ago

Unfortunately, it would hardly be useful to you, since it was early draft just to experiment with the lsp4s library and connecting to OMC using stdin/stdout. It is probably better than nothing, but most probably you already have much more working code. Or don't you have any LSP server at all right now? If so, I can publish this early draft several days later.

Maybe OpenModelica/OMEdit#171 would be more interesting source of information and ideas even being written in C++...

atrosinenko commented 5 years ago

@thorade I ultimately managed to publish it, please excuse me for the delay: https://github.com/atrosinenko/om-lsp-draft. But it is quite ugly and mostly not working :) Published it "just in case".

thorade commented 5 years ago

Thank you anyway, might be helpful to someone!