All Projects → kenkangxgwe → lsp-wl

kenkangxgwe / lsp-wl

Licence: MIT License
A Wolfram Language Server

Programming Languages

Mathematica
289 projects

Projects that are alternatives of or similar to lsp-wl

tower-lsp
Language Server Protocol implementation written in Rust
Stars: ✭ 455 (+189.81%)
Mutual labels:  language-server-protocol, lsp
vis-lspc
language server protocol client for the vis editor
Stars: ✭ 24 (-84.71%)
Mutual labels:  language-server-protocol, lsp
codeparser
Parse Wolfram Language source code as abstract syntax trees (ASTs) or concrete syntax trees (CSTs)
Stars: ✭ 84 (-46.5%)
Mutual labels:  wolfram-language, wolfram-mathematica
FEMAddOns
Finite Element Method addons for Wolfram Language
Stars: ✭ 41 (-73.89%)
Mutual labels:  wolfram-language, wolfram-mathematica
atom-ide-scala
Scala & Dotty support for Atom IDE (🧟‍♂️ zombie repo)
Stars: ✭ 47 (-70.06%)
Mutual labels:  language-server-protocol, lsp
LspCpp
A Language Server Protocol implementation in C++
Stars: ✭ 40 (-74.52%)
Mutual labels:  language-server-protocol, lsp
vscode
The Visual Studio Code Extension for the Erlang Language Server
Stars: ✭ 62 (-60.51%)
Mutual labels:  language-server-protocol, lsp
Powershelleditorservices
A common platform for PowerShell development support in any editor or application!
Stars: ✭ 394 (+150.96%)
Mutual labels:  debugger, language-server-protocol
ide-go
Go language support for Atom-IDE, powered by Sourcegraph's Go Language Server
Stars: ✭ 39 (-75.16%)
Mutual labels:  language-server-protocol, lsp
vim-lamp
💡Language Server Protocol client for Vim.
Stars: ✭ 34 (-78.34%)
Mutual labels:  language-server-protocol, lsp
lsp-test
A functional test framework for LSP servers
Stars: ✭ 35 (-77.71%)
Mutual labels:  language-server-protocol, lsp
OpenCascadeLink
Open source package for OpenCascadeLink, which is bundled with Wolfram Language products as of version 12.1
Stars: ✭ 23 (-85.35%)
Mutual labels:  wolfram-language, wolfram-mathematica
camel-lsp-client-vscode
This is a client implementation of the Apache Camel Language Server Protocol for Visual Studio Code
Stars: ✭ 24 (-84.71%)
Mutual labels:  lsp, vscode-language
groovy-language-server
A language server for Groovy
Stars: ✭ 132 (-15.92%)
Mutual labels:  language-server-protocol, lsp
Dap Mode
Emacs ❤️ Debug Adapter Protocol
Stars: ✭ 809 (+415.29%)
Mutual labels:  debugger, lsp
typescript-language-server
TypeScript & JavaScript Language Server
Stars: ✭ 1,118 (+612.1%)
Mutual labels:  language-server-protocol, lsp
Haskell Ide Engine
The engine for haskell ide-integration. Not an IDE
Stars: ✭ 2,433 (+1449.68%)
Mutual labels:  language-server-protocol, lsp
Csharp Language Server Protocol
Language Server Protocol in C#
Stars: ✭ 230 (+46.5%)
Mutual labels:  language-server-protocol, lsp
lxtk
Language Client/Server Toolkit
Stars: ✭ 22 (-85.99%)
Mutual labels:  language-server-protocol, lsp
wolfram-notebook-embedder
JavaScript embedder for Wolfram Cloud notebooks
Stars: ✭ 48 (-69.43%)
Mutual labels:  wolfram-language, wolfram-mathematica

Wolfram Language Server

Develop with: Wolfram Language License: MIT CI

WolframLanguageServerLogo

Table of Contents

Wolfram Language Server (WLServer) is an implementation of the Microsoft's Language Server Protocol (LSP) for Wolfram Language. This server is implemented in Wolfram Language itself.

Our current goal is to provide the experience as good as the Mathematica FrontEnd with addition power from the editor.

We have provided the client-side code for VS Code here, which is based on some slight modifications of Microsoft's LSP example. If you are using other editors supporting LSP, some adaptation to the client would certainly work too.

Installation

  1. Wolfram Mathematica (11.2 or higher1) or Wolfram Engine (12.0 or higher).

  2. Use git to clone this repository.

    git clone https://github.com/kenkangxgwe/lsp-wl.git
  3. Install the dependent paclets with the correct versions (currently 1.0 or later) from the Wolfram kernel / Mathematica. (This will cost some time for the first time) :

    PacletInstall["CodeParser"]
    PacletInstall["CodeInspector"]
  4. Install the client. Currently, we provide the VS Code extension on Visual Studio Marketplace: Wolfram Language Server For other editors, please refer to the wiki.

  5. You may also want to install GitLink packet in order to check for updates.

Run the Server

Clients can start the server by running the init.wls file from Wolfram Mathematica executables

wolfram -script /path/to/lsp-wl/init.wls [args]
# or
wolframscript -f /path/to/lsp-wl/init.wls [args]

