eclipse-lemminx / lemminx-maven

lemminx-maven
Eclipse Public License 2.0
38 stars 31 forks source link

how provide to emacs of lsp-mode for use it #226

Closed zcjava closed 3 years ago

zcjava commented 3 years ago

i use lsp-mode 's lsp4xml(lemminx) in pom.xml. but not auto code complete for dependency's article and version tip. how integration lemminx-maven for emacs.

mickaelistria commented 3 years ago

See https://github.com/eclipse/lemminx/blob/master/docs/LemMinX-Extensions.md about how LemMinX extension work in general. The extensions (and their dependencies) need to be added to the classpath when starting LemMinX.

zcjava commented 3 years ago

See https://github.com/eclipse/lemminx/blob/master/docs/LemMinX-Extensions.md about how LemMinX extension work in general. The extensions (and their dependencies) need to be added to the classpath when starting LemMinX.

ensure emacs can use it by lsp-mode?

mickaelistria commented 3 years ago

I don't know whether and how emacs LSP mode can support this; it's the responsibility of the plugin/mode/user who defines how to start the language server (eg launch java -jar lemminx.jar) to also add the necessary -cp lemminx-maven.jar:maven-core.jar... argument to include this extension.

zcjava commented 3 years ago

I don't know whether and how emacs LSP mode can support this; it's the responsibility of the plugin/mode/user who defines how to start the language server (eg launch java -jar lemminx.jar) to also add the necessary -cp lemminx-maven.jar:maven-core.jar... argument to include this extension.

ok, i try it.

zcjava commented 3 years ago

I don't know whether and how emacs LSP mode can support this; it's the responsibility of the plugin/mode/user who defines how to start the language server (eg launch java -jar lemminx.jar) to also add the necessary -cp lemminx-maven.jar:maven-core.jar... argument to include this extension.

ok, i try it.

image image i try it, but not work

zcjava commented 3 years ago

I don't know whether and how emacs LSP mode can support this; it's the responsibility of the plugin/mode/user who defines how to start the language server (eg launch java -jar lemminx.jar) to also add the necessary -cp lemminx-maven.jar:maven-core.jar... argument to include this extension.

look above

mickaelistria commented 3 years ago

Ypu also need to add the dependencies to the classpath. If you capture the Language Server log, it should tell you about some ClassNotFoundException that are typical of missing dependencies.

zcjava commented 3 years ago

Ypu also need to add the dependencies to the classpath. If you capture the Language Server log, it should tell you about some ClassNotFoundException that are typical of missing dependencies.

you mean is that add maven-core.jar lemminx-maven.jar in my maven project's .classpath? can u provide sample?

mickaelistria commented 3 years ago

No, you need to start LemMinX with the extra -cp argument that includes the extension (lemminx-maven) and its dependencies (maven-core, maven-indexer...). The list of dependencies for lemminx-maven can be retrieved with the standard mvn dependency:list command. This would typically be something like java -classpath org.eclipse.lemminx-uber.jar:lemminx-maven.jar:maven-artifact-3.8.1.jar:maven-settings-3.8.1.jar:commons-lang3-3.8.1.jar:plexus-component-annotations-2.1.0.jar:jansi-1.17.1.jar:maven-model-3.8.1.jar:aether-connector-okhttp-0.17.8.jar:maven-resolver-connector-basic-1.6.2.jar:maven-resolver-transport-wagon-1.6.2.jar:maven-shared-utils-3.2.1.jar:maven-embedder-3.8.1.jar:failureaccess-1.0.1.jar:maven-settings-builder-3.8.1.jar:guava-30.1-jre.jar:commons-cli-1.4.jar:plexus-interpolation-1.25.jar:cdi-api-1.0.jar:maven-resolver-provider-3.8.1.jar:maven-compat-3.8.1.jar:maven-resolver-api-1.6.2.jar:j2objc-annotations-1.3.jar:error_prone_annotations-2.3.4.jar:maven-resolver-util-1.6.2.jar:maven-resolver-spi-1.6.2.jar:jsr250-api-1.0.jar:maven-plugin-api-3.8.1.jar:okhttp-3.14.1.jar:guice-4.2.1-no_aop.jar:maven-builder-support-3.8.1.jar:listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar:okio-1.17.3.jar:wagon-file-3.4.3.jar:plexus-sec-dispatcher-1.4.jar:maven-repository-metadata-3.8.1.jar:plexus-classworlds-2.6.0.jar:org.eclipse.sisu.plexus-0.3.4.jar:maven-core-3.8.1.jar:maven-model-builder-3.8.1.jar:commons-io-2.5.jar:checker-qual-3.5.0.jar:plexus-build-api-0.0.7.jar:org.eclipse.sisu.inject-0.3.4.jar:plexus-cipher-1.7.jar:wagon-provider-api-3.4.3.jar:plexus-utils-3.2.1.jar:maven-resolver-impl-1.6.2.jar:lucene-queryparser-5.5.5.jar:lucene-backward-codecs-5.5.5.jar:indexer-core-6.0.0.jar:lucene-analyzers-common-5.5.5.jar:lucene-sandbox-5.5.5.jar:lucene-core-5.5.5.jar:lucene-highlighter-5.5.5.jar:lucene-join-5.5.5.jar:lucene-memory-5.5.5.jar:lucene-queries-5.5.5.jar:javax.inject_1.0.0.v20091030.jar:org.slf4j.api_1.7.30.v20200204-2150.jar org.eclipse.lemminx.XMLServerLauncher Overall, you'll need to get yourself familiar with the java command-line and how to run a Java application to expect being successful at tweaking the launch command of lemminx.

