-
Notifications
You must be signed in to change notification settings - Fork 18
2. How to use
OdooLS is a language server. You can use it in an IDE or as a CLI tool. Let's explore both ways
By implementing the LSP protocol, OdooLS can easily be included in your IDE if this one supports it.
We already implemented some integrations. Follow the links to know more about it, how to install and use it:
- VsCode: https://github.com/odoo/odoo-ls-vscode
- PyCharm: https://github.com/odoo/odoo-ls-pycharm
- NeoVim: https://github.com/odoo/odoo-ls-neovim
If you are interested by an integration in another IDE, do not hesitate to suggest it to us by opening an issue. You can try to implement yourself too by following this guide
Check the wiki related to your IDE:
- VsCode
- PyCharm
- NeoVim
Even if OdooLS is designed to work in real time on your project, you can use it too as a static tool and run it to get diagnostics on your code.
To use it as a CLI, be sure first to have a valid environment.
To run properly, you need the executable (odoo_ls_server
or odoo_ls_server.exe
).
Next to it, you must have the typeshed directory. You already downloaded it if you built it from sources (in repository/server/typeshed). If not, clone the repository next to your executable.
That's enough to run OdooLS, but now you'll need to provide project information
Basically, you have to run
./odoo_ls_server --parse
to run server in one-shot mode. The server will load your project and output all diagnostics to a json file.
However, you'll need to give some information about your project:
The path to your Odoo folder:
-c /path/to/odoo
The additional addons you want to include:
-a /path/to/addons_folder_1 -a /path/to/addons_folder_2
Do not include each module separatively, but as you would do in odoo command line, with the folder containing all your modules.
You can specify the output file name with -o output.json
The option --tracked-folders /your/folder
can be used to filter outputs. When using this parameter, only diagnostics emitted from this directory will be in the resulting json file.
If your installation of typeshed is not next to your executable or if you want to change provided stubs, you can use -s /path_to_typeshed/stubs
. You will have to provide the path to the different stdlib too with --stdlib path_to_typeshed/stdlib
If you don't want to use typeshed stubs (but stdlib is mandatory), you can use --no-typeshed-stubs
. OdooLS will then try to read sources from installed packages directly instead of stubs (Not really recommended)
A full command could then look like this:
./odoo_ls_server --parse -c /data/sources/odoo -a /data/sources/enterprise -a /data/build/design-themes -o /data/output/odoo_lint.json -s /data/build/typeshed/stubs -s /data/sources/odoo-ls/server/additional_stubs --tracked-folders /data/sources/enterprise --stdlib /data/build/typeshed/stdlib
It will then output all diagnostics about enterprise folder in /data/output/odoo_lint.json
You can use the option --help
to get more information about other available parameters.