Generative AI Conversations

The Pieces for Sublime Text Plugin provides versatile tools for leveraging generative AI to gain insights, debug, and optimize code seamlessly within your editor.


Accessing Copilot Chat in Sublime Text

There are two primary ways to access Generative AI Conversations with the Pieces Copilot.

via Right-Click Menu

  1. Select Code and Right-Click in the Editor: Highlight any code segment and right-click to open the Tool Menu.

  2. Select a Relevant Action: Choose Start Conversation About The Current Selection to open a new conversation.

via Command Palette

Open the command palette with ⌘+shift+p (macOS) or ctrl+shift+p (Windows/Linux), and enter commands such as:

  • Pieces: Ask Copilot About Active File: Provides insights for the current file open in your Sublime Text editor.
  • Pieces: Ask About The Current Project: Offers context-aware assistance across your entire project.

Read more about what commands are available in the Pieces for Sublime Text Plugin.

Contextualized Chats

There are 3 levels of contextual awareness you can use when starting a conversation or adding code to an existing Copilot Chat with the Pieces Copilot.

Pieces: Start Conversation About The Current Selection

One of the simplest ways to ask the Pieces Copilot a question about a specific class, method, function, or script is to use the right-click menu Start Conversation About The Current Selection option.

This feature makes it incredibly convenient for users to get quick insights or answers to specific questions about their code.

Once selected, you can enter your prompt in the text input field at the bottom of the Sublime editor's view and press enter.

Pieces: Ask About The Current File

The Pieces: Ask About The Current File feature focuses on providing insights and assistance with the specific file you're working on.

To use this feature, open up the command palette using ⌘+shift+p (macOS) or ctrl+shift+p (Windows/Linux) and enter Pieces: Ask About The Current File, then enter your question into the input field.

After running the initial command, you can then query the LLM, which will use the file as context to generate accurate and useful responses.

This is ideal for developers who need a comprehensive understanding of a file, such as its dependencies, functions, and classes.

Pieces: Ask About The Current Project

Similar to the file-level command, the Pieces: Ask About The Current Project command lets developers understand every corner of an entire project.

Open the command palette with ⌘+shift+p (macOS) or ctrl+shift+p (Windows/Linux) and enter Pieces: Ask About The Current Project, then type in your question.

This feature can also highlight errors and suggest improvements on a wider scale, but its main benefit and use case is to help developers navigate their codebase by utilizing the Pieces context-awareness engine to provide relevant and accurate information with even the most specific of prompts.

Adding Context to Copilot Chats

There are a number of individual items you can add as context to a chat, namely Files, Folders, and Snippets.

This flexibility is especially useful when reference materials are not directly accessible from Sublime Text or when you want to compartmentalize context and minimize overlap by keeping files or folders from other projects separate from your active file's workflow.

To do this, you can select the Message Icon on the left side of any of your chats in the Copilot Chat window, openable from the command palette or the right-click menu.

Click the Message Icon then add whatever context items you need.

Improving Code Consistency & Standardization

The Pieces Copilot helps improve code quality by identifying inconsistencies and providing actionable suggestions for standardization.

Naming Inconsistencies

If functions across your workspace use inconsistent naming patterns (e.g., authenticateUser in authHandler.go vs. retrieveUserProfile in userHandler.go), Pieces Copilot can suggest adopting a standardized naming convention for better readability and maintainability, like this:

// authHandler.go
func authenticateUser(ctx context.Context, credentials Credentials) (User, error) {
    if credentials.Username == "" || credentials.Password == "" {
        return User{}, errors.New("missing credentials")
    }
}

Inconsistent Error Handling

If error-handling strategies differ across files (e.g., structured errors in authService.go vs. inconsistent handling in userService.go), Pieces Copilot can help unify the approach:

// authService.go
func LoginUser(credentials Credentials) (string, error) {
    token, err := authenticate(credentials)
    if err != nil {
        return "", fmt.Errorf("login failed: %w", err)
    }
    return token, nil
}
Updated on