Diagnostics and Fix-ItsΒΆ

In order to show diagnostics in the editor, you need to implemenet an Ide.DiagnosticProvider and override two methods: do_diagnose_async and do_diagnose_finish.

The do_diagnose_async is an asynchronous method that will be called with a callback as the fifth parameter. The callback can be passed to a Gio.Task for easy handling. When the task is done, do_diagnose_finish will be called with the Gio.Task object and is expected to return an Ide.Diagnostics object.

# my_plugin.py

import gi
gi.require_version('Ide', '1.0')
from gi.repository import (

class MyDiagnosticProvider(Ide.Object, Ide.DiagnosticProvider):
    def do_diagnose_async(self, file: Ide.File, buffer: Ide.Buffer, cancellable, callback, user_data):
        task = Gio.Task.new(self, cancellable, callback)
        task.diagnostics_list = []

        start = Ide.SourceLocation.new(file, 0, 0, 0)
        severity = Ide.DiagnosticSeverity.WARNING
        error_message = 'Diagnostic example'

        diagnostic = Ide.Diagnostic.new(severity, error_message, start)


    def do_diagnose_finish(self, result: Gio.Task) -> Ide.Diagnostics:
        if result.propagate_boolean():
            return Ide.Diagnostics.new(result.diagnostics_list)

You also need to register the plugin as a diagnostic provider in the .plugin file. There is a X-Diagnostic-Provider-Languages field which specify the supported languages and X-Diagnostic-Provider-Languages-Priority which specify the diagnostic priority.

For example, a C diagnostic plugin will have a plugin file that look similar to this: