Skip to content

Implement a custom tool with the server

Florian Daloze edited this page Oct 24, 2023 · 2 revisions

If you want to implement your own integration of the language server for an IDE of your choice, 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.

Prerequisites

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, you can read the specifications. To be precise or if you encounter an issue with the protocol, you should know that the server uses PyGLS to implement the protocol.

Specificities of the Odoo Language Server

Alongside the classic LSP implementation, you have to send and be able to respond to some custom messages:

Odoo/loadingStatusUpdate

  • 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

Odoo/displayCrashNotification

  • Server -> client
  • type: notification
  • parameters:
    • "content": dict. Contains the keys:
      • "crashInfo": string. contains the traceback.

Odoo/getConfiguration

  • Server -> client
  • type: request
  • response format:
    • "id": int. Id of the request (see LSP)
    • "name": string. The name of the actual configuration
    • "odooPath": string. Path to Odoo community main folder
    • "addons": list[string]. List of all addon paths.
    • "pythonPath": string. Path or command to launch to run python3 (for example: 'python3' or '/home/user/venv/my_env/bin/python3')

Classic configuration

The protocol provides the request workspace/configuration that should be used to pull the configuration of the client. This route is used alongside the custom Odoo/getConfiguration to provide workspace-specific settings. The request will ask for the ConfigurationItem:

ConfigurationItem(
    scope_uri='window',
    section="Odoo")

Here is then the list of settings you have to provide to the server:

  • autoRefresh: string of one the following values: "onSave", "afterDelay", "off". Indicates when the server must refresh his internal database to integrate your recent changes.

  • autoRefreshDelay: int. Define the delay the server has to wait before refreshing data after an update.

If you face any issue with your implementation, do not hesitate to open an issue