FoamScience / foam-language-server

A language server for OpenFOAM case files
27 stars 0 forks source link
editor language-server-protocol openfoam

FOAM Language Server

This project is young; still at early phases of development, so expect things to change considerably

DISCLAIMER: This offering is not approved or endorsed by OpenCFD Limited, producer and distributor of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks.

An implementation of the Language Server Protocol (LSP) for OpenFOAM dictionaries.

Here is a quick demo of the most important features:

foam lsp demo

For a more detailed explanation, check this slide out.

We're supporting the following features (* for partial or limited support):

The following common LSP features will not be considered in the near future (and PRs to these areas are actually discourages):

Installation and configuration

Installation

If you want the (somewhat) stable code (from Releases):

npm install foam-language-server

If you want the bleeding-edge features, with all the bleeding-edge bugs:

git clone --depth 1 --single-branch -b develop https://github.com/FoamScience/foam-language-server
npm install
npm test

Configuration

Root directory detection

It's important that your text editor detects the case directory as the "root directory" because diagnostics will depend on it. Most editors will ask the LSP for the root directory, but for those which don't, you'll have to configure it manually.

LSP configuration

[TODO: Section not complete]

Take a look at the return value of connection.onInitialization in server/foam-ls.ts for an up-to-date list of capabilities.

FAQ

Not a (Neo)VIM user?

can I ask WHY?

It is possible to run this LSP implementation with any text editor or IDE which supports LSP (most do), however Neo(VIM) has a clear priority and you may have to give up some features for things to work on other editors.

Can I run it on Windows?

Sure, you can. It's basically a piece of C++/JavaScript technology which has nothing to do with OpenFOAM code base (other than parsing its file format, of course).

Currently the only feature which has a slim chance of working on Windows is the "diagnostics" feature, because it needs to fire the case's solver to see if it errors out (and captures stderr).

If you have solvers on your Windows PATH, and diagnostics are not showing up; please file a bug report.

Contributing to this project

Please skim through CONTRIBUTING.md if you plan to join on the fun.