Skip to content

Commit a38812b

Browse files
committed
feat: updated default editor lsp options
1 parent 485ab24 commit a38812b

File tree

4 files changed

+49
-2
lines changed

4 files changed

+49
-2
lines changed

bundles/com.espressif.idf.lsp/META-INF/MANIFEST.MF

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ Bundle-RequiredExecutionEnvironment: JavaSE-17
1616
Automatic-Module-Name: com.espressif.idf.lsp
1717
Bundle-ActivationPolicy: lazy
1818
Bundle-Name: ESP-IDF LSP Plugin
19-
Service-Component: OSGI-INF/com.espressif.idf.lsp.preferences.IDFClangdEnable.xml,OSGI-INF/com.espressif.idf.lsp.preferences.IDFClangdOptionsDefaults.xml
19+
Service-Component: OSGI-INF/com.espressif.idf.lsp.preferences.IDFClangdEnable.xml,OSGI-INF/com.espressif.idf.lsp.preferences.IDFClangdOptionsDefaults.xml, OSGI-INF/com.espressif.idf.lsp.preferences.IDFEditorMetadataDefaults.xml
2020

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.cdt.lsp.internal.editor.EditorMetadataDefaults">
3+
<property name="service.ranking" type="Integer" value="0"/>
4+
<service>
5+
<provide interface="org.eclipse.cdt.lsp.editor.EditorMetadata"/>
6+
</service>
7+
<implementation class="com.espressif.idf.lsp.preferences.IDFEditorMetadataDefaults"/>
8+
</scr:component>

bundles/com.espressif.idf.lsp/src/com/espressif/idf/lsp/LspPluginStartup.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class LspPluginStartup implements IStartup
1818
public void earlyStartup()
1919
{
2020
// Disabling the CDT indexer by default when the LSP plugin so that we could only use C/C++ LSP Server
21-
//This will also avoid parser exceptions and unnecessary processing overhead which is not needed.
21+
// This will also avoid parser exceptions and unnecessary processing overhead which is not needed.
2222
CCorePlugin.getIndexManager().setDefaultIndexerId(IPDOMManager.ID_NO_INDEXER);
2323
}
2424

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package com.espressif.idf.lsp.preferences;
2+
3+
import java.util.ArrayList;
4+
import java.util.List;
5+
import java.util.Set;
6+
7+
import org.eclipse.cdt.lsp.config.ConfigurationMetadataBase;
8+
import org.eclipse.cdt.lsp.editor.EditorMetadata;
9+
import org.eclipse.core.runtime.preferences.PreferenceMetadata;
10+
import org.osgi.service.component.annotations.Component;
11+
12+
@Component(property = { "service.ranking:Integer=0" })
13+
public class IDFEditorMetadataDefaults extends ConfigurationMetadataBase implements EditorMetadata
14+
{
15+
16+
@Override
17+
protected List<PreferenceMetadata<?>> definePreferences()
18+
{
19+
Set<String> filteredKeys = Set.of(Predefined.showTryLspBanner.identifer(),
20+
Predefined.preferLspEditor.identifer());
21+
var filteredDefaults = Predefined.defaults.stream().filter(pref -> filteredKeys.contains(pref.identifer()))
22+
.toList();
23+
24+
var showTryLspBannerCustomDefault = wrapWithCustomDefaultValue(false, Predefined.showTryLspBanner);
25+
var preferLspEditorCustomDefault = wrapWithCustomDefaultValue(true, Predefined.preferLspEditor);
26+
27+
List<PreferenceMetadata<?>> mergedPreferences = new ArrayList<>(filteredDefaults);
28+
mergedPreferences.add(showTryLspBannerCustomDefault);
29+
mergedPreferences.add(preferLspEditorCustomDefault);
30+
31+
return mergedPreferences;
32+
}
33+
34+
private <T> PreferenceMetadata<T> wrapWithCustomDefaultValue(T customDefaultValue, PreferenceMetadata<T> metadata)
35+
{
36+
return new PreferenceMetadata<>(metadata.valueClass(), metadata.identifer(), customDefaultValue,
37+
metadata.name(), metadata.description());
38+
}
39+
}

0 commit comments

Comments
 (0)