Buck: Installing and using the IntelliJ Plugin

Installing and using the IntelliJ Plugin

To use the Buck Intellij Plugin you will have to install Buck, by following the guide from Downloading and Installing Buck.

Installing the plugin

You can download the plugin from here or manually build it by following the guide from Building the Buck Intellij Plugin. After that, you can install it by following the Installing Plugin from Disk guide.

Using the plugin

After you have installed it, you can view the Buck Plugin Tool Window by accessing View > Tool Windows > Buck.

Utility Functions

  1. Buck Code Completion

    Helps you complete the names of keywords and buck rule names within the visibility scope.

  2. Go to Buck File

    Jump to the BUCK file of current source file. To access it you can:

    • Tools > Buck > Go to Buck file
    • Right click > Buck > Go to Buck file
    • ⇧ + ⌘ + P

  3. Go to Buck Dependencies

    Quickly jump to other BUCK files with ⌘ + Click or ⌘ + B.

  4. Reformat BUCK files

    The Buck Plugin lets you reformat source code to meet the requirements of your code style. The plugin also supports customized spacing and indenting in the buck code style settings. You can access it by going to Code > Reformat Code or by pressing ⌥ + ⌘ + L.

  5. Sort buck dependencies

    You can access it by going to Code > Optimise Imports or by pressing ^ + ⌥ + O.

  6. Automatically Convert to Buck Dependencies after Paste in BUCK file

    For example:

    • "import com.example.activity.MyFirstActivity" -> "//java/com/example/activity:activity"
    • "package com.example.activity;" -> "//java/com/example/activity:activity"
    • "com.example.activity.MyFirstActivity" -> "//java/com/example/activity:activity"

  7. Error Annotation

    If a Buck dependency does not exist, it will be marked with red.

  8. Commenting and Uncommenting

    You can comment or uncomment selected lines of a BUCK file by accessing Code > Comment with Line Comment or by pressing ⌘ + /.

Executing Buck Commands

  1. Select target

    Before you start doing any of the below mentioned actions you will have to select a buck target.

    You can start selecting the buck target either by pressing the associated icon from the Buck Plugin tool window or by using ⇧ + ⌘ + J.

    If you have an alias, you can just search for it. If you don't have an alias you have to write the whole path to the BUCK file. Once you are at the directory with the BUCK file, the plugin will search for all the available targets, which may take some time.

    You can use autocomplete by pressing → and navigate through the search by pressing ↑ and ↓.
  2. Build target

    Once you selected the target you can start a buck build either by pressing the associated icon from the Buck Plugin tool window or by using ⇧ + ⌘ + S.

  3. Show Buck/compiler errors and easily go through them

    When building, you may receive compiler errors. You can easily navigate through them and on double click you will be sent to the appropriate column and line.

  4. Install target

    Once you selected the target you can start a buck install either by pressing the associated icon from the Buck Plugin tool window or by using ⇧ + ⌘ + X.

  5. Uninstall target

    Once you selected the target you can start a buck uninstall either by pressing the associated icon from the Buck Plugin tool window or by using ⇧ + ⌘ + M.

  6. Test target

    Once you selected the target you can start a buck test either by pressing the associated icon from the Buck Plugin tool window or by using ⇧ + ⌘ + Y.

  7. Buck project target

    Once you selected the target you can start a buck project either by pressing the associated icon from the Buck Plugin tool window or by using ⇧ + ⌘ + B.

  8. Buck kill

    Once you started one of the above mentioned actions you can stop it either by pressing the associated icon from the Buck Plugin tool window or by using ⇧ + ⌘ + L.

Settings

  1. Buck Settings

    You can set your buck executable path and other install settings by going to Preferences > Tools > Buck.

  2. Code Style Settings

    You can set code style settings by going to Preferences > Editor > Code Style > Buck.

  3. Colors & Font Settings

    You can set the syntax highlighting colors from Preferences > Editor > Colors & Fonts > Buck.