-
Notifications
You must be signed in to change notification settings - Fork 18
5. Implement a custom tool with the server
If you want to implement your own integration of the language server for an IDE of your choice by using the LSP protocol, or if you want to build a tool that will use it in another scenario, you are at the right place. This page will show you all necessary steps you have to follow in order to make it work.
If you face any issue with your implementation, do not hesitate to open an issue
The language server implements the Language Server Protocol, published by Microsoft. The following content will only show what is custom in this protocol. For any information about the protocol itself, you can read the specifications. To be precise or if you encounter an issue with the protocol, you should know that the server uses a home-made implemention based on lsp-types.
The protocol provides the request workspace/configuration
that should be used to pull the configuration of the client.
The request will come from the server and ask for the ConfigurationItem:
ConfigurationItem(
scope_uri=None,
section="Odoo")
Most of the configuration variables are set through the odools.toml file. You should only provide two options in your settings at a project-level:
- selectedProfile: The name of the profile the user want to use. If you don't implement the
$Odoo/setConfiguration
message, user can always use the valuesdefault
andDisabled
OdooLS can work as a normal LSP. So a basic integration should work.
However, you can handle some custom messags to improve user experience. As you can see, they are all prefixed with $
, meaning that the implementation of these messages are optional.
- Server -> client
- type: notification
- parameters:
- "server_pid": int.
- description: This message will send you the server PID in case you would need it.
- Server -> client
- type: notification
- parameters:
- "status": string. Values: 'start' or 'stop'.
- description: indicates if the server is working or not. Useful to display a loading status
- Server -> client
- type: notification
- parameters:
- "crashInfo": string. contains the traceback.
- "pid": Process ID of OdooLS. Can be used to find related log file.
This message will send to you all available profiles. User would then be able to select the one he want to use by changing the setting selectedProfile
from the section "Odoo"
- Server -> client
- type: notification
- parameters:
- "html": dict. containing HTML representation of each profile
- Key: Config Profile name
- Value: HTML representation of the config profile to be displayed by the client.
- "configFile": array
- element: each element is a serialization of the config, refer to the config wiki page
- "html": dict. containing HTML representation of each profile
- Server -> Client
- type: notification
- description: Server request to initialize a restart sequence from the client side. If you receive this message, restart the server properly