Skip to content
This repository has been archived by the owner on Apr 1, 2020. It is now read-only.

Language Support

Bryan Phelps edited this page Jan 18, 2018 · 41 revisions

Language Support

Oni utilizes the Language Server Protocol (LSP) to provide common IDE functionality for any arbitrary programming language. This enables features like code completion, go-to definition, and method signature help.

Included Language Servers

Oni comes with a few language servers bundled:

Configuration

Language options are configurable via the configuration settings in your config.js.

In general, language options are specified in the form language.<language-identifier>.<option>, where language-identifier corresponds to the file type.

Auto-Closing Pairs

Auto-closing pairs is a feature that automatically 'closes' certain character pairs.

This has two general settings:

  • autoClosingPairs.enabled - (boolean) - specifies whether auto-closing pairs are active. Default is true.
  • autoClosingPairs.default - (AutoClosingPair[]) - specifies the default set of auto-closing pairs, if not overridden by a language setting.

With the default set of auto-closing pairs defined as:

    "autoClosingPairs.default": [
        { "open": "{", "close": "}" },
        { "open": "[", "close": "]" },
        { "open": "(", "close": ")" },
    ],

Auto-closing pairs can be specified per language via the language.<language-identifier>.autoClosingPairs setting, in the same format as above.

Language Servers

Language servers are configurable via the language.<language-identifier>.languageServer.<setting>, and the following settings are available:

  • command - (String) (required) - The command to start the language server. This could be a javascript file or an executable. REQUIRED
  • arguments (String[]) (optional) - An array of arguments to pass to the language server
  • rootFiles (String) (optional) - A set of files that are treated as the root. When this is specified, Oni will search upward for this, and start the language server in the root folder
  • configuration (any) (optional) - Additional javascript objects to send to the language server via the workspace/onConfigurationChanged event

An example configuration might be:

"language.reason.languageServer.command": "ocaml-language-server",
"language.reason.languageServer.arguments": ["--stdio"],
"language.reason.languageServer.rootFiles": [".merlin, bsconfig.json"],
"language.reason.languageServer.configuration": {}

The only required option is the language server command, however, some language servers may require you to use the full set of parameters.

NOTE: Language servers implement different transports - stdio, ipc, socket. Today, Oni only supports stdio

To find a language server, check out langserver.org

Other Settings

Aside from language servers, there are other settings available for customizing languages in Oni:

  • language.<language-identifier>.completionTriggerCharacters (string[]) - an array of characters that can trigger completion.

  • NOT IMPLEMENTED YET - language.<language-identifier>.autoPairs

Language Notes

JavaScript and TypeScript

JavaScript and TypeScript support is enabled out-of-the-box using the TypeScript Standalone Server. No setup and configuration is necessary, however, you will get better results if you use a tsconfig.json or a jsconfig.json to structure your project.

JavaScript and Flow

If you would like to add flow support (a static type checker for javascript), you will need to add the flow-language-server, This can be done by running yarn global add flow-language-server or npm install -g flow-language-server, then adding the following lines to your oni config.js

  'language.javascript.languageServer.command': 'flow-language-server',
  'language.javascript.languageServer.arguments': ['--stdio'],

Javascript and Vue

To add language support for vue, the javascript framework and it's filetype, you will need to complete the following steps.

  1. Run npm install -g vue-language-server
  2. Add the following to your config.js
 'language.vue.languageServer.command':'vls'

C/C++

C and C++ language support is set up by default to use clangd, and expects clangd available in your path.

  • Get a working clangd (both code and executables are available here)
  • Make sure that clangd is available globally (for instance, by adding it to an environment variable)

For information on setting it up, please refer to the clangd documentation.

C#

C# language support is not configured by default, and requires the oni-language-csharp plugin, which provides language capabilities for both .NET and Mono.

Follow the installation instructions to get started.

Go

Go language support depends on the go-langserver by SourceGraph, which provides language support for Go. Follow their installation instructions as this language server is not bundled out-of-the-box with Oni.

go-langserver must be available in your PATH. You can override this by setting the language.go.languageServer.command configuration value.

Known Issues

Python

Python language support depends on pyls by Palantir, which provides language support for Python. Follow their installation instructions as this language server is not bundled out-of-the-box with Oni.

pyls must be available in your PATH. You can override this by setting the language.python.languageServer.command configuration value.

Reason and OCaml

Oni comes with ocaml-language-server out-of-the-box, however, make sure you have the other pre-requisites installed and that merlin is configured properly.