The posible arguments for the server are

  • --help, -h to print help information.
  • --socket=port to assign the port to which the server will connect. (Default: 6536)
  • --tcp-server=port to assign the port at which the server will start. (Default: 6536)
  • --pipe=pipename to specify the pipe name for the server to connect to.
  • --log=level, -l level to specify the logging level of the server. (Levels: error, warn, info, debug. Default: info)
  • --test, -t to run the unit test for the server.

If you want to run the server from Mathematica you can use the following code.

initfile = "/path/to/lsp-wl/init.wls";
args = {};
Block[{$ScriptCommandLine = Prepend[args, initfile], Quit = Function[{}, Throw[Null]]},
    Catch[<< (initfile)]
];

To use the debugger adapter (current in a very early stage), you need to include debuggerPort in the initializationOptions. And attach the frontend to that port. For VS Code, it is automatically done by the extension.

Language Server Features

DocumentSymbol

You may typeset your package in the same way that Mathematica FrontEnd handles it: a cell begins with two lines of comments, where the first line specifies the style of the cell and the second line names it. So you may get the outline structure of the file.

(* ::Title:: *)
(*Title of the file*)

(* ::Section:: *)
(*Section 1*)

documentSymbol

Hover

Provide documentations for functions and variables from the System` context, such as String and $Path, the MessageName and the special numerical literals with ^^ or *^.

hover

Completion

The completion is shown by the client automatically. Functions and system variables from the System` context that matches the input would be displayed. To enter an unicode character, you may use the leader key \ followed by the alias just like esc in Wolfram FrondEnd. E.g., <esc>a in the FrontEnd is input as \a in the editor and the server will show you the available completions.

completion-unicode

Completion Resolve: Further information (such as documentation) would be provided for the items in the list.

completion

Diagnostics

Syntax error would be underlined. This feature is powered by CodeParser and CodeInspector paclets, thank you @bostick.

diagnostics

Definition / References / Document Highlight

It is now able to look up the definition and references of a local variable in a scope such as Module or pattern rules.

references

Code Action

Code action is now able to,

  • Open the documentation of system symbols in Mathematica (Not available for Wolfram Engine).
    documentation

  • Evaluate the selected code if debugger is running. See Evaluate.

Document Color / Color Presentation

Both Named Colors and Color Models with constant parameters are able to show and modify.
(Experimental, may have performance issues.)

documentColor

Notes

The project is under development, so more features are on the way. Notice that, syntax highlight will not be provided as long as it is excluded from the LSP, but I believe there are already plenty of good Mathematica highlighters available for your editor.

Here is a full list of LSP features.

Debug Adapter Features

Evaluate

Code evaluation can be run from the code action of the selection or code lens below each section title. The results are usually shown in the debug console on the editor side.

evaluate-code-action

Expressions can also be directly input from the debug console.

evaluate-debug-console

Variables

After evaluation, the symbol values can be retrieved from the editor. This includes the own values of variables and the down/up/sub values of functions defined.

variables

The behavior of the variables mimics the workspace in MATLAB, so all the symbols defined in the debug console as well as evaluated from the file will be recorded. This also includes contexts other than Global` . The editor can also watch on a specific expression after each evaluation if applicable.

Notes

Here is a full list of DAP features.

Contribute

Design Principles

  1. The files are located according to its context name. The init.wls is the entry script that parses the commandline arguments, loads packages and starts the server. This is intended to be different from a paclet, since it is not intended to be normally used inside Mathematica / Wolfram Kernel.

  2. We implemented a stateless (by passing the state around :)) server in WolframLanguageServer`Server` that will parse and handle messages.

  3. DataType` is a simple type system extracted as an independent package in the Matypetica library that supports pattern test on every field of a data structure. The operations on the data objects are designed to be immutable.

  4. WolframLanguageServer`Test`* stores the unit tests for some of the functions which are integrated into GitHub Action.

Todo list

It will be nice if you want to make a contribution to the following topic.

  • Our server-client communication only supports Socket with TCP protocol. We tried to use ZMQ_Stream protocol and SocketListen[] to enable concurrency, but it fails to send responses back to the client.

  • It will be helpful to implement a stdio channel, so that the Mathematica earlier than 11.2 will also be supported, but it is really hard to expose the stdin channel. Hope this will be dicussed in future release of Wolfram kernel.

  • More editor clients are needed. You can feel free to open a repository and create a pull request to add the clients in README.md once your client is released.

  • Thanks to CodeParser and CodeInspector paclets, we are able to parse the code and extract useful information. Please consider to contribute to them as well.

    If you have ideas about how to use these fantastic language tools to help the language server with more features, please send us issues or pull requests.

If you want to help us with this project, feel free to fork and create a pull request. Do not forget to add unit tests if possible.

Donations 💵

If you really like this project, please donate to us! $5 (or equivalently ¥35). A cup of coffee would certainly brighten our day! Your donation would be the motivation for us to move forward, thanks in advance 😄.

Footnotes

[1] SocketListen[] is used for server-client communication, which is introduced since 11.2. ^

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].