Accessing Copilot Chats in Sublime Text
There are two primary ways to access Generative AI Conversations with the Pieces Copilot.
via Right-Click Menu
<Image src="https://storage.googleapis.com/hashnode_product_documentation_assets/sublime_text_plugin_assets/pieces_ai_copilot/chat/about_current_selection.png" alt="" align="center" fullwidth="true" />
via Command Palette
Open the command palette with ⌘+shift+p (macOS) or ctrl+shift+p (Windows/Linux), and enter commands such as:
Pieces: Copilot: Opens a clean-slate chat with Pieces Copilot.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 easiest ways to ask the Pieces Copilot a question about a specific class, method, function, or script is to open the right-click menu, hover over the Ask Copilot section, and select the About Current Selection option.
To use this feature:
<Image src="https://storage.googleapis.com/hashnode_product_documentation_assets/sublime_text_plugin_assets/pieces_ai_copilot/chat/chatting_with_selection.gif" alt="" align="center" fullwidth="true" />
This feature makes it incredibly convenient for users to get quick insights or answers to specific questions about their code.
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:
<Image src="https://storage.googleapis.com/hashnode_product_documentation_assets/cdn_migrate_repair_2/sublime/ask_about_current_file.png" alt="" align="center" fullwidth="true" />
After running the initial command, you can then query the LLM, which will use the file as context to generate accurate and useful responses.
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.
To ask about the current project:
<Image src="https://storage.googleapis.com/hashnode_product_documentation_assets/cdn_migrate_repair_2/sublime/ask_about_current_project.png" alt="" align="center" fullwidth="true" />
This feature highlights errors and suggests improvements on a larger scale. Its main benefit is helping developers navigate their codebase by using the Pieces context-awareness engine to provide accurate information, even for specific 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 useful when reference materials aren't directly accessible from Sublime Text or when you want to compartmentalize context by keeping files or folders from other projects separate from your active workflow.
To do this:
<Image src="https://storage.googleapis.com/hashnode_product_documentation_assets/sublime_text_plugin_assets/pieces_ai_copilot/chat/adding_context_to_copilot_chats.gif" alt="" align="center" fullwidth="true" />
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
}