zcjava commented 3 years ago

image

zcjava commented 3 years ago

No, you need to start LemMinX with the extra -cp argument that includes the extension (lemminx-maven) and its dependencies (maven-core, maven-indexer...). The list of dependencies for lemminx-maven can be retrieved with the standard mvn dependency:list command. This would typically be something like java -classpath org.eclipse.lemminx-uber.jar:lemminx-maven.jar:maven-artifact-3.8.1.jar:maven-settings-3.8.1.jar:commons-lang3-3.8.1.jar:plexus-component-annotations-2.1.0.jar:jansi-1.17.1.jar:maven-model-3.8.1.jar:aether-connector-okhttp-0.17.8.jar:maven-resolver-connector-basic-1.6.2.jar:maven-resolver-transport-wagon-1.6.2.jar:maven-shared-utils-3.2.1.jar:maven-embedder-3.8.1.jar:failureaccess-1.0.1.jar:maven-settings-builder-3.8.1.jar:guava-30.1-jre.jar:commons-cli-1.4.jar:plexus-interpolation-1.25.jar:cdi-api-1.0.jar:maven-resolver-provider-3.8.1.jar:maven-compat-3.8.1.jar:maven-resolver-api-1.6.2.jar:j2objc-annotations-1.3.jar:error_prone_annotations-2.3.4.jar:maven-resolver-util-1.6.2.jar:maven-resolver-spi-1.6.2.jar:jsr250-api-1.0.jar:maven-plugin-api-3.8.1.jar:okhttp-3.14.1.jar:guice-4.2.1-no_aop.jar:maven-builder-support-3.8.1.jar:listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar:okio-1.17.3.jar:wagon-file-3.4.3.jar:plexus-sec-dispatcher-1.4.jar:maven-repository-metadata-3.8.1.jar:plexus-classworlds-2.6.0.jar:org.eclipse.sisu.plexus-0.3.4.jar:maven-core-3.8.1.jar:maven-model-builder-3.8.1.jar:commons-io-2.5.jar:checker-qual-3.5.0.jar:plexus-build-api-0.0.7.jar:org.eclipse.sisu.inject-0.3.4.jar:plexus-cipher-1.7.jar:wagon-provider-api-3.4.3.jar:plexus-utils-3.2.1.jar:maven-resolver-impl-1.6.2.jar:lucene-queryparser-5.5.5.jar:lucene-backward-codecs-5.5.5.jar:indexer-core-6.0.0.jar:lucene-analyzers-common-5.5.5.jar:lucene-sandbox-5.5.5.jar:lucene-core-5.5.5.jar:lucene-highlighter-5.5.5.jar:lucene-join-5.5.5.jar:lucene-memory-5.5.5.jar:lucene-queries-5.5.5.jar:javax.inject_1.0.0.v20091030.jar:org.slf4j.api_1.7.30.v20200204-2150.jar org.eclipse.lemminx.XMLServerLauncher Overall, you'll need to get yourself familiar with the java command-line and how to run a Java application to expect being successful at tweaking the launch command of lemminx.

too much jar. do u have these jar download url all in one ?

mickaelistria commented 3 years ago

too much jar. do u have these jar download url all in one ?

No, but contribution to add that to the project would be welcome.

mickaelistria commented 3 years ago

