Skip to main content

Pieces for Developers JetBrains Plugin

Download the 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

info

In order to use the Pieces JetBrains Plugin, you must have Pieces OS. We recommend also using 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.

Save Snippets to Pieces for JetBrains

To save code to Pieces from your JetBrains IDE, simply highlight the snippet or file and save with:

  1. Keyboard Shortcut
    • Windows: CTRL + P(x2)
    • macOS: CMD + P
  2. Right Click
    • Right-click and select Save to Pieces

View Saved Snippets

There are a few ways to view your full list of code snippets in your IDE.

Right-click context menu:

  1. Right-click in your editor
  2. Find "My Saved Pieces" in the context menu
  3. 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

  1. Find the Pieces for Developers Icon in the sidebar tray
  2. 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.

Pieces Copilot in Jetbrains

Utilize the Pieces Copilot from Pieces for Jetbrains— no need to leave your IDE. You will not have to change your settings in the Pieces Desktop App. 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.

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

  1. Open the Search Everywhere Window
  2. 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
  3. 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:

  1. Select the snippet in the Pieces tool window
  2. Hit Alt + Enter (⌥⏎ on macOS) or right-click and select “Edit…” from the pop-up menu
  3. Make your changes
  4. 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.

info

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:

  1. Highlight a code snippet in your editor
  2. Right-click and select “Explore with Pieces Insights”
  3. Click the “View Insights” success message in the lower right corner of your editor
  4. Pieces will open a new window on the right toolbar with a markdown file that showcases your snippet, its description, and other associated metadata
  5. 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.

info

In order to Explore Materials, you must be connected to your Pieces Cloud.

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:

  1. Highlight a code snippet in your editor
  2. Right-click and select “Find Related Materials in Pieces”
  3. 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:

  1. Use ⌘ + ⇧ + A (on macOS) or Ctrl + ⇧ + A (Windows/Linux) shortcut to invoke action search dialog
  2. Start typing "Choose Boot Java Runtime for the IDE…”
  3. Select the latest version with annotation ending with "JCEF”.
  4. 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 naviagte 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.

Support and Community