[Postponed] Language Server + VSCode Plugin for Sophia

Application Status

Status: Postponed on the 30.07.2020
Last updated: 22.06.2020
Submited by: Marco Walz, [email protected]
Team: Employees of 51nodes GmbH
Approved Budget (in h):
Used Budget (in h):
Planned Delivery: see (totalized) duration of milestones in “Required Work” section

Funding category

Open Source Development

Application Title

Language Server + VSCode Plugin for Sophia

Applicant

Intro: Marco Walz from kryptokrauts / 51nodes
Team: Employees of 51nodes GmbH

Value Application

By implementing the Language Server Protocol (LSP) for Sophia it will be possible to create plugins for different editors (e.g. VSCode, Sublime, Atom, …) while maintaining the reference implementation of the language server to handle the logic behind the scenes.

This can save many costs and makes it easier to maintain different plugins.

Definition of Terms

The proposal is about providing a Language Server implementation for the Sophia language.

The Language Server Protocol (LSP) was originally developed by Microsoft for their editor VSCode and in 2016 Microsoft announced a collaboration with Red Hat and Codenvy to standardize the protocol specification.

More information about LSP here:

At the same time a plugin for VSCode will be developed which makes use of the Language Server.

Following features will be covered:

  • Syntax highlighting
  • Diagnostics / error feedback
  • Go to definition / find references
  • Code completion
  • Symbol search
  • Signature help
  • Hover

Status Quo

Currently such a Language Server implementation does not exist for Sophia. This means that if somebody wants to provide a plugin for a certain editor the whole logic needs to be (re-)written in order to provide language specific features.

However, there are already two plugins available which could generally be used. But they are outdated and currently only provide syntax highlighting. Useful and important features like diagnostics, go to definition & code completion are missing.

Here the current available plugins:

It is important to mention that syntax highlighting still needs to be implemented on the client-side plugin. But this can be reused from the VSCode plugin mentioned above.

Required Work / Estimate

We propose different incremental milestones. This allows us to better plan/estimate the workload and the foundation to be flexible regarding the approved budget.

The result of each milestone will be a working VSCode plugin that communicates with the corresponding Language Server. The Language Server will cover the functionalities defined in the respective milestone(s).

At the end of each milestone we ask to approve the next milestone. Based on new findings and feedback it might be necessary to adjust the estimated time and/or change the priority of specific features.

For the Language Server we are flexible about the programming language to build with. Currently we favor to use TypeScript.

If desired, we can publish a release for each milestone in the Visual Studio Marketplace.

Milestone 1 (~200 hours)

With the end of the first milestone, developers will be able to use the VSCode plugin including the Language Server implementation. This will be documented in the readme within the repository. We will review and integrate the syntax highlighting capabilities of the existing plugin and implement the diagnostics feature which will allow developers to get valuable error feedback during development.

Required work:

  • Project setup (VSCode plugin & Language Server)
  • Review and integration of syntax highlighting capabilities of the existing plugin
  • Prepare Language Server capabilities and log/print incoming client-messages in debug-mode
  • Define required configuration parameters
  • Logic for diagnostics / error feedback
    • It’s probably best to utilize the Sophia compiler here and use the response of the compiler to provide meaningful messages
    • Pragma for the compiler version needs to be considered
      => configurable endpoint for different versions of aesophia_http
    • Tests for different compiler pragmas
  • Documentation about how the VSCode-plugin and Language Server can be used/debugged

Deliverables:

  • VSCode plugin
    • Syntax-highlighting
    • Configuration settings (e.g. URLs of different Sophia compilers to use by the Language Server)
    • Diagnostics / error-feedback
  • Language Server
    • Logging/printing messages for different Language Server capabilities in debug-mode
    • Implementation of diagnostics / error feedback
  • Documentation how to use the VSCode-plugin

Estimated duration: ~10 weeks (1 person, 20 hours per week)

