First, thank you! Robot Framework Language Server welcomes anyone wishing to contribute to the project ;)
To start contributing usually the first step would be choosing what you'd like to work on, usually one of the issues from: https://github.com/robocorp/robotframework-lsp/issues. If what you want to work on isn't there, feel free to create an issue for what you'd like to do and state in the issue that you'd like to provide a pull request (to avoid possible work duplication from 2 people working at the same thing).
After deciding what you what to work on, it's time to get the code and bootstrap your development environment.
Fork the repository at GitHub (https://github.com/robocorp/robotframework-lsp) and then clone the sources of your fork with git to your local machine.
After getting the code, the following steps are needed:
-
Get git submodules:
git submodule update --init --recursive -
Install NodeJs (https://nodejs.org/en/) -- make sure that
nodeandnpmare in thePATH. -
Install Yarn (https://yarnpkg.com/) -- make sure that
yarnis in thePATH. -
Install Python and create environment:
In Windows:
python -m venv .venv
.venv/Scripts/activate.bat
python -m pip install -r robocorp-code/tests/test_requirements.txt
python -m pip install -r robocorp-code/dev_requirements.txt
python -m pip install robotframework
python -m pip install robotremoteserver
echo %cd%\robotframework-ls\src > .venv\Lib\site-packages\rf_src.pth
echo %cd%\robocorp-code\src >> .venv\Lib\site-packages\rf_src.pth
echo %cd%\robocorp-python-ls-core\src >> .venv\Lib\site-packages\rf_src.pth
echo %cd%\robotframework-ls\tests >> .venv\Lib\site-packages\rf_src.pth
echo %cd%\robocorp-code\tests >> .venv\Lib\site-packages\rf_src.pth
echo %cd%\robocorp-python-ls-core\tests >> .venv\Lib\site-packages\rf_src.pth
In Linux:
python3 -m venv .venv
source ./.venv/bin/activate
python3 -m pip install -r tests/test_requirements.txt
python3 -m pip install robotframework
python3 -m pip install robotremoteserver
export PY_VER=$(python3 -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')")
echo $PWD/robotframework-ls/src > .venv/lib/python${PY_VER}/site-packages/rf_src.pth
echo $PWD/robocorp-code/src >> .venv/lib/python${PY_VER}/site-packages/rf_src.pth
echo $PWD/robocorp-python-ls-core/src >> .venv/lib/python${PY_VER}/site-packages/rf_src.pth
echo $PWD/robotframework-ls/tests >> .venv/lib/python${PY_VER}/site-packages/rf_src.pth
echo $PWD/robocorp-code/tests >> .venv/lib/python${PY_VER}/site-packages/rf_src.pth
echo $PWD/robocorp-python-ls-core/tests >> .venv/lib/python${PY_VER}/site-packages/rf_src.pth
Head to the root directory (where package.json is located) and run:
yarn install.
After this step, it should be possible to open the roboframework-lsp folder in VSCode and launch
Extension: Roboframework-lsp to have a new instance of VSCode with the loaded extension.
After doing the code changes, it's possible to create a pull request.
See: Creating Pull Request for more details.
Please take into account the following guidelines of the Robot Framework Language Server codebase:
- The codebase follows a TDD style and all code added must be added with the related tests.
- Imports should be local (and not top-level) whenever possible in the
Robot Framework Language Servercodebase (so, unless it's a really common import across the whole codebase or something required to be top-level -- such as typing -- it should be local). - Typing: most of the typing should be done through protocols and not nominal typing (see the
protocols.pyacross the codebase). - Typing for the language server specification is done at:
robocorp_ls_core.lsp. - Classes that are intended to implement some protocol should use
robocorp_ls_core.protocols.check_implements(see docstrings on that function on how to use it). - Features should be self contained (so, for instance, document symbols is in
document_symbol.pyand semantic highlighting is insemantic_highlighting.py). Unless a feature really becomes huge (such as code-completion), most of the code should reside in the same module and functions are usually preferred over classes -- but not always ;). robotframework_ls.robotframework_ls_impl.RobotFrameworkLanguageServeris just a facade to distribute requests and it shouldn't importrobotanywhere. Rather it forwards requests torobotframework_ls.server_api.server.RobotFrameworkServerApiwhich is running in another process (which can then import the module that actually implements the request, which can importrobot).- Remember that the
package.jsonis generated fromcodegen/codegen_package.py.
- Third-party libraries must be vendored as it can't be relied that they'll be installed at the client (so, the license must be compatible).
- If a third party-library is vendored or some code is copied from anywhere, make sure to add it to the
ThirdPartyNotices.txtin the repository root and to add the proper headers if it was copied code.
- Code is formatted with black, with the version found in
dev_requirements.txt. - Code is type-checked with mypy, with the version found in
dev_requirements.txt.- Keep in mind that the code is type-checked in
Python 3.8but it needs to run inPython 3.7+.
- Keep in mind that the code is type-checked in
- Github Actions are used to run the tests and make sure that formatting/type checking works.
To build a VSIX, follow the steps in https://code.visualstudio.com/api/working-with-extensions/publishing-extension
(if everything is setup, vsce package from the root directory should do it).