From 0a3190c58f40bc1f5c30b991de9cca6af51e793d Mon Sep 17 00:00:00 2001 From: Michael Panchenko Date: Thu, 3 Apr 2025 19:03:00 +0200 Subject: [PATCH] Readme on how to add support for a new language --- CONTRIBUTING.md | 21 +++++++++++++++++++++ README.md | 9 ++++++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 31feeedb..1f2f696b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -44,3 +44,24 @@ for you. Note: For the Windows subsystem for Linux (WSL), you may need to adjust the path for the volume. + +## Adding a New Supported Language + +Serena interacts with code through language servers which are included in +the `multilspy` package. It is rather easy to include a new supported language +if an LSP implementation for it exists. You just need to: + +1. create a new subclass of `LanguageServer` +2. add a new value to the `Language` enum +3. make a new `elif` case in the `LanguageServer.create` method +4. write minor tests + +The subclasses are typically easy to write, have a look at the +[PyrightLanguageServer](src/multilspy/language_servers/pyright_language_server/pyright_server.py) +for an example, or at any other implementation to see how non-python +dependencies for language servers are handled there. + +⚠️ Important: The LSP allows for lot of optional fields and symbols, so the language servers may differ +in some details, even if they follow the LSP. Therefore you should include some code of the new +language in `test/resources` and add tests for symbolic read operations on that code. Have a look +at `test/multilspy/test_symbol_retrieval.py` for an example of such tests for the python LS. diff --git a/README.md b/README.md index 390c832f..a6de5a51 100644 --- a/README.md +++ b/README.md @@ -482,9 +482,12 @@ Without these projects, Serena would not have been possible (or would have been ## Customizing Serena -It is very easy to extend Serena with your own ideas. Just implement a new Tool by subclassing from -`serena.agent.Tool`. By default, the `SerenaAgent` will immediately have access to it. We look forward -to seeing what the community will come up with! For details on contributing, see [here](/CONTRIBUTING.md). +It is very easy to extend Serena's AI functionality with your own ideas. +Just implement a new Tool by subclassing from +`serena.agent.Tool`. By default, the `SerenaAgent` will immediately have access to it. + +It is also relatively straightforward to add [support for a new language](/CONTRIBUTING.md#adding-a-new-supported-language). We look forward to seeing what the community will come up with! +For details on contributing, see [here](/CONTRIBUTING.md). ## Full List of Tools