-
Notifications
You must be signed in to change notification settings - Fork 298
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.
Oni comes with a few language servers bundled:
- HTML - provided by vscode-html-languageserver-bin
- CSS/LESS/SASS - provided by vscode-css-languageserver-bin
- JavaScript/TypeScript - provided by typescript's Standalone Server
- Reason / OCaml - provided by ocaml-language-server
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 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 istrue
. -
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 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 theworkspace/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 supportsstdio
To find a language server, check out langserver.org
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
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.
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'],
To add language support for vue
, the javascript framework and it's filetype,
you will need to complete the following steps.
- Run
npm install -g vue-language-server
- Add the following to your
config.js
'language.vue.languageServer.command':'vls'
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# 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 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 thelanguage.go.languageServer.command
configuration value.
Known Issues
- There is no Windows support at the moment - this is being tracked by sourcegraph/go-langserver#113.
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 thelanguage.python.languageServer.command
configuration value.
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.