Creating a Plugin

Plugins can be written in any language that supports compiling to a WebAssembly file (.wasm).


Here's an example Rust plugin created with the generate_plugin_code macro from dprint-core.

use std::path::PathBuf;
use std::collections::HashMap;
use serde::{Serialize, Deserialize};
use dprint_core::generate_plugin_code;
use dprint_core::configuration::{

#[derive(Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
struct Configuration {
    // add configuration properties here

fn resolve_config(
    config: HashMap<String, String>,
    global_config: &GlobalConfiguration,
) -> ResolveConfigurationResult<Configuration> {
    // implement...

fn get_plugin_config_key() -> String {
    // return the JSON object key name used in the configuration file
    // ex. String::from("json")

fn get_plugin_file_extensions() -> Vec<String> {
    // return the file extensions this plugin will format
    // ex. vec![String::from("json")]

fn get_plugin_help_url() -> String {
    // return the help url of the plugin
    // ex. String::from("")

fn get_plugin_config_schema_url() -> String {
    // for now, return an empty string. Return a schema url once VSCode
    // supports $schema properties in descendant objects:

fn get_plugin_license_text() -> String {

fn format_text(
    file_path: &PathBuf,
    file_text: &str,
    config: &Configuration,
) -> Result<String, String> {
    // implement...


Add the following to Cargo.toml:

crate-type = ["lib", "cdylib"]

Then finally, compile with:

cargo build --release --target=wasm32-unknown-unknown

Other Languages

If you are interested in implementing plugins in another language that supports compiling to a .wasm file, please open an issue and I will try to help point you in the right direction.