Please first make sure you gather enough basic knowledge about running Java programs and building project with Maven by going through their basic introduction tutorial; and then you'll probably figure it all out by yourself. I don't have the resource to do Java and Maven training here.

angelozerr commented 3 years ago

If I remember we can create an uber JAR in https://github.com/eclipse/lemminx-maven/commit/3c70e7be367d8ebb8922033a4d367bd44f554b96 no?

zcjava commented 3 years ago

image image

is not work? i donnot know how solve it

zcjava commented 3 years ago

If I remember we can create an uber JAR in 3c70e7b no? is it image

angelozerr commented 3 years ago

I think this zip contains all required jars but its not an uber jar which merge all requiered jars.

It seems that you have some NPE that which are strange. I suspect that settings when lemminx server starts are not expected. But we should fix that in our side.

Is it possible to start your lsp traces when your start the server please.

zcjava commented 3 years ago

I think this zip contains all required jars but its not an uber jar which merge all requiered jars.

It seems that you have some NPE that which are strange. I suspect that settings when lemminx server starts are not expected. But we should fix that in our side.

Is it possible to start your lsp traces when your start the server please.

why not support uberjar download for us ? need i create i use zip contains all all requiered jars to java run . is it ok. what reason the problem?

not result

zcjava commented 3 years ago

i use jdk version is oracle's openjdk-11 . is it possible to jdk version reason

angelozerr commented 3 years ago

why not support uberjar download for us ? need i create i use zip contains all all requiered jars to java run . is it ok. what reason the problem?

Today lemminx maven is very well integrated inside Eclipse IDE, but not for another LSP clients for the moment. I agree with you, we should have an uber jar for another LSP clients. @fbricon do you remember why we provide jars dependencies and not an uber jar?

@zcjava it should be very nice if you could share your LSP traces as text file. Please start the lemminx server and do some actiosn like hover, etc and get this LSP trace. The thing which interested me is about initialize params trace. I supsect that settings are wrong.

zcjava commented 3 years ago

why not support uberjar download for us ? need i create i use zip contains all all requiered jars to java run . is it ok. what reason the problem?

Today lemminx maven is very well integrated inside Eclipse IDE, but not for another LSP clients for the moment. I agree with you, we should have an uber jar for another LSP clients. @fbricon do you remember why we provide jars dependencies and not an uber jar?

@zcjava it should be very nice if you could share your LSP traces as text file. Please start the lemminx server and do some actiosn like hover, etc and get this LSP trace. The thing which interested me is about initialize params trace. I supsect that settings are wrong.

angelozerr commented 3 years ago

