ballerina-platform / lsp4intellij

This language client library provides language server protocol support for IntelliJ IDEA and other Jetbrains IDEs.
Apache License 2.0
428 stars 104 forks source link

diagnostics not work for v0.95.2 #333

Open dongwa opened 11 months ago

dongwa commented 11 months ago

Description:

update to 0.95.2, diagnostics not work

Affected Versions: 0.95.2 OS, DB, other environment details and versions: macos

brendanator commented 10 months ago

I don't know if this is the source of your issue, but I've noticed that PreloadingActivity is no longer called in the latest versions of Intellij. In README.md, it suggests to use this but it has been replaced by StartupActivitiy (also deprecated) and ProjectActivity in later versions of Intellij. Here's how I approached it:

public class MyStartupActivity implements StartupActivity {
    private static boolean INITIALIZED_APPLICATION = false;

    /**
     * Called after each project is started
     */
    @Override
    public synchronized void runActivity(@NotNull Project project) {
        // Only initialize the application once
        if (!INITIALIZED_APPLICATION) {
            setupLsp();
            INITIALIZED_APPLICATION = true;
        }
    }

    private void setupLsp() {
        IntellijLanguageClient.addServerDefinition(new RawCommandServerDefinition("bal", new String[]{"path/to/launcher-script.sh"}));
    }

plugin.xml

        <postStartupActivity
                implementation="full.package.name.MyStartupActivity"/>