Pieces for Developers JetBrains Plugin
Using the Pieces for Developers JetBrains Plugin in combination with the Pieces Desktop App makes saving and reusing code simple within your IDE.
Installing the Pieces for Developers JetBrains Plugin
In order to use the Pieces JetBrains Plugin, you must have Pieces OS. We also recommend downloading the Pieces for Developers Desktop App.
You can install the JetBrains plugin through the JetBrains Marketplace or by searching for Pieces in the plugins search of your IDE.
Once you've installed the plugin, you can begin using Pieces without restarting your IDE.
Pieces Copilot
Utilize a powerful Copilot integrated into your IDE, bringing your development to the next level.
-
Ask Copilot
- Ask the Copilot about a file, folder, snippet, code fragment, or terminal output. All available by right-clicking, and then selecting 'Ask Copilot'.
-
Pieces: Fix
- Integrated into the VS Code quick fix menu, when you have an error in your code, simply open the quick fix menu and select 'Pieces: Fix' to have the Copilot resolve your issue for you.
-
Pieces: Comment & Pieces: Explain
- Each method in your code has a code lens (like git lens) that allows you to explain, or comment your code.
-
A familiar chat experience spread across all your favorite text editing softwares
- The Copilot chat window has the same familiar features integrated into multiple text editing softwares: VS Code, Jetbrains, Visual Studio, Web Extension, Obsidian, and JupyterLab.
Save Snippets to Pieces for JetBrains
To save code to Pieces from your JetBrains IDE, simply highlight the snippet or file and save with:
- Keyboard Shortcut
- Windows:
CTRL + P(x2)
- macOS:
⌘ + P
- Windows:
- Right Click
- Right-click and select
Save to Pieces
- Right-click and select
View Saved Snippets
There are a few ways to view your full list of code snippets in your IDE.
Right-click context menu:
- Right-click in your editor
- Find "My Saved Pieces" in the context menu
- When you hover over "My Saved Pieces," a pop out window will open on the side of the context menu, showing you a list of your saved code snippets
Sidebar Menu
- Find the Pieces for Developers Icon in the sidebar tray
- Select the Pieces Icon and a sidebar viewer will open with all of your snippets in a language-based list
The Sidebar Menu automatically expands the folder of language snippets that match the file where you're currently working.
Preview Saved Snippets in Markdown
If you'd like to get a closer look at a snippet before adding it to your project, double-click on the snippet in the list view, and it will open in a Markdown preview. You'll be able to see the snippet and its context, including any tags, descriptions, titles, related links, and related people.
As it's super easy to open several previews at once, we've also made it simple to close all of those tabs. Right-click on a snippet tab and select "Close All Snippets" to instantly close every snippet tab except for the one you're focused on.
Refresh your Saved Snippets in your JetBrains IDE
You can view your most recently saved snippets from the right-click context menu in JetBrains. To refresh that list after saving a new snippet:
- Right-click in your code and select “Refresh Saved Pieces”
or
- Click the refresh button at the top of the sidebar view
Sometimes, when saving new snippets from other plugins and extensions, you'll have to refresh your list to get a fully updated snippet list.
Select your Copilot Runtime
With the Pieces for Jetbrains plugin, there are multiple LLMs that you can utilize depending on the model you prefer for your specific environment. You can read more about the different copilot models that you can choose from on this page.
To select your model, open the Pieces Copilot chat and select "Copilot Runtimes" below the text box at the bottom of the chat. A secondary window will open with model selections. If you have already downloaded a copilot model from another product in the Pieces Suite, it will be available for you here, too. If you do not already have a local runtime downloaded, you will have to download it onto your machine.
Using local models allows for the flexibility to work in a completely offline environment without sacrificing Pieces Copilot.
Real Time Snippet Streaming
Each product in the Pieces Suite uses Pieces OS to get information about your snippets' context. When you update a snippet in the Pieces Desktop App - such as a name or description, tags or any of the other metadata — those changes are also reflected in your Pieces for JetBrains instance without refreshing.
If your snippets are not updating right away, try pressing the refresh button at the top of your snippet list.
Search for Snippets with the JetBrains Plugin
- Open the Search Everywhere Window
- Double-tap the shift key and switch to the Pieces tab or Use the
Ctrl + Shift + P
([⌘⇧P] on macOS) keyboard shortcut to open a tab focused solely on your Pieces snippets - Your search queries will return snippets that you've saved
You can also find saved snippets while searching in the 'All' tab, as results come from anywhere in your IDE.
Edit Snippets with the JetBrains Plugin
Editing a snippet is super easy and can be done within your IDE without opening a separate window. When you edit, a new tab will open so that you can adjust the contents of your code snippet.
To open and edit a previously saved snippet:
- Select the snippet in the Pieces tool window
- Hit
Alt + Enter
(⌥⏎ on macOS) or right-click and select “Edit…” from the pop-up menu - Make your changes
- Save the snippet using
Ctrl + S
(⌘ + S on macOS)
You can adjust your snippet's name, description, and classification from the right-click context menu.
Use Suggested Save in JetBrains
Pieces can intelligently identify and save snippets based on re-use patterns in your JetBrains workflow. Whenever Pieces saves a snippet, you'll see a "Saved a Piece!" confirmation in the bottom right corner of your screen. Your snippet is now saved in Pieces with auto-generated metadata.
To opt-out of Suggested Save, go to Preferences, Tools, Pieces
and click on Suggested Save.
Suggested Snippets
Pieces offers you relevant code snippets based on your current activities and saved snippets. To access the suggested snippets, open the Pieces plugin and click on the dropdown menu labeled Suggested snippets
. Here, you will be presented with a selection of code snippets that are closely aligned with your ongoing JetBrains workflow. The more you utilize the suggested code snippets, the more accurate and relevant they become to your coding style and the workflow.
Explored Materials
Exploring materials with Pieces Insights enables you to gain deeper insights into a code snippet without needing to store it in your repository.
To Explore a material:
- Highlight a code snippet in your editor
- Right-click and select “Explore with Pieces Insights”
- Click the “View Insights” success message in the lower right corner of your editor
- Pieces will open a new window on the right toolbar with a markdown file that showcases your snippet, its description, and other associated metadata
- To revisit explored materials, click on the Pieces icon on the right side toolbar or click
Shift + Shift
and search for Pieces Insights in the search bar
If you'd like to automatically save your explored materials to your Pieces repository, go to Settings > Tools > Pieces
and click on Automatically save explored materials
.
Explored materials can be organized independently for various JetBrains products, or they can be synchronized by selecting the desired preference from the dropdown menu within the insights storage settings.
In order to Explore Materials, you must be connected to your Pieces Cloud.
Related Materials
Related materials are code snippets that are similar to the code you're currently working on. Pieces is capable of identifying related code snippets, even if you're interested in code that isn't originally part of the Pieces snippet. To find related materials:
- Highlight a code snippet in your editor
- Right-click and select “Find Related Materials in Pieces”
- Click the “View Insights” success message in the lower right corner of your editor to open the related materials in the Side Panel so that you can easily add them to your project.
Updating
The Pieces JetBrains Plugin will automatically update when a new version is available. You can also manually update the plugin by going to Plugins > Installed
, finding Pieces, and clicking the update button.
Troubleshooting
Pieces Copilot: Enabling JCEF Runtime and Downgrade
Pieces Copilot relies on JCEF, a very important component of JetBrains Runtime bundled with your IDE. By default, Android Studio is launched with a runtime version that does not support JCEF.
Switch your Java runtime to JCEF enabled runtime inside your global IDE settings.
Note that this operation will require a restart of your IDE, so it’s always worth saving your work before doing this.
It’s important to know that the latest stable release of Android Studio (Hedgehog 2023.1.1) unfortunately won’t benefit from this workaround, and it may throw errors regarding GPU processes restarting too many times. If you are using Android Studio Hedgehog, please consider downgrading to the second-latest stable release, in this case Giraffe 2022.3.1 Patch 4 until the issue is patched in Android Studio.
In order to switch your runtime:
- Use
⌘ + ⇧ + A
(on macOS) orCtrl + ⇧ + A
(Windows/Linux) shortcut to invoke action search dialog - Start typing "Choose Boot Java Runtime for the IDE…”
- Select the latest version with annotation ending with "JCEF”.
- When you click OK and restart your IDE, Copilot should start working properly.
I can't find the Pieces JetBrains Plugin in the JetBrains Marketplace!
If you can't find the Pieces for Developers JetBrains Plugin in the JetBrains Marketplace, you can navigate directly to it with this link.
For any other issues with the Pieces for Developers JetBrains Plugin
Go to Tools > Pieces
and make sure to select appropriate options for your use case. If you're still having issues, please reach out to us at Pieces Support.
Uninstalling the Pieces Plugin
To uninstall the Pieces for Developers JetBrains Plugin, go to Plugins > Installed
, find the Pieces plugin, and click the uninstall button in the dropdown menu.
In order for Pieces to be completely uninstalled from the JetBrains IDE, you'll need to restart your IDE.