<!-- Plugin Configuration File -->
<idea-plugin>
    <id>com.mojeter.linthis.plugin</id>
    <name>linthis</name>
    <vendor email="zhlinh@gmail.com" url="https://github.com/zhlinh/linthis">zhlinh</vendor>

    <description><![CDATA[
    <h2>linthis - Multi-language Linter and Formatter</h2>
    <p>
        A unified linting and formatting tool for multiple programming languages,
        powered by the linthis Language Server Protocol (LSP) server.
    </p>

    <h3>Features</h3>
    <ul>
        <li>Real-time diagnostics via LSP</li>
        <li>Format on save</li>
        <li>Quick fixes and suggestions</li>
        <li>Lint on file open/save</li>
        <li>Configurable via .linthis.toml</li>
    </ul>

    <h3>Supported Languages</h3>
    <ul>
        <li>Rust (clippy, rustfmt)</li>
        <li>Python (ruff, black, isort)</li>
        <li>TypeScript/JavaScript (ESLint, Prettier)</li>
        <li>Go (golangci-lint, gofmt)</li>
        <li>Java (checkstyle, google-java-format)</li>
        <li>C/C++ (clang-tidy, clang-format)</li>
        <li>Objective-C (clang-tidy, clang-format)</li>
        <li>Swift (SwiftLint, swift-format)</li>
        <li>Kotlin (detekt, ktlint)</li>
        <li>Lua (luacheck, stylua)</li>
        <li>Dart (dart analyze, dart format)</li>
        <li>Shell/Bash (shellcheck, shfmt)</li>
        <li>Ruby (rubocop)</li>
        <li>PHP (phpcs, php-cs-fixer)</li>
        <li>Scala (scalafix, scalafmt)</li>
        <li>C# (dotnet format)</li>
        <li>And more...</li>
    </ul>

    <h3>Quick Start</h3>
    <ol>
        <li>Install <b>LSP4IJ plugin</b> and <b>linthis CLI</b> (see Requirements below)</li>
        <li>Install this Linthis plugin</li>
        <li>Open a supported file - The LSP server starts automatically</li>
        <li>View diagnostics in editor gutter and Problems view</li>
    </ol>

    <h3>Usage</h3>
    <p>
        Access linthis actions from <b>Tools → Linthis</b> menu:
    </p>
    <ul>
        <li><b>Lint Current File</b> - Run linter on the current file</li>
        <li><b>Format Current File</b> - Format the current file</li>
    </ul>
    <p>
        <img src="https://plugins.jetbrains.com/files/29860/screenshot_efe42203-d43e-4ae7-95c8-b394f2539229" alt="Linthis Tools Menu" width="400"/>
    </p>
    <p>
        Additional menu actions:
    </p>
    <ul>
        <li><b>Code → Reformat Code</b> - Also triggers LSP-based formatting</li>
        <li><b>View → Tool Windows → Problems</b> - Show all diagnostics</li>
    </ul>

    <h3>Viewing Diagnostics</h3>
    <p>Linting issues are displayed in multiple places:</p>
    <ul>
        <li><b>Editor Gutter</b> - Icons indicate warnings/errors on specific lines</li>
        <li><b>Problems Tool Window</b> - View → Tool Windows → Problems</li>
        <li><b>Inline Highlights</b> - Underlines in the code editor</li>
        <li><b>Hover Tooltips</b> - Hover over highlighted code to see details</li>
    </ul>

    <h3>Configuration</h3>
    <p>
        Configure linthis in <b>Settings → Tools → Linthis</b>:
    </p>
    <ul>
        <li><b>Lint on file open</b> - Run linter when opening files (default: on)</li>
        <li><b>Lint on save</b> - Run linter when saving files (default: on)</li>
        <li><b>Format on save</b> - Auto-format files when saving (default: off)</li>
        <li><b>Linthis path</b> - Custom path to linthis executable (leave empty for auto-detect)</li>
        <li><b>Additional arguments</b> - Extra CLI arguments for linthis</li>
    </ul>
    <p>
        <img src="https://plugins.jetbrains.com/files/29860/screenshot_45c0e613-a97f-44c9-8700-23bd410aa2db" alt="Linthis Settings" width="600"/>
    </p>

    <h3>Keyboard Shortcuts</h3>
    <p>
        To configure shortcuts, go to <b>Settings → Keymap</b>, search for "Linthis", and add your preferred shortcuts.
    </p>
    <p>Suggested shortcuts (not set by default to avoid conflicts):</p>
    <ul>
        <li>Lint Current File: <code>Ctrl+Shift+;</code> / <code>Cmd+Shift+;</code></li>
        <li>Format Current File: <code>Ctrl+Shift+'</code> / <code>Cmd+Shift+'</code></li>
    </ul>

    <h3>LSP Server Status</h3>
    <p>
        Check the Language Server status at <b>View → Tool Windows → Language Servers</b>. You can:
    </p>
    <ul>
        <li>See if Linthis server is running</li>
        <li>View server logs</li>
        <li>Restart the server if needed</li>
    </ul>

    <h3>Requirements</h3>
    <ol>
        <li>
            <b>LSP4IJ plugin</b> (version 0.11.0 or later required):
            <br>Install from <a href="https://plugins.jetbrains.com/plugin/23257-lsp4ij">JetBrains Marketplace</a>
        </li>
        <li>
            <b>linthis CLI tool</b>:
            <pre>pip install linthis</pre>
            or with uv (recommended)
            <pre>uv pip install linthis</pre>
            or
            <pre>cargo install linthis</pre>
        </li>
    </ol>

    <h3>Troubleshooting</h3>
    <ul>
        <li><b>Linthis not found</b> - Verify installation with <code>linthis --version</code>, ensure it's in PATH, then restart IDE</li>
        <li><b>No diagnostics showing</b> - Check file type support, verify .linthis.toml config, check Language Servers status</li>
        <li><b>LSP server not starting</b> - Enable debug logging in Help → Diagnostic Tools → Debug Log Settings (add #com.linthis)</li>
    </ul>
    ]]></description>

    <change-notes><![CDATA[
    <h3>0.1.0</h3>
    <ul>
        <li>Feature: Security scanning for dependencies</li>
        <li>Feature: License compliance checking</li>
        <li>Feature: Code complexity visualization</li>
        <li>Feature: AI-assisted fix suggestions</li>
    </ul>
    <h3>0.0.1</h3>
    <ul>
        <li>Initial release</li>
        <li>LSP integration for linting and formatting</li>
        <li>Support for 18+ programming languages</li>
    </ul>
    ]]></change-notes>

    <!-- Product and platform compatibility -->
    <depends>com.intellij.modules.platform</depends>
    <!-- LSP4IJ is required for LSP-based linting -->
    <depends>com.redhat.devtools.lsp4ij</depends>

    <extensions defaultExtensionNs="com.intellij">
        <!-- Notification group for linthis messages -->
        <notificationGroup id="Linthis Notifications"
                           displayType="BALLOON"
                           key="notification.group.linthis"/>

        <!-- Settings configurable -->
        <projectConfigurable
                parentId="tools"
                instance="com.mojeter.linthis.plugin.settings.LinthisSettingsConfigurable"
                id="com.mojeter.linthis.settings"
                displayName="Linthis"
                nonDefaultProject="true"/>

        <!-- Project service for settings -->
        <projectService
                serviceImplementation="com.mojeter.linthis.plugin.settings.LinthisSettings"/>
    </extensions>

    <!-- Actions -->
    <actions>
        <group id="Linthis.ActionGroup" text="Linthis" popup="true">
            <add-to-group group-id="ToolsMenu" anchor="last"/>

            <action id="Linthis.Lint"
                    class="com.mojeter.linthis.plugin.actions.LinthisLintAction"
                    text="Lint Current File"
                    description="Run linthis linter on the current file">
                <!-- No default shortcut to avoid conflicts. Users can configure in Settings → Keymap → Linthis -->
            </action>

            <action id="Linthis.Format"
                    class="com.mojeter.linthis.plugin.actions.LinthisFormatAction"
                    text="Format Current File"
                    description="Format the current file using linthis">
                <!-- No default shortcut to avoid conflicts. Users can configure in Settings → Keymap → Linthis -->
            </action>
        </group>
    </actions>

    <!-- Project-level listeners -->
    <projectListeners>
        <listener class="com.mojeter.linthis.plugin.listeners.LinthisFileOpenListener"
                  topic="com.intellij.openapi.fileEditor.FileEditorManagerListener"/>
    </projectListeners>

    <extensions defaultExtensionNs="com.redhat.devtools.lsp4ij">
        <!-- LSP Server descriptor -->
        <server id="linthisServer"
                name="Linthis"
                factoryClass="com.mojeter.linthis.plugin.LinthisLanguageServerFactory">
            <description><![CDATA[
            Linthis Language Server provides linting and formatting for multiple languages.
            ]]></description>
        </server>

        <!-- Language mappings - map file types to the LSP server -->
        <languageMapping language="JAVA" serverId="linthisServer"/>
        <languageMapping language="kotlin" serverId="linthisServer"/>
        <languageMapping language="Python" serverId="linthisServer"/>
        <languageMapping language="JavaScript" serverId="linthisServer"/>
        <languageMapping language="TypeScript" serverId="linthisServer"/>
        <languageMapping language="Go" serverId="linthisServer"/>
        <languageMapping language="Rust" serverId="linthisServer"/>
        <languageMapping language="ObjectiveC" serverId="linthisServer"/>
        <languageMapping language="Swift" serverId="linthisServer"/>
        <languageMapping language="C" serverId="linthisServer"/>
        <languageMapping language="C++" serverId="linthisServer"/>
        <languageMapping language="Lua" serverId="linthisServer"/>
        <languageMapping language="Dart" serverId="linthisServer"/>
        <languageMapping language="Shell Script" serverId="linthisServer"/>
        <languageMapping language="Ruby" serverId="linthisServer"/>
        <languageMapping language="PHP" serverId="linthisServer"/>
        <languageMapping language="Scala" serverId="linthisServer"/>
        <languageMapping language="C#" serverId="linthisServer"/>

        <!-- File pattern mappings for additional file types -->
        <fileNamePatternMapping patterns="*.rs" serverId="linthisServer"/>
        <fileNamePatternMapping patterns="*.py;*.pyi" serverId="linthisServer"/>
        <fileNamePatternMapping patterns="*.ts;*.tsx" serverId="linthisServer"/>
        <fileNamePatternMapping patterns="*.js;*.jsx;*.mjs;*.cjs" serverId="linthisServer"/>
        <fileNamePatternMapping patterns="*.go" serverId="linthisServer"/>
        <fileNamePatternMapping patterns="*.java" serverId="linthisServer"/>
        <fileNamePatternMapping patterns="*.kt;*.kts" serverId="linthisServer"/>
        <fileNamePatternMapping patterns="*.swift" serverId="linthisServer"/>
        <fileNamePatternMapping patterns="*.m;*.mm" serverId="linthisServer"/>
        <fileNamePatternMapping patterns="*.c;*.h" serverId="linthisServer"/>
        <fileNamePatternMapping patterns="*.cpp;*.cc;*.cxx;*.hpp;*.hh;*.hxx" serverId="linthisServer"/>
        <fileNamePatternMapping patterns="*.lua" serverId="linthisServer"/>
        <fileNamePatternMapping patterns="*.dart" serverId="linthisServer"/>
        <fileNamePatternMapping patterns="*.sh;*.bash;*.zsh" serverId="linthisServer"/>
        <fileNamePatternMapping patterns="*.rb" serverId="linthisServer"/>
        <fileNamePatternMapping patterns="*.php" serverId="linthisServer"/>
        <fileNamePatternMapping patterns="*.scala;*.sc" serverId="linthisServer"/>
        <fileNamePatternMapping patterns="*.cs" serverId="linthisServer"/>
    </extensions>

    <applicationListeners>
        <listener class="com.mojeter.linthis.plugin.LinthisStartupListener"
                  topic="com.intellij.ide.AppLifecycleListener"/>
        <listener class="com.mojeter.linthis.plugin.listeners.LinthisDocumentListener"
                  topic="com.intellij.openapi.fileEditor.FileDocumentManagerListener"/>
    </applicationListeners>
</idea-plugin>
