diff --git a/clients/eclipse/feature/feature.xml b/clients/eclipse/feature/feature.xml index 08e72166f5fc..d187feae7da8 100644 --- a/clients/eclipse/feature/feature.xml +++ b/clients/eclipse/feature/feature.xml @@ -2,7 +2,7 @@ @@ -19,6 +19,6 @@ + version="0.0.1.9"/> diff --git a/clients/eclipse/plugin/META-INF/MANIFEST.MF b/clients/eclipse/plugin/META-INF/MANIFEST.MF index 670b39e9629b..64f781b8c95e 100644 --- a/clients/eclipse/plugin/META-INF/MANIFEST.MF +++ b/clients/eclipse/plugin/META-INF/MANIFEST.MF @@ -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, diff --git a/clients/eclipse/plugin/src/com/tabbyml/tabby4eclipse/lsp/ConnectionProvider.java b/clients/eclipse/plugin/src/com/tabbyml/tabby4eclipse/lsp/ConnectionProvider.java index bc24228f61be..86e23d38e39c 100644 --- a/clients/eclipse/plugin/src/com/tabbyml/tabby4eclipse/lsp/ConnectionProvider.java +++ b/clients/eclipse/plugin/src/com/tabbyml/tabby4eclipse/lsp/ConnectionProvider.java @@ -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"); @@ -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(); @@ -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; + } } diff --git a/clients/eclipse/plugin/src/com/tabbyml/tabby4eclipse/lsp/protocol/ClientCapabilities.java b/clients/eclipse/plugin/src/com/tabbyml/tabby4eclipse/lsp/protocol/ClientCapabilities.java new file mode 100644 index 000000000000..2d1213b1b237 --- /dev/null +++ b/clients/eclipse/plugin/src/com/tabbyml/tabby4eclipse/lsp/protocol/ClientCapabilities.java @@ -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; + } + } +} diff --git a/clients/eclipse/plugin/src/com/tabbyml/tabby4eclipse/lsp/protocol/ClientInfo.java b/clients/eclipse/plugin/src/com/tabbyml/tabby4eclipse/lsp/protocol/ClientInfo.java new file mode 100644 index 000000000000..e8652a37fcf4 --- /dev/null +++ b/clients/eclipse/plugin/src/com/tabbyml/tabby4eclipse/lsp/protocol/ClientInfo.java @@ -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; + } + } +} \ No newline at end of file diff --git a/clients/eclipse/plugin/src/com/tabbyml/tabby4eclipse/lsp/protocol/ClientProvidedConfig.java b/clients/eclipse/plugin/src/com/tabbyml/tabby4eclipse/lsp/protocol/ClientProvidedConfig.java new file mode 100644 index 000000000000..03e3e31409ea --- /dev/null +++ b/clients/eclipse/plugin/src/com/tabbyml/tabby4eclipse/lsp/protocol/ClientProvidedConfig.java @@ -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; + } + } +} diff --git a/clients/eclipse/plugin/src/com/tabbyml/tabby4eclipse/lsp/protocol/CompletionEventId.java b/clients/eclipse/plugin/src/com/tabbyml/tabby4eclipse/lsp/protocol/CompletionEventId.java index c3975630e75f..9fe9d400fff8 100644 --- a/clients/eclipse/plugin/src/com/tabbyml/tabby4eclipse/lsp/protocol/CompletionEventId.java +++ b/clients/eclipse/plugin/src/com/tabbyml/tabby4eclipse/lsp/protocol/CompletionEventId.java @@ -1,27 +1,27 @@ package com.tabbyml.tabby4eclipse.lsp.protocol; public class CompletionEventId { - private String completionId; - private int choiceIndex; + private String completionId; + private int choiceIndex; - public CompletionEventId(String completionId, int choiceIndex) { - this.completionId = completionId; - this.choiceIndex = choiceIndex; - } + public CompletionEventId(String completionId, int choiceIndex) { + this.completionId = completionId; + this.choiceIndex = choiceIndex; + } - public String getCompletionId() { - return completionId; - } + public String getCompletionId() { + return completionId; + } - public void setCompletionId(String completionId) { - this.completionId = completionId; - } + public void setCompletionId(String completionId) { + this.completionId = completionId; + } - public int getChoiceIndex() { - return choiceIndex; - } + public int getChoiceIndex() { + return choiceIndex; + } - public void setChoiceIndex(int choiceIndex) { - this.choiceIndex = choiceIndex; - } + public void setChoiceIndex(int choiceIndex) { + this.choiceIndex = choiceIndex; + } } diff --git a/clients/eclipse/plugin/src/com/tabbyml/tabby4eclipse/lsp/protocol/InitializationOptions.java b/clients/eclipse/plugin/src/com/tabbyml/tabby4eclipse/lsp/protocol/InitializationOptions.java new file mode 100644 index 000000000000..eefc075ec36c --- /dev/null +++ b/clients/eclipse/plugin/src/com/tabbyml/tabby4eclipse/lsp/protocol/InitializationOptions.java @@ -0,0 +1,41 @@ +package com.tabbyml.tabby4eclipse.lsp.protocol; + +public class InitializationOptions { + private ClientProvidedConfig config; + private ClientInfo clientInfo; + private ClientCapabilities clientCapabilities; + + public InitializationOptions() { + } + + public InitializationOptions(ClientProvidedConfig config, ClientInfo clientInfo, + ClientCapabilities clientCapabilities) { + this.config = config; + this.clientInfo = clientInfo; + this.clientCapabilities = clientCapabilities; + } + + public ClientProvidedConfig getConfig() { + return config; + } + + public void setConfig(ClientProvidedConfig config) { + this.config = config; + } + + public ClientInfo getClientInfo() { + return clientInfo; + } + + public void setClientInfo(ClientInfo clientInfo) { + this.clientInfo = clientInfo; + } + + public ClientCapabilities getClientCapabilities() { + return clientCapabilities; + } + + public void setClientCapabilities(ClientCapabilities clientCapabilities) { + this.clientCapabilities = clientCapabilities; + } +} diff --git a/clients/eclipse/plugin/src/com/tabbyml/tabby4eclipse/lsp/protocol/InlineCompletionItem.java b/clients/eclipse/plugin/src/com/tabbyml/tabby4eclipse/lsp/protocol/InlineCompletionItem.java index 520c1526b0cd..55795c3eb942 100644 --- a/clients/eclipse/plugin/src/com/tabbyml/tabby4eclipse/lsp/protocol/InlineCompletionItem.java +++ b/clients/eclipse/plugin/src/com/tabbyml/tabby4eclipse/lsp/protocol/InlineCompletionItem.java @@ -4,74 +4,73 @@ import org.eclipse.lsp4j.Range; public class InlineCompletionItem { - private String insertText; - private String filterText; - private Range range; - private Command command; - private Data data; - - public InlineCompletionItem(String insertText, String filterText, Range range, Command command, Data data) { - this.insertText = insertText; - this.filterText = filterText; - this.range = range; - this.command = command; - this.data = data; - } - - public String getInsertText() { - return insertText; - } - - public void setInsertText(String insertText) { - this.insertText = insertText; - } - - public String getFilterText() { - return filterText; - } - - public void setFilterText(String filterText) { - this.filterText = filterText; - } - - public Range getRange() { - return range; - } - - public void setRange(Range range) { - this.range = range; - } - - public Command getCommand() { - return command; - } - - public void setCommand(Command command) { - this.command = command; - } - - public Data getData() { - return data; - } - - public void setData(Data data) { - this.data = data; - } - - public static class Data { - private CompletionEventId eventId; - - public Data(CompletionEventId eventId) { - this.eventId = eventId; - } - - public CompletionEventId getEventId() { - return eventId; - } - - public void setEventId(CompletionEventId eventId) { - this.eventId = eventId; - } - } + private String insertText; + private String filterText; + private Range range; + private Command command; + private Data data; + + public InlineCompletionItem(String insertText, String filterText, Range range, Command command, Data data) { + this.insertText = insertText; + this.filterText = filterText; + this.range = range; + this.command = command; + this.data = data; + } + + public String getInsertText() { + return insertText; + } + + public void setInsertText(String insertText) { + this.insertText = insertText; + } + + public String getFilterText() { + return filterText; + } + + public void setFilterText(String filterText) { + this.filterText = filterText; + } + + public Range getRange() { + return range; + } + + public void setRange(Range range) { + this.range = range; + } + + public Command getCommand() { + return command; + } + + public void setCommand(Command command) { + this.command = command; + } + + public Data getData() { + return data; + } + + public void setData(Data data) { + this.data = data; + } + + public static class Data { + private CompletionEventId eventId; + + public Data(CompletionEventId eventId) { + this.eventId = eventId; + } + + public CompletionEventId getEventId() { + return eventId; + } + + public void setEventId(CompletionEventId eventId) { + this.eventId = eventId; + } + } } - diff --git a/clients/eclipse/plugin/src/com/tabbyml/tabby4eclipse/lsp/protocol/InlineCompletionList.java b/clients/eclipse/plugin/src/com/tabbyml/tabby4eclipse/lsp/protocol/InlineCompletionList.java index f180c0a9476a..f96c5dd45dbf 100644 --- a/clients/eclipse/plugin/src/com/tabbyml/tabby4eclipse/lsp/protocol/InlineCompletionList.java +++ b/clients/eclipse/plugin/src/com/tabbyml/tabby4eclipse/lsp/protocol/InlineCompletionList.java @@ -3,27 +3,27 @@ import java.util.List; public class InlineCompletionList { - private boolean isIncomplete; - private List items; + private boolean isIncomplete; + private List items; - public InlineCompletionList(boolean isIncomplete, List items) { - this.isIncomplete = isIncomplete; - this.items = items; - } + public InlineCompletionList(boolean isIncomplete, List items) { + this.isIncomplete = isIncomplete; + this.items = items; + } - public boolean isIncomplete() { - return isIncomplete; - } + public boolean isIncomplete() { + return isIncomplete; + } - public void setIncomplete(boolean isIncomplete) { - this.isIncomplete = isIncomplete; - } + public void setIncomplete(boolean isIncomplete) { + this.isIncomplete = isIncomplete; + } - public List getItems() { - return items; - } + public List getItems() { + return items; + } - public void setItems(List items) { - this.items = items; - } + public void setItems(List items) { + this.items = items; + } } diff --git a/clients/eclipse/plugin/src/com/tabbyml/tabby4eclipse/lsp/protocol/InlineCompletionParams.java b/clients/eclipse/plugin/src/com/tabbyml/tabby4eclipse/lsp/protocol/InlineCompletionParams.java index f0403550a772..28a3391a2690 100644 --- a/clients/eclipse/plugin/src/com/tabbyml/tabby4eclipse/lsp/protocol/InlineCompletionParams.java +++ b/clients/eclipse/plugin/src/com/tabbyml/tabby4eclipse/lsp/protocol/InlineCompletionParams.java @@ -5,103 +5,105 @@ import org.eclipse.lsp4j.Range; public class InlineCompletionParams { - private InlineCompletionContext context; - private TextDocumentIdentifier textDocument; - private Position position; - - public InlineCompletionParams(InlineCompletionContext context, TextDocumentIdentifier textDocument, Position position) { - this.context = context; - this.textDocument = textDocument; - this.position = position; - } - - public InlineCompletionContext getContext() { - return context; - } - - public void setContext(InlineCompletionContext context) { - this.context = context; - } - - public TextDocumentIdentifier getTextDocument() { - return textDocument; - } - - public void setTextDocument(TextDocumentIdentifier textDocument) { - this.textDocument = textDocument; - } - - public Position getPosition() { - return position; - } - - public void setPosition(Position position) { - this.position = position; - } - - public static class InlineCompletionContext { - private InlineCompletionTriggerKind triggerKind; - private SelectedCompletionInfo selectedCompletionInfo; - - public InlineCompletionContext(InlineCompletionTriggerKind triggerKind, SelectedCompletionInfo selectedCompletionInfo) { - this.triggerKind = triggerKind; - this.selectedCompletionInfo = selectedCompletionInfo; - } - - public InlineCompletionTriggerKind getTriggerKind() { - return triggerKind; - } - - public void setTriggerKind(InlineCompletionTriggerKind triggerKind) { - this.triggerKind = triggerKind; - } - - public SelectedCompletionInfo getSelectedCompletionInfo() { - return selectedCompletionInfo; - } - - public void setSelectedCompletionInfo(SelectedCompletionInfo selectedCompletionInfo) { - this.selectedCompletionInfo = selectedCompletionInfo; - } - } - - public enum InlineCompletionTriggerKind { - Invoked(0), Automatic(1); - - private final int value; - - InlineCompletionTriggerKind(int value) { - this.value = value; - } - - public int getValue() { - return value; - } - } - - public static class SelectedCompletionInfo { - private String text; - private Range range; - - public SelectedCompletionInfo(String text, Range range) { - this.text = text; - this.range = range; - } - - public String getText() { - return text; - } - - public void setText(String text) { - this.text = text; - } - - public Range getRange() { - return range; - } - - public void setRange(Range range) { - this.range = range; - } - } + private InlineCompletionContext context; + private TextDocumentIdentifier textDocument; + private Position position; + + public InlineCompletionParams(InlineCompletionContext context, TextDocumentIdentifier textDocument, + Position position) { + this.context = context; + this.textDocument = textDocument; + this.position = position; + } + + public InlineCompletionContext getContext() { + return context; + } + + public void setContext(InlineCompletionContext context) { + this.context = context; + } + + public TextDocumentIdentifier getTextDocument() { + return textDocument; + } + + public void setTextDocument(TextDocumentIdentifier textDocument) { + this.textDocument = textDocument; + } + + public Position getPosition() { + return position; + } + + public void setPosition(Position position) { + this.position = position; + } + + public static class InlineCompletionContext { + private InlineCompletionTriggerKind triggerKind; + private SelectedCompletionInfo selectedCompletionInfo; + + public InlineCompletionContext(InlineCompletionTriggerKind triggerKind, + SelectedCompletionInfo selectedCompletionInfo) { + this.triggerKind = triggerKind; + this.selectedCompletionInfo = selectedCompletionInfo; + } + + public InlineCompletionTriggerKind getTriggerKind() { + return triggerKind; + } + + public void setTriggerKind(InlineCompletionTriggerKind triggerKind) { + this.triggerKind = triggerKind; + } + + public SelectedCompletionInfo getSelectedCompletionInfo() { + return selectedCompletionInfo; + } + + public void setSelectedCompletionInfo(SelectedCompletionInfo selectedCompletionInfo) { + this.selectedCompletionInfo = selectedCompletionInfo; + } + } + + public enum InlineCompletionTriggerKind { + Invoked(0), Automatic(1); + + private final int value; + + InlineCompletionTriggerKind(int value) { + this.value = value; + } + + public int getValue() { + return value; + } + } + + public static class SelectedCompletionInfo { + private String text; + private Range range; + + public SelectedCompletionInfo(String text, Range range) { + this.text = text; + this.range = range; + } + + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } + + public Range getRange() { + return range; + } + + public void setRange(Range range) { + this.range = range; + } + } }