Working With Lanuguage Identifiers
1. Disable/Enable Programming Languages To Be Supported
The main Copilot4Eclipse preferece page includes a list of programming languages recognized by GitHub Copilot. Enable and disable the programming languages in this list that you want Copilot4Eclipse to support. When you disable a programming language in the list, Copilot4Eclipse will discontinue generating inline code completions for all editors for that programming language.
When you use the Copilot menu > Disable Completions for <langauge> the effect will be similar to unselecting the language in the Copilot4Eclipse preference page.
2. What is a Language Identifier
A language identifier (languageId) is a simple structure that uniquely names a programming language and its display form. LanguageIds are a part of the Language Server Specification and are included in the editing context provided to GitHub Copilot when generating code suggestions. Thus it is important to correctly identify the languageId of each Eclipse editor.
Copilot4Eclipse detects the languageId for an Ecipse editor by matching the editor's underlying file with a list of file-name patterns and their associated languageId. You can view languageId<->file naming patterns in the Copilot4Eclipse preference page.
Plaintext
is the default languageId when no languageId can be identified for an editor.
2. Modifying LanguageId->File Naming Patterns
We recognize that the the file-naming patterns for a languageId may not reflect your environment. Thus we provide a simple mechanism for overriding the system file-naming patterns of any languageId.
Let's walk through an experiment where we add SVG to the file-naming pattern of the XML languageId. The SVG image file format is a type of XML file.
- In your home directory create a writable folder named
.copilot4eclipse/
. - In the
.copilot4eclipse/
folder create an empty file namedlanguageIds.json
. LanguageId definitions defined in this file override the system definitions. So the plan is to provide our custom XML file-naming patterns that includes.svg
in this file in a few steps from now.
In order to minimizing coding errors we will use the system XML languageId definition as a template for our new definition.
- Open the Copilot4Eclipse system file also named
languageIds.json
in an editor. It is found in theplugins/com.genuitec.copilot4eclipse_1.0.0.2024*
folder of your Eclipse installation.
In the example below the version of Eclipse is eclipse-committers-2023-06.
- Search for the XML languageId definition and copy it to the system clipboard.
-
Paste the system version of the XML languageId into your local
~/.copilot4eclipse/languageIds.json
file. The file format is of an array of languageIds. So the XML langaugeId must be nested between[
and]
as shown below. -
Add
.svg
to the extensions array and save the file
- Restart Eclipse and confirm the
.svg
file extension is listed in the XML languageId entry on the Copilot4Ecilpse preference page.
If you have questions about customizing languageIds or any other topic in this guide please contact us.