Note:

  • We might be able to deliver faster but cannot promise to finish faster than 10 weeks

Milestone 2 (~70hours)

By finishing the second milestone we want developers to be able to jump to type and function definitions. It should also be possible to find all references of selected types or functions. Last but not least we want to provide code completion capabilities to enhance the developer experience.

Required work:

  • Logic for go to definition / find references
    • This functionality allows to find references of selected types/functions and jump to type/function definitions
  • Logic for code completion
    • Propose types/functions when entering characters

Deliverables (in addition to Milestone 1):

  • VSCode plugin
    • Including changes to support the Language Server features
  • Language Server
    • Implementation of go to definition and find references
    • Implementation of code completion

Estimated duration: ~4 weeks (1 person, 20 hours per week)

Note:

  • We might be able to deliver faster but cannot promise to finish faster than 4 weeks

Milestone 3 (~30 hours)

After finishing milestone 3 developers will be able to search for different symbols (types, functions) in a file or the whole workspace using the VSCode plugin.

Required work:

  • Logic for symbol search
    • find occurrences of types/functions in a file or in the whole workspace

Deliverables (in addition to Milestone 2):

  • VSCode plugin
    • Including changes to support the Language Server features
  • Language Server
    • Implementation of symbol search

Estimated duration: ~1-2 weeks (1 person, 20 hours per week)

Note:

  • We might be able to deliver faster but cannot promise to finish faster than 2 weeks

Milestone 4 (~60 hours)

In Milestone 4 we aim to further improve the developer experience by adding capabilities for signature help und hover. Signature help will provide the developer information about missing function-parameters and the hover functionality will provide general information about a type or function on hover.

Required work:

  • Logic for signature help
    • Show information about required parameters of functions
  • Logic for hover functionality
    • Display information about types/functions on hover

Deliverables (in addition to Milestone 3):

  • VSCode plugin
    • Including changes to support the Language Server features
  • Language Server
    • Implementation of signature help
    • Implementation of hover functionality

Estimated duration: ~3 weeks (1 person, 20 hours per week)

Milestone 5 (~20 hours)

In milestone 5 we will finalize the documentation so that it is clear what features are supported by the VSCode plugin and the Language Server and what features could be added in the future. E.g. code-formatting is not included in this proposal. It will be clear for Sophia developers how to use and configure the VSCode plugin and it will be clear for developers how to contribute to the Language Server implementation and debug it. Last but not least the release of the VSCode plugin will be added to the Visual Studio Marketplace.

Required work:

  • Finalize documentation
  • Publish release to Visual Studio Marketplace

Estimated delivery: ~1 week (1 person, 20 hours per week)

Known Limitations

There aren’t specific limitations.

Outlook

After completion we will publish the results in a detailed blog article and share that information on various social media channels.

Additionally, the Sophia Language Server will be included in the following list:

We are looking forward to collect feedback from developers and potentially extend/improve the Language Server. Currently e.g. code formatting isn’t part of the proposal and could be added if needed.

Publishment

The results of the proposal will be published free of any proprietary license (open-source, open-access) in the following repositories:

Related work

For Solidity it is currently also being considered to implement the LSP:

For Sophia there exists a REPL which is written in Erlang:

14 Likes

Sounds great to me!

2 Likes

I like the Idea, Just one more thing If its possible to some how port Solidity Contracts to Sophia or perhpas compile to .json for AEternity that will be awesome

thanks for your feedback. the solidity migration is a bit out of topic here. a thing that would definitely be quite easy to implement is to provide an aeternity Sophia contract interface based on the Solidity ABI. but then it would still be necessary to implement the logic of the functions. so the benefit of that wouldn’t be that great. maybe you should start another thread to discuss that topic.

2 Likes

Looks great @marc0olo and as a VSCode user myself I need it :slight_smile:

4 Likes

@marc0olo Thank you very much for you nice VSCode Plugin Application. ACF had decided to postponed your application.