Alexey-T / CudaText

Cross-platform text editor, written in Free Pascal
Mozilla Public License 2.0
2.53k stars 173 forks source link

how to config the OpenJDK lsp client settings? #4335

Closed RESDXChgfore9hing closed 2 years ago

RESDXChgfore9hing commented 2 years ago

it gives me these error

ERROR: error on loading json. Log file: D:\2ndProgramFiles\cudatext\settings\cudax.log
NOTE: LSP: server config error - no associated lexers: D:\2ndProgramFiles\cudatext\settings\lsp_Java.json
NOTE: LSP: no server configs loaded from "D:\2ndProgramFiles\cudatext\settings"

Here is my lsp_Java.json>

{
  "lexers": {
    "Java": "java"
  },
  "cmd_unix": [
      "",
  ],
  "cmd_windows": [
      "x:&&X:\CrossJava\FSetnearbyJDK.bat&&d:&&cd D:\testlsp\jdt&&D:\testlsp\jdt\run.bat",
  ],
}

The lsp itself works perfectly, as an eg,

C:\Users\a>x:&&X:\CrossJava\FSetnearbyJDK.bat&&d:&&cd D:\testlsp\jdt&&D:\testlsp\jdt\run.bat

D:\testlsp\jdt>java -Declipse.application=org.eclipse.jdt.ls.core.id1 -Dosgi.bundles.defaultStartLevel=4 -Declipse.product=org.eclipse.jdt.ls.core.product -Dlog.level=ERROR -noverify -Xmx1G --add-modules=ALL-SYSTEM --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED -jar ./plugins/org.eclipse.equinox.launcher_1.6.400.v20210924-0641.jar -configuration ./config_win -data D:\testlsp\jdt\defaultsharedworkspace
OpenJDK 64-Bit Server VM warning: Options -Xverify:none and -noverify were deprecated in JDK 13 and will likely be removed in a future release.
WARNING: Using incubator modules: jdk.incubator.vector, jdk.incubator.foreign
Alexey-T commented 2 years ago

error on loading json. means you need to double backslashes in JSON. and split space-separated string to N-items list: "item1", "item2", "item3"

Alexey-T commented 2 years ago

Runner cannot run the complex Batch command from you - so put it into the run.cmd file and then change the windows command to run new CMD file: maybe like this:

"cmd_windows": [
  "cmd.exe", "c:\\path\\to\\run.cmd"
  ],
RESDXChgfore9hing commented 2 years ago

awesome i think its running perfectly LSP: starting server - Java; root: None Startup: 1070ms, plugins: 580ms (lsp 563ms, tabs_list 15ms)

The lsp server seems to not properly working though no auto completion no function suggestion or hint. but at least cudatext lsp client seems to be recognizing it running. closing this issue.

Alexey-T commented 2 years ago

let's see what you will get, what reply, at Eclipse linked topic. you need to show them your CMD script to start server.

veksha commented 2 years ago

The lsp server seems to not properly working though no auto completion no function suggestion or hint.

is it not working in other editors too?

RESDXChgfore9hing commented 2 years ago

no idea didnt try it with other client.maybe can try kate.hmmm.

Alexey-T commented 2 years ago

Maybe try the Sublime Text with the same lsp client. if it works, report here.

RESDXChgfore9hing commented 2 years ago

sadly i have absolutely no experience with sublime,and searching doesnt seems to have any result about setting local lsp server.

RESDXChgfore9hing commented 2 years ago

Here is the update for making the JDK lsp fully working(theoretically),https://github.com/eclipse/eclipse.jdt.ls/issues/2210

The last few comment hints that we need to supply some info from client to the server at startup.How can i do that in cudatext?

veksha commented 2 years ago

try to save project file to desired folder:

image

didn't try with Java LSP (can't setup), but this is how client request looks like for Python: CudaText will generate this request to the server:

(rootUri and workspaceFolders are there!)

{
    "jsonrpc": "2.0",
    "method": "initialize",
    "params": {
        "processId": 5356,
        "rootUri": "file:///C:/Users/yura/Desktop",
        "workspaceFolders": [{
            "uri": "file:///C:/Users/yura/Desktop",
            "name": "Root"
        }],
        "trace": "off",
        "capabilities": {
            "textDocument": {
                "synchronization": {
                    "didSave": true,
                    "dynamicRegistration": true
                },
                "publishDiagnostics": {
                    "relatedInformation": true
                },
                "completion": {
                    "dynamicRegistration": true,
                    "completionItem": {
                        "snippetSupport": true
                    },
                    "completionItemKind": {
                        "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]
                    }
                },
                "hover": {
                    "dynamicRegistration": true,
                    "contentFormat": ["markdown", "plaintext"]
                },
                "definition": {
                    "dynamicRegistration": true,
                    "linkSupport": true
                },
                "signatureHelp": {
                    "dynamicRegistration": true,
                    "signatureInformation": {
                        "documentationFormat": ["markdown", "plaintext"],
                        "parameterInformation": {
                            "labelOffsetSupport": true
                        },
                        "activeParameterSupport": true
                    }
                },
                "implementation": {
                    "linkSupport": true,
                    "dynamicRegistration": true
                },
                "references": {
                    "dynamicRegistration": true
                },
                "callHierarchy": {
                    "dynamicRegistration": true
                },
                "declaration": {
                    "linkSupport": true,
                    "dynamicRegistration": true
                },
                "typeDefinition": {
                    "linkSupport": true,
                    "dynamicRegistration": true
                },
                "formatting": {
                    "dynamicRegistration": true
                },
                "rangeFormatting": {
                    "dynamicRegistration": true
                },
                "documentSymbol": {
                    "hierarchicalDocumentSymbolSupport": true,
                    "dynamicRegistration": true,
                    "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]
                    }
                }
            },
            "window": {
                "showMessage": {},
                "workDoneProgress": true
            },
            "workspace": {
                "symbol": {
                    "dynamicRegistration": true,
                    "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]
                    }
                },
                "workspaceFolders": true,
                "configuration": true,
                "didChangeConfiguration": {
                    "dynamicRegistration": true
                }
            }
        }
    },
    "id": 0
}
veksha commented 2 years ago

this is how to set up lsp in Sublime:

Install Package Control (if missing)
Install the LSP Package (if missing)
In Sublime, go to Preferences > Package Settings > LSP > Settings
Add this lines to your LSP Settings:
{
  "clients":
  {
      "jls":
      {
          "enabled": true,
          "command": ["<path-to-java-language-server>"],
          "scopes": ["source.java"],
          "syntaxes": ["Packages/Java/Java.sublime-syntax"],
          "languageId": "java"
      }
  }
}
RESDXChgfore9hing commented 2 years ago

where is that config file located. or is the json need to be in my project location?

veksha commented 2 years ago

are you asking about Sublime?

RESDXChgfore9hing commented 2 years ago

no cudatext.I currently didnt use sublime.

RESDXChgfore9hing commented 2 years ago

currently i just want to get the lsp working with cudatext and then see how it goes in my daily dev.