emacs-lsp / lsp-java

lsp-mode :heart: java
https://emacs-lsp.github.io/lsp-java
GNU General Public License v3.0
647 stars 90 forks source link

lsp-java not working with java-ts-mode #451

Closed marasenna closed 1 year ago

marasenna commented 1 year ago

Describe the bug

When running lsp in java-ts-mode you get LSP :: Connected to [jdtls:port/starting dir] message in the minibuffer, but nothing happens after that. The modeline is always displaying jdtls:port/starting.

To Reproduce

  1. Delete lsp-mode lsp-java directories from ~/.emacs.d/elpa directory
  2. Delete eclipse.jdt.ls directory from ~/.emacs.d/.cache/lsp directory
  3. Run emacs -q
  4. Evaluate the following config:
    
    (require 'package)
    (add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/"))
    (package-initialize)
    (package-refresh-contents)
    (setq use-package-always-ensure t)
    (require 'use-package)

(use-package lsp-mode :config (setq lsp-print-io t) (use-package lsp-ui) (use-package lsp-java)

5. Create a new directory
6. In there, create a new java file
7. Run `M-x java-ts-mode`
8. Run `M-x lsp`
9. Accept jdtls installation
10. After installing, import project in current directory
11. Try to write some java code to see no lsp features

![1693735590](https://github.com/emacs-lsp/lsp-java/assets/94115437/6e355616-c80a-488e-996d-c9c8ad058267)

**Expected behavior**

It should work the same as with `java-mode`

![1693735660](https://github.com/emacs-lsp/lsp-java/assets/94115437/de960903-e8a4-436e-a5b1-9b372ba8c1ad)

**Logs**

From \*Messages\* buffer:

using config for config_linux LSP :: Sending to process failed with the following error: Wrong type argument: json-value-p, set-from-style LSP :: Connected to [jdtls:17517/starting /home/pasha/test].

From \*lsp-log\*:

Command "semgrep lsp" is not present on the path. Command "semgrep lsp" is not present on the path. Found the following clients for /home/pasha/test/Test.java: (server-id jdtls, priority 0) The following clients were selected based on priority: (server-id jdtls, priority 0) Sep 3, 2023, 1:29:13 PM Main thread is waiting


From \*lsp-log: jdtls\*:

[Trace - 01:29:11 PM] Sending request 'initialize - (77)'. Params: { "processId": 15302, "rootPath": "/home/pasha/test", "clientInfo": { "name": "emacs", "version": "GNU Emacs 29.1 (build 2, x86_64-unknown-linux-gnu, GTK+ Version 3.24.38, cairo version 1.16.0)\n of 2023-08-03" }, "rootUri": "file:///home/pasha/test", "capabilities": { "general": { "positionEncodings": [ "utf-32", "utf-16" ] }, "workspace": { "workspaceEdit": { "documentChanges": true, "resourceOperations": [ "create", "rename", "delete" ] }, "applyEdit": true, "symbol": { "symbolKind": { "valueSet": [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 ] } }, "executeCommand": { "dynamicRegistration": false }, "didChangeWatchedFiles": { "dynamicRegistration": true }, "workspaceFolders": true, "configuration": true, "codeLens": { "refreshSupport": true }, "fileOperations": { "didCreate": false, "willCreate": false, "didRename": true, "willRename": true, "didDelete": false, "willDelete": false } }, "textDocument": { "declaration": { "dynamicRegistration": true, "linkSupport": true }, "definition": { "dynamicRegistration": true, "linkSupport": true }, "references": { "dynamicRegistration": true }, "implementation": { "dynamicRegistration": true, "linkSupport": true }, "typeDefinition": { "dynamicRegistration": true, "linkSupport": true }, "synchronization": { "willSave": true, "didSave": true, "willSaveWaitUntil": true }, "documentSymbol": { "symbolKind": { "valueSet": [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 ] }, "hierarchicalDocumentSymbolSupport": true }, "formatting": { "dynamicRegistration": true }, "rangeFormatting": { "dynamicRegistration": true }, "onTypeFormatting": { "dynamicRegistration": true }, "rename": { "dynamicRegistration": true, "prepareSupport": true }, "codeAction": { "dynamicRegistration": true, "isPreferredSupport": true, "codeActionLiteralSupport": { "codeActionKind": { "valueSet": [ "", "quickfix", "refactor", "refactor.extract", "refactor.inline", "refactor.rewrite", "source", "source.organizeImports" ] } }, "resolveSupport": { "properties": [ "edit", "command" ] }, "dataSupport": true }, "completion": { "completionItem": { "snippetSupport": true, "documentationFormat": [ "markdown", "plaintext" ], "resolveAdditionalTextEditsSupport": true, "insertReplaceSupport": true, "deprecatedSupport": true, "resolveSupport": { "properties": [ "documentation", "detail", "additionalTextEdits", "command" ] }, "insertTextModeSupport": { "valueSet": [ 1, 2 ] } }, "contextSupport": true, "dynamicRegistration": true }, "signatureHelp": { "signatureInformation": { "parameterInformation": { "labelOffsetSupport": true } }, "dynamicRegistration": true }, "documentLink": { "dynamicRegistration": true, "tooltipSupport": true }, "hover": { "contentFormat": [ "markdown", "plaintext" ], "dynamicRegistration": true }, "foldingRange": { "dynamicRegistration": true }, "selectionRange": { "dynamicRegistration": true }, "callHierarchy": { "dynamicRegistration": false }, "typeHierarchy": { "dynamicRegistration": true }, "publishDiagnostics": { "relatedInformation": true, "tagSupport": { "valueSet": [ 1, 2 ] }, "versionSupport": true }, "linkedEditingRange": { "dynamicRegistration": true } }, "window": { "workDoneProgress": true, "showDocument": { "support": true } } }, "initializationOptions": { "settings": { "java": { "errors": { "incompleteClasspath": { "severity": "warning" } }, "dependency": { "packagePresentation": "flat" }, "configuration": { "checkProjectSettingsExclusions": true, "updateBuildConfiguration": "automatic", "maven": { "notCoveredPluginExecutionSeverity": "warning", "defaultMojoExecutionAction": "ignore" }, "workspaceCacheLimit": 90 }, "trace": { "server": "off" }, "import": { "gradle": { "enabled": true, "wrapper": { "enabled": true }, "offline": { "enabled": false }, "annotationProcessing": { "enabled": true } }, "maven": { "enabled": true, "offline": { "enabled": false }, "disableTestClasspathFlag": false }, "exclusions": [ "/node_modules/", "/.metadata/", "/archetype-resources/", "/META-INF/maven/" ], "generatesMetadataFilesAtProjectRoot": false }, "maven": { "downloadSources": false, "updateSnapshots": false }, "referencesCodeLens": { "enabled": false }, "signatureHelp": { "enabled": true, "description": { "enabled": false } }, "implementationsCodeLens": { "enabled": false }, "format": { "enabled": true, "comments": { "enabled": true }, "onType": { "enabled": true }, "tabSize": "set-from-style" }, "saveActions": { "organizeImports": false }, "project": { "resourceFilters": [ "node_modules", ".metadata", "archetype-resources", "META-INF/maven" ], "referencedLibraries": [ "lib/*/.jar" ], "importOnFirstTimeStartup": "automatic", "importHint": true, "outputPath": "", "encoding": "ignore" }, "autobuild": { "enabled": true }, "selectionRange": { "enabled": true }, "maxConcurrentBuilds": 1, "completion": { "enabled": true, "overwrite": true, "guessMethodArguments": true, "favoriteStaticMembers": [ "org.junit.Assert.", "org.junit.Assume.", "org.junit.jupiter.api.Assertions.", "org.junit.jupiter.api.Assumptions.", "org.junit.jupiter.api.DynamicContainer.", "org.junit.jupiter.api.DynamicTest.", "org.mockito.Mockito.", "org.mockito.ArgumentMatchers.", "org.mockito.Answers." ], "importOrder": [ "java", "javax", "com", "org" ], "filteredTypes": [ "java.awt.", "com.sun.*" ], "maxResults": 0, "postfix": { "enabled": true }, "matchCase": "auto", "lazyResolveTextEdit": { "enabled": false } }, "foldingRange": { "enabled": true }, "progressReports": { "enabled": true }, "codeGeneration": { "hashCodeEquals": { "useJava7Objects": false, "useInstanceof": false }, "useBlocks": false, "generateComments": false, "toString": { "template": "${object.className} [${member.name()}=${member.value}, ${otherMembers}]", "codeStyle": "STRING_CONCATENATION", "skipNullValues": false, "listArrayContents": true, "limitElements": 0 }, "insertionLocation": "afterCursor" }, "showBuildStatusOnStart": { "enabled": false }, "server": { "launchMode": "Hybrid" }, "sources": { "organizeImports": { "starThreshold": 99, "staticStarThreshold": 99 } }, "imports": { "gradle": { "wrapper": { "checksums": [] } } }, "eclipse": { "downloadSources": false }, "recommendations": { "dependency": { "analytics": { "show": true } } }, "references": { "includeAccessors": true, "includeDecompiledSources": true }, "typeHierarchy": { "lazyLoad": false }, "symbols": { "includeSourceMethodDeclarations": false }, "quickfix": { "showAt": "line" }, "inlayHints": { "parameterNames": { "enabled": "literals" } }, "jdt": { "ls": { "lombokSupport": { "enabled": true }, "protobufSupport": { "enabled": true }, "androidSupport": { "enabled": "auto" } } }, "codeAction": { "sortMembers": { "avoidVolatileChanges": true } }, "compile": { "nullAnalysis": { "nonnull": [ "javax.annotation.Nonnull", "org.eclipse.jdt.annotation.NonNull", "org.springframework.lang.NonNull" ], "nullable": [ "javax.annotation.Nullable", "org.eclipse.jdt.annotation.Nullable", "org.springframework.lang.Nullable" ], "mode": "interactive" } }, "sharedIndexes": { "enabled": "auto", "location": "" }, "refactoring": { "extract": { "interface": { "replace": true } } } } }, "extendedClientCapabilities": { "progressReportProvider": true, "classFileContentsSupport": true, "classFileContentsSupport": true, "overrideMethodsPromptSupport": true, "hashCodeEqualsPromptSupport": true, "advancedOrganizeImportsSupport": true, "generateConstructorsPromptSupport": true, "generateToStringPromptSupport": true, "advancedGenerateAccessorsSupport": true, "advancedExtractRefactoringSupport": true, "moveRefactoringSupport": true, "resolveAdditionalTextEditsSupport": true }, "bundles": [ "/home/pasha/.emacs.d/.cache/lsp/eclipse.jdt.ls/bundles/com.microsoft.java.test.plugin-0.28.0.jar", "/home/pasha/.emacs.d/.cache/lsp/eclipse.jdt.ls/bundles/com.microsoft.jdtls.ext.core-0.5.1.jar", "/home/pasha/.emacs.d/.cache/lsp/eclipse.jdt.ls/bundles/dg.jdt.ls.decompiler.cfr-0.0.2-201802221740.jar", "/home/pasha/.emacs.d/.cache/lsp/eclipse.jdt.ls/bundles/dg.jdt.ls.decompiler.common-0.0.2-201802221740.jar", "/home/pasha/.emacs.d/.cache/lsp/eclipse.jdt.ls/bundles/dg.jdt.ls.decompiler.fernflower-0.0.2-201802221740.jar", "/home/pasha/.emacs.d/.cache/lsp/eclipse.jdt.ls/bundles/dg.jdt.ls.decompiler.procyon-0.0.2-201802221740.jar", "/home/pasha/.emacs.d/.cache/lsp/eclipse.jdt.ls/bundles/io.projectreactor.reactor-core.jar", "/home/pasha/.emacs.d/.cache/lsp/eclipse.jdt.ls/bundles/java.debug.plugin.jar", "/home/pasha/.emacs.d/.cache/lsp/eclipse.jdt.ls/bundles/jdt-ls-commons.jar", "/home/pasha/.emacs.d/.cache/lsp/eclipse.jdt.ls/bundles/jdt-ls-extension.jar", "/home/pasha/.emacs.d/.cache/lsp/eclipse.jdt.ls/bundles/org.apiguardian_1.1.0.v20190826-0900.jar", "/home/pasha/.emacs.d/.cache/lsp/eclipse.jdt.ls/bundles/org.eclipse.jdt.junit4.runtime_1.1.1200.v20200214-0716.jar", "/home/pasha/.emacs.d/.cache/lsp/eclipse.jdt.ls/bundles/org.eclipse.jdt.junit5.runtime_1.0.900.v20200513-0617.jar", "/home/pasha/.emacs.d/.cache/lsp/eclipse.jdt.ls/bundles/org.junit.jupiter.api_5.6.0.v20200203-2009.jar", "/home/pasha/.emacs.d/.cache/lsp/eclipse.jdt.ls/bundles/org.junit.jupiter.engine_5.6.0.v20200203-2009.jar", "/home/pasha/.emacs.d/.cache/lsp/eclipse.jdt.ls/bundles/org.junit.jupiter.migrationsupport_5.6.0.v20200203-2009.jar", "/home/pasha/.emacs.d/.cache/lsp/eclipse.jdt.ls/bundles/org.junit.jupiter.params_5.6.0.v20200203-2009.jar", "/home/pasha/.emacs.d/.cache/lsp/eclipse.jdt.ls/bundles/org.junit.platform.commons_1.6.0.v20200203-2009.jar", "/home/pasha/.emacs.d/.cache/lsp/eclipse.jdt.ls/bundles/org.junit.platform.engine_1.6.0.v20200203-2009.jar", "/home/pasha/.emacs.d/.cache/lsp/eclipse.jdt.ls/bundles/org.junit.platform.launcher_1.6.0.v20200203-2009.jar", "/home/pasha/.emacs.d/.cache/lsp/eclipse.jdt.ls/bundles/org.junit.platform.runner_1.6.0.v20200203-2009.jar", "/home/pasha/.emacs.d/.cache/lsp/eclipse.jdt.ls/bundles/org.junit.platform.suite.api_1.6.0.v20200203-2009.jar", "/home/pasha/.emacs.d/.cache/lsp/eclipse.jdt.ls/bundles/org.junit.vintage.engine_5.6.0.v20200203-2009.jar", "/home/pasha/.emacs.d/.cache/lsp/eclipse.jdt.ls/bundles/org.opentest4j_1.2.0.v20190826-0900.jar", "/home/pasha/.emacs.d/.cache/lsp/eclipse.jdt.ls/bundles/org.reactivestreams.reactive-streams.jar" ], "workspaceFolders": [ "file:///home/pasha/test" ] }, "workDoneToken": "1", "workspaceFolders": [ { "uri": "file:///home/pasha/test", "name": "test" } ] }

[Trace - 01:29:12 PM] Received notification 'window/logMessage'. Params: { "type": 3, "message": "Sep 3, 2023, 1:29:12 PM Main thread is waiting" }

huangfeiyu commented 1 year ago

@marasenna https://github.com/emacs-lsp/lsp-java/issues/447 offered a solution.