Thanks @zcjava for your trace. Your initializationOptions is null. In vscode-xml we have that: I think the problem is that lemminx expects initializationOptions.Have you xml support without lemminx maven?

    "initializationOptions": {
        "settings": {
            "xml": {
                "java": {
                    "home": "C:\\Users\\azerr\\Tools\\java-11-openjdk-11.0.7.10-1.windows.redhat.x86_64"
                },
                "server": {
                    "vmargs": "-Xmx1G -XX:+UseG1GC -XX:+UseStringDeduplication",
                    "workDir": "~/.lemminx",
                    "preferBinary": false,
                    "silenceExtensionWarning": false,
                    "binary": {
                        "path": "",
                        "args": "",
                        "trustedHashes": [
                            "b6a0f35f9d1cd73fc3804d9d92c5ce8923bd97b78e2018fb1a607958f58bcda6"
                        ]
                    }
                },
                "trace": {
                    "server": "verbose"
                },
                "logs": {
                    "client": true,
                    "file": "C:\\Users\\azerr\\.lemminx\\lemminx.log"
                },
                "catalogs": [
                    "catalog-preferences/catalog.xml"
                ],
                "fileAssociations": [
                    {
                        "pattern": "**/*.fsproj",
                        "systemId": "MSBuild/Microsoft.Build.Commontypes.xsd"
                    }
                ],
                "format": {
                    "enabled": true,
                    "emptyElements": "collapse",
                    "enforceQuoteStyle": "ignore",
                    "joinCDATALines": false,
                    "joinCommentLines": false,
                    "joinContentLines": false,
                    "preserveAttributeLineBreaks": true,
                    "preserveEmptyContent": true,
                    "preservedNewlines": 2,
                    "spaceBeforeEmptyCloseTag": true,
                    "xsiSchemaLocationSplit": "none",
                    "splitAttributes": true,
                    "splitAttributesIndentSize": 2,
                    "closingBracketNewLine": false,
                    "trimFinalNewlines": false,
                    "trimTrailingWhitespace": true,
                    "insertFinalNewline": false
                },
                "preferences": {
                    "quoteStyle": "double",
                    "showSchemaDocumentationType": "all"
                },
                "completion": {
                    "autoCloseTags": true,
                    "autoCloseRemovesContent": true
                },
                "codeLens": {
                    "enabled": true
                },
                "validation": {
                    "enabled": true,
                    "namespaces": {
                        "enabled": "onNamespaceEncountered"
                    },
                    "schema": {
                        "enabled": "always"
                    },
                    "disallowDocTypeDecl": false,
                    "resolveExternalEntities": true,
                    "noGrammar": "hint",
                    "schemaVersion": "1.1"
                },
                "symbols": {
                    "enabled": true,
                    "excluded": [],
                    "maxItemsComputed": 5000,
                    "showReferencedGrammars": true,
                    "filters": [
                        {
                            "pattern": "test.xml",
                            "expressions": [
                                {
                                    "xpath": "//Layout"
                                },
                                {
                                    "xpath": "//Record"
                                },
                                {
                                    "xpath": "//Record/@*"
                                },
                                {
                                    "xpath": "//",
                                    "excluded": true
                                }
                            ]
                        },
                        {
                            "pattern": "pom.xml",
                            "expressions": [
                                {
                                    "xpath": "//version/text()"
                                },
                                {
                                    "xpath": "//groupId/text()"
                                }
                            ]
                        },
                        {
                            "pattern": "bean*.xml",
                            "expressions": [
                                {
                                    "xpath": "//@*"
                                }
                            ]
                        }
                    ]
                },
                "extension": {
                    "jars": [],
                    "jarsOLD": [
                        "C:\\Users\\azerr\\git\\lemminx-maven\\lemminx-maven\\target\\lemminx-maven-0.2.1-SNAPSHOT-zip-with-dependencies/*.jar",
                        "C:\\Users\\azerr\\git\\liberty-language-server\\lemminx-liberty\\target\\lemminx-liberty-1.0-SNAPSHOT.jar"
                    ]
                },
                "telemetry": {
                    "enabled": true
                },
                "useCache": true
            }
        },
        "extendedClientCapabilities": {
            "codeLens": {
                "codeLensKind": {
                    "valueSet": [
                        "references",
                        "association",
                        "open.uri"
                    ]
                }
            },
            "actionableNotificationSupport": true,
            "openSettingsCommandSupport": true,
            "bindingWizardSupport": true,
            "shouldLanguageServerExitOnShutdown": true
        }
    }
angelozerr commented 3 years ago

Have you xml support without lemminx maven?

forget my comment, according to your trace, you should have lemminx support.

@zcjava could you share too your file with execptions please.

angelozerr commented 3 years ago

@mickaelistria according exception screnshot of @zcjava, it seems that there is a NPE in https://github.com/eclipse/lemminx-maven/blob/c8cdf504505e0b9586abf857e8ecf736ccd4be7b/lemminx-maven/src/main/java/org/eclipse/lemminx/extensions/maven/MavenLemminxExtension.java#L132

In case of @zcjava, I think xmlSettings is null.

settings = XMLMavenGeneralSettings.getGeneralXMLSettings(xmlSettings).getMaven();

You should manage default settings for maven when there are no settings

mickaelistria commented 3 years ago

@zcjava Please report a specific issue about the exception noticed by Angelo, and consider submitting a PR to support that case.

zcjava commented 3 years ago

@mickaelistria according exception screnshot of @zcjava, it seems that there is a NPE in

https://github.com/eclipse/lemminx-maven/blob/c8cdf504505e0b9586abf857e8ecf736ccd4be7b/lemminx-maven/src/main/java/org/eclipse/lemminx/extensions/maven/MavenLemminxExtension.java#L132

In case of @zcjava, I think xmlSettings is null.

settings = XMLMavenGeneralSettings.getGeneralXMLSettings(xmlSettings).getMaven();

You should manage default settings for maven when there are no settings

how settings maven default settings in emacs'env or lsp-mode 、lsp-xml。mvn is my'system global command. in /usr/local/bin. in emacs ,i use exec-path-from-shell load system envs. ensure mvn command aviable. i set maven'settings.xml in ~/.m2 . what i need set ?

zcjava commented 3 years ago

@zcjava Please report a specific issue about the exception noticed by Angelo, and consider submitting a PR to support that case.

ok , @angelozerr #227