Skip to content

Commit

Permalink
fix(eclipse): impl initialization options. (#2819)
Browse files Browse the repository at this point in the history
  • Loading branch information
icycodes authored Aug 9, 2024
1 parent 7409e34 commit 3a87d1a
Show file tree
Hide file tree
Showing 11 changed files with 577 additions and 208 deletions.
4 changes: 2 additions & 2 deletions clients/eclipse/feature/feature.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<feature
id="com.tabbyml.features.tabby4eclipse"
label="Tabby"
version="0.0.1.8"
version="0.0.1.9"
provider-name="com.tabbyml">

<description url="http://www.example.com/description">
Expand All @@ -19,6 +19,6 @@

<plugin
id="com.tabbyml.tabby4eclipse"
version="0.0.1.8"/>
version="0.0.1.9"/>

</feature>
2 changes: 1 addition & 1 deletion clients/eclipse/plugin/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Tabby Plugin for Eclipse
Bundle-SymbolicName: com.tabbyml.tabby4eclipse;singleton:=true
Bundle-Version: 0.0.1.8
Bundle-Version: 0.0.1.9
Bundle-Activator: com.tabbyml.tabby4eclipse.Activator
Bundle-Vendor: com.tabbyml
Require-Bundle: org.eclipse.ui,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,26 @@

import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URL;
import java.util.List;

import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.lsp4e.server.ProcessStreamConnectionProvider;
import org.osgi.framework.Bundle;

import com.tabbyml.tabby4eclipse.Activator;
import com.tabbyml.tabby4eclipse.Logger;
import com.tabbyml.tabby4eclipse.lsp.protocol.ClientCapabilities;
import com.tabbyml.tabby4eclipse.lsp.protocol.ClientCapabilities.TabbyClientCapabilities;
import com.tabbyml.tabby4eclipse.lsp.protocol.ClientCapabilities.TextDocumentClientCapabilities;
import com.tabbyml.tabby4eclipse.lsp.protocol.ClientInfo;
import com.tabbyml.tabby4eclipse.lsp.protocol.ClientInfo.TabbyPluginInfo;
import com.tabbyml.tabby4eclipse.lsp.protocol.ClientProvidedConfig;
import com.tabbyml.tabby4eclipse.lsp.protocol.InitializationOptions;

public class ConnectionProvider extends ProcessStreamConnectionProvider {
private Logger logger = new Logger("ConnectionProvider");
Expand Down Expand Up @@ -60,6 +69,11 @@ private static boolean isWindows() {
return System.getProperty("os.name").toLowerCase().contains("win");
}

@Override
public Object getInitializationOptions(@Nullable URI rootUri) {
return new InitializationOptions(getProvidedConfig(), getClientInfo(), getClientCapabilities());
}

@Override
public void start() throws IOException {
super.start();
Expand All @@ -71,4 +85,33 @@ public void stop() {
super.stop();
logger.info("Tabby language server stopped.");
}

private ClientProvidedConfig getProvidedConfig() {
ClientProvidedConfig config = new ClientProvidedConfig();
return config;
}

private ClientInfo getClientInfo() {
TabbyPluginInfo tabbyPluginInfo = new TabbyPluginInfo();
Bundle bundle = Platform.getBundle(Activator.PLUGIN_ID);
tabbyPluginInfo.setName(Activator.PLUGIN_ID);
tabbyPluginInfo.setVersion(bundle.getVersion().toString());

ClientInfo clientInfo = new ClientInfo();
clientInfo.setTabbyPlugin(tabbyPluginInfo);
return clientInfo;
}

private ClientCapabilities getClientCapabilities() {
TextDocumentClientCapabilities textDocumentClientCapabilities = new TextDocumentClientCapabilities();
textDocumentClientCapabilities.setCompletion(false);
textDocumentClientCapabilities.setInlineCompletion(true);

TabbyClientCapabilities tabbyClientCapabilities = new TabbyClientCapabilities();

ClientCapabilities clientCapabilities = new ClientCapabilities();
clientCapabilities.setTextDocument(textDocumentClientCapabilities);
clientCapabilities.setTabby(tabbyClientCapabilities);
return clientCapabilities;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
package com.tabbyml.tabby4eclipse.lsp.protocol;

public class ClientCapabilities {
private TextDocumentClientCapabilities textDocument;
private TabbyClientCapabilities tabby;

public ClientCapabilities() {
}

public TextDocumentClientCapabilities getTextDocument() {
return textDocument;
}

public void setTextDocument(TextDocumentClientCapabilities textDocument) {
this.textDocument = textDocument;
}

public TabbyClientCapabilities getTabby() {
return tabby;
}

public void setTabby(TabbyClientCapabilities tabby) {
this.tabby = tabby;
}

public static class TextDocumentClientCapabilities {
private boolean completion;
private boolean inlineCompletion;

public TextDocumentClientCapabilities() {
this.completion = false;
this.inlineCompletion = false;
}

public boolean getCompletion() {
return completion;
}

public void setCompletion(boolean completion) {
this.completion = completion;
}

public boolean getInlineCompletion() {
return inlineCompletion;
}

public void setInlineCompletion(boolean inlineCompletion) {
this.inlineCompletion = inlineCompletion;
}
}

public static class TabbyClientCapabilities {
private boolean agent;
private boolean workspaceFileSystem;
private boolean dataStore;
private boolean languageSupport;
private boolean gitProvider;
private boolean editorOptions;

public TabbyClientCapabilities() {
this.agent = false;
this.workspaceFileSystem = false;
this.dataStore = false;
this.languageSupport = false;
this.gitProvider = false;
this.editorOptions = false;
}

public boolean getAgent() {
return agent;
}

public void setAgent(boolean agent) {
this.agent = agent;
}

public boolean getWorkspaceFileSystem() {
return workspaceFileSystem;
}

public void setWorkspaceFileSystem(boolean workspaceFileSystem) {
this.workspaceFileSystem = workspaceFileSystem;
}

public boolean getDataStore() {
return dataStore;
}

public void setDateStore(boolean dataStore) {
this.dataStore = dataStore;
}

public boolean getLanguageSupport() {
return languageSupport;
}

public void setLanguageSupport(boolean languageSupport) {
this.languageSupport = languageSupport;
}

public boolean getGitProvider() {
return gitProvider;
}

public void setGitProvider(boolean gitProvider) {
this.gitProvider = gitProvider;
}

public boolean getEditorOptions() {
return editorOptions;
}

public void setEditorOptions(boolean editorOptions) {
this.editorOptions = editorOptions;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package com.tabbyml.tabby4eclipse.lsp.protocol;

public class ClientInfo {
private String name;
private String version;
private TabbyPluginInfo tabbyPlugin;

public ClientInfo() {
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getVersion() {
return version;
}

public void setVersion(String version) {
this.version = version;
}

public TabbyPluginInfo getTabbyPlugin() {
return tabbyPlugin;
}

public void setTabbyPlugin(TabbyPluginInfo tabbyPlugin) {
this.tabbyPlugin = tabbyPlugin;
}

public static class TabbyPluginInfo {
private String name;
private String version;

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getVersion() {
return version;
}

public void setVersion(String version) {
this.version = version;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
package com.tabbyml.tabby4eclipse.lsp.protocol;

public class ClientProvidedConfig {
private ServerConfig server;
private InlineCompletionConfig inlineCompletion;
private String keybindings;
private AnonymousUsageTrackingConfig anonymousUsageTracking;

public ClientProvidedConfig() {
}

public ServerConfig getServer() {
return server;
}

public void setServer(ServerConfig server) {
this.server = server;
}

public InlineCompletionConfig getInlineCompletion() {
return inlineCompletion;
}

public void setInlineCompletion(InlineCompletionConfig inlineCompletion) {
this.inlineCompletion = inlineCompletion;
}

public String getKeybindings() {
return keybindings;
}

public void setKeybindings(String keybindings) {
this.keybindings = keybindings;
}

public AnonymousUsageTrackingConfig getAnonymousUsageTracking() {
return anonymousUsageTracking;
}

public void setAnonymousUsageTracking(AnonymousUsageTrackingConfig anonymousUsageTracking) {
this.anonymousUsageTracking = anonymousUsageTracking;
}

public static class ServerConfig {
private String endpoint;
private String token;

public ServerConfig(String endpoint, String token) {
this.endpoint = endpoint;
this.token = token;
}

public String getEndpoint() {
return endpoint;
}

public void setEndpoint(String endpoint) {
this.endpoint = endpoint;
}

public String getToken() {
return token;
}

public void setToken(String token) {
this.token = token;
}
}

public static class InlineCompletionConfig {
private String triggerMode;

public InlineCompletionConfig(String triggerMode) {
this.triggerMode = triggerMode;
}

public String getTriggerMode() {
return triggerMode;
}

public void setTriggerMode(String triggerMode) {
this.triggerMode = triggerMode;
}

public static class TriggerMode {
public static final String AUTO = "auto";
public static final String MANUAL = "manual";
}
}

public static class Keybindings {
public static final String DEFAULT = "default";
public static final String TABBY_STYLE = "tabby-style";
public static final String CUSTOMIZE = "customize";
}

public static class AnonymousUsageTrackingConfig {
private boolean disable;

public AnonymousUsageTrackingConfig(boolean disable) {
this.disable = disable;
}

public boolean getDisable() {
return disable;
}

public void setDisable(boolean disable) {
this.disable = disable;
}
}
}
Loading

0 comments on commit 3a87d1a

Please sign